Added a RAM Watch window to the debugger

Conflicts:
	Source/Core/Core/HW/Memmap.cpp
	Source/Core/Core/HW/Memmap.h
	Source/Core/DolphinWX/Debugger/CodeWindow.h
This commit is contained in:
skidau 2014-10-19 21:45:40 +11:00
parent df37649b9f
commit 613cae613a
21 changed files with 628 additions and 89 deletions

View File

@ -217,3 +217,86 @@ void TMemCheck::Action(DebugInterface *debug_interface, u32 iValue, u32 addr, bo
debug_interface->BreakNow(); debug_interface->BreakNow();
} }
} }
bool Watches::IsAddressWatch(u32 _iAddress)
{
for (const TWatch& bp : m_Watches)
if (bp.iAddress == _iAddress)
return true;
return false;
}
Watches::TWatchesStr Watches::GetStrings() const
{
TWatchesStr bps;
for (const TWatch& bp : m_Watches)
{
std::stringstream ss;
ss << std::hex << bp.iAddress << " " << (bp.bOn ? "n" : "");
bps.push_back(ss.str());
}
return bps;
}
void Watches::AddFromStrings(const TWatchesStr& bpstrs)
{
for (const std::string& bpstr : bpstrs)
{
TWatch bp;
std::stringstream ss;
ss << std::hex << bpstr;
ss >> bp.iAddress;
bp.bOn = bpstr.find("n") != bpstr.npos;
Add(bp);
}
}
void Watches::Add(const TWatch& bp)
{
if (!IsAddressWatch(bp.iAddress))
{
m_Watches.push_back(bp);
}
}
void Watches::Add(u32 em_address)
{
if (!IsAddressWatch(em_address)) // only add new addresses
{
TWatch pt; // breakpoint settings
pt.bOn = true;
pt.iAddress = em_address;
m_Watches.push_back(pt);
}
}
void Watches::Update(int count, u32 em_address)
{
m_Watches.at(count).iAddress = em_address;
}
void Watches::UpdateName(int count, std::string name)
{
m_Watches.at(count).name = name;
}
void Watches::Remove(u32 em_address)
{
for (auto i = m_Watches.begin(); i != m_Watches.end(); ++i)
{
if (i->iAddress == em_address)
{
m_Watches.erase(i);
return;
}
}
}
void Watches::Clear()
{
m_Watches.clear();
}

View File

@ -44,6 +44,13 @@ struct TMemCheck
bool write, int size, u32 pc); bool write, int size, u32 pc);
}; };
struct TWatch
{
std::string name = "";
u32 iAddress;
bool bOn;
};
// Code breakpoints. // Code breakpoints.
class BreakPoints class BreakPoints
{ {
@ -99,3 +106,33 @@ public:
void Clear() { m_MemChecks.clear(); } void Clear() { m_MemChecks.clear(); }
}; };
class Watches
{
public:
typedef std::vector<TWatch> TWatches;
typedef std::vector<std::string> TWatchesStr;
const TWatches& GetWatches() { return m_Watches; }
TWatchesStr GetStrings() const;
void AddFromStrings(const TWatchesStr& bps);
bool IsAddressWatch(u32 _iAddress);
// Add BreakPoint
void Add(u32 em_address);
void Add(const TWatch& bp);
void Update(int count, u32 em_address);
void UpdateName(int count, std::string name);
// Remove Breakpoint
void Remove(u32 _iAddress);
void Clear();
void DeleteByAddress(u32 _Address);
private:
TWatches m_Watches;
};

View File

@ -18,6 +18,7 @@ public:
virtual void ClearBreakpoint(unsigned int /*address*/){} virtual void ClearBreakpoint(unsigned int /*address*/){}
virtual void ClearAllBreakpoints() {} virtual void ClearAllBreakpoints() {}
virtual void ToggleBreakpoint(unsigned int /*address*/){} virtual void ToggleBreakpoint(unsigned int /*address*/){}
virtual void AddWatch(unsigned int /*address*/){}
virtual void ClearAllMemChecks() {} virtual void ClearAllMemChecks() {}
virtual bool IsMemCheck(unsigned int /*address*/) {return false;} virtual bool IsMemCheck(unsigned int /*address*/) {return false;}
virtual void ToggleMemCheck(unsigned int /*address*/){} virtual void ToggleMemCheck(unsigned int /*address*/){}

View File

