From cb56b3f76bc2b34abbff2b2e1ee347188051ca79 Mon Sep 17 00:00:00 2001 From: ty Date: Wed, 24 Feb 2021 17:59:40 -0500 Subject: [PATCH] Debugger: Add "Go to address" for both disasm and memory view --- pcsx2/gui/Debugger/CtrlDisassemblyView.cpp | 8 ++++++++ pcsx2/gui/Debugger/CtrlMemView.cpp | 7 ++++++- pcsx2/gui/Debugger/DebugEvents.cpp | 1 + pcsx2/gui/Debugger/DebugEvents.h | 1 + pcsx2/gui/Debugger/DisassemblyDialog.cpp | 16 ++++++++++++++++ 5 files changed, 32 insertions(+), 1 deletion(-) diff --git a/pcsx2/gui/Debugger/CtrlDisassemblyView.cpp b/pcsx2/gui/Debugger/CtrlDisassemblyView.cpp index 94d8b1de8..01c6e13e9 100644 --- a/pcsx2/gui/Debugger/CtrlDisassemblyView.cpp +++ b/pcsx2/gui/Debugger/CtrlDisassemblyView.cpp @@ -62,6 +62,7 @@ enum DisassemblyMenuIdentifiers ID_DISASM_SETPCTOHERE, ID_DISASM_TOGGLEBREAKPOINT, ID_DISASM_FOLLOWBRANCH, + ID_DISASM_GOTOADDRESS, ID_DISASM_GOTOINMEMORYVIEW, ID_DISASM_KILLFUNCTION, ID_DISASM_RENAMEFUNCTION, @@ -168,6 +169,7 @@ CtrlDisassemblyView::CtrlDisassemblyView(wxWindow* parent, DebugInterface* _cpu) menu.Append(ID_DISASM_TOGGLEBREAKPOINT, L"Toggle Breakpoint"); menu.Append(ID_DISASM_FOLLOWBRANCH, L"Follow Branch"); menu.AppendSeparator(); + menu.Append(ID_DISASM_GOTOADDRESS, L"Go to Address"); menu.Append(ID_DISASM_GOTOINMEMORYVIEW, L"Go to in Memory View"); menu.AppendSeparator(); menu.Append(ID_DISASM_ADDFUNCTION, L"Add Function Here"); @@ -669,6 +671,9 @@ void CtrlDisassemblyView::onPopupClick(wxCommandEvent& evt) wxTheClipboard->Close(); } break; + case ID_DISASM_GOTOADDRESS: + postEvent(debEVT_GOTOADDRESS, 0); + break; case ID_DISASM_GOTOINMEMORYVIEW: postEvent(debEVT_GOTOINMEMORYVIEW,curAddress); break; @@ -685,6 +690,9 @@ void CtrlDisassemblyView::onPopupClick(wxCommandEvent& evt) case ID_DISASM_RUNTOHERE: postEvent(debEVT_RUNTOPOS,curAddress); break; + case ID_DISASM_TOGGLEBREAKPOINT: + toggleBreakpoint(false); + break; case ID_DISASM_DISASSEMBLETOFILE: disassembleToFile(); break; diff --git a/pcsx2/gui/Debugger/CtrlMemView.cpp b/pcsx2/gui/Debugger/CtrlMemView.cpp index 73fdd0815..584d15dad 100644 --- a/pcsx2/gui/Debugger/CtrlMemView.cpp +++ b/pcsx2/gui/Debugger/CtrlMemView.cpp @@ -45,6 +45,7 @@ wxEND_EVENT_TABLE() enum MemoryViewMenuIdentifiers { ID_MEMVIEW_GOTOINDISASM = 1, + ID_MEMVIEW_GOTOADDRESS, ID_MEMVIEW_COPYADDRESS, ID_MEMVIEW_FOLLOWADDRESS, ID_MEMVIEW_DISPLAYVALUE_8, @@ -82,6 +83,7 @@ CtrlMemView::CtrlMemView(wxWindow* parent, DebugInterface* _cpu) underlineFont.SetPixelSize(wxSize(charWidth,rowHeight)); menu.Append(ID_MEMVIEW_GOTOINDISASM, L"Go to in Disasm"); + menu.Append(ID_MEMVIEW_GOTOADDRESS, L"Go to address"); menu.Append(ID_MEMVIEW_COPYADDRESS, L"Copy address"); menu.Append(ID_MEMVIEW_FOLLOWADDRESS, L"Follow address"); menu.AppendSeparator(); @@ -326,7 +328,10 @@ void CtrlMemView::onPopupClick(wxCommandEvent& evt) } break; case ID_MEMVIEW_GOTOINDISASM: - postEvent(debEVT_GOTOINDISASM,curAddress); + postEvent(debEVT_GOTOINDISASM,1); + break; + case ID_MEMVIEW_GOTOADDRESS: + postEvent(debEVT_GOTOADDRESS, curAddress); break; case ID_MEMVIEW_FOLLOWADDRESS: gotoAddress(cpu->read32(curAddress), true); diff --git a/pcsx2/gui/Debugger/DebugEvents.cpp b/pcsx2/gui/Debugger/DebugEvents.cpp index b650d2396..6c3a5db9d 100644 --- a/pcsx2/gui/Debugger/DebugEvents.cpp +++ b/pcsx2/gui/Debugger/DebugEvents.cpp @@ -18,6 +18,7 @@ wxDEFINE_EVENT(debEVT_SETSTATUSBARTEXT, wxCommandEvent); wxDEFINE_EVENT(debEVT_UPDATELAYOUT, wxCommandEvent); +wxDEFINE_EVENT(debEVT_GOTOADDRESS, wxCommandEvent); wxDEFINE_EVENT(debEVT_GOTOINMEMORYVIEW, wxCommandEvent); wxDEFINE_EVENT(debEVT_REFERENCEMEMORYVIEW, wxCommandEvent); wxDEFINE_EVENT(debEVT_GOTOINDISASM, wxCommandEvent); diff --git a/pcsx2/gui/Debugger/DebugEvents.h b/pcsx2/gui/Debugger/DebugEvents.h index f82351afc..e8032ad11 100644 --- a/pcsx2/gui/Debugger/DebugEvents.h +++ b/pcsx2/gui/Debugger/DebugEvents.h @@ -19,6 +19,7 @@ wxDECLARE_EVENT(debEVT_SETSTATUSBARTEXT, wxCommandEvent); wxDECLARE_EVENT(debEVT_UPDATELAYOUT, wxCommandEvent); +wxDECLARE_EVENT(debEVT_GOTOADDRESS, wxCommandEvent); wxDECLARE_EVENT(debEVT_GOTOINMEMORYVIEW, wxCommandEvent); wxDECLARE_EVENT(debEVT_REFERENCEMEMORYVIEW, wxCommandEvent); wxDECLARE_EVENT(debEVT_GOTOINDISASM, wxCommandEvent); diff --git a/pcsx2/gui/Debugger/DisassemblyDialog.cpp b/pcsx2/gui/Debugger/DisassemblyDialog.cpp index 3573510c6..51dabfc99 100644 --- a/pcsx2/gui/Debugger/DisassemblyDialog.cpp +++ b/pcsx2/gui/Debugger/DisassemblyDialog.cpp @@ -33,6 +33,7 @@ wxBEGIN_EVENT_TABLE(DisassemblyDialog, wxFrame) EVT_COMMAND( wxID_ANY, debEVT_SETSTATUSBARTEXT, DisassemblyDialog::onDebuggerEvent ) EVT_COMMAND( wxID_ANY, debEVT_UPDATELAYOUT, DisassemblyDialog::onDebuggerEvent ) + EVT_COMMAND( wxID_ANY, debEVT_GOTOADDRESS, DisassemblyDialog::onDebuggerEvent ) EVT_COMMAND( wxID_ANY, debEVT_GOTOINMEMORYVIEW, DisassemblyDialog::onDebuggerEvent ) EVT_COMMAND( wxID_ANY, debEVT_REFERENCEMEMORYVIEW, DisassemblyDialog::onDebuggerEvent ) EVT_COMMAND( wxID_ANY, debEVT_RUNTOPOS, DisassemblyDialog::onDebuggerEvent ) @@ -483,6 +484,21 @@ void DisassemblyDialog::onDebuggerEvent(wxCommandEvent& evt) currentCpu->GetSizer()->Layout(); topSizer->Layout(); update(); + } else if (type == debEVT_GOTOADDRESS) + { + DebugInterface* cpu = reinterpret_cast(evt.GetClientData()); + u64 addr; + if (!executeExpressionWindow(this, cpu, addr)) + return; + + if (currentCpu != NULL) { + // GetInt() is 0 when called by the disassembly view, 1 when called by the memory view + if (!evt.GetInt()) + currentCpu->getDisassembly()->gotoAddress(addr); + else + currentCpu->getMemoryView()->gotoAddress(addr); + } + update(); } else if (type == debEVT_GOTOINMEMORYVIEW) { if (currentCpu != NULL)