From 2cfe80ccc0cbe30da425911cda2ca65e77682ae7 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 21 May 2016 18:30:06 -0700 Subject: [PATCH] Add a basic context menu to the state list. This allows us to toggle breakpoints on specific commands. --- GPU/Debugger/Breakpoints.cpp | 8 ++++ GPU/Debugger/Breakpoints.h | 8 +--- Windows/GEDebugger/TabState.cpp | 65 +++++++++++++++++++++++++++++++-- Windows/GEDebugger/TabState.h | 12 +++--- Windows/ppsspp.rc | 9 +++++ Windows/resource.h | 3 +- 6 files changed, 90 insertions(+), 15 deletions(-) diff --git a/GPU/Debugger/Breakpoints.cpp b/GPU/Debugger/Breakpoints.cpp index 268c3a1522..8c3e9c5e28 100644 --- a/GPU/Debugger/Breakpoints.cpp +++ b/GPU/Debugger/Breakpoints.cpp @@ -233,6 +233,14 @@ bool IsRenderTargetBreakpoint(u32 addr) { return breakRenderTargets.find(addr) != breakRenderTargets.end(); } +bool IsOpBreakpoint(u32 op, bool &temp) { + return IsCmdBreakpoint(op >> 24, temp); +} + +bool IsOpBreakpoint(u32 op) { + return IsCmdBreakpoint(op >> 24); +} + bool IsCmdBreakpoint(u8 cmd, bool &temp) { temp = breakCmdsTemp[cmd]; return breakCmds[cmd]; diff --git a/GPU/Debugger/Breakpoints.h b/GPU/Debugger/Breakpoints.h index 99a2c34394..282b325dd2 100644 --- a/GPU/Debugger/Breakpoints.h +++ b/GPU/Debugger/Breakpoints.h @@ -50,11 +50,7 @@ namespace GPUBreakpoints { void ClearAllBreakpoints(); void ClearTempBreakpoints(); - static inline bool IsOpBreakpoint(u32 op, bool &temp) { - return IsCmdBreakpoint(op >> 24, temp); - } + bool IsOpBreakpoint(u32 op, bool &temp); - static inline bool IsOpBreakpoint(u32 op) { - return IsCmdBreakpoint(op >> 24); - } + bool IsOpBreakpoint(u32 op); }; diff --git a/Windows/GEDebugger/TabState.cpp b/Windows/GEDebugger/TabState.cpp index 8388c1a62e..849b54bbff 100644 --- a/Windows/GEDebugger/TabState.cpp +++ b/Windows/GEDebugger/TabState.cpp @@ -17,12 +17,18 @@ #include "base/basictypes.h" #include "Windows/resource.h" +#include "Windows/main.h" #include "Windows/InputBox.h" #include "Windows/GEDebugger/GEDebugger.h" #include "Windows/GEDebugger/TabState.h" #include "GPU/GPUState.h" #include "GPU/GeDisasm.h" #include "GPU/Common/GPUDebugInterface.h" +#include "GPU/Debugger/Breakpoints.h" + +using namespace GPUBreakpoints; + +const int POPUP_SUBMENU_ID_GEDBG_STATE = 9; // TODO: Show an icon or something for breakpoints, toggle. static const GenericListViewColumn stateValuesCols[] = { @@ -844,12 +850,65 @@ void CtrlStateValues::OnDoubleClick(int row, int column) { } } -void CtrlStateValues::OnRightClick(int row, int column, const POINT& point) { - if (gpuDebug == NULL) { +void CtrlStateValues::OnRightClick(int row, int column, const POINT &point) { + if (gpuDebug == nullptr) { return; } - // TODO: Copy, break, watch... enable? + const auto info = rows_[row]; + const auto state = gpuDebug->GetGState(); + + POINT screenPt(point); + ClientToScreen(GetHandle(), &screenPt); + + HMENU subMenu = GetSubMenu(g_hPopupMenus, POPUP_SUBMENU_ID_GEDBG_STATE); + switch (TrackPopupMenuEx(subMenu, TPM_RIGHTBUTTON | TPM_RETURNCMD, screenPt.x, screenPt.y, GetHandle(), 0)) + { + case ID_DISASM_TOGGLEBREAKPOINT: + if (IsCmdBreakpoint(info.cmd)) { + RemoveCmdBreakpoint(info.cmd); + RemoveCmdBreakpoint(info.otherCmd); + RemoveCmdBreakpoint(info.otherCmd2); + } else { + AddCmdBreakpoint(info.cmd); + if (info.otherCmd) { + AddCmdBreakpoint(info.otherCmd); + } + if (info.otherCmd2) { + AddCmdBreakpoint(info.otherCmd2); + } + } + break; + + case ID_DISASM_COPYINSTRUCTIONHEX: { + char temp[16]; + snprintf(temp, sizeof(temp), "%08x", gstate.cmdmem[info.cmd] & 0x00FFFFFF); + W32Util::CopyTextToClipboard(GetHandle(), temp); + break; + } + + case ID_DISASM_COPYINSTRUCTIONDISASM: { + const bool enabled = info.enableCmd == 0 || (state.cmdmem[info.enableCmd] & 1) == 1; + const u32 value = state.cmdmem[info.cmd] & 0xFFFFFF; + const u32 otherValue = state.cmdmem[info.otherCmd] & 0xFFFFFF; + const u32 otherValue2 = state.cmdmem[info.otherCmd2] & 0xFFFFFF; + + wchar_t dest[512]; + FormatStateRow(dest, info, value, enabled, otherValue, otherValue2); + W32Util::CopyTextToClipboard(GetHandle(), dest); + break; + } + + case ID_DEBDG_COPYALL: + CopyRows(0, GetRowCount()); + break; + + case ID_REGLIST_CHANGE: + OnDoubleClick(row, column); + break; + } + + // TODO: Watch? } void CtrlStateValues::SetCmdValue(u32 op) { diff --git a/Windows/GEDebugger/TabState.h b/Windows/GEDebugger/TabState.h index c31ef8bfe3..f0454e2f2a 100644 --- a/Windows/GEDebugger/TabState.h +++ b/Windows/GEDebugger/TabState.h @@ -27,11 +27,13 @@ public: CtrlStateValues(const TabStateRow *rows, int rowCount, HWND hwnd); protected: - virtual bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT& returnValue) { return false; }; - virtual void GetColumnText(wchar_t* dest, int row, int col); - virtual int GetRowCount() { return rowCount_; } - virtual void OnDoubleClick(int row, int column); - virtual void OnRightClick(int row, int column, const POINT& point); + bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT& returnValue) override { + return false; + } + void GetColumnText(wchar_t* dest, int row, int col) override; + int GetRowCount() override { return rowCount_; } + void OnDoubleClick(int row, int column) override; + void OnRightClick(int row, int column, const POINT& point) override; private: void SetCmdValue(u32 op); diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index a897379485..d12e66e01b 100644 --- a/Windows/ppsspp.rc +++ b/Windows/ppsspp.rc @@ -626,6 +626,15 @@ BEGIN MENUITEM "Go to Address...", ID_GEDBG_GOTOADDR MENUITEM "Go to in Memory View", ID_DISASM_GOTOINMEMORYVIEW END + POPUP "stateoptions" + BEGIN + MENUITEM "Copy Value (Hex)", ID_DISASM_COPYINSTRUCTIONHEX + MENUITEM "Copy Value (Formatted)", ID_DISASM_COPYINSTRUCTIONDISASM + MENUITEM "Copy Entire Tab (Formatted)",ID_DEBDG_COPYALL + MENUITEM SEPARATOR + MENUITEM "Toggle Breakpoint", ID_DISASM_TOGGLEBREAKPOINT + MENUITEM "Change...", ID_REGLIST_CHANGE + END END #endif // English (United States) resources diff --git a/Windows/resource.h b/Windows/resource.h index 46856d4167..f7ecd6c642 100644 --- a/Windows/resource.h +++ b/Windows/resource.h @@ -325,6 +325,7 @@ #define ID_OPTIONS_DISPLAY_LAYOUT 40160 #define ID_OPTIONS_VULKAN 40161 #define IDC_GEDBG_BREAKTARGET 40162 +#define ID_DEBDG_COPYALL 40163 // Dummy option to let the buffered rendering hotkey cycle through all the options. #define ID_OPTIONS_BUFFEREDRENDERINGDUMMY 40500 @@ -337,7 +338,7 @@ #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 256 -#define _APS_NEXT_COMMAND_VALUE 40163 +#define _APS_NEXT_COMMAND_VALUE 40164 #define _APS_NEXT_CONTROL_VALUE 1199 #define _APS_NEXT_SYMED_VALUE 101 #endif