mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 13:30:02 +00:00
Debugger: Allow adding/removing watches.
This commit is contained in:
parent
879e91dbf6
commit
85a071568c
@ -2302,7 +2302,8 @@ set(WindowsFiles
|
||||
Windows/Debugger/Debugger_SymbolMap.h
|
||||
Windows/Debugger/Debugger_VFPUDlg.cpp
|
||||
Windows/Debugger/Debugger_VFPUDlg.h
|
||||
Windows/Debugger/SimpleELF.h
|
||||
Windows/Debugger/WatchItemWindow.cpp
|
||||
Windows/Debugger/WatchItemWindow.h
|
||||
Windows/GEDebugger/CtrlDisplayListView.cpp
|
||||
Windows/GEDebugger/SimpleGLWindow.cpp
|
||||
Windows/GEDebugger/TabState.cpp
|
||||
|
@ -3,8 +3,9 @@
|
||||
#include <windowsx.h>
|
||||
#include <commctrl.h>
|
||||
#include "Windows/Debugger/BreakpointWindow.h"
|
||||
#include "Windows/Debugger/DebuggerShared.h"
|
||||
#include "Windows/Debugger/CtrlDisAsmView.h"
|
||||
#include "Windows/Debugger/DebuggerShared.h"
|
||||
#include "Windows/Debugger/WatchItemWindow.h"
|
||||
#include "Windows/W32Util/ContextMenu.h"
|
||||
#include "Windows/MainWindow.h"
|
||||
#include "Windows/resource.h"
|
||||
@ -902,11 +903,39 @@ void CtrlWatchList::OnRightClick(int itemIndex, int column, const POINT &pt) {
|
||||
}
|
||||
|
||||
void CtrlWatchList::AddWatch() {
|
||||
WatchItemWindow win(nullptr, GetHandle(), cpu_);
|
||||
if (win.Exec()) {
|
||||
WatchInfo info;
|
||||
if (cpu_->initExpression(win.GetExpression().c_str(), info.expression)) {
|
||||
info.name = win.GetName();
|
||||
info.originalExpression = win.GetExpression();
|
||||
watches_.push_back(info);
|
||||
Update();
|
||||
} else {
|
||||
char errorMessage[512];
|
||||
snprintf(errorMessage, sizeof(errorMessage), "Invalid expression \"%s\": %s", win.GetExpression().c_str(), getExpressionError());
|
||||
MessageBoxA(GetHandle(), errorMessage, "Error", MB_OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CtrlWatchList::EditWatch(int pos) {
|
||||
WatchItemWindow win(nullptr, GetHandle(), cpu_);
|
||||
win.Init(watches_[pos].name, watches_[pos].originalExpression);
|
||||
if (win.Exec()) {
|
||||
if (cpu_->initExpression(win.GetExpression().c_str(), watches_[pos].expression)) {
|
||||
watches_[pos].name = win.GetName();
|
||||
watches_[pos].originalExpression = win.GetExpression();
|
||||
Update();
|
||||
} else {
|
||||
char errorMessage[512];
|
||||
snprintf(errorMessage, sizeof(errorMessage), "Invalid expression \"%s\": %s", win.GetExpression().c_str(), getExpressionError());
|
||||
MessageBoxA(GetHandle(), errorMessage, "Error", MB_OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CtrlWatchList::DeleteWatch(int pos) {
|
||||
watches_.erase(watches_.begin() + pos);
|
||||
Update();
|
||||
}
|
||||
|
103
Windows/Debugger/WatchItemWindow.cpp
Normal file
103
Windows/Debugger/WatchItemWindow.cpp
Normal file
@ -0,0 +1,103 @@
|
||||
// Copyright (c) 2023- PPSSPP Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0 or later versions.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include "Common/Common.h"
|
||||
#include "Common/Data/Encoding/Utf8.h"
|
||||
#include "Windows/Debugger/WatchItemWindow.h"
|
||||
#include "Windows/resource.h"
|
||||
|
||||
INT_PTR CALLBACK WatchItemWindow::StaticDlgFunc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam) {
|
||||
WatchItemWindow *thiz;
|
||||
if (iMsg == WM_INITDIALOG) {
|
||||
SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)lParam);
|
||||
thiz = (WatchItemWindow *)lParam;
|
||||
} else {
|
||||
thiz = (WatchItemWindow *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
|
||||
}
|
||||
|
||||
if (!thiz)
|
||||
return FALSE;
|
||||
return thiz->DlgFunc(hWnd, iMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
INT_PTR WatchItemWindow::DlgFunc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam) {
|
||||
switch (iMsg) {
|
||||
case WM_INITDIALOG:
|
||||
SetWindowTextW(GetDlgItem(hWnd, IDC_BREAKPOINT_ADDRESS), ConvertUTF8ToWString(name_).c_str());
|
||||
SetWindowTextW(GetDlgItem(hWnd, IDC_BREAKPOINT_CONDITION), ConvertUTF8ToWString(expression_).c_str());
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam)) {
|
||||
case IDC_BREAKPOINT_OK:
|
||||
switch (HIWORD(wParam)) {
|
||||
case BN_CLICKED:
|
||||
if (FetchDialogData(hWnd)) {
|
||||
EndDialog(hWnd, true);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
};
|
||||
break;
|
||||
case IDC_BREAKPOINT_CANCEL:
|
||||
switch (HIWORD(wParam)) {
|
||||
case BN_CLICKED:
|
||||
EndDialog(hWnd, false);
|
||||
return TRUE;
|
||||
};
|
||||
break;
|
||||
case IDOK:
|
||||
if (FetchDialogData(hWnd)) {
|
||||
EndDialog(hWnd, true);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
case IDCANCEL:
|
||||
EndDialog(hWnd, false);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool WatchItemWindow::Exec() {
|
||||
return DialogBoxParam(GetModuleHandle(0), MAKEINTRESOURCE(IDD_CPUWATCH), parentHwnd_, StaticDlgFunc, (LPARAM)this) != 0;
|
||||
}
|
||||
|
||||
bool WatchItemWindow::FetchDialogData(HWND hwnd) {
|
||||
wchar_t textValue[512];
|
||||
|
||||
GetWindowTextW(GetDlgItem(hwnd, IDC_BREAKPOINT_ADDRESS), textValue, ARRAY_SIZE(textValue));
|
||||
name_ = ConvertWStringToUTF8(textValue);
|
||||
|
||||
GetWindowTextW(GetDlgItem(hwnd, IDC_BREAKPOINT_CONDITION), textValue, ARRAY_SIZE(textValue));
|
||||
expression_ = ConvertWStringToUTF8(textValue);
|
||||
PostfixExpression compiled;
|
||||
if (!cpu_->initExpression(expression_.c_str(), compiled)) {
|
||||
char errorMessage[512];
|
||||
snprintf(errorMessage, sizeof(errorMessage), "Invalid expression \"%s\": %s", expression_.c_str(), getExpressionError());
|
||||
MessageBoxA(hwnd, errorMessage, "Error", MB_OK);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
53
Windows/Debugger/WatchItemWindow.h
Normal file
53
Windows/Debugger/WatchItemWindow.h
Normal file
@ -0,0 +1,53 @@
|
||||
// Copyright (c) 2023- PPSSPP Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0 or later versions.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "Common/CommonWindows.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Core/Debugger/DebugInterface.h"
|
||||
|
||||
class WatchItemWindow {
|
||||
public:
|
||||
WatchItemWindow(HINSTANCE inst, HWND parent, DebugInterface *cpu) : parentHwnd_(parent), cpu_(cpu) {}
|
||||
|
||||
void Init(const std::string &name, const std::string &expression) {
|
||||
name_ = name;
|
||||
expression_ = expression;
|
||||
}
|
||||
|
||||
bool Exec();
|
||||
|
||||
const std::string &GetName() const {
|
||||
return name_;
|
||||
}
|
||||
const std::string &GetExpression() const {
|
||||
return expression_;
|
||||
}
|
||||
|
||||
private:
|
||||
static INT_PTR CALLBACK StaticDlgFunc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam);
|
||||
INT_PTR DlgFunc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam);
|
||||
bool FetchDialogData(HWND hwnd);
|
||||
|
||||
HWND parentHwnd_;
|
||||
DebugInterface *cpu_;
|
||||
|
||||
std::string name_;
|
||||
std::string expression_;
|
||||
};
|
@ -832,6 +832,7 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CaptureDevice.cpp" />
|
||||
<ClCompile Include="Debugger\WatchItemWindow.cpp" />
|
||||
<ClCompile Include="GPU\D3D11Context.cpp" />
|
||||
<ClCompile Include="GPU\D3D9Context.cpp" />
|
||||
<ClCompile Include="Debugger\BreakpointWindow.cpp" />
|
||||
@ -1385,6 +1386,7 @@
|
||||
</ClInclude>
|
||||
<ClInclude Include="BufferLock.h" />
|
||||
<ClInclude Include="CaptureDevice.h" />
|
||||
<ClInclude Include="Debugger\WatchItemWindow.h" />
|
||||
<ClInclude Include="GPU\D3D11Context.h" />
|
||||
<ClInclude Include="GPU\D3D9Context.h" />
|
||||
<ClInclude Include="Debugger\BreakpointWindow.h" />
|
||||
|
@ -274,6 +274,9 @@
|
||||
<ClCompile Include="W32Util\UAHMenuBar.cpp">
|
||||
<Filter>Windows\W32Util</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Debugger\WatchItemWindow.cpp">
|
||||
<Filter>Windows\Debugger</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Debugger\CtrlDisAsmView.h">
|
||||
@ -559,6 +562,9 @@
|
||||
<ClInclude Include="W32Util\UAHMenuBar.h">
|
||||
<Filter>Windows\W32Util</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Debugger\WatchItemWindow.h">
|
||||
<Filter>Windows\Debugger</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="icon1.ico">
|
||||
|
@ -389,6 +389,19 @@ BEGIN
|
||||
PUSHBUTTON "Cancel",IDCANCEL,173,79,50,14
|
||||
END
|
||||
|
||||
IDD_CPUWATCH DIALOGEX 0, 0, 236, 70
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Watch"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
LTEXT "Name",IDC_STATIC,7,9,36,8
|
||||
EDITTEXT IDC_BREAKPOINT_ADDRESS,56,7,173,14,ES_AUTOHSCROLL
|
||||
LTEXT "Expression",IDC_STATIC,7,28,36,8
|
||||
EDITTEXT IDC_BREAKPOINT_CONDITION,56,26,173,14,ES_AUTOHSCROLL
|
||||
DEFPUSHBUTTON "OK",IDC_BREAKPOINT_OK,144,47,41,14
|
||||
PUSHBUTTON "Cancel",IDC_BREAKPOINT_CANCEL,186,47,42,14
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
@ -59,6 +59,7 @@
|
||||
#define IDD_GEDBG_TAB_VERTICES 254
|
||||
#define IDD_GEDBG_TAB_MATRICES 255
|
||||
#define IDD_GEDBG_STEPCOUNT 256
|
||||
#define IDD_CPUWATCH 257
|
||||
|
||||
#define IDC_STOPGO 1001
|
||||
#define IDC_ADDRESS 1002
|
||||
@ -349,7 +350,7 @@
|
||||
// Next default values for new objects
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 256
|
||||
#define _APS_NEXT_RESOURCE_VALUE 258
|
||||
#define _APS_NEXT_COMMAND_VALUE 40231
|
||||
#define _APS_NEXT_CONTROL_VALUE 1202
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
|
Loading…
Reference in New Issue
Block a user