Add watchlist feature to the GE debugger.

This way you can pick out items you want to watch.
This commit is contained in:
Unknown W. Brackets 2016-05-21 19:11:42 -07:00
parent 8ba14b5858
commit 8b5669828b
6 changed files with 71 additions and 9 deletions

View File

@ -113,6 +113,9 @@ CGEDebugger::CGEDebugger(HINSTANCE _hInstance, HWND _hParent)
lists = new TabDisplayLists(_hInstance, m_hDlg);
tabs->AddTabDialog(lists, L"Lists");
watch = new TabStateWatch(_hInstance, m_hDlg);
tabs->AddTabDialog(watch, L"Watch");
tabs->ShowTab(0, true);
// set window position
@ -135,6 +138,7 @@ CGEDebugger::~CGEDebugger() {
delete vertices;
delete matrices;
delete lists;
delete watch;
delete tabs;
delete fbTabs;
}
@ -225,6 +229,7 @@ void CGEDebugger::UpdatePreviews() {
vertices->Update();
matrices->Update();
lists->Update();
watch->Update();
}
u32 CGEDebugger::TexturePreviewFlags(const GPUgstate &state) {
@ -766,6 +771,12 @@ BOOL CGEDebugger::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) {
GPU_SetCmdValue((u32)wParam);
}
break;
case WM_GEDBG_UPDATE_WATCH:
// Just a notification to update.
if (watch)
watch->Update();
break;
}
return FALSE;

View File

