Skip to content

Commit

Permalink
Add a basic context menu to the state list.
Browse files Browse the repository at this point in the history
This allows us to toggle breakpoints on specific commands.
  • Loading branch information
unknownbrackets committed May 22, 2016
1 parent 916c53c commit 2cfe80c
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 15 deletions.
8 changes: 8 additions & 0 deletions GPU/Debugger/Breakpoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
8 changes: 2 additions & 6 deletions GPU/Debugger/Breakpoints.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
65 changes: 62 additions & 3 deletions Windows/GEDebugger/TabState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = {
Expand Down Expand Up @@ -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) {
Expand Down
12 changes: 7 additions & 5 deletions Windows/GEDebugger/TabState.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ class CtrlStateValues: public GenericListControl {
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);
Expand Down
9 changes: 9 additions & 0 deletions Windows/ppsspp.rc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion Windows/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 2cfe80c

Please sign in to comment.