@ -131,6 +131,11 @@ void PPCDebugInterface::ToggleBreakpoint(unsigned int address)
PowerPC::breakpoints.Add(address); PowerPC::breakpoints.Add(address);
} }
void PPCDebugInterface::AddWatch(unsigned int address)
{
PowerPC::watches.Add(address);
}
void PPCDebugInterface::ClearAllMemChecks() void PPCDebugInterface::ClearAllMemChecks()
{ {
PowerPC::memchecks.Clear(); PowerPC::memchecks.Clear();

View File

@ -22,6 +22,7 @@ public:
virtual void SetBreakpoint(unsigned int address) override; virtual void SetBreakpoint(unsigned int address) override;
virtual void ClearBreakpoint(unsigned int address) override; virtual void ClearBreakpoint(unsigned int address) override;
virtual void ClearAllBreakpoints() override; virtual void ClearAllBreakpoints() override;
virtual void AddWatch(unsigned int address) override;
virtual void ToggleBreakpoint(unsigned int address) override; virtual void ToggleBreakpoint(unsigned int address) override;
virtual void ClearAllMemChecks() override; virtual void ClearAllMemChecks() override;
virtual bool IsMemCheck(unsigned int address) override; virtual bool IsMemCheck(unsigned int address) override;

View File

@ -35,6 +35,7 @@ static volatile CPUState state = CPU_POWERDOWN;
Interpreter * const interpreter = Interpreter::getInstance(); Interpreter * const interpreter = Interpreter::getInstance();
static CoreMode mode; static CoreMode mode;
Watches watches;
BreakPoints breakpoints; BreakPoints breakpoints;
MemChecks memchecks; MemChecks memchecks;
PPCDebugInterface debug_interface; PPCDebugInterface debug_interface;

View File

@ -114,6 +114,7 @@ enum CPUState
extern PowerPCState ppcState; extern PowerPCState ppcState;
extern Watches watches;
extern BreakPoints breakpoints; extern BreakPoints breakpoints;
extern MemChecks memchecks; extern MemChecks memchecks;
extern PPCDebugInterface debug_interface; extern PPCDebugInterface debug_interface;

View File

@ -45,6 +45,8 @@ set(GUI_SRCS
Debugger/MemoryWindow.cpp Debugger/MemoryWindow.cpp
Debugger/RegisterView.cpp Debugger/RegisterView.cpp
Debugger/RegisterWindow.cpp Debugger/RegisterWindow.cpp
Debugger/WatchView.cpp
Debugger/WatchWindow.cpp
FifoPlayerDlg.cpp FifoPlayerDlg.cpp
Frame.cpp Frame.cpp
FrameAui.cpp FrameAui.cpp

View File

@ -52,6 +52,7 @@
#include "DolphinWX/Debugger/DebuggerUIUtil.h" #include "DolphinWX/Debugger/DebuggerUIUtil.h"
#include "DolphinWX/Debugger/JitWindow.h" #include "DolphinWX/Debugger/JitWindow.h"
#include "DolphinWX/Debugger/RegisterWindow.h" #include "DolphinWX/Debugger/RegisterWindow.h"
#include "DolphinWX/Debugger/WatchWindow.h"
extern "C" // Bitmaps extern "C" // Bitmaps
{ {
@ -93,6 +94,7 @@ CCodeWindow::CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter
: wxPanel(parent, id, position, size, style, name) : wxPanel(parent, id, position, size, style, name)
, Parent(parent) , Parent(parent)
, m_RegisterWindow(nullptr) , m_RegisterWindow(nullptr)
, m_WatchWindow(nullptr)
, m_BreakpointWindow(nullptr) , m_BreakpointWindow(nullptr)
, m_MemoryWindow(nullptr) , m_MemoryWindow(nullptr)
, m_JitWindow(nullptr) , m_JitWindow(nullptr)
@ -152,6 +154,7 @@ void CCodeWindow::OnHostMessage(wxCommandEvent& event)
Update(); Update();
if (codeview) codeview->Center(PC); if (codeview) codeview->Center(PC);
if (m_RegisterWindow) m_RegisterWindow->NotifyUpdate(); if (m_RegisterWindow) m_RegisterWindow->NotifyUpdate();
if (m_WatchWindow) m_WatchWindow->NotifyUpdate();
break; break;
case IDM_UPDATEBREAKPOINTS: case IDM_UPDATEBREAKPOINTS:

View File

@ -19,6 +19,7 @@
class CFrame; class CFrame;
class CRegisterWindow; class CRegisterWindow;
class CWatchWindow;
class CBreakPointWindow; class CBreakPointWindow;
class CMemoryWindow; class CMemoryWindow;
class CJitWindow; class CJitWindow;
@ -35,111 +36,113 @@ class wxMenuBar;
class CCodeWindow : public wxPanel class CCodeWindow : public wxPanel
{ {
public: public:
CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter, CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter,
CFrame * parent, CFrame * parent,
wxWindowID id = wxID_ANY, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL | wxBORDER_NONE, long style = wxTAB_TRAVERSAL | wxBORDER_NONE,
const wxString& name = _("Code")); const wxString& name = _("Code"));
void Load(); void Load();
void Save(); void Save();
// Parent interaction // Parent interaction
CFrame *Parent; CFrame *Parent;
wxMenuBar * GetMenuBar(); wxMenuBar * GetMenuBar();
wxToolBar * GetToolBar(); wxToolBar * GetToolBar();
wxBitmap m_Bitmaps[ToolbarDebugBitmapMax]; wxBitmap m_Bitmaps[ToolbarDebugBitmapMax];
bool UseInterpreter(); bool UseInterpreter();
bool BootToPause(); bool BootToPause();
bool AutomaticStart(); bool AutomaticStart();
bool JITNoBlockCache(); bool JITNoBlockCache();
bool JITNoBlockLinking(); bool JITNoBlockLinking();
bool JumpToAddress(u32 address); bool JumpToAddress(u32 address);
void Update() override; void Update() override;
void NotifyMapLoaded(); void NotifyMapLoaded();
void CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParameter, wxMenuBar *pMenuBar); void CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParameter, wxMenuBar *pMenuBar);
void CreateMenuOptions(wxMenu *pMenu); void CreateMenuOptions(wxMenu *pMenu);
void CreateMenuSymbols(wxMenuBar *pMenuBar); void CreateMenuSymbols(wxMenuBar *pMenuBar);
void RecreateToolbar(wxToolBar*); void RecreateToolbar(wxToolBar*);
void PopulateToolbar(wxToolBar* toolBar); void PopulateToolbar(wxToolBar* toolBar);
void UpdateButtonStates(); void UpdateButtonStates();
void OpenPages(); void OpenPages();
void UpdateManager(); void UpdateManager();
// Menu bar // Menu bar
// ------------------- // -------------------
void OnCPUMode(wxCommandEvent& event); // CPU Mode menu void OnCPUMode(wxCommandEvent& event); // CPU Mode menu
void OnJITOff(wxCommandEvent& event); void OnJITOff(wxCommandEvent& event);
void ToggleCodeWindow(bool bShow); void ToggleCodeWindow(bool bShow);
void ToggleRegisterWindow(bool bShow); void ToggleRegisterWindow(bool bShow);
void ToggleBreakPointWindow(bool bShow); void ToggleWatchWindow(bool bShow);
void ToggleMemoryWindow(bool bShow); void ToggleBreakPointWindow(bool bShow);
void ToggleJitWindow(bool bShow); void ToggleMemoryWindow(bool bShow);
void ToggleSoundWindow(bool bShow); void ToggleJitWindow(bool bShow);
void ToggleVideoWindow(bool bShow); void ToggleSoundWindow(bool bShow);
void ToggleVideoWindow(bool bShow);
void OnChangeFont(wxCommandEvent& event); void OnChangeFont(wxCommandEvent& event);
void OnCodeStep(wxCommandEvent& event); void OnCodeStep(wxCommandEvent& event);
void OnAddrBoxChange(wxCommandEvent& event); void OnAddrBoxChange(wxCommandEvent& event);
void OnSymbolsMenu(wxCommandEvent& event); void OnSymbolsMenu(wxCommandEvent& event);
void OnJitMenu(wxCommandEvent& event); void OnJitMenu(wxCommandEvent& event);
void OnProfilerMenu(wxCommandEvent& event); void OnProfilerMenu(wxCommandEvent& event);
// Sub dialogs // Sub dialogs
CRegisterWindow* m_RegisterWindow; CRegisterWindow* m_RegisterWindow;
CBreakPointWindow* m_BreakpointWindow; CWatchWindow* m_WatchWindow;
CMemoryWindow* m_MemoryWindow; CBreakPointWindow* m_BreakpointWindow;
CJitWindow* m_JitWindow; CMemoryWindow* m_MemoryWindow;
DSPDebuggerLLE* m_SoundWindow; CJitWindow* m_JitWindow;
GFXDebuggerPanel* m_VideoWindow; DSPDebuggerLLE* m_SoundWindow;
GFXDebuggerPanel* m_VideoWindow;
// Settings // Settings
bool bAutomaticStart; bool bBootToPause; bool bAutomaticStart; bool bBootToPause;
bool bShowOnStart[IDM_VIDEOWINDOW - IDM_LOGWINDOW + 1]; bool bShowOnStart[IDM_VIDEOWINDOW - IDM_LOGWINDOW + 1];
int iNbAffiliation[IDM_CODEWINDOW - IDM_LOGWINDOW + 1]; int iNbAffiliation[IDM_CODEWINDOW - IDM_LOGWINDOW + 1];
private: private:
enum enum
{ {
// Debugger GUI Objects // Debugger GUI Objects
ID_CODEVIEW, ID_CODEVIEW,
ID_CALLSTACKLIST, ID_CALLSTACKLIST,
ID_CALLERSLIST, ID_CALLERSLIST,
ID_CALLSLIST, ID_CALLSLIST,
ID_SYMBOLLIST ID_SYMBOLLIST
}; };
void OnSymbolListChange(wxCommandEvent& event); void OnSymbolListChange(wxCommandEvent& event);
void OnSymbolListContextMenu(wxContextMenuEvent& event); void OnSymbolListContextMenu(wxContextMenuEvent& event);
void OnCallstackListChange(wxCommandEvent& event); void OnCallstackListChange(wxCommandEvent& event);
void OnCallersListChange(wxCommandEvent& event); void OnCallersListChange(wxCommandEvent& event);
void OnCallsListChange(wxCommandEvent& event); void OnCallsListChange(wxCommandEvent& event);
void OnCodeViewChange(wxCommandEvent &event); void OnCodeViewChange(wxCommandEvent &event);
void OnHostMessage(wxCommandEvent& event); void OnHostMessage(wxCommandEvent& event);
// Debugger functions // Debugger functions
void SingleStep(); void SingleStep();
void StepOver(); void StepOver();
void StepOut(); void StepOut();
void ToggleBreakpoint(); void ToggleBreakpoint();
void UpdateLists(); void UpdateLists();
void UpdateCallstack(); void UpdateCallstack();
void InitBitmaps(); void InitBitmaps();
CCodeView* codeview; CCodeView* codeview;
wxListBox* callstack; wxListBox* callstack;
wxListBox* symbols; wxListBox* symbols;
wxListBox* callers; wxListBox* callers;
wxListBox* calls; wxListBox* calls;
Common::Event sync_event; Common::Event sync_event;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };

View File

@ -51,6 +51,7 @@
#include "DolphinWX/Debugger/JitWindow.h" #include "DolphinWX/Debugger/JitWindow.h"
#include "DolphinWX/Debugger/MemoryWindow.h" #include "DolphinWX/Debugger/MemoryWindow.h"
#include "DolphinWX/Debugger/RegisterWindow.h" #include "DolphinWX/Debugger/RegisterWindow.h"
#include "DolphinWX/Debugger/WatchWindow.h"
// Save and load settings // Save and load settings
@ -421,6 +422,8 @@ void CCodeWindow::OpenPages()
Parent->ToggleLogConfigWindow(true); Parent->ToggleLogConfigWindow(true);
if (bShowOnStart[IDM_REGISTERWINDOW - IDM_LOGWINDOW]) if (bShowOnStart[IDM_REGISTERWINDOW - IDM_LOGWINDOW])
ToggleRegisterWindow(true); ToggleRegisterWindow(true);
if (bShowOnStart[IDM_WATCHWINDOW - IDM_LOGWINDOW])
ToggleWatchWindow(true);
if (bShowOnStart[IDM_BREAKPOINTWINDOW - IDM_LOGWINDOW]) if (bShowOnStart[IDM_BREAKPOINTWINDOW - IDM_LOGWINDOW])
ToggleBreakPointWindow(true); ToggleBreakPointWindow(true);
if (bShowOnStart[IDM_MEMORYWINDOW - IDM_LOGWINDOW]) if (bShowOnStart[IDM_MEMORYWINDOW - IDM_LOGWINDOW])
@ -461,6 +464,24 @@ void CCodeWindow::ToggleRegisterWindow(bool bShow)
} }
} }
void CCodeWindow::ToggleWatchWindow(bool bShow)
{
GetMenuBar()->FindItem(IDM_WATCHWINDOW)->Check(bShow);
if (bShow)
{
if (!m_WatchWindow)
m_WatchWindow = new CWatchWindow(Parent, IDM_WATCHWINDOW);
Parent->DoAddPage(m_WatchWindow,
iNbAffiliation[IDM_WATCHWINDOW - IDM_LOGWINDOW],
Parent->bFloatWindow[IDM_WATCHWINDOW - IDM_LOGWINDOW]);
}
else // Close
{
Parent->DoRemovePage(m_WatchWindow, false);
m_WatchWindow = nullptr;
}
}
void CCodeWindow::ToggleBreakPointWindow(bool bShow) void CCodeWindow::ToggleBreakPointWindow(bool bShow)
{ {
GetMenuBar()->FindItem(IDM_BREAKPOINTWINDOW)->Check(bShow); GetMenuBar()->FindItem(IDM_BREAKPOINTWINDOW)->Check(bShow);

View File

@ -38,6 +38,7 @@ enum
IDM_COPYCODE, IDM_COPYCODE,
IDM_RUNTOHERE, IDM_RUNTOHERE,
IDM_DYNARECRESULTS, IDM_DYNARECRESULTS,
IDM_WATCHADDRESS,
IDM_TOGGLEMEMORY, IDM_TOGGLEMEMORY,
IDM_VIEWASFP, IDM_VIEWASFP,
IDM_VIEWASASCII, IDM_VIEWASASCII,
@ -180,6 +181,11 @@ void CMemoryView::OnPopupMenu(wxCommandEvent& event)
break; break;
#endif #endif
case IDM_WATCHADDRESS:
debugger->AddWatch(selection);
Refresh();
break;
case IDM_TOGGLEMEMORY: case IDM_TOGGLEMEMORY:
memory ^= 1; memory ^= 1;
Refresh(); Refresh();
@ -215,6 +221,7 @@ void CMemoryView::OnMouseDownR(wxMouseEvent& event)
menu->Append(IDM_COPYADDRESS, _("Copy &address")); menu->Append(IDM_COPYADDRESS, _("Copy &address"));
menu->Append(IDM_COPYHEX, _("Copy &hex")); menu->Append(IDM_COPYHEX, _("Copy &hex"));
#endif #endif
menu->Append(IDM_WATCHADDRESS, _("Add to &watch"));
menu->Append(IDM_TOGGLEMEMORY, _("Toggle &memory")); menu->Append(IDM_TOGGLEMEMORY, _("Toggle &memory"));
wxMenu* viewAsSubMenu = new wxMenu; wxMenu* viewAsSubMenu = new wxMenu;

View File

@ -0,0 +1,212 @@
// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <wx/chartype.h>
#include <wx/colour.h>
#include <wx/defs.h>
#include <wx/grid.h>
#include <wx/string.h>
#include <wx/windowid.h>
#include "Common/GekkoDisassembler.h"
#include "Core/HW/Memmap.h"
#include "Core/PowerPC/PowerPC.h"
#include "DolphinWX/WxUtils.h"
#include "DolphinWX/Debugger/DebuggerUIUtil.h"
#include "DolphinWX/Debugger/WatchView.h"
class wxWindow;
static std::string GetWatchName(int count)
{
return PowerPC::watches.GetWatches().at(count - 1).name;
}
static u32 GetWatchAddr(int count)
{
return PowerPC::watches.GetWatches().at(count - 1).iAddress;
}
static u32 GetWatchValue(int count)
{
return Memory::ReadUnchecked_U32(GetWatchAddr(count));
}
static void AddWatchAddr(int count, u32 value)
{
PowerPC::watches.Add(value);
}
static void UpdateWatchAddr(int count, u32 value)
{
PowerPC::watches.Update(count - 1, value);
}
static void SetWatchName(int count, std::string value)
{
PowerPC::watches.UpdateName(count - 1, value);
}
static void SetWatchValue(int count, u32 value)
{
Memory::WriteUnchecked_U32(value, GetWatchAddr(count));
}
wxString CWatchTable::GetValue(int row, int col)
{
if (row == 0)
{
// Column Labels
switch (col)
{
case 0: return wxString::Format("Label");
case 1: return wxString::Format("Addr");
case 2: return wxString::Format("Hex");
case 3: return wxString::Format("Dec");
case 4: return wxString::Format("Str");
default: return wxEmptyString;
}
}
else if (row <= PowerPC::watches.GetWatches().size())
{
if (PowerPC::GetState() != PowerPC::CPU_POWERDOWN)
{
switch (col)
{
case 0: return wxString::Format("%s", GetWatchName(row));
case 1: return wxString::Format("%08x", GetWatchAddr(row));
case 2: return wxString::Format("%08x", GetWatchValue(row));
case 3: return wxString::Format("%lu", GetWatchValue(row));
case 4:
{
u32 addr = GetWatchAddr(row);
if (Memory::IsRAMAddress(addr))
return Memory::GetString(addr, 32).c_str();
else
return wxEmptyString;
}
default: return wxEmptyString;
}
}
}
return wxEmptyString;
}
void CWatchTable::SetValue(int row, int col, const wxString& strNewVal)
{
u32 newVal = 0;
if (col == 0 || TryParse("0x" + WxStrToStr(strNewVal), &newVal))
{
if (row > 0)
{
switch (col)
{
case 0:
{
SetWatchName(row, std::string(WxStrToStr(strNewVal)));
break;
}
case 1:
{
if (row > (int)PowerPC::watches.GetWatches().size())
{
AddWatchAddr(row, newVal);
row = (int)PowerPC::watches.GetWatches().size();
}
else
{
UpdateWatchAddr(row, newVal);
}
break;
}
case 2:
{
SetWatchValue(row, newVal);
break;
}
default:
break;
}
}
}
}
void CWatchTable::UpdateWatch()
{
for (int i = 0; i < (int)PowerPC::watches.GetWatches().size(); ++i)
{
m_CachedWatchHasChanged[i] = (m_CachedWatch[i] != GetWatchValue(i + 1));
m_CachedWatch[i] = GetWatchValue(i + 1);
}
}
wxGridCellAttr *CWatchTable::GetAttr(int row, int col, wxGridCellAttr::wxAttrKind)
{
wxGridCellAttr *attr = new wxGridCellAttr();
attr->SetBackgroundColour(*wxWHITE);
attr->SetFont(DebuggerFont);
switch (col)
{
case 1:
attr->SetAlignment(wxALIGN_LEFT, wxALIGN_CENTER);
break;
case 3:
case 4:
attr->SetAlignment(wxALIGN_LEFT, wxALIGN_CENTER);
break;
default:
attr->SetAlignment(wxALIGN_LEFT, wxALIGN_CENTER);
break;
}
if (row == 0)
{
attr->SetReadOnly(true);
attr->SetBackgroundColour(*wxBLACK);
attr->SetTextColour(*wxWHITE);
}
else
{
bool red = false;
switch (col)
{
case 1: red = m_CachedWatchHasChanged[row]; break;
}
attr->SetTextColour(red ? *wxRED : *wxBLACK);
if (row > (int)(PowerPC::watches.GetWatches().size() + 1))
{
attr->SetReadOnly(true);
attr->SetBackgroundColour(*wxLIGHT_GREY);
}
}
attr->IncRef();
return attr;
}
CWatchView::CWatchView(wxWindow *parent, wxWindowID id)
: wxGrid(parent, id)
{
SetTable(new CWatchTable(), false);
SetRowLabelSize(0);
SetColLabelSize(0);
DisableDragRowSize();
if (PowerPC::GetState() != PowerPC::CPU_POWERDOWN)
{
AutoSizeColumns();
}
}
void CWatchView::Update()
{
if (PowerPC::GetState() != PowerPC::CPU_POWERDOWN)
{
ForceRefresh();
((CWatchTable *)GetTable())->UpdateWatch();
}
}

View File

@ -0,0 +1,50 @@
// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#pragma once
#include <array>
#include <string>
#include <wx/defs.h>
#include <wx/grid.h>
#include <wx/string.h>
#include <wx/windowid.h>
#include "Common/CommonTypes.h"
class wxWindow;
class CWatchTable : public wxGridTableBase
{
enum
{
NUM_SPECIALS = 1,
MAX_SPECIALS = 256,
};
public:
CWatchTable()
{
}
int GetNumberCols() override { return 5; }
int GetNumberRows() override { return MAX_SPECIALS; }
wxString GetValue(int row, int col) override;
void SetValue(int row, int col, const wxString &) override;
wxGridCellAttr *GetAttr(int, int, wxGridCellAttr::wxAttrKind) override;
void UpdateWatch();
private:
std::array<u32, MAX_SPECIALS> m_CachedWatch;
std::array<bool, MAX_SPECIALS> m_CachedWatchHasChanged;
DECLARE_NO_COPY_CLASS(CWatchTable);
};
class CWatchView : public wxGrid
{
public:
CWatchView(wxWindow* parent, wxWindowID id);
void Update() override;
};

View File

@ -0,0 +1,46 @@
// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <cstddef>
#include <wx/defs.h>
#include <wx/event.h>
#include <wx/gdicmn.h>
#include <wx/panel.h>
#include <wx/sizer.h>
#include <wx/string.h>
#include <wx/windowid.h>
#include "DolphinWX/Debugger/WatchView.h"
#include "DolphinWX/Debugger/WatchWindow.h"
class wxWindow;
BEGIN_EVENT_TABLE(CWatchWindow, wxPanel)
END_EVENT_TABLE()
CWatchWindow::CWatchWindow(wxWindow* parent, wxWindowID id,
const wxPoint& position, const wxSize& size,
long style, const wxString& name)
: wxPanel(parent, id, position, size, style, name)
, m_GPRGridView(nullptr)
{
CreateGUIControls();
}
void CWatchWindow::CreateGUIControls()
{
wxBoxSizer *sGrid = new wxBoxSizer(wxVERTICAL);
m_GPRGridView = new CWatchView(this, ID_GPR);
sGrid->Add(m_GPRGridView, 1, wxGROW);
SetSizer(sGrid);
NotifyUpdate();
}
void CWatchWindow::NotifyUpdate()
{
if (m_GPRGridView != nullptr)
m_GPRGridView->Update();
}

View File

@ -0,0 +1,42 @@
// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#pragma once
#include <wx/defs.h>
#include <wx/event.h>
#include <wx/gdicmn.h>
#include <wx/panel.h>
#include <wx/string.h>
#include <wx/translation.h>
#include <wx/windowid.h>
class CWatchView;
class wxWindow;
class CWatchWindow
: public wxPanel
{
public:
CWatchWindow(wxWindow* parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL | wxNO_BORDER,
const wxString& name = _("Watch"));
void NotifyUpdate();
private:
DECLARE_EVENT_TABLE();
enum
{
ID_GPR = 1002
};
CWatchView* m_GPRGridView;
void CreateGUIControls();
};

View File

@ -71,6 +71,8 @@
<ClCompile Include="Debugger\MemoryWindow.cpp" /> <ClCompile Include="Debugger\MemoryWindow.cpp" />
<ClCompile Include="Debugger\RegisterView.cpp" /> <ClCompile Include="Debugger\RegisterView.cpp" />
<ClCompile Include="Debugger\RegisterWindow.cpp" /> <ClCompile Include="Debugger\RegisterWindow.cpp" />
<ClCompile Include="Debugger\WatchView.cpp" />
<ClCompile Include="Debugger\WatchWindow.cpp" />
<ClCompile Include="FifoPlayerDlg.cpp" /> <ClCompile Include="FifoPlayerDlg.cpp" />
<ClCompile Include="Frame.cpp" /> <ClCompile Include="Frame.cpp" />
<ClCompile Include="FrameAui.cpp" /> <ClCompile Include="FrameAui.cpp" />
@ -124,6 +126,8 @@
<ClInclude Include="Debugger\MemoryWindow.h" /> <ClInclude Include="Debugger\MemoryWindow.h" />
<ClInclude Include="Debugger\RegisterView.h" /> <ClInclude Include="Debugger\RegisterView.h" />
<ClInclude Include="Debugger\RegisterWindow.h" /> <ClInclude Include="Debugger\RegisterWindow.h" />
<ClInclude Include="Debugger\WatchView.h" />
<ClInclude Include="Debugger\WatchWindow.h" />
<ClInclude Include="FifoPlayerDlg.h" /> <ClInclude Include="FifoPlayerDlg.h" />
<ClInclude Include="Frame.h" /> <ClInclude Include="Frame.h" />
<ClInclude Include="GameListCtrl.h" /> <ClInclude Include="GameListCtrl.h" />

View File

@ -90,6 +90,12 @@
<ClCompile Include="Debugger\RegisterWindow.cpp"> <ClCompile Include="Debugger\RegisterWindow.cpp">
<Filter>GUI\Debugger</Filter> <Filter>GUI\Debugger</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Debugger\WatchView.cpp">
<Filter>GUI\Debugger</Filter>
</ClCompile>
<ClCompile Include="Debugger\WatchWindow.cpp">
<Filter>GUI\Debugger</Filter>
</ClCompile>
<ClCompile Include="InputConfigDiag.cpp"> <ClCompile Include="InputConfigDiag.cpp">
<Filter>GUI\InputConfig</Filter> <Filter>GUI\InputConfig</Filter>
</ClCompile> </ClCompile>
@ -222,6 +228,12 @@
<ClInclude Include="Debugger\RegisterWindow.h"> <ClInclude Include="Debugger\RegisterWindow.h">
<Filter>GUI\Debugger</Filter> <Filter>GUI\Debugger</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Debugger\WatchView.h">
<Filter>GUI\Debugger</Filter>
</ClInclude>
<ClInclude Include="Debugger\WatchWindow.h">
<Filter>GUI\Debugger</Filter>
</ClInclude>
<ClInclude Include="InputConfigDiag.h"> <ClInclude Include="InputConfigDiag.h">
<Filter>GUI\InputConfig</Filter> <Filter>GUI\InputConfig</Filter>
</ClInclude> </ClInclude>
@ -303,4 +315,4 @@
<ItemGroup> <ItemGroup>
<Image Include="$(CoreDir)..\..\Installer\Dolphin.ico" /> <Image Include="$(CoreDir)..\..\Installer\Dolphin.ico" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -179,6 +179,9 @@ void CFrame::OnToggleWindow(wxCommandEvent& event)
case IDM_REGISTERWINDOW: case IDM_REGISTERWINDOW:
g_pCodeWindow->ToggleRegisterWindow(bShow); g_pCodeWindow->ToggleRegisterWindow(bShow);
break; break;
case IDM_WATCHWINDOW:
g_pCodeWindow->ToggleWatchWindow(bShow);
break;
case IDM_BREAKPOINTWINDOW: case IDM_BREAKPOINTWINDOW:
g_pCodeWindow->ToggleBreakPointWindow(bShow); g_pCodeWindow->ToggleBreakPointWindow(bShow);
break; break;
@ -208,6 +211,7 @@ void CFrame::ClosePages()
{ {
g_pCodeWindow->ToggleCodeWindow(false); g_pCodeWindow->ToggleCodeWindow(false);
g_pCodeWindow->ToggleRegisterWindow(false); g_pCodeWindow->ToggleRegisterWindow(false);
g_pCodeWindow->ToggleWatchWindow(false);
g_pCodeWindow->ToggleBreakPointWindow(false); g_pCodeWindow->ToggleBreakPointWindow(false);
g_pCodeWindow->ToggleMemoryWindow(false); g_pCodeWindow->ToggleMemoryWindow(false);
g_pCodeWindow->ToggleJitWindow(false); g_pCodeWindow->ToggleJitWindow(false);
@ -247,6 +251,8 @@ void CFrame::OnNotebookPageClose(wxAuiNotebookEvent& event)
ToggleLogConfigWindow(false); ToggleLogConfigWindow(false);
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_REGISTERWINDOW) if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_REGISTERWINDOW)
g_pCodeWindow->ToggleRegisterWindow(false); g_pCodeWindow->ToggleRegisterWindow(false);
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_WATCHWINDOW)
g_pCodeWindow->ToggleWatchWindow(false);
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_BREAKPOINTWINDOW) if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_BREAKPOINTWINDOW)
g_pCodeWindow->ToggleBreakPointWindow(false); g_pCodeWindow->ToggleBreakPointWindow(false);
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_JITWINDOW) if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_JITWINDOW)

View File

@ -285,6 +285,7 @@ wxMenuBar* CFrame::CreateMenu()
const wxString MenuText[] = { const wxString MenuText[] = {
wxTRANSLATE("&Registers"), wxTRANSLATE("&Registers"),
wxTRANSLATE("&Watch"),
wxTRANSLATE("&Breakpoints"), wxTRANSLATE("&Breakpoints"),
wxTRANSLATE("&Memory"), wxTRANSLATE("&Memory"),
wxTRANSLATE("&JIT"), wxTRANSLATE("&JIT"),

View File

@ -150,6 +150,7 @@ enum
IDM_LOGWINDOW, IDM_LOGWINDOW,
IDM_LOGCONFIGWINDOW, IDM_LOGCONFIGWINDOW,
IDM_REGISTERWINDOW, IDM_REGISTERWINDOW,
IDM_WATCHWINDOW,
IDM_BREAKPOINTWINDOW, IDM_BREAKPOINTWINDOW,
IDM_MEMORYWINDOW, IDM_MEMORYWINDOW,
IDM_JITWINDOW, IDM_JITWINDOW,