@ -32,6 +32,7 @@ enum {
WM_GEDBG_TOGGLEPCBREAKPOINT,
WM_GEDBG_RUNTOWPARAM,
WM_GEDBG_SETCMDWPARAM,
WM_GEDBG_UPDATE_WATCH,
};
enum BreakNextType {
@ -52,6 +53,7 @@ class TabStateTexture;
class TabStateSettings;
class TabVertices;
class TabMatrices;
class TabStateWatch;
struct GPUgstate;
class CGEDebugger : public Dialog {
@ -94,6 +96,7 @@ private:
TabMatrices *matrices;
SimpleGLWindow *primaryWindow;
SimpleGLWindow *secondWindow;
TabStateWatch *watch;
TabControl *tabs;
TabControl *fbTabs;
int textureLevel_;

View File

@ -268,6 +268,19 @@ static const TabStateRow stateSettingsRows[] = {
// GE_CMD_TRANSFERSTART,
// GE_CMD_UNKNOWN_*
static std::vector<TabStateRow> watchList;
static void ToggleWatchList(const TabStateRow &info) {
for (size_t i = 0; i < watchList.size(); ++i) {
if (watchList[i].cmd == info.cmd) {
watchList.erase(watchList.begin() + i);
return;
}
}
watchList.push_back(info);
}
CtrlStateValues::CtrlStateValues(const TabStateRow *rows, int rowCount, HWND hwnd)
: GenericListControl(hwnd, stateValuesListDef),
rows_(rows), rowCount_(rowCount) {
@ -863,6 +876,14 @@ void CtrlStateValues::OnRightClick(int row, int column, const POINT &point) {
HMENU subMenu = GetSubMenu(g_hPopupMenus, POPUP_SUBMENU_ID_GEDBG_STATE);
SetMenuDefaultItem(subMenu, ID_REGLIST_CHANGE, FALSE);
// Ehh, kinda ugly.
if (rows_ == &watchList[0]) {
ModifyMenu(subMenu, ID_GEDBG_WATCH, MF_BYCOMMAND | MF_STRING, ID_GEDBG_WATCH, L"Remove Watch");
} else {
ModifyMenu(subMenu, ID_GEDBG_WATCH, MF_BYCOMMAND | MF_STRING, ID_GEDBG_WATCH, L"Add Watch");
}
switch (TrackPopupMenuEx(subMenu, TPM_RIGHTBUTTON | TPM_RETURNCMD, screenPt.x, screenPt.y, GetHandle(), 0))
{
case ID_DISASM_TOGGLEBREAKPOINT:
@ -900,21 +921,24 @@ void CtrlStateValues::OnRightClick(int row, int column, const POINT &point) {
break;
}
case ID_DEBDG_COPYALL:
case ID_GEDBG_COPYALL:
CopyRows(0, GetRowCount());
break;
case ID_REGLIST_CHANGE:
OnDoubleClick(row, column);
break;
}
// TODO: Watch?
case ID_GEDBG_WATCH:
ToggleWatchList(info);
SendMessage(GetParent(GetParent(GetHandle())), WM_GEDBG_UPDATE_WATCH, 0, 0);
break;
}
}
void CtrlStateValues::SetCmdValue(u32 op) {
SendMessage(GetParent(GetParent(GetHandle())), WM_GEDBG_SETCMDWPARAM, op, NULL);
Update();
Update();
}
TabStateValues::TabStateValues(const TabStateRow *rows, int rowCount, LPCSTR dialogID, HINSTANCE _hInstance, HWND _hParent)
@ -981,3 +1005,12 @@ TabStateSettings::TabStateSettings(HINSTANCE _hInstance, HWND _hParent)
TabStateTexture::TabStateTexture(HINSTANCE _hInstance, HWND _hParent)
: TabStateValues(stateTextureRows, ARRAY_SIZE(stateTextureRows), (LPCSTR)IDD_GEDBG_TAB_VALUES, _hInstance, _hParent) {
}
TabStateWatch::TabStateWatch(HINSTANCE _hInstance, HWND _hParent)
: TabStateValues(&watchList[0], 0, (LPCSTR)IDD_GEDBG_TAB_VALUES, _hInstance, _hParent) {
}
void TabStateWatch::Update() {
values->UpdateRows(&watchList[0], (int)watchList.size());
TabStateValues::Update();
}

View File

@ -26,6 +26,12 @@ class CtrlStateValues: public GenericListControl {
public:
CtrlStateValues(const TabStateRow *rows, int rowCount, HWND hwnd);
// Used by watch.
void UpdateRows(const TabStateRow *rows, int rowCount) {
rows_ = rows;
rowCount_ = rowCount;
}
protected:
bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT& returnValue) override {
return false;
@ -54,10 +60,10 @@ public:
protected:
BOOL DlgProc(UINT message, WPARAM wParam, LPARAM lParam);
CtrlStateValues *values;
private:
void UpdateSize(WORD width, WORD height);
CtrlStateValues *values;
};
class TabStateFlags : public TabStateValues {
@ -79,3 +85,10 @@ class TabStateTexture : public TabStateValues {
public:
TabStateTexture(HINSTANCE _hInstance, HWND _hParent);
};
class TabStateWatch : public TabStateValues {
public:
TabStateWatch(HINSTANCE _hInstance, HWND _hParent);
void Update() override;
};

View File

@ -632,9 +632,10 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "Copy Value (Hex)", ID_DISASM_COPYINSTRUCTIONHEX
MENUITEM "Copy Value (Formatted)", ID_DISASM_COPYINSTRUCTIONDISASM
MENUITEM "Copy Entire Tab (Formatted)",ID_DEBDG_COPYALL
MENUITEM "Copy Entire Tab (Formatted)",ID_GEDBG_COPYALL
MENUITEM SEPARATOR
MENUITEM "Toggle Breakpoint", ID_DISASM_TOGGLEBREAKPOINT
MENUITEM "Add Watch", ID_GEDBG_WATCH
END
END

View File

@ -325,7 +325,8 @@
#define ID_OPTIONS_DISPLAY_LAYOUT 40160
#define ID_OPTIONS_VULKAN 40161
#define IDC_GEDBG_BREAKTARGET 40162
#define ID_DEBDG_COPYALL 40163
#define ID_GEDBG_COPYALL 40163
#define ID_GEDBG_WATCH 40164
// Dummy option to let the buffered rendering hotkey cycle through all the options.
#define ID_OPTIONS_BUFFEREDRENDERINGDUMMY 40500
@ -338,7 +339,7 @@
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 256
#define _APS_NEXT_COMMAND_VALUE 40164
#define _APS_NEXT_COMMAND_VALUE 40165
#define _APS_NEXT_CONTROL_VALUE 1199
#define _APS_NEXT_SYMED_VALUE 101
#endif