Merge pull request #15402 from unknownbrackets/debugger-highlight

GE Debugger: Highlight changed state values
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2022-02-13 21:42:43 +01:00
commit 858539c5b0
10 files changed
+170 -41

No files matched your search

+26 -10
View File
@@ -65,6 +65,8 @@ static GPUDebugBuffer bufferClut;
static int bufferLevel;
static u32 pauseSetCmdValue;
static GPUgstate lastGState;
static void SetPauseAction(PauseAction act, bool waitComplete = true) {
pauseLock.lock();
std::unique_lock<std::mutex> guard(actionLock);
@@ -133,6 +135,22 @@ static void RunPauseAction() {
pauseAction = PAUSE_BREAK;
}
static void StartStepping() {
if (lastGState.cmdmem[1] == 0) {
lastGState = gstate;
// Play it safe so we don't keep resetting.
lastGState.cmdmem[1] |= 0x01000000;
}
gpuDebug->NotifySteppingEnter();
isStepping = true;
}
static void StopStepping() {
gpuDebug->NotifySteppingExit();
lastGState = gstate;
isStepping = false;
}
bool SingleStep() {
std::unique_lock<std::mutex> guard(pauseLock);
if (coreState != CORE_RUNNING && coreState != CORE_NEXTFRAME && coreState != CORE_STEPPING) {
@@ -147,13 +165,9 @@ bool SingleStep() {
return false;
}
gpuDebug->NotifySteppingEnter();
isStepping = true;
StartStepping();
RunPauseAction();
gpuDebug->NotifySteppingExit();
isStepping = false;
StopStepping();
return true;
}
@@ -171,13 +185,12 @@ bool EnterStepping() {
return false;
}
gpuDebug->NotifySteppingEnter();
StartStepping();
// Just to be sure.
if (pauseAction == PAUSE_CONTINUE) {
pauseAction = PAUSE_BREAK;
}
isStepping = true;
stepCounter++;
do {
@@ -185,8 +198,7 @@ bool EnterStepping() {
pauseWait.wait(guard);
} while (pauseAction != PAUSE_CONTINUE);
gpuDebug->NotifySteppingExit();
isStepping = false;
StopStepping();
return true;
}
@@ -263,4 +275,8 @@ void ForceUnpause() {
actionWait.notify_all();
}
GPUgstate LastState() {
return lastGState;
}
} // namespace
+3
View File
@@ -22,6 +22,7 @@
#include "Common/CommonTypes.h"
#include "Core/Core.h"
#include "GPU/Common/GPUDebugInterface.h"
#include "GPU/GPUState.h"
namespace GPUStepping {
// Should be called from the emu thread.
@@ -42,4 +43,6 @@ namespace GPUStepping {
void ResumeFromStepping();
void ForceUnpause();
GPUgstate LastState();
};
+8 -8
View File
@@ -362,17 +362,17 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam)
leftTabs->HandleNotify(lParam);
break;
case IDC_BREAKPOINTLIST:
breakpointList->HandleNotify(lParam);
break;
SetWindowLongPtr(m_hDlg, DWLP_MSGRESULT, breakpointList->HandleNotify(lParam));
return TRUE;
case IDC_THREADLIST:
threadList->HandleNotify(lParam);
break;
SetWindowLongPtr(m_hDlg, DWLP_MSGRESULT, threadList->HandleNotify(lParam));
return TRUE;
case IDC_STACKFRAMES:
stackTraceView->HandleNotify(lParam);
break;
SetWindowLongPtr(m_hDlg, DWLP_MSGRESULT, stackTraceView->HandleNotify(lParam));
return TRUE;
case IDC_MODULELIST:
moduleList->HandleNotify(lParam);
break;
SetWindowLongPtr(m_hDlg, DWLP_MSGRESULT, moduleList->HandleNotify(lParam));
return TRUE;
case IDC_DEBUG_BOTTOMTABS:
bottomTabs->HandleNotify(lParam);
break;
+4 -4
View File
@@ -258,11 +258,11 @@ BOOL TabDisplayLists::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) {
switch (wParam)
{
case IDC_GEDBG_LISTS_STACK:
stack->HandleNotify(lParam);
break;
SetWindowLongPtr(m_hDlg, DWLP_MSGRESULT, stack->HandleNotify(lParam));
return TRUE;
case IDC_GEDBG_LISTS_ALLLISTS:
allLists->HandleNotify(lParam);
break;
SetWindowLongPtr(m_hDlg, DWLP_MSGRESULT, allLists->HandleNotify(lParam));
return TRUE;
}
break;
+30 -2
View File
@@ -15,8 +15,10 @@
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include <commctrl.h>
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Log.h"
#include "Common/Data/Text/Parsers.h"
#include "Common/StringUtils.h"
#include "Windows/resource.h"
@@ -28,6 +30,7 @@
#include "GPU/GeDisasm.h"
#include "GPU/Common/GPUDebugInterface.h"
#include "GPU/Debugger/Breakpoints.h"
#include "GPU/Debugger/Stepping.h"
using namespace GPUBreakpoints;
@@ -1009,11 +1012,36 @@ void CtrlStateValues::OnRightClick(int row, int column, const POINT &point) {
}
}
bool CtrlStateValues::OnRowPrePaint(int row, LPNMLVCUSTOMDRAW msg) {
if (RowValuesChanged(row)) {
msg->clrText = RGB(255, 0, 0);
return true;
}
return false;
}
void CtrlStateValues::SetCmdValue(u32 op) {
SendMessage(GetParent(GetParent(GetHandle())), WM_GEDBG_SETCMDWPARAM, op, NULL);
Update();
}
bool CtrlStateValues::RowValuesChanged(int row) {
_assert_(gpuDebug != nullptr && row >= 0 && row < rowCount_);
const auto info = rows_[row];
const auto state = gpuDebug->GetGState();
const auto lastState = GPUStepping::LastState();
if (state.cmdmem[info.cmd] != lastState.cmdmem[info.cmd])
return true;
if (info.otherCmd && state.cmdmem[info.otherCmd] != lastState.cmdmem[info.otherCmd])
return true;
if (info.otherCmd2 && state.cmdmem[info.otherCmd2] != lastState.cmdmem[info.otherCmd2])
return true;
return false;
}
TabStateValues::TabStateValues(const TabStateRow *rows, int rowCount, LPCSTR dialogID, HINSTANCE _hInstance, HWND _hParent)
: Dialog(dialogID, _hInstance, _hParent) {
values = new CtrlStateValues(rows, rowCount, GetDlgItem(m_hDlg, IDC_GEDBG_VALUES));
@@ -1054,8 +1082,8 @@ BOOL TabStateValues::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) {
switch (wParam)
{
case IDC_GEDBG_VALUES:
values->HandleNotify(lParam);
break;
SetWindowLongPtr(m_hDlg, DWLP_MSGRESULT, values->HandleNotify(lParam));
return TRUE;
}
break;
}
+4
View File
@@ -41,7 +41,11 @@ protected:
void OnDoubleClick(int row, int column) override;
void OnRightClick(int row, int column, const POINT& point) override;
bool ListenRowPrePaint() override { return true; }
bool OnRowPrePaint(int row, LPNMLVCUSTOMDRAW msg) override;
private:
bool RowValuesChanged(int row);
void SetCmdValue(u32 op);
const TabStateRow *rows_;
+54 -9
View File
@@ -15,6 +15,7 @@
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include <commctrl.h>
#include "Common/CommonTypes.h"
#include "Common/StringUtils.h"
#include "Core/System.h"
@@ -28,6 +29,7 @@
#include "GPU/GeDisasm.h"
#include "GPU/Common/GPUDebugInterface.h"
#include "GPU/Debugger/Breakpoints.h"
#include "GPU/Debugger/Stepping.h"
static const GenericListViewColumn vertexListCols[] = {
{ L"X", 0.1f },
@@ -355,8 +357,8 @@ BOOL TabVertices::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) {
switch (wParam)
{
case IDC_GEDBG_VERTICES:
values->HandleNotify(lParam);
break;
SetWindowLongPtr(m_hDlg, DWLP_MSGRESULT, values->HandleNotify(lParam));
return TRUE;
}
break;
}
@@ -370,14 +372,57 @@ CtrlMatrixList::CtrlMatrixList(HWND hwnd)
Update();
}
bool CtrlMatrixList::GetValue(int row, int col, float &val) {
bool CtrlMatrixList::OnColPrePaint(int row, int col, LPNMLVCUSTOMDRAW msg) {
const auto state = gpuDebug->GetGState();
const auto lastState = GPUStepping::LastState();
bool changed = false;
if (col < MATRIXLIST_COL_0) {
for (int c = MATRIXLIST_COL_0; c <= MATRIXLIST_COL_3; ++c) {
changed = changed || ColChanged(lastState, state, row, c);
}
} else {
changed = ColChanged(lastState, state, row, col);
}
// At the column level, we have to reset the color back.
static int lastRow = -1;
static COLORREF rowDefaultText;
if (lastRow != row) {
rowDefaultText = msg->clrText;
lastRow = row;
}
if (changed) {
msg->clrText = RGB(255, 0, 0);
return true;
} else if (msg->clrText != rowDefaultText) {
msg->clrText = rowDefaultText;
return true;
}
return false;
}
bool CtrlMatrixList::ColChanged(const GPUgstate &lastState, const GPUgstate &state, int row, int col) {
union {
float f;
uint32_t u;
} newVal, oldVal;
if (!GetValue(state, row, col, newVal.f) || !GetValue(lastState, row, col, oldVal.f))
return false;
// If there's any difference in bits, highlight.
return newVal.u != oldVal.u;
}
bool CtrlMatrixList::GetValue(const GPUgstate &state, int row, int col, float &val) {
if (!gpuDebug || row < 0 || row >= MATRIXLIST_ROW_COUNT || col < 0 || col >= MATRIXLIST_COL_COUNT)
return false;
if (col < MATRIXLIST_COL_0)
col = MATRIXLIST_COL_0;
auto state = gpuDebug->GetGState();
if (row >= MATRIXLIST_ROW_BONE_0_0) {
int b = (row - MATRIXLIST_ROW_BONE_0_0) / 3;
int r = (row - MATRIXLIST_ROW_BONE_0_0) % 3;
@@ -419,7 +464,7 @@ void CtrlMatrixList::GetColumnText(wchar_t *dest, int row, int col) {
}
float val;
if (!GetValue(row, col, val)) {
if (!GetValue(gpuDebug->GetGState(), row, col, val)) {
wcscpy(dest, L"Invalid");
return;
}
@@ -534,7 +579,7 @@ void CtrlMatrixList::OnDoubleClick(int row, int column) {
}
float val;
if (!GetValue(row, column, val))
if (!GetValue(gpuDebug->GetGState(), row, column, val))
return;
std::string strvalue = StringFromFormat("%f", val);
@@ -594,7 +639,7 @@ void CtrlMatrixList::OnRightClick(int row, int column, const POINT &point) {
case ID_DISASM_COPYINSTRUCTIONDISASM:
{
float val;
if (GetValue(row, column, val)) {
if (GetValue(gpuDebug->GetGState(), row, column, val)) {
wchar_t dest[512];
swprintf(dest, 511, L"%f", val);
W32Util::CopyTextToClipboard(GetHandle(), dest);
@@ -652,8 +697,8 @@ BOOL TabMatrices::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) {
switch (wParam)
{
case IDC_GEDBG_MATRICES:
values->HandleNotify(lParam);
break;
SetWindowLongPtr(m_hDlg, DWLP_MSGRESULT, values->HandleNotify(lParam));
return TRUE;
}
break;
}
+5 -1
View File
@@ -83,8 +83,12 @@ protected:
void OnDoubleClick(int row, int column) override;
void OnRightClick(int row, int column, const POINT &point) override;
bool ListenColPrePaint() override { return true; }
bool OnColPrePaint(int row, int col, LPNMLVCUSTOMDRAW msg) override;
private:
bool GetValue(int row, int col, float &val);
bool GetValue(const GPUgstate &state, int row, int col, float &val);
bool ColChanged(const GPUgstate &lastState, const GPUgstate &state, int row, int col);
void ToggleBreakpoint(int row);
};
+29 -6
View File
@@ -215,8 +215,7 @@ void GenericListControl::SetIconList(int w, int h, const std::vector<HICON> &ico
ListView_SetImageList(handle, (HIMAGELIST)images_, LVSIL_STATE);
}
void GenericListControl::HandleNotify(LPARAM lParam)
{
int GenericListControl::HandleNotify(LPARAM lParam) {
LPNMHDR mhdr = (LPNMHDR) lParam;
if (mhdr->code == NM_DBLCLK)
@@ -224,7 +223,7 @@ void GenericListControl::HandleNotify(LPARAM lParam)
LPNMITEMACTIVATE item = (LPNMITEMACTIVATE) lParam;
if ((item->iItem != -1 && item->iItem < GetRowCount()) || sendInvalidRows)
OnDoubleClick(item->iItem,item->iSubItem);
return;
return 0;
}
if (mhdr->code == NM_RCLICK)
@@ -232,7 +231,29 @@ void GenericListControl::HandleNotify(LPARAM lParam)
const LPNMITEMACTIVATE item = (LPNMITEMACTIVATE)lParam;
if ((item->iItem != -1 && item->iItem < GetRowCount()) || sendInvalidRows)
OnRightClick(item->iItem,item->iSubItem,item->ptAction);
return;
return 0;
}
if (mhdr->code == NM_CUSTOMDRAW && (ListenRowPrePaint() || ListenColPrePaint())) {
LPNMLVCUSTOMDRAW msg = (LPNMLVCUSTOMDRAW)lParam;
switch (msg->nmcd.dwDrawStage) {
case CDDS_PREPAINT:
return CDRF_NOTIFYITEMDRAW;
case CDDS_ITEMPREPAINT:
if (OnRowPrePaint((int)msg->nmcd.dwItemSpec, msg)) {
return CDRF_NEWFONT;
}
return ListenColPrePaint() ? CDRF_NOTIFYSUBITEMDRAW : CDRF_DODEFAULT;
case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
if (OnColPrePaint((int)msg->nmcd.dwItemSpec, msg->iSubItem, msg)) {
return CDRF_NEWFONT;
}
return CDRF_DODEFAULT;
}
return CDRF_DODEFAULT;
}
if (mhdr->code == LVN_GETDISPINFO)
@@ -247,7 +268,7 @@ void GenericListControl::HandleNotify(LPARAM lParam)
dispInfo->item.pszText = stringBuffer;
dispInfo->item.mask |= LVIF_TEXT;
return;
return 0;
}
// handle checkboxes
@@ -263,8 +284,10 @@ void GenericListControl::HandleNotify(LPARAM lParam)
OnToggle(item->iItem,newImage == 2);
}
return;
return 0;
}
return 0;
}
void GenericListControl::Update() {
+7 -1
View File
@@ -33,6 +33,7 @@ struct GenericListViewDef
#define GLVC_CENTERED 1
typedef struct tagNMLVCUSTOMDRAW *LPNMLVCUSTOMDRAW;
// the most significant bit states whether the key is currently down.
// simply checking if it's != 0 is not enough, as bit0 is set if
@@ -44,7 +45,7 @@ class GenericListControl
public:
GenericListControl(HWND hwnd, const GenericListViewDef& def);
virtual ~GenericListControl();
void HandleNotify(LPARAM lParam);
int HandleNotify(LPARAM lParam);
void Update();
int GetSelectedIndex();
HWND GetHandle() { return handle; };
@@ -62,6 +63,11 @@ protected:
virtual void CopyRows(int start, int size);
virtual void OnToggle(int item, bool newValue) { };
virtual bool ListenRowPrePaint() { return false; }
virtual bool ListenColPrePaint() { return false; }
virtual bool OnRowPrePaint(int row, LPNMLVCUSTOMDRAW msg) { return false; }
virtual bool OnColPrePaint(int row, int col, LPNMLVCUSTOMDRAW msg) { return false; }
private:
static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
void ProcessUpdate();