diff --git a/Source/Core/Common/BreakPoints.cpp b/Source/Core/Common/BreakPoints.cpp index 50b4d56be5..8ef93758ab 100644 --- a/Source/Core/Common/BreakPoints.cpp +++ b/Source/Core/Common/BreakPoints.cpp @@ -219,7 +219,7 @@ void TMemCheck::Action(DebugInterface *debug_interface, u32 iValue, u32 addr, bo } -bool Watches::IsAddressWatch(u32 _iAddress) +const bool Watches::IsAddressWatch(u32 _iAddress) { for (const TWatch& bp : m_Watches) if (bp.iAddress == _iAddress) diff --git a/Source/Core/Common/BreakPoints.h b/Source/Core/Common/BreakPoints.h index cd18eedd60..73854b8167 100644 --- a/Source/Core/Common/BreakPoints.h +++ b/Source/Core/Common/BreakPoints.h @@ -118,7 +118,7 @@ public: TWatchesStr GetStrings() const; void AddFromStrings(const TWatchesStr& bps); - bool IsAddressWatch(u32 _iAddress); + const bool IsAddressWatch(u32 _iAddress); // Add BreakPoint void Add(u32 em_address); diff --git a/Source/Core/DolphinWX/Debugger/RegisterView.cpp b/Source/Core/DolphinWX/Debugger/RegisterView.cpp index 9cf8f6809b..928a709f88 100644 --- a/Source/Core/DolphinWX/Debugger/RegisterView.cpp +++ b/Source/Core/DolphinWX/Debugger/RegisterView.cpp @@ -271,7 +271,7 @@ void CRegisterView::OnMouseDownR(wxGridEvent& event) int col = event.GetCol(); wxString strNewVal = GetValueByRowCol(row, col); - TryParse("0x" + WxStrToStr(strNewVal), &addr); + TryParse("0x" + WxStrToStr(strNewVal), &m_selectedAddress); wxMenu* menu = new wxMenu; menu->Append(IDM_WATCHADDRESS, _("Add to &watch")); @@ -289,14 +289,14 @@ void CRegisterView::OnPopupMenu(wxCommandEvent& event) switch (event.GetId()) { case IDM_WATCHADDRESS: - PowerPC::watches.Add(addr); + PowerPC::watches.Add(m_selectedAddress); if (watch_window) watch_window->NotifyUpdate(); Refresh(); break; case IDM_VIEWMEMORY: if (memory_window) - memory_window->JumpToAddress(addr); + memory_window->JumpToAddress(m_selectedAddress); Refresh(); break; } diff --git a/Source/Core/DolphinWX/Debugger/RegisterView.h b/Source/Core/DolphinWX/Debugger/RegisterView.h index 959446083b..ef2cfbd705 100644 --- a/Source/Core/DolphinWX/Debugger/RegisterView.h +++ b/Source/Core/DolphinWX/Debugger/RegisterView.h @@ -75,5 +75,5 @@ public: void OnPopupMenu(wxCommandEvent& event); private: - u32 addr = 0; + u32 m_selectedAddress = 0; }; diff --git a/Source/Core/DolphinWX/Debugger/WatchView.cpp b/Source/Core/DolphinWX/Debugger/WatchView.cpp index 6982dd8816..590c71ae3a 100644 --- a/Source/Core/DolphinWX/Debugger/WatchView.cpp +++ b/Source/Core/DolphinWX/Debugger/WatchView.cpp @@ -6,18 +6,31 @@ #include #include #include +#include #include #include #include "Common/GekkoDisassembler.h" #include "Core/HW/Memmap.h" #include "Core/PowerPC/PowerPC.h" +#include "DolphinWX/Frame.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/WatchView.h" +#include "DolphinWX/Debugger/WatchWindow.h" class wxWindow; +enum +{ + IDM_DELETEWATCH, + IDM_VIEWMEMORY, +}; + + static std::string GetWatchName(int count) { return PowerPC::watches.GetWatches().at(count - 1).name; @@ -53,7 +66,7 @@ static void SetWatchValue(int count, u32 value) Memory::WriteUnchecked_U32(value, GetWatchAddr(count)); } -wxString CWatchTable::GetValue(int row, int col) +static wxString GetValueByRowCol(int row, int col) { if (row == 0) { @@ -93,6 +106,11 @@ wxString CWatchTable::GetValue(int row, int col) return wxEmptyString; } +wxString CWatchTable::GetValue(int row, int col) +{ + return GetValueByRowCol(row, col); +} + void CWatchTable::SetValue(int row, int col, const wxString& strNewVal) { u32 newVal = 0; @@ -210,3 +228,50 @@ void CWatchView::Update() ((CWatchTable *)GetTable())->UpdateWatch(); } } + +void CWatchView::OnMouseDownR(wxGridEvent& event) +{ + // popup menu + int row = event.GetRow(); + int col = event.GetCol(); + + if (col == 1 || col == 2) + { + wxString strNewVal = GetValueByRowCol(row, col); + TryParse("0x" + WxStrToStr(strNewVal), &m_selectedAddress); + m_selectedRow = row; + + wxMenu* menu = new wxMenu; + menu->Append(IDM_DELETEWATCH, _("&Delete watch")); + menu->Append(IDM_VIEWMEMORY, _("View &memory")); + PopupMenu(menu); + } +} + +void CWatchView::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; + + wxString strNewVal; + + switch (event.GetId()) + { + case IDM_DELETEWATCH: + strNewVal = GetValueByRowCol(m_selectedRow, 1); + TryParse("0x" + WxStrToStr(strNewVal), &m_selectedAddress); + PowerPC::watches.Remove(m_selectedAddress); + if (watch_window) + watch_window->NotifyUpdate(); + Refresh(); + break; + case IDM_VIEWMEMORY: + if (memory_window) + memory_window->JumpToAddress(m_selectedAddress); + Refresh(); + break; + } + event.Skip(); +} diff --git a/Source/Core/DolphinWX/Debugger/WatchView.h b/Source/Core/DolphinWX/Debugger/WatchView.h index 4f093624a0..dceaa0f3d7 100644 --- a/Source/Core/DolphinWX/Debugger/WatchView.h +++ b/Source/Core/DolphinWX/Debugger/WatchView.h @@ -19,7 +19,6 @@ class CWatchTable : public wxGridTableBase { enum { - NUM_SPECIALS = 1, MAX_SPECIALS = 256, }; @@ -47,4 +46,10 @@ class CWatchView : public wxGrid public: CWatchView(wxWindow* parent, wxWindowID id); void Update() override; + void OnMouseDownR(wxGridEvent& event); + void OnPopupMenu(wxCommandEvent& event); + +private: + u32 m_selectedAddress = 0; + u32 m_selectedRow = 0; }; diff --git a/Source/Core/DolphinWX/Debugger/WatchWindow.cpp b/Source/Core/DolphinWX/Debugger/WatchWindow.cpp index 8f6f578b01..7ac1630625 100644 --- a/Source/Core/DolphinWX/Debugger/WatchWindow.cpp +++ b/Source/Core/DolphinWX/Debugger/WatchWindow.cpp @@ -17,6 +17,8 @@ class wxWindow; BEGIN_EVENT_TABLE(CWatchWindow, wxPanel) +EVT_GRID_CELL_RIGHT_CLICK(CWatchView::OnMouseDownR) +EVT_MENU(-1, CWatchView::OnPopupMenu) END_EVENT_TABLE()