debugger: better saving/loading of breakpoints/memchecks to file
no more softice style :( git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7240 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
7d3ad0b1fe
commit
d7a9dc7df8
|
@ -16,11 +16,164 @@
|
||||||
// http://code.google.com/p/dolphin-emu/
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
|
||||||
#include "DebugInterface.h"
|
#include "DebugInterface.h"
|
||||||
#include "BreakPoints.h"
|
#include "BreakPoints.h"
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
void TMemCheck::Action(DebugInterface *debug_interface, u32 iValue, u32 addr, bool write, int size, u32 pc)
|
bool BreakPoints::IsAddressBreakPoint(u32 _iAddress)
|
||||||
|
{
|
||||||
|
for (TBreakPoints::iterator i = m_BreakPoints.begin(); i != m_BreakPoints.end(); ++i)
|
||||||
|
if (i->iAddress == _iAddress)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BreakPoints::IsTempBreakPoint(u32 _iAddress)
|
||||||
|
{
|
||||||
|
for (TBreakPoints::iterator i = m_BreakPoints.begin(); i != m_BreakPoints.end(); ++i)
|
||||||
|
if (i->iAddress == _iAddress && i->bTemporary)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
BreakPoints::TBreakPointsStr BreakPoints::GetStrings() const
|
||||||
|
{
|
||||||
|
TBreakPointsStr bps;
|
||||||
|
for (TBreakPoints::const_iterator i = m_BreakPoints.begin();
|
||||||
|
i != m_BreakPoints.end(); ++i)
|
||||||
|
{
|
||||||
|
if (!i->bTemporary)
|
||||||
|
{
|
||||||
|
std::stringstream bp;
|
||||||
|
bp << std::hex << i->iAddress << " " << (i->bOn ? "n" : "");
|
||||||
|
bps.push_back(bp.str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return bps;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BreakPoints::AddFromStrings(const TBreakPointsStr& bps)
|
||||||
|
{
|
||||||
|
for (TBreakPointsStr::const_iterator i = bps.begin(); i != bps.end(); ++i)
|
||||||
|
{
|
||||||
|
TBreakPoint bp;
|
||||||
|
std::stringstream bpstr;
|
||||||
|
bpstr << std::hex << *i;
|
||||||
|
bpstr >> bp.iAddress;
|
||||||
|
bp.bOn = i->find("n") != i->npos;
|
||||||
|
bp.bTemporary = false;
|
||||||
|
Add(bp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BreakPoints::Add(const TBreakPoint& bp)
|
||||||
|
{
|
||||||
|
if (!IsAddressBreakPoint(bp.iAddress))
|
||||||
|
m_BreakPoints.push_back(bp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BreakPoints::Add(u32 em_address, bool temp)
|
||||||
|
{
|
||||||
|
if (!IsAddressBreakPoint(em_address)) // only add new addresses
|
||||||
|
{
|
||||||
|
TBreakPoint pt; // breakpoint settings
|
||||||
|
pt.bOn = true;
|
||||||
|
pt.bTemporary = temp;
|
||||||
|
pt.iAddress = em_address;
|
||||||
|
|
||||||
|
m_BreakPoints.push_back(pt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BreakPoints::Remove(u32 _iAddress)
|
||||||
|
{
|
||||||
|
for (TBreakPoints::const_iterator i = m_BreakPoints.begin(); i != m_BreakPoints.end(); ++i)
|
||||||
|
{
|
||||||
|
if (i->iAddress == _iAddress)
|
||||||
|
{
|
||||||
|
m_BreakPoints.erase(i);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MemChecks::TMemChecksStr MemChecks::GetStrings() const
|
||||||
|
{
|
||||||
|
TMemChecksStr mcs;
|
||||||
|
for (TMemChecks::const_iterator i = m_MemChecks.begin();
|
||||||
|
i != m_MemChecks.end(); ++i)
|
||||||
|
{
|
||||||
|
std::stringstream mc;
|
||||||
|
mc << std::hex << i->StartAddress;
|
||||||
|
mc << " " << (i->bRange ? i->EndAddress : i->StartAddress) << " " <<
|
||||||
|
(i->bRange ? "n" : "") << (i->OnRead ? "r" : "") <<
|
||||||
|
(i->OnWrite ? "w" : "") << (i->Log ? "l" : "") << (i->Break ? "p" : "");
|
||||||
|
mcs.push_back(mc.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
return mcs;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MemChecks::AddFromStrings(const TMemChecksStr& mcs)
|
||||||
|
{
|
||||||
|
for (TMemChecksStr::const_iterator i = mcs.begin(); i != mcs.end(); ++i)
|
||||||
|
{
|
||||||
|
TMemCheck mc;
|
||||||
|
std::stringstream mcstr;
|
||||||
|
mcstr << std::hex << *i;
|
||||||
|
mcstr >> mc.StartAddress;
|
||||||
|
mc.bRange = i->find("n") != i->npos;
|
||||||
|
mc.OnRead = i->find("r") != i->npos;
|
||||||
|
mc.OnWrite = i->find("w") != i->npos;
|
||||||
|
mc.Log = i->find("l") != i->npos;
|
||||||
|
mc.Break = i->find("p") != i->npos;
|
||||||
|
if (mc.bRange)
|
||||||
|
mcstr >> mc.EndAddress;
|
||||||
|
else
|
||||||
|
mc.EndAddress = mc.StartAddress;
|
||||||
|
Add(mc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MemChecks::Add(const TMemCheck& _rMemoryCheck)
|
||||||
|
{
|
||||||
|
if (GetMemCheck(_rMemoryCheck.StartAddress) == 0)
|
||||||
|
m_MemChecks.push_back(_rMemoryCheck);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MemChecks::Remove(u32 _Address)
|
||||||
|
{
|
||||||
|
for (TMemChecks::const_iterator i = m_MemChecks.begin(); i != m_MemChecks.end(); ++i)
|
||||||
|
{
|
||||||
|
if (i->StartAddress == _Address)
|
||||||
|
{
|
||||||
|
m_MemChecks.erase(i);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TMemCheck *MemChecks::GetMemCheck(u32 address)
|
||||||
|
{
|
||||||
|
for (TMemChecks::iterator i = m_MemChecks.begin(); i != m_MemChecks.end(); ++i)
|
||||||
|
{
|
||||||
|
if (i->bRange)
|
||||||
|
{
|
||||||
|
if (address >= i->StartAddress && address <= i->EndAddress)
|
||||||
|
return &(*i);
|
||||||
|
}
|
||||||
|
else if (i->StartAddress == address)
|
||||||
|
return &(*i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// none found
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TMemCheck::Action(DebugInterface *debug_interface, u32 iValue, u32 addr,
|
||||||
|
bool write, int size, u32 pc)
|
||||||
{
|
{
|
||||||
if ((write && OnWrite) || (!write && OnRead))
|
if ((write && OnWrite) || (!write && OnRead))
|
||||||
{
|
{
|
||||||
|
@ -36,119 +189,3 @@ void TMemCheck::Action(DebugInterface *debug_interface, u32 iValue, u32 addr, bo
|
||||||
debug_interface->breakNow();
|
debug_interface->breakNow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BreakPoints::IsAddressBreakPoint(u32 _iAddress)
|
|
||||||
{
|
|
||||||
std::vector<TBreakPoint>::iterator iter;
|
|
||||||
for (iter = m_BreakPoints.begin(); iter != m_BreakPoints.end(); ++iter)
|
|
||||||
if ((*iter).iAddress == _iAddress)
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BreakPoints::IsTempBreakPoint(u32 _iAddress)
|
|
||||||
{
|
|
||||||
std::vector<TBreakPoint>::iterator iter;
|
|
||||||
|
|
||||||
for (iter = m_BreakPoints.begin(); iter != m_BreakPoints.end(); ++iter)
|
|
||||||
if ((*iter).iAddress == _iAddress && (*iter).bTemporary)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BreakPoints::Add(u32 em_address, bool temp)
|
|
||||||
{
|
|
||||||
if (!IsAddressBreakPoint(em_address)) // only add new addresses
|
|
||||||
{
|
|
||||||
TBreakPoint pt; // breakpoint settings
|
|
||||||
pt.bOn = true;
|
|
||||||
pt.bTemporary = temp;
|
|
||||||
pt.iAddress = em_address;
|
|
||||||
|
|
||||||
m_BreakPoints.push_back(pt);
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BreakPoints::Remove(u32 _iAddress)
|
|
||||||
{
|
|
||||||
std::vector<TBreakPoint>::iterator iter;
|
|
||||||
for (iter = m_BreakPoints.begin(); iter != m_BreakPoints.end(); ++iter)
|
|
||||||
{
|
|
||||||
if ((*iter).iAddress == _iAddress)
|
|
||||||
{
|
|
||||||
m_BreakPoints.erase(iter);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BreakPoints::Clear()
|
|
||||||
{
|
|
||||||
m_BreakPoints.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BreakPoints::DeleteByAddress(u32 _Address)
|
|
||||||
{
|
|
||||||
// first check breakpoints
|
|
||||||
{
|
|
||||||
std::vector<TBreakPoint>::iterator iter;
|
|
||||||
for (iter = m_BreakPoints.begin(); iter != m_BreakPoints.end(); ++iter)
|
|
||||||
{
|
|
||||||
if ((*iter).iAddress == _Address)
|
|
||||||
{
|
|
||||||
m_BreakPoints.erase(iter);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MemChecks::Add(const TMemCheck& _rMemoryCheck)
|
|
||||||
{
|
|
||||||
m_MemChecks.push_back(_rMemoryCheck);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
TMemCheck *MemChecks::GetMemCheck(u32 address)
|
|
||||||
{
|
|
||||||
std::vector<TMemCheck>::iterator iter;
|
|
||||||
for (iter = m_MemChecks.begin(); iter != m_MemChecks.end(); ++iter)
|
|
||||||
{
|
|
||||||
if ((*iter).bRange)
|
|
||||||
{
|
|
||||||
if (address >= (*iter).StartAddress && address <= (*iter).EndAddress)
|
|
||||||
return &(*iter);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ((*iter).StartAddress == address)
|
|
||||||
return &(*iter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//none found
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MemChecks::Clear()
|
|
||||||
{
|
|
||||||
m_MemChecks.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MemChecks::DeleteByAddress(u32 _Address)
|
|
||||||
{
|
|
||||||
std::vector<TMemCheck>::iterator iter;
|
|
||||||
for (iter = m_MemChecks.begin(); iter != m_MemChecks.end(); ++iter)
|
|
||||||
{
|
|
||||||
if ((*iter).StartAddress == _Address)
|
|
||||||
{
|
|
||||||
m_MemChecks.erase(iter);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -36,6 +36,8 @@ struct TMemCheck
|
||||||
{
|
{
|
||||||
TMemCheck() {
|
TMemCheck() {
|
||||||
numHits = 0;
|
numHits = 0;
|
||||||
|
StartAddress = EndAddress = 0;
|
||||||
|
bRange = OnRead = OnWrite = Log = Break = false;
|
||||||
}
|
}
|
||||||
u32 StartAddress;
|
u32 StartAddress;
|
||||||
u32 EndAddress;
|
u32 EndAddress;
|
||||||
|
@ -50,7 +52,8 @@ struct TMemCheck
|
||||||
|
|
||||||
u32 numHits;
|
u32 numHits;
|
||||||
|
|
||||||
void Action(DebugInterface *dbg_interface, u32 _iValue, u32 addr, bool write, int size, u32 pc);
|
void Action(DebugInterface *dbg_interface, u32 _iValue, u32 addr,
|
||||||
|
bool write, int size, u32 pc);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Code breakpoints.
|
// Code breakpoints.
|
||||||
|
@ -58,19 +61,24 @@ class BreakPoints
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::vector<TBreakPoint> TBreakPoints;
|
typedef std::vector<TBreakPoint> TBreakPoints;
|
||||||
|
typedef std::vector<std::string> TBreakPointsStr;
|
||||||
|
|
||||||
const TBreakPoints& GetBreakPoints() { return m_BreakPoints; }
|
const TBreakPoints& GetBreakPoints() { return m_BreakPoints; }
|
||||||
|
|
||||||
|
TBreakPointsStr GetStrings() const;
|
||||||
|
void AddFromStrings(const TBreakPointsStr& bps);
|
||||||
|
|
||||||
// is address breakpoint
|
// is address breakpoint
|
||||||
bool IsAddressBreakPoint(u32 _iAddress);
|
bool IsAddressBreakPoint(u32 _iAddress);
|
||||||
bool IsTempBreakPoint(u32 _iAddress);
|
bool IsTempBreakPoint(u32 _iAddress);
|
||||||
|
|
||||||
// Add BreakPoint
|
// Add BreakPoint
|
||||||
bool Add(u32 em_address, bool temp=false);
|
void Add(u32 em_address, bool temp=false);
|
||||||
|
void Add(const TBreakPoint& bp);
|
||||||
|
|
||||||
// Remove Breakpoint
|
// Remove Breakpoint
|
||||||
bool Remove(u32 _iAddress);
|
void Remove(u32 _iAddress);
|
||||||
void Clear();
|
void Clear() { m_BreakPoints.clear(); };
|
||||||
|
|
||||||
void DeleteByAddress(u32 _Address);
|
void DeleteByAddress(u32 _Address);
|
||||||
|
|
||||||
|
@ -85,15 +93,22 @@ class MemChecks
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::vector<TMemCheck> TMemChecks;
|
typedef std::vector<TMemCheck> TMemChecks;
|
||||||
|
typedef std::vector<std::string> TMemChecksStr;
|
||||||
|
|
||||||
TMemChecks m_MemChecks;
|
TMemChecks m_MemChecks;
|
||||||
|
|
||||||
const TMemChecks& GetMemChecks() { return m_MemChecks; }
|
const TMemChecks& GetMemChecks() { return m_MemChecks; }
|
||||||
|
|
||||||
|
TMemChecksStr GetStrings() const;
|
||||||
|
void AddFromStrings(const TMemChecksStr& mcs);
|
||||||
|
|
||||||
void Add(const TMemCheck& _rMemoryCheck);
|
void Add(const TMemCheck& _rMemoryCheck);
|
||||||
|
|
||||||
// memory breakpoint
|
// memory breakpoint
|
||||||
TMemCheck *GetMemCheck(u32 address);
|
TMemCheck *GetMemCheck(u32 address);
|
||||||
void DeleteByAddress(u32 _Address);
|
void Remove(u32 _Address);
|
||||||
|
|
||||||
void Clear();
|
void Clear() { m_MemChecks.clear(); };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -156,7 +156,7 @@ void PPCDebugInterface::toggleMemCheck(unsigned int address)
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
PowerPC::memchecks.DeleteByAddress(address);
|
PowerPC::memchecks.Remove(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PPCDebugInterface::insertBLR(unsigned int address, unsigned int value)
|
void PPCDebugInterface::insertBLR(unsigned int address, unsigned int value)
|
||||||
|
|
|
@ -112,6 +112,9 @@ void CBreakPointView::Update()
|
||||||
SetItemData(Item, rMemCheck.StartAddress);
|
SetItemData(Item, rMemCheck.StartAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetColumnWidth(2, -1);
|
||||||
|
SetColumnWidth(3, -1);
|
||||||
|
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,8 +124,8 @@ void CBreakPointView::DeleteCurrentSelection()
|
||||||
if (Item >= 0)
|
if (Item >= 0)
|
||||||
{
|
{
|
||||||
u32 Address = (u32)GetItemData(Item);
|
u32 Address = (u32)GetItemData(Item);
|
||||||
PowerPC::breakpoints.DeleteByAddress(Address);
|
PowerPC::breakpoints.Remove(Address);
|
||||||
PowerPC::memchecks.DeleteByAddress(Address);
|
PowerPC::memchecks.Remove(Address);
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,7 +139,7 @@ CBreakPointBar::CBreakPointBar(CBreakPointWindow* parent, const wxWindowID id, c
|
||||||
SetBackgroundColour(wxColour(0x555555));
|
SetBackgroundColour(wxColour(0x555555));
|
||||||
SetForegroundColour(wxColour(0xffffff));
|
SetForegroundColour(wxColour(0xffffff));
|
||||||
|
|
||||||
// load orignal size 48x48
|
// load original size 48x48
|
||||||
wxMemoryInputStream st1(toolbar_delete_png, sizeof(toolbar_delete_png));
|
wxMemoryInputStream st1(toolbar_delete_png, sizeof(toolbar_delete_png));
|
||||||
wxMemoryInputStream st2(toolbar_add_breakpoint_png, sizeof(toolbar_add_breakpoint_png));
|
wxMemoryInputStream st2(toolbar_add_breakpoint_png, sizeof(toolbar_add_breakpoint_png));
|
||||||
wxMemoryInputStream st3(toolbar_add_memcheck_png, sizeof(toolbar_add_memcheck_png));
|
wxMemoryInputStream st3(toolbar_add_memcheck_png, sizeof(toolbar_add_memcheck_png));
|
||||||
|
@ -157,15 +160,14 @@ CBreakPointBar::CBreakPointBar(CBreakPointWindow* parent, const wxWindowID id, c
|
||||||
void CBreakPointBar::PopulateBar()
|
void CBreakPointBar::PopulateBar()
|
||||||
{
|
{
|
||||||
InsertItem(IDM_DELETE, _("Delete"), 0);
|
InsertItem(IDM_DELETE, _("Delete"), 0);
|
||||||
InsertItem(IDM_CLEAR, _("Clear all"), 0);
|
InsertItem(IDM_CLEAR, _("Clear"), 0);
|
||||||
|
|
||||||
InsertItem(IDM_ADD_BREAKPOINT, _("Add BP..."), 1);
|
InsertItem(IDM_ADD_BREAKPOINT, _("+BP"), 1);
|
||||||
InsertItem(IDM_ADD_BREAKPOINTMANY, _("Add BPs..."), 1);
|
|
||||||
|
|
||||||
// just add memory breakpoints if you can use them
|
// just add memory breakpoints if you can use them
|
||||||
if (Memory::AreMemoryBreakpointsActivated())
|
if (Memory::AreMemoryBreakpointsActivated())
|
||||||
{
|
InsertItem(IDM_ADD_MEMORYCHECK, _("+MC"), 2);
|
||||||
InsertItem(IDM_ADD_MEMORYCHECK, _("Add MC..."), 2);
|
|
||||||
InsertItem(IDM_ADD_MEMORYCHECKMANY, _("Add MCs..."), 2);
|
InsertItem(IDM_SAVEALL, _("Load"));
|
||||||
}
|
InsertItem(IDM_SAVEALL, _("Save"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,10 @@
|
||||||
#include "FileUtil.h"
|
#include "FileUtil.h"
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(CBreakPointWindow, wxPanel)
|
BEGIN_EVENT_TABLE(CBreakPointWindow, wxPanel)
|
||||||
EVT_LIST_ITEM_ACTIVATED(ID_BPS, CBreakPointWindow::OnActivated)
|
EVT_CLOSE(CBreakPointWindow::OnClose)
|
||||||
EVT_LIST_ITEM_SELECTED(ID_TOOLBAR, CBreakPointWindow::OnSelectItem)
|
EVT_LIST_ITEM_SELECTED(ID_BPS, CBreakPointWindow::OnSelectBP)
|
||||||
|
EVT_LIST_ITEM_RIGHT_CLICK(ID_BPS, CBreakPointWindow::OnRightClick)
|
||||||
|
EVT_LIST_ITEM_SELECTED(ID_TOOLBAR, CBreakPointWindow::OnSelectToolbar)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
CBreakPointWindow::CBreakPointWindow(CCodeWindow* _pCodeWindow, wxWindow* parent,
|
CBreakPointWindow::CBreakPointWindow(CCodeWindow* _pCodeWindow, wxWindow* parent,
|
||||||
|
@ -41,6 +43,11 @@ CBreakPointWindow::CBreakPointWindow(CCodeWindow* _pCodeWindow, wxWindow* parent
|
||||||
CreateGUIControls();
|
CreateGUIControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CBreakPointWindow::OnClose(wxCloseEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
SaveAll();
|
||||||
|
}
|
||||||
|
|
||||||
void CBreakPointWindow::CreateGUIControls()
|
void CBreakPointWindow::CreateGUIControls()
|
||||||
{
|
{
|
||||||
SetSize(8, 8, 400, 370);
|
SetSize(8, 8, 400, 370);
|
||||||
|
@ -53,69 +60,65 @@ void CBreakPointWindow::CreateGUIControls()
|
||||||
|
|
||||||
wxBoxSizer* sizerH = new wxBoxSizer(wxVERTICAL);
|
wxBoxSizer* sizerH = new wxBoxSizer(wxVERTICAL);
|
||||||
sizerH->Add(m_BreakPointBar, 0, wxALL | wxEXPAND);
|
sizerH->Add(m_BreakPointBar, 0, wxALL | wxEXPAND);
|
||||||
sizerH->Add((wxListCtrl*)m_BreakPointListView, 1, wxEXPAND);
|
sizerH->Add(m_BreakPointListView, 1, wxEXPAND);
|
||||||
|
|
||||||
NotifyUpdate();
|
|
||||||
SetSizer(sizerH);
|
SetSizer(sizerH);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBreakPointWindow::OnSelectItem(wxListEvent& event)
|
void CBreakPointWindow::OnSelectToolbar(wxListEvent& event)
|
||||||
{
|
{
|
||||||
switch(event.GetItem().GetId())
|
switch(event.GetItem().GetId())
|
||||||
{
|
{
|
||||||
case IDM_DELETE:
|
case IDM_DELETE:
|
||||||
OnDelete();
|
OnDelete();
|
||||||
m_BreakPointBar->SetItemState(event.GetItem().GetId(), 0, wxLIST_STATE_FOCUSED);
|
|
||||||
break;
|
break;
|
||||||
case IDM_CLEAR:
|
case IDM_CLEAR:
|
||||||
OnClear();
|
OnClear();
|
||||||
m_BreakPointBar->SetItemState(event.GetItem().GetId(), 0, wxLIST_STATE_FOCUSED);
|
|
||||||
break;
|
break;
|
||||||
case IDM_ADD_BREAKPOINT:
|
case IDM_ADD_BREAKPOINT:
|
||||||
OnAddBreakPoint();
|
OnAddBreakPoint();
|
||||||
break;
|
break;
|
||||||
case IDM_ADD_BREAKPOINTMANY:
|
|
||||||
OnAddBreakPointMany();
|
|
||||||
break;
|
|
||||||
case IDM_ADD_MEMORYCHECK:
|
case IDM_ADD_MEMORYCHECK:
|
||||||
OnAddMemoryCheck();
|
OnAddMemoryCheck();
|
||||||
break;
|
break;
|
||||||
case IDM_ADD_MEMORYCHECKMANY:
|
case IDM_LOADALL:
|
||||||
OnAddMemoryCheckMany();
|
LoadAll();
|
||||||
|
case IDM_SAVEALL:
|
||||||
|
SaveAll();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBreakPointWindow::NotifyUpdate()
|
void CBreakPointWindow::NotifyUpdate()
|
||||||
{
|
{
|
||||||
if (m_BreakPointListView != NULL) m_BreakPointListView->Update();
|
if (m_BreakPointListView)
|
||||||
|
m_BreakPointListView->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBreakPointWindow::OnDelete()
|
void CBreakPointWindow::OnDelete()
|
||||||
{
|
{
|
||||||
if (m_BreakPointListView)
|
if (m_BreakPointListView)
|
||||||
{
|
|
||||||
m_BreakPointListView->DeleteCurrentSelection();
|
m_BreakPointListView->DeleteCurrentSelection();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void CBreakPointWindow::OnActivated(wxListEvent& event)
|
// jump to begin addr
|
||||||
|
void CBreakPointWindow::OnSelectBP(wxListEvent& event)
|
||||||
{
|
{
|
||||||
long Index = event.GetIndex();
|
long Index = event.GetIndex();
|
||||||
if (Index >= 0)
|
if (Index >= 0)
|
||||||
{
|
{
|
||||||
u32 Address = (u32)m_BreakPointListView->GetItemData(Index);
|
u32 Address = (u32)m_BreakPointListView->GetItemData(Index);
|
||||||
if (m_pCodeWindow != NULL)
|
if (m_pCodeWindow)
|
||||||
{
|
|
||||||
m_pCodeWindow->JumpToAddress(Address);
|
m_pCodeWindow->JumpToAddress(Address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// modify
|
||||||
|
void CBreakPointWindow::OnRightClick(wxListEvent& event)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Breakpoint actions
|
// Clear all breakpoints and memchecks
|
||||||
// ---------------------
|
|
||||||
|
|
||||||
// Clear all breakpoints
|
|
||||||
void CBreakPointWindow::OnClear()
|
void CBreakPointWindow::OnClear()
|
||||||
{
|
{
|
||||||
PowerPC::breakpoints.Clear();
|
PowerPC::breakpoints.Clear();
|
||||||
|
@ -123,143 +126,43 @@ void CBreakPointWindow::OnClear()
|
||||||
NotifyUpdate();
|
NotifyUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add one breakpoint
|
|
||||||
void CBreakPointWindow::OnAddBreakPoint()
|
void CBreakPointWindow::OnAddBreakPoint()
|
||||||
{
|
{
|
||||||
BreakPointDlg bpDlg(this, this);
|
BreakPointDlg bpDlg(this, this);
|
||||||
bpDlg.ShowModal();
|
bpDlg.ShowModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load breakpoints from file
|
void CBreakPointWindow::OnAddMemoryCheck()
|
||||||
void CBreakPointWindow::OnAddBreakPointMany()
|
|
||||||
{
|
|
||||||
// load ini
|
|
||||||
IniFile ini;
|
|
||||||
std::string filename = std::string(File::GetUserPath(D_GAMECONFIG_IDX)) + "BreakPoints.ini";
|
|
||||||
|
|
||||||
if (ini.Load(filename.c_str())) // check if there is any file there
|
|
||||||
{
|
|
||||||
// get lines from a certain section
|
|
||||||
std::vector<std::string> lines;
|
|
||||||
if (!ini.GetLines("BreakPoints", lines))
|
|
||||||
{
|
|
||||||
wxMessageBox(_("You have no [BreakPoints] line in your file"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (std::vector<std::string>::const_iterator iter = lines.begin(); iter != lines.end(); ++iter)
|
|
||||||
{
|
|
||||||
std::string line = StripSpaces(*iter);
|
|
||||||
u32 Address = 0;
|
|
||||||
if (AsciiToHex(line.c_str(), Address))
|
|
||||||
{
|
|
||||||
PowerPC::breakpoints.Add(Address);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Only update after we are done with the loop
|
|
||||||
NotifyUpdate();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wxMessageBox(_("Couldn't find GameConfig/BreakPoints.ini file"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Memory check actions
|
|
||||||
// ---------------------
|
|
||||||
void
|
|
||||||
CBreakPointWindow::OnAddMemoryCheck()
|
|
||||||
{
|
{
|
||||||
MemoryCheckDlg memDlg(this);
|
MemoryCheckDlg memDlg(this);
|
||||||
memDlg.ShowModal();
|
memDlg.ShowModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load memory checks from file
|
void CBreakPointWindow::SaveAll()
|
||||||
void CBreakPointWindow::OnAddMemoryCheckMany()
|
|
||||||
{
|
{
|
||||||
// load ini
|
// simply dump all to bp/mc files in a way we can read again
|
||||||
IniFile ini;
|
IniFile ini;
|
||||||
std::string filename = std::string(File::GetUserPath(D_GAMECONFIG_IDX)) + "MemoryChecks.ini";
|
if (ini.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX)))
|
||||||
|
{
|
||||||
|
ini.SetLines("BreakPoints", PowerPC::breakpoints.GetStrings());
|
||||||
|
ini.SetLines("MemoryChecks", PowerPC::memchecks.GetStrings());
|
||||||
|
ini.Save(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ini.Load(filename.c_str()))
|
void CBreakPointWindow::LoadAll()
|
||||||
{
|
{
|
||||||
// get lines from a certain section
|
IniFile ini;
|
||||||
std::vector<std::string> lines;
|
BreakPoints::TBreakPointsStr newbps;
|
||||||
if (!ini.GetLines("MemoryChecks", lines))
|
MemChecks::TMemChecksStr newmcs;
|
||||||
{
|
|
||||||
wxMessageBox(_("You have no [MemoryChecks] line in your file"));
|
if (!ini.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX)))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
for (std::vector<std::string>::const_iterator iter = lines.begin(); iter != lines.end(); ++iter)
|
if (ini.GetLines("BreakPoints", newbps))
|
||||||
{
|
PowerPC::breakpoints.AddFromStrings(newbps);
|
||||||
std::string line = StripSpaces(*iter);
|
if (ini.GetLines("MemoryChecks", newmcs, false))
|
||||||
std::vector<std::string> pieces;
|
PowerPC::memchecks.AddFromStrings(newmcs);
|
||||||
SplitString(line, ' ', pieces); // split string
|
|
||||||
|
|
||||||
TMemCheck MemCheck;
|
|
||||||
u32 sAddress = 0;
|
|
||||||
u32 eAddress = 0;
|
|
||||||
bool doCommon = false;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------
|
|
||||||
// Decide if we have a range or just one address, and if we should break or not
|
|
||||||
// --------------
|
|
||||||
if (
|
|
||||||
pieces.size() == 1
|
|
||||||
&& AsciiToHex(pieces[0].c_str(), sAddress)
|
|
||||||
&& pieces[0].size() == 8
|
|
||||||
)
|
|
||||||
{
|
|
||||||
// address range
|
|
||||||
MemCheck.StartAddress = sAddress;
|
|
||||||
MemCheck.EndAddress = sAddress;
|
|
||||||
doCommon = true;
|
|
||||||
MemCheck.Break = false;
|
|
||||||
}
|
|
||||||
else if(
|
|
||||||
pieces.size() == 2
|
|
||||||
&& AsciiToHex(pieces[0].c_str(), sAddress) && AsciiToHex(pieces[1].c_str(), eAddress)
|
|
||||||
&& pieces[0].size() == 8 && pieces[1].size() == 8
|
|
||||||
)
|
|
||||||
{
|
|
||||||
// address range
|
|
||||||
MemCheck.StartAddress = sAddress;
|
|
||||||
MemCheck.EndAddress = eAddress;
|
|
||||||
doCommon = true;
|
|
||||||
MemCheck.Break = false;
|
|
||||||
}
|
|
||||||
else if(
|
|
||||||
pieces.size() == 3
|
|
||||||
&& AsciiToHex(pieces[0].c_str(), sAddress) && AsciiToHex(pieces[1].c_str(), eAddress)
|
|
||||||
&& pieces[0].size() == 8 && pieces[1].size() == 8 && pieces[2].size() == 1
|
|
||||||
)
|
|
||||||
{
|
|
||||||
// address range
|
|
||||||
MemCheck.StartAddress = sAddress;
|
|
||||||
MemCheck.EndAddress = eAddress;
|
|
||||||
doCommon = true;
|
|
||||||
MemCheck.Break = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (doCommon)
|
|
||||||
{
|
|
||||||
// settings for the memory check
|
|
||||||
MemCheck.OnRead = true;
|
|
||||||
MemCheck.OnWrite = true;
|
|
||||||
MemCheck.Log = true;
|
|
||||||
//MemCheck.Break = false; // this is also what sets Active "on" in the breakpoint window
|
|
||||||
// so don't think it's off because we are only writing this to the log
|
|
||||||
PowerPC::memchecks.Add(MemCheck);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Update after we are done with the loop
|
|
||||||
NotifyUpdate();
|
NotifyUpdate();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
wxMessageBox(_("You have no ") + wxString::FromAscii(File::GetUserPath(D_GAMECONFIG_IDX)) + _("MemoryChecks.ini file"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -29,18 +29,14 @@ enum
|
||||||
IDM_DELETE = 0,
|
IDM_DELETE = 0,
|
||||||
IDM_CLEAR,
|
IDM_CLEAR,
|
||||||
IDM_ADD_BREAKPOINT,
|
IDM_ADD_BREAKPOINT,
|
||||||
IDM_ADD_BREAKPOINTMANY,
|
|
||||||
IDM_ADD_MEMORYCHECK,
|
IDM_ADD_MEMORYCHECK,
|
||||||
IDM_ADD_MEMORYCHECKMANY
|
IDM_LOADALL,
|
||||||
|
IDM_SAVEALL
|
||||||
};
|
};
|
||||||
|
|
||||||
class CBreakPointWindow
|
class CBreakPointWindow
|
||||||
: public wxPanel
|
: public wxPanel
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CBreakPointWindow(CCodeWindow* _pCodeWindow,
|
CBreakPointWindow(CCodeWindow* _pCodeWindow,
|
||||||
|
@ -52,14 +48,9 @@ class CBreakPointWindow
|
||||||
long style = wxTAB_TRAVERSAL | wxBORDER_NONE);
|
long style = wxTAB_TRAVERSAL | wxBORDER_NONE);
|
||||||
|
|
||||||
void NotifyUpdate();
|
void NotifyUpdate();
|
||||||
void OnDelete();
|
|
||||||
void OnClear();
|
|
||||||
void OnAddBreakPoint();
|
|
||||||
void OnAddBreakPointMany();
|
|
||||||
void OnAddMemoryCheck();
|
|
||||||
void OnAddMemoryCheckMany();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
DECLARE_EVENT_TABLE();
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -71,13 +62,17 @@ class CBreakPointWindow
|
||||||
CBreakPointView* m_BreakPointListView;
|
CBreakPointView* m_BreakPointListView;
|
||||||
CCodeWindow* m_pCodeWindow;
|
CCodeWindow* m_pCodeWindow;
|
||||||
|
|
||||||
// void RecreateToolbar();
|
void OnClose(wxCloseEvent& event);
|
||||||
// void PopulateToolbar(wxToolBar* toolBar);
|
void OnSelectToolbar(wxListEvent& event);
|
||||||
// void InitBitmaps();
|
void OnSelectBP(wxListEvent& event);
|
||||||
|
void OnRightClick(wxListEvent& event);
|
||||||
void CreateGUIControls();
|
void CreateGUIControls();
|
||||||
|
void OnDelete();
|
||||||
void OnSelectItem(wxListEvent& event);
|
void OnClear();
|
||||||
void OnActivated(wxListEvent& event);
|
void OnAddBreakPoint();
|
||||||
|
void OnAddMemoryCheck();
|
||||||
|
void SaveAll();
|
||||||
|
void LoadAll();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue