From d0a3bb765088b8d6f923ef62aac4761de332a12f Mon Sep 17 00:00:00 2001 From: skidau Date: Fri, 24 Oct 2014 00:47:00 +1100 Subject: [PATCH] Added "Add to watch" context menu items to the Memory and Register windows. Added "View memory" context menu item to the Register window. --- Source/Core/DolphinWX/Debugger/MemoryView.cpp | 9 +++ .../Core/DolphinWX/Debugger/RegisterView.cpp | 58 ++++++++++++++++++- Source/Core/DolphinWX/Debugger/RegisterView.h | 12 ++-- .../DolphinWX/Debugger/RegisterWindow.cpp | 3 + 4 files changed, 77 insertions(+), 5 deletions(-) diff --git a/Source/Core/DolphinWX/Debugger/MemoryView.cpp b/Source/Core/DolphinWX/Debugger/MemoryView.cpp index f05c1b96fa..4effea6520 100644 --- a/Source/Core/DolphinWX/Debugger/MemoryView.cpp +++ b/Source/Core/DolphinWX/Debugger/MemoryView.cpp @@ -25,10 +25,13 @@ #include "Common/DebugInterface.h" #include "Common/StringUtil.h" #include "Core/HW/Memmap.h" +#include "DolphinWX/Frame.h" #include "DolphinWX/Globals.h" #include "DolphinWX/WxUtils.h" +#include "DolphinWX/Debugger/CodeWindow.h" #include "DolphinWX/Debugger/DebuggerUIUtil.h" #include "DolphinWX/Debugger/MemoryView.h" +#include "DolphinWX/Debugger/WatchWindow.h" enum { @@ -162,6 +165,10 @@ void CMemoryView::OnScrollWheel(wxMouseEvent& event) void CMemoryView::OnPopupMenu(wxCommandEvent& event) { + CFrame* main_frame = (CFrame*)(GetParent()->GetParent()->GetParent()); + CCodeWindow* code_window = main_frame->g_pCodeWindow; + CWatchWindow* watch_window = code_window->m_WatchWindow; + #if wxUSE_CLIPBOARD wxTheClipboard->Open(); #endif @@ -183,6 +190,8 @@ void CMemoryView::OnPopupMenu(wxCommandEvent& event) case IDM_WATCHADDRESS: debugger->AddWatch(selection); + if (watch_window) + watch_window->NotifyUpdate(); Refresh(); break; diff --git a/Source/Core/DolphinWX/Debugger/RegisterView.cpp b/Source/Core/DolphinWX/Debugger/RegisterView.cpp index 6f13a4a2ba..9cf8f6809b 100644 --- a/Source/Core/DolphinWX/Debugger/RegisterView.cpp +++ b/Source/Core/DolphinWX/Debugger/RegisterView.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -15,14 +16,25 @@ #include "Core/HW/ProcessorInterface.h" #include "Core/PowerPC/Gekko.h" #include "Core/PowerPC/PowerPC.h" +#include "DolphinWX/Frame.h" +#include "DolphinWX/Globals.h" #include "DolphinWX/WxUtils.h" +#include "DolphinWX/Debugger/CodeWindow.h" #include "DolphinWX/Debugger/DebuggerUIUtil.h" +#include "DolphinWX/Debugger/MemoryWindow.h" #include "DolphinWX/Debugger/RegisterView.h" +#include "DolphinWX/Debugger/WatchWindow.h" class wxWindow; // F-zero 80005e60 wtf?? +enum +{ + IDM_WATCHADDRESS, + IDM_VIEWMEMORY, +}; + static const char *special_reg_names[] = { "PC", "LR", "CTR", "CR", "FPSCR", "MSR", "SRR0", "SRR1", "Exceptions", "Int Mask", "Int Cause", "DSISR", "DAR", "PT hashmask" }; @@ -49,7 +61,7 @@ static u32 GetSpecialRegValue(int reg) } } -wxString CRegTable::GetValue(int row, int col) +static wxString GetValueByRowCol(int row, int col) { if (row < 32) { @@ -130,6 +142,11 @@ wxString CRegTable::GetValue(int row, int col) return wxEmptyString; } +wxString CRegTable::GetValue(int row, int col) +{ + return GetValueByRowCol(row, col); +} + static void SetSpecialRegValue(int reg, u32 value) { switch (reg) @@ -246,3 +263,42 @@ void CRegisterView::Update() ForceRefresh(); ((CRegTable *)GetTable())->UpdateCachedRegs(); } + +void CRegisterView::OnMouseDownR(wxGridEvent& event) +{ + // popup menu + int row = event.GetRow(); + int col = event.GetCol(); + + wxString strNewVal = GetValueByRowCol(row, col); + TryParse("0x" + WxStrToStr(strNewVal), &addr); + + wxMenu* menu = new wxMenu; + menu->Append(IDM_WATCHADDRESS, _("Add to &watch")); + menu->Append(IDM_VIEWMEMORY, _("View &memory")); + PopupMenu(menu); +} + +void CRegisterView::OnPopupMenu(wxCommandEvent& event) +{ + CFrame* main_frame = (CFrame*)(GetParent()->GetParent()); + CCodeWindow* code_window = main_frame->g_pCodeWindow; + CWatchWindow* watch_window = code_window->m_WatchWindow; + CMemoryWindow* memory_window = code_window->m_MemoryWindow; + + switch (event.GetId()) + { + case IDM_WATCHADDRESS: + PowerPC::watches.Add(addr); + if (watch_window) + watch_window->NotifyUpdate(); + Refresh(); + break; + case IDM_VIEWMEMORY: + if (memory_window) + memory_window->JumpToAddress(addr); + Refresh(); + break; + } + event.Skip(); +} diff --git a/Source/Core/DolphinWX/Debugger/RegisterView.h b/Source/Core/DolphinWX/Debugger/RegisterView.h index 663d8734b5..959446083b 100644 --- a/Source/Core/DolphinWX/Debugger/RegisterView.h +++ b/Source/Core/DolphinWX/Debugger/RegisterView.h @@ -30,14 +30,13 @@ class wxWindow; // Interrupt Mask (PI) // Interrupt Cause(PI) +#define NUM_SPECIALS 14 + class CRegTable : public wxGridTableBase { - enum - { - NUM_SPECIALS = 14, - }; public: + CRegTable() { memset(m_CachedRegs, 0, sizeof(m_CachedRegs)); @@ -72,4 +71,9 @@ class CRegisterView : public wxGrid public: CRegisterView(wxWindow* parent, wxWindowID id); void Update() override; + void OnMouseDownR(wxGridEvent& event); + void OnPopupMenu(wxCommandEvent& event); + +private: + u32 addr = 0; }; diff --git a/Source/Core/DolphinWX/Debugger/RegisterWindow.cpp b/Source/Core/DolphinWX/Debugger/RegisterWindow.cpp index f385bf20d0..2e3d2611dd 100644 --- a/Source/Core/DolphinWX/Debugger/RegisterWindow.cpp +++ b/Source/Core/DolphinWX/Debugger/RegisterWindow.cpp @@ -11,12 +11,15 @@ #include #include +#include "Core/PowerPC/PowerPC.h" #include "DolphinWX/Debugger/RegisterView.h" #include "DolphinWX/Debugger/RegisterWindow.h" class wxWindow; BEGIN_EVENT_TABLE(CRegisterWindow, wxPanel) +EVT_GRID_CELL_RIGHT_CLICK(CRegisterView::OnMouseDownR) +EVT_MENU(-1, CRegisterView::OnPopupMenu) END_EVENT_TABLE()