From 7804c2c026112706a6614926a99616e3c1e3fa6e Mon Sep 17 00:00:00 2001 From: John Peterson Date: Sat, 18 Oct 2008 02:21:59 +0000 Subject: [PATCH] Added option to load breakpoints and memory checks from a file. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@905 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Src/Debugger/Debugger_BreakPoints.cpp | 22 ++-- .../Core/Src/Debugger/Debugger_BreakPoints.h | 1 + Source/Core/DebuggerWX/Src/BreakPointDlg.cpp | 3 +- .../Core/DebuggerWX/Src/BreakpointWindow.cpp | 110 ++++++++++++++++++ Source/Core/DebuggerWX/Src/BreakpointWindow.h | 8 +- Source/Core/DebuggerWX/Src/MemoryCheckDlg.cpp | 1 + 6 files changed, 134 insertions(+), 11 deletions(-) diff --git a/Source/Core/Core/Src/Debugger/Debugger_BreakPoints.cpp b/Source/Core/Core/Src/Debugger/Debugger_BreakPoints.cpp index 9f22debd1c..28595c0a6d 100644 --- a/Source/Core/Core/Src/Debugger/Debugger_BreakPoints.cpp +++ b/Source/Core/Core/Src/Debugger/Debugger_BreakPoints.cpp @@ -25,10 +25,8 @@ #include "Common.h" - #include "../HW/CPU.h" #include "../Host.h" - #include "../PowerPC/SymbolDB.h" #include "Debugger_BreakPoints.h" @@ -48,8 +46,10 @@ void TMemCheck::Action(u32 iValue, u32 addr, bool write, int size, u32 pc) if (Log) { LOG(MEMMAP,"CHK %08x %s%i at %08x (%s)", - iValue, write ? "Write" : "Read", size*8, addr, - g_symbolDB.GetDescription(addr)); + iValue, write ? "Write" : "Read", // read or write + size*8, addr, // address + g_symbolDB.GetDescription(addr) // symbol map description + ); } if (Break) CCPU::Break(); @@ -101,16 +101,14 @@ TMemCheck *CBreakPoints::GetMemCheck(u32 address) void CBreakPoints::AddBreakPoint(u32 _iAddress, bool temp) { - if (!IsAddressBreakPoint(_iAddress)) + if (!IsAddressBreakPoint(_iAddress)) // only add new addresses { - TBreakPoint pt; + TBreakPoint pt; // breakpoint settings pt.bOn = true; pt.bTemporary = temp; pt.iAddress = _iAddress; m_BreakPoints.push_back(pt); - - Host_UpdateBreakPointView(); } } @@ -133,13 +131,19 @@ void CBreakPoints::RemoveBreakPoint(u32 _iAddress) void CBreakPoints::ClearAllBreakPoints() { m_BreakPoints.clear(); + m_MemChecks.clear(); + Host_UpdateBreakPointView(); +} + +// update breakpoint window +void CBreakPoints::UpdateBreakPointView() +{ Host_UpdateBreakPointView(); } void CBreakPoints::AddMemoryCheck(const TMemCheck& _rMemoryCheck) { m_MemChecks.push_back(_rMemoryCheck); - Host_UpdateBreakPointView(); } void CBreakPoints::AddAutoBreakpoints() diff --git a/Source/Core/Core/Src/Debugger/Debugger_BreakPoints.h b/Source/Core/Core/Src/Debugger/Debugger_BreakPoints.h index b7ddaed804..382877b7be 100644 --- a/Source/Core/Core/Src/Debugger/Debugger_BreakPoints.h +++ b/Source/Core/Core/Src/Debugger/Debugger_BreakPoints.h @@ -80,6 +80,7 @@ public: static void AddMemoryCheck(const TMemCheck& _rMemoryCheck); static void ClearAllBreakPoints(); + static void UpdateBreakPointView(); static void AddAutoBreakpoints(); diff --git a/Source/Core/DebuggerWX/Src/BreakPointDlg.cpp b/Source/Core/DebuggerWX/Src/BreakPointDlg.cpp index cd58d6a23e..2a13bcb7a3 100644 --- a/Source/Core/DebuggerWX/Src/BreakPointDlg.cpp +++ b/Source/Core/DebuggerWX/Src/BreakPointDlg.cpp @@ -77,7 +77,8 @@ void BreakPointDlg::OnOK(wxCommandEvent& /*event*/) if (AsciiToHex(AddressString.mb_str(), Address)) { CBreakPoints::AddBreakPoint(Address); - Close(); + CBreakPoints::UpdateBreakPointView(); + Close(); } } diff --git a/Source/Core/DebuggerWX/Src/BreakpointWindow.cpp b/Source/Core/DebuggerWX/Src/BreakpointWindow.cpp index 52745456b4..ed3ef56b3d 100644 --- a/Source/Core/DebuggerWX/Src/BreakpointWindow.cpp +++ b/Source/Core/DebuggerWX/Src/BreakpointWindow.cpp @@ -23,6 +23,7 @@ #include "BreakPointDlg.h" #include "MemoryCheckDlg.h" #include "IniFile.h" +#include "Debugger/Debugger_BreakPoints.h" // for TMemCheck #include @@ -37,8 +38,11 @@ static const long TOOLBAR_STYLE = wxTB_FLAT | wxTB_DOCKABLE | wxTB_TEXT; BEGIN_EVENT_TABLE(CBreakPointWindow, wxFrame) EVT_CLOSE(CBreakPointWindow::OnClose) EVT_MENU(IDM_DELETE, CBreakPointWindow::OnDelete) + EVT_MENU(IDM_CLEAR, CBreakPointWindow::OnClear) EVT_MENU(IDM_ADD_BREAKPOINT, CBreakPointWindow::OnAddBreakPoint) + EVT_MENU(IDM_ADD_BREAKPOINTMANY, CBreakPointWindow::OnAddBreakPointMany) EVT_MENU(IDM_ADD_MEMORYCHECK, CBreakPointWindow::OnAddMemoryCheck) + EVT_MENU(IDM_ADD_MEMORYCHECKMANY, CBreakPointWindow::OnAddMemoryCheckMany) EVT_LIST_ITEM_ACTIVATED(ID_BPS, CBreakPointWindow::OnActivated) END_EVENT_TABLE() @@ -115,13 +119,18 @@ CBreakPointWindow::PopulateToolbar(wxToolBar* toolBar) toolBar->SetToolBitmapSize(wxSize(w, h)); toolBar->AddTool(IDM_DELETE, _T("Delete"), m_Bitmaps[Toolbar_Delete], _T("Delete the selected BreakPoint or MemoryCheck")); + toolBar->AddTool(IDM_CLEAR, _T("Clear all"), m_Bitmaps[Toolbar_Delete], _T("Clear all BreakPoints and MemoryChecks")); + toolBar->AddSeparator(); + toolBar->AddTool(IDM_ADD_BREAKPOINT, _T("BP"), m_Bitmaps[Toolbar_Add_BreakPoint], _T("Add BreakPoint...")); + toolBar->AddTool(IDM_ADD_BREAKPOINTMANY, _T("BPs"), m_Bitmaps[Toolbar_Add_BreakPoint], _T("Add BreakPoints...")); // just add memory breakpoints if you can use them if (Memory::AreMemoryBreakpointsActivated()) { toolBar->AddTool(IDM_ADD_MEMORYCHECK, _T("MC"), m_Bitmaps[Toolbar_Add_Memcheck], _T("Add MemoryCheck...")); + toolBar->AddTool(IDM_ADD_MEMORYCHECKMANY, _T("MCs"), m_Bitmaps[Toolbar_Add_Memcheck], _T("Add MemoryChecks...")); } // after adding the buttons to the toolbar, must call Realize() to reflect @@ -190,6 +199,17 @@ CBreakPointWindow::OnDelete(wxCommandEvent& event) } +// ========================================================================================== +// Clear all breakpoints +// ------------ +void +CBreakPointWindow::OnClear(wxCommandEvent& event) +{ + CBreakPoints::ClearAllBreakPoints(); +} +// ============ + + void CBreakPointWindow::OnAddBreakPoint(wxCommandEvent& event) { @@ -198,6 +218,47 @@ CBreakPointWindow::OnAddBreakPoint(wxCommandEvent& event) } +// ========================================================================================== +// Load breakpoints from file +// -------------- +void +CBreakPointWindow::OnAddBreakPointMany(wxCommandEvent& event) +{ + // load ini + IniFile ini; + std::string filename = std::string("GameIni/BreakPoints.ini"); + + if (ini.Load(filename.c_str())) // check if there is any file there + { + // get lines from a certain section + std::vector lines; + if (!ini.GetLines("BreakPoints", lines)) + { + wxMessageBox(_T("You have no [BreakPoints] line in your file")); + return; + } + + for (std::vector::const_iterator iter = lines.begin(); iter != lines.end(); ++iter) + { + std::string line = StripSpaces(*iter); + u32 Address = 0; + if (AsciiToHex(line.c_str(), Address)) + { + CBreakPoints::AddBreakPoint(Address); + } + } + // only update after we are done with the loop + CBreakPoints::UpdateBreakPointView(); + } + else + { + wxMessageBox(_T("You have no GameIni/BreakPoints.ini file")); + } + +} +// ================= + + void CBreakPointWindow::OnAddMemoryCheck(wxCommandEvent& event) { @@ -206,6 +267,55 @@ CBreakPointWindow::OnAddMemoryCheck(wxCommandEvent& event) } +// ========================================================================================== +// Load memory checks from file +// -------------- +void +CBreakPointWindow::OnAddMemoryCheckMany(wxCommandEvent& event) +{ + // load ini + IniFile ini; + std::string filename = std::string("GameIni/MemoryChecks.ini"); + + if (ini.Load(filename.c_str())) + { + // get lines from a certain section + std::vector lines; + if (!ini.GetLines("MemoryChecks", lines)) + { + wxMessageBox(_T("You have no [MemoryChecks] line in your file")); + return; + } + + for (std::vector::const_iterator iter = lines.begin(); iter != lines.end(); ++iter) + { + std::string line = StripSpaces(*iter); + u32 Address = 0; + if (AsciiToHex(line.c_str(), Address)) + { + // settting for the memory check + TMemCheck MemCheck; + MemCheck.StartAddress = Address; + MemCheck.EndAddress = Address; + 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 + CBreakPoints::AddMemoryCheck(MemCheck); + } + } + // update after we are done with the loop + CBreakPoints::UpdateBreakPointView(); + } + else + { + wxMessageBox(_T("You have no GameIni/MemoryChecks.ini file")); + } +} +// ================= + + void CBreakPointWindow::OnActivated(wxListEvent& event) { diff --git a/Source/Core/DebuggerWX/Src/BreakpointWindow.h b/Source/Core/DebuggerWX/Src/BreakpointWindow.h index b753314043..27870dd811 100644 --- a/Source/Core/DebuggerWX/Src/BreakpointWindow.h +++ b/Source/Core/DebuggerWX/Src/BreakpointWindow.h @@ -54,8 +54,11 @@ class CBreakPointWindow ID_TOOLBAR = 500, ID_BPS = 1002, IDM_DELETE, + IDM_CLEAR, IDM_ADD_BREAKPOINT, - IDM_ADD_MEMORYCHECK + IDM_ADD_BREAKPOINTMANY, + IDM_ADD_MEMORYCHECK, + IDM_ADD_MEMORYCHECKMANY }; enum @@ -79,8 +82,11 @@ class CBreakPointWindow void InitBitmaps(); void OnDelete(wxCommandEvent& event); + void OnClear(wxCommandEvent& event); void OnAddBreakPoint(wxCommandEvent& event); + void OnAddBreakPointMany(wxCommandEvent& event); void OnAddMemoryCheck(wxCommandEvent& event); + void OnAddMemoryCheckMany(wxCommandEvent& event); void OnActivated(wxListEvent& event); }; diff --git a/Source/Core/DebuggerWX/Src/MemoryCheckDlg.cpp b/Source/Core/DebuggerWX/Src/MemoryCheckDlg.cpp index f22e869601..41e09aec49 100644 --- a/Source/Core/DebuggerWX/Src/MemoryCheckDlg.cpp +++ b/Source/Core/DebuggerWX/Src/MemoryCheckDlg.cpp @@ -101,6 +101,7 @@ void MemoryCheckDlg::OnOK(wxCommandEvent& /*event*/) MemCheck.Break = true; CBreakPoints::AddMemoryCheck(MemCheck); + CBreakPoints::UpdateBreakPointView(); Close(); } }