2013-04-18 03:43:35 +00:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2011-02-28 20:40:15 +00:00
|
|
|
#include "BreakpointWindow.h"
|
2008-12-08 05:30:24 +00:00
|
|
|
#include "BreakpointView.h"
|
|
|
|
#include "CodeWindow.h"
|
|
|
|
#include "HW/Memmap.h"
|
2009-08-31 21:07:20 +00:00
|
|
|
#include "BreakpointDlg.h"
|
2008-12-08 05:30:24 +00:00
|
|
|
#include "MemoryCheckDlg.h"
|
2009-06-28 11:47:39 +00:00
|
|
|
#include "PowerPC/PowerPC.h"
|
2010-02-02 21:56:29 +00:00
|
|
|
#include "FileUtil.h"
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2011-02-25 23:15:53 +00:00
|
|
|
extern "C" {
|
|
|
|
#include "../../resources/toolbar_add_breakpoint.c"
|
|
|
|
#include "../../resources/toolbar_add_memorycheck.c"
|
|
|
|
#include "../../resources/toolbar_debugger_delete.c"
|
|
|
|
}
|
|
|
|
|
2011-02-27 23:03:08 +00:00
|
|
|
class CBreakPointBar : public wxAuiToolBar
|
2011-02-25 23:15:53 +00:00
|
|
|
{
|
2011-02-27 23:03:08 +00:00
|
|
|
public:
|
2013-01-13 09:12:29 +00:00
|
|
|
CBreakPointBar(CBreakPointWindow* parent, const wxWindowID id)
|
2011-02-27 23:03:08 +00:00
|
|
|
: wxAuiToolBar(parent, id, wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_TEXT)
|
|
|
|
{
|
|
|
|
SetToolBitmapSize(wxSize(24, 24));
|
|
|
|
|
|
|
|
m_Bitmaps[Toolbar_Delete] =
|
|
|
|
wxBitmap(wxGetBitmapFromMemory(toolbar_delete_png).ConvertToImage().Rescale(24, 24));
|
|
|
|
m_Bitmaps[Toolbar_Add_BP] =
|
|
|
|
wxBitmap(wxGetBitmapFromMemory(toolbar_add_breakpoint_png).ConvertToImage().Rescale(24, 24));
|
|
|
|
m_Bitmaps[Toolbar_Add_MC] =
|
|
|
|
wxBitmap(wxGetBitmapFromMemory(toolbar_add_memcheck_png).ConvertToImage().Rescale(24, 24));
|
|
|
|
|
|
|
|
AddTool(ID_DELETE, wxT("Delete"), m_Bitmaps[Toolbar_Delete]);
|
2013-01-13 09:12:29 +00:00
|
|
|
Bind(wxEVT_COMMAND_TOOL_CLICKED, &CBreakPointWindow::OnDelete, parent, ID_DELETE);
|
2011-02-27 23:03:08 +00:00
|
|
|
|
|
|
|
AddTool(ID_CLEAR, wxT("Clear"), m_Bitmaps[Toolbar_Delete]);
|
2013-01-13 09:12:29 +00:00
|
|
|
Bind(wxEVT_COMMAND_TOOL_CLICKED, &CBreakPointWindow::OnClear, parent, ID_CLEAR);
|
2011-02-27 23:03:08 +00:00
|
|
|
|
|
|
|
AddTool(ID_ADDBP, wxT("+BP"), m_Bitmaps[Toolbar_Add_BP]);
|
2013-01-13 09:12:29 +00:00
|
|
|
Bind(wxEVT_COMMAND_TOOL_CLICKED, &CBreakPointWindow::OnAddBreakPoint, parent, ID_ADDBP);
|
2011-02-27 23:03:08 +00:00
|
|
|
|
|
|
|
// Add memory breakpoints if you can use them
|
|
|
|
if (Memory::AreMemoryBreakpointsActivated())
|
|
|
|
{
|
|
|
|
AddTool(ID_ADDMC, wxT("+MC"), m_Bitmaps[Toolbar_Add_MC]);
|
2013-01-13 09:12:29 +00:00
|
|
|
Bind(wxEVT_COMMAND_TOOL_CLICKED, &CBreakPointWindow::OnAddMemoryCheck, parent, ID_ADDMC);
|
2011-02-27 23:03:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AddTool(ID_LOAD, wxT("Load"), m_Bitmaps[Toolbar_Delete]);
|
2013-01-13 09:12:29 +00:00
|
|
|
Bind(wxEVT_COMMAND_TOOL_CLICKED, &CBreakPointWindow::LoadAll, parent, ID_LOAD);
|
2011-02-27 23:03:08 +00:00
|
|
|
|
|
|
|
AddTool(ID_SAVE, wxT("Save"), m_Bitmaps[Toolbar_Delete]);
|
2013-01-13 09:12:29 +00:00
|
|
|
Bind(wxEVT_COMMAND_TOOL_CLICKED, &CBreakPointWindow::Event_SaveAll, parent, ID_SAVE);
|
2011-02-27 23:03:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2011-02-25 23:15:53 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
Toolbar_Delete,
|
|
|
|
Toolbar_Add_BP,
|
|
|
|
Toolbar_Add_MC,
|
2011-02-27 23:03:08 +00:00
|
|
|
Num_Bitmaps
|
2011-02-25 23:15:53 +00:00
|
|
|
};
|
|
|
|
|
2011-02-27 23:03:08 +00:00
|
|
|
enum
|
2011-02-25 23:15:53 +00:00
|
|
|
{
|
2011-02-27 23:03:08 +00:00
|
|
|
ID_DELETE = 2000,
|
|
|
|
ID_CLEAR,
|
|
|
|
ID_ADDBP,
|
|
|
|
ID_ADDMC,
|
|
|
|
ID_LOAD,
|
|
|
|
ID_SAVE
|
|
|
|
};
|
|
|
|
|
|
|
|
wxBitmap m_Bitmaps[Num_Bitmaps];
|
2011-02-25 23:15:53 +00:00
|
|
|
};
|
|
|
|
|
2009-09-07 20:51:02 +00:00
|
|
|
BEGIN_EVENT_TABLE(CBreakPointWindow, wxPanel)
|
2011-02-25 09:35:56 +00:00
|
|
|
EVT_CLOSE(CBreakPointWindow::OnClose)
|
2011-02-28 20:40:15 +00:00
|
|
|
EVT_LIST_ITEM_SELECTED(wxID_ANY, CBreakPointWindow::OnSelectBP)
|
2008-12-08 05:30:24 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2010-07-27 02:39:12 +00:00
|
|
|
CBreakPointWindow::CBreakPointWindow(CCodeWindow* _pCodeWindow, wxWindow* parent,
|
|
|
|
wxWindowID id, const wxString& title, const wxPoint& position,
|
|
|
|
const wxSize& size, long style)
|
2011-02-27 23:03:08 +00:00
|
|
|
: wxPanel(parent, id, position, size, style, title)
|
2010-07-26 03:46:14 +00:00
|
|
|
, m_pCodeWindow(_pCodeWindow)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2011-02-28 20:40:15 +00:00
|
|
|
m_mgr.SetManagedWindow(this);
|
|
|
|
m_mgr.SetFlags(wxAUI_MGR_DEFAULT | wxAUI_MGR_LIVE_RESIZE);
|
|
|
|
|
|
|
|
m_BreakPointListView = new CBreakPointView(this, wxID_ANY);
|
|
|
|
|
|
|
|
m_mgr.AddPane(new CBreakPointBar(this, wxID_ANY), wxAuiPaneInfo().ToolbarPane().Top().
|
|
|
|
LeftDockable(false).RightDockable(false).BottomDockable(false).Floatable(false));
|
|
|
|
m_mgr.AddPane(m_BreakPointListView, wxAuiPaneInfo().CenterPane());
|
|
|
|
m_mgr.Update();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2011-02-27 23:03:08 +00:00
|
|
|
CBreakPointWindow::~CBreakPointWindow()
|
|
|
|
{
|
|
|
|
m_mgr.UnInit();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CBreakPointWindow::OnClose(wxCloseEvent& event)
|
2011-02-25 09:35:56 +00:00
|
|
|
{
|
|
|
|
SaveAll();
|
2011-02-27 23:03:08 +00:00
|
|
|
event.Skip();
|
2011-02-25 09:35:56 +00:00
|
|
|
}
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
void CBreakPointWindow::NotifyUpdate()
|
|
|
|
{
|
2011-02-27 23:03:08 +00:00
|
|
|
m_BreakPointListView->Update();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2011-02-27 23:03:08 +00:00
|
|
|
void CBreakPointWindow::OnDelete(wxCommandEvent& WXUNUSED(event))
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2011-02-27 23:03:08 +00:00
|
|
|
m_BreakPointListView->DeleteCurrentSelection();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2011-02-25 09:35:56 +00:00
|
|
|
// jump to begin addr
|
|
|
|
void CBreakPointWindow::OnSelectBP(wxListEvent& event)
|
2009-08-27 11:08:52 +00:00
|
|
|
{
|
2010-07-26 03:46:14 +00:00
|
|
|
long Index = event.GetIndex();
|
|
|
|
if (Index >= 0)
|
|
|
|
{
|
|
|
|
u32 Address = (u32)m_BreakPointListView->GetItemData(Index);
|
2011-02-25 09:35:56 +00:00
|
|
|
if (m_pCodeWindow)
|
2010-07-26 03:46:14 +00:00
|
|
|
m_pCodeWindow->JumpToAddress(Address);
|
|
|
|
}
|
2009-08-27 11:08:52 +00:00
|
|
|
}
|
|
|
|
|
2011-02-25 09:35:56 +00:00
|
|
|
// Clear all breakpoints and memchecks
|
2011-02-27 23:03:08 +00:00
|
|
|
void CBreakPointWindow::OnClear(wxCommandEvent& WXUNUSED(event))
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2009-06-28 11:47:39 +00:00
|
|
|
PowerPC::breakpoints.Clear();
|
2009-09-27 21:28:09 +00:00
|
|
|
PowerPC::memchecks.Clear();
|
2009-08-27 11:08:52 +00:00
|
|
|
NotifyUpdate();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
2010-07-26 03:46:14 +00:00
|
|
|
|
2011-02-27 23:03:08 +00:00
|
|
|
void CBreakPointWindow::OnAddBreakPoint(wxCommandEvent& WXUNUSED(event))
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2011-02-27 23:03:08 +00:00
|
|
|
BreakPointDlg bpDlg(this);
|
2008-12-08 05:30:24 +00:00
|
|
|
bpDlg.ShowModal();
|
|
|
|
}
|
2010-07-26 03:46:14 +00:00
|
|
|
|
2011-02-27 23:03:08 +00:00
|
|
|
void CBreakPointWindow::OnAddMemoryCheck(wxCommandEvent& WXUNUSED(event))
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
|
|
|
MemoryCheckDlg memDlg(this);
|
|
|
|
memDlg.ShowModal();
|
|
|
|
}
|
|
|
|
|
2011-02-27 23:03:08 +00:00
|
|
|
void CBreakPointWindow::Event_SaveAll(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
SaveAll();
|
|
|
|
}
|
|
|
|
|
2011-02-25 09:35:56 +00:00
|
|
|
void CBreakPointWindow::SaveAll()
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2011-02-25 09:35:56 +00:00
|
|
|
// simply dump all to bp/mc files in a way we can read again
|
2008-12-08 05:30:24 +00:00
|
|
|
IniFile ini;
|
2011-02-25 09:35:56 +00:00
|
|
|
if (ini.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX)))
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2011-02-25 09:35:56 +00:00
|
|
|
ini.SetLines("BreakPoints", PowerPC::breakpoints.GetStrings());
|
|
|
|
ini.SetLines("MemoryChecks", PowerPC::memchecks.GetStrings());
|
|
|
|
ini.Save(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
}
|
2009-09-02 21:00:45 +00:00
|
|
|
|
2011-02-27 23:03:08 +00:00
|
|
|
void CBreakPointWindow::LoadAll(wxCommandEvent& WXUNUSED(event))
|
2011-02-25 09:35:56 +00:00
|
|
|
{
|
|
|
|
IniFile ini;
|
|
|
|
BreakPoints::TBreakPointsStr newbps;
|
|
|
|
MemChecks::TMemChecksStr newmcs;
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2011-02-25 09:35:56 +00:00
|
|
|
if (!ini.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX)))
|
|
|
|
return;
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2011-02-25 23:15:53 +00:00
|
|
|
if (ini.GetLines("BreakPoints", newbps, false))
|
2011-02-25 09:35:56 +00:00
|
|
|
PowerPC::breakpoints.AddFromStrings(newbps);
|
|
|
|
if (ini.GetLines("MemoryChecks", newmcs, false))
|
|
|
|
PowerPC::memchecks.AddFromStrings(newmcs);
|
|
|
|
|
|
|
|
NotifyUpdate();
|
|
|
|
}
|