Skip to content

Commit

Permalink
Added a RAM Watch window to the debugger
Browse files Browse the repository at this point in the history
Conflicts:
	Source/Core/Core/HW/Memmap.cpp
	Source/Core/Core/HW/Memmap.h
	Source/Core/DolphinWX/Debugger/CodeWindow.h
  • Loading branch information
skidau committed Oct 21, 2014
1 parent 92b646b commit 1d71676
Show file tree
Hide file tree
Showing 21 changed files with 643 additions and 104 deletions.
83 changes: 83 additions & 0 deletions Source/Core/Common/BreakPoints.cpp
Expand Up @@ -217,3 +217,86 @@ void TMemCheck::Action(DebugInterface *debug_interface, u32 iValue, u32 addr, bo
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();
}
37 changes: 37 additions & 0 deletions Source/Core/Common/BreakPoints.h
Expand Up @@ -44,6 +44,13 @@ struct TMemCheck
bool write, int size, u32 pc);
};

struct TWatch
{
std::string name = "";
u32 iAddress;
bool bOn;
};

// Code breakpoints.
class BreakPoints
{
Expand Down Expand Up @@ -99,3 +106,33 @@ class MemChecks

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;
};
1 change: 1 addition & 0 deletions Source/Core/Common/DebugInterface.h
Expand Up @@ -18,6 +18,7 @@ class DebugInterface
virtual void ClearBreakpoint(unsigned int /*address*/){}
virtual void ClearAllBreakpoints() {}
virtual void ToggleBreakpoint(unsigned int /*address*/){}
virtual void AddWatch(unsigned int /*address*/){}
virtual void ClearAllMemChecks() {}
virtual bool IsMemCheck(unsigned int /*address*/) {return false;}
virtual void ToggleMemCheck(unsigned int /*address*/){}
Expand Down
5 changes: 5 additions & 0 deletions Source/Core/Core/Debugger/PPCDebugInterface.cpp
Expand Up @@ -131,6 +131,11 @@ void PPCDebugInterface::ToggleBreakpoint(unsigned int address)
PowerPC::breakpoints.Add(address);
}

void PPCDebugInterface::AddWatch(unsigned int address)
{
PowerPC::watches.Add(address);
}

void PPCDebugInterface::ClearAllMemChecks()
{
PowerPC::memchecks.Clear();
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/Debugger/PPCDebugInterface.h
Expand Up @@ -22,6 +22,7 @@ class PPCDebugInterface final : public DebugInterface
virtual void SetBreakpoint(unsigned int address) override;
virtual void ClearBreakpoint(unsigned int address) override;
virtual void ClearAllBreakpoints() override;
virtual void AddWatch(unsigned int address) override;
virtual void ToggleBreakpoint(unsigned int address) override;
virtual void ClearAllMemChecks() override;
virtual bool IsMemCheck(unsigned int address) override;
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/PowerPC/PowerPC.cpp
Expand Up @@ -35,6 +35,7 @@ static volatile CPUState state = CPU_POWERDOWN;
Interpreter * const interpreter = Interpreter::getInstance();
static CoreMode mode;

Watches watches;
BreakPoints breakpoints;
MemChecks memchecks;
PPCDebugInterface debug_interface;
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/PowerPC/PowerPC.h
Expand Up @@ -114,6 +114,7 @@ enum CPUState

extern PowerPCState ppcState;

extern Watches watches;
extern BreakPoints breakpoints;
extern MemChecks memchecks;
extern PPCDebugInterface debug_interface;
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/DolphinWX/CMakeLists.txt
Expand Up @@ -45,6 +45,8 @@ set(GUI_SRCS
Debugger/MemoryWindow.cpp
Debugger/RegisterView.cpp
Debugger/RegisterWindow.cpp
Debugger/WatchView.cpp
Debugger/WatchWindow.cpp
FifoPlayerDlg.cpp
Frame.cpp
FrameAui.cpp
Expand Down
3 changes: 3 additions & 0 deletions Source/Core/DolphinWX/Debugger/CodeWindow.cpp
Expand Up @@ -52,6 +52,7 @@
#include "DolphinWX/Debugger/DebuggerUIUtil.h"
#include "DolphinWX/Debugger/JitWindow.h"
#include "DolphinWX/Debugger/RegisterWindow.h"
#include "DolphinWX/Debugger/WatchWindow.h"

extern "C" // Bitmaps
{
Expand Down Expand Up @@ -93,6 +94,7 @@ CCodeWindow::CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter
: wxPanel(parent, id, position, size, style, name)
, Parent(parent)
, m_RegisterWindow(nullptr)
, m_WatchWindow(nullptr)
, m_BreakpointWindow(nullptr)
, m_MemoryWindow(nullptr)
, m_JitWindow(nullptr)
Expand Down Expand Up @@ -152,6 +154,7 @@ void CCodeWindow::OnHostMessage(wxCommandEvent& event)
Update();
if (codeview) codeview->Center(PC);
if (m_RegisterWindow) m_RegisterWindow->NotifyUpdate();
if (m_WatchWindow) m_WatchWindow->NotifyUpdate();
break;

case IDM_UPDATEBREAKPOINTS:
Expand Down

0 comments on commit 1d71676

Please sign in to comment.