2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2013-04-18 03:43:35 +00:00
|
|
|
// Refer to the license.txt file included.
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2016-12-23 19:18:14 +00:00
|
|
|
#include "DolphinWX/Debugger/BreakpointWindow.h"
|
|
|
|
|
2016-10-03 07:29:50 +00:00
|
|
|
#include <array>
|
|
|
|
|
2016-06-24 10:16:10 +00:00
|
|
|
// clang-format off
|
|
|
|
#include <wx/bitmap.h>
|
2016-06-24 08:43:46 +00:00
|
|
|
#include <wx/aui/framemanager.h>
|
2014-02-22 22:36:30 +00:00
|
|
|
#include <wx/image.h>
|
|
|
|
#include <wx/listbase.h>
|
|
|
|
#include <wx/panel.h>
|
2016-06-24 10:16:10 +00:00
|
|
|
// clang-format on
|
2014-02-22 22:36:30 +00:00
|
|
|
|
|
|
|
#include "Common/CommonTypes.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Common/FileUtil.h"
|
2014-02-22 22:36:30 +00:00
|
|
|
#include "Common/IniFile.h"
|
2014-10-24 13:13:53 +00:00
|
|
|
#include "Core/ConfigManager.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Core/HW/Memmap.h"
|
2016-12-23 19:18:14 +00:00
|
|
|
#include "Core/PowerPC/BreakPoints.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Core/PowerPC/PowerPC.h"
|
|
|
|
#include "DolphinWX/Debugger/BreakpointDlg.h"
|
|
|
|
#include "DolphinWX/Debugger/BreakpointView.h"
|
|
|
|
#include "DolphinWX/Debugger/CodeWindow.h"
|
|
|
|
#include "DolphinWX/Debugger/MemoryCheckDlg.h"
|
2016-07-15 21:59:05 +00:00
|
|
|
#include "DolphinWX/AuiToolBar.h"
|
2016-06-24 08:43:46 +00:00
|
|
|
#include "DolphinWX/WxUtils.h"
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2016-07-15 21:59:05 +00:00
|
|
|
class CBreakPointBar : public DolphinAuiToolBar
|
2011-02-25 23:15:53 +00:00
|
|
|
{
|
2011-02-27 23:03:08 +00:00
|
|
|
public:
|
2016-06-24 08:43:46 +00:00
|
|
|
CBreakPointBar(CBreakPointWindow* parent, const wxWindowID id)
|
2016-07-15 21:59:05 +00:00
|
|
|
: DolphinAuiToolBar(parent, id, wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_TEXT)
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2018-04-12 05:56:15 +00:00
|
|
|
InitializeThemedBitmaps();
|
2011-02-27 23:03:08 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
AddTool(ID_DELETE, _("Delete"), m_Bitmaps[Toolbar_Delete]);
|
|
|
|
Bind(wxEVT_TOOL, &CBreakPointWindow::OnDelete, parent, ID_DELETE);
|
2011-02-27 23:03:08 +00:00
|
|
|
|
2018-04-12 05:56:15 +00:00
|
|
|
AddTool(ID_CLEAR, _("Clear"), m_Bitmaps[Toolbar_Clear]);
|
2016-06-24 08:43:46 +00:00
|
|
|
Bind(wxEVT_TOOL, &CBreakPointWindow::OnClear, parent, ID_CLEAR);
|
2011-02-27 23:03:08 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
AddTool(ID_ADDBP, "+BP", m_Bitmaps[Toolbar_Add_BP]);
|
|
|
|
Bind(wxEVT_TOOL, &CBreakPointWindow::OnAddBreakPoint, parent, ID_ADDBP);
|
2011-02-27 23:03:08 +00:00
|
|
|
|
2016-10-06 14:46:09 +00:00
|
|
|
AddTool(ID_ADDMC, "+MBP", m_Bitmaps[Toolbar_Add_MC]);
|
2016-09-09 18:10:48 +00:00
|
|
|
Bind(wxEVT_TOOL, &CBreakPointWindow::OnAddMemoryCheck, parent, ID_ADDMC);
|
2011-02-27 23:03:08 +00:00
|
|
|
|
2018-04-12 05:56:15 +00:00
|
|
|
AddTool(ID_LOAD, _("Load"), m_Bitmaps[Toolbar_Load]);
|
2016-06-24 08:43:46 +00:00
|
|
|
Bind(wxEVT_TOOL, &CBreakPointWindow::Event_LoadAll, parent, ID_LOAD);
|
2011-02-27 23:03:08 +00:00
|
|
|
|
2018-04-12 05:56:15 +00:00
|
|
|
AddTool(ID_SAVE, _("Save"), m_Bitmaps[Toolbar_Save]);
|
2016-06-24 08:43:46 +00:00
|
|
|
Bind(wxEVT_TOOL, &CBreakPointWindow::Event_SaveAll, parent, ID_SAVE);
|
|
|
|
}
|
2011-02-27 23:03:08 +00:00
|
|
|
|
2018-04-12 05:56:15 +00:00
|
|
|
void ReloadBitmaps()
|
|
|
|
{
|
|
|
|
Freeze();
|
|
|
|
|
|
|
|
InitializeThemedBitmaps();
|
|
|
|
for (int i = 0; i < ID_NUM; ++i)
|
|
|
|
SetToolBitmap(i, m_Bitmaps[i]);
|
|
|
|
|
|
|
|
Thaw();
|
|
|
|
}
|
|
|
|
|
2011-02-27 23:03:08 +00:00
|
|
|
private:
|
2016-06-24 08:43:46 +00:00
|
|
|
enum
|
|
|
|
{
|
2018-04-12 05:56:15 +00:00
|
|
|
Toolbar_Delete = 0,
|
|
|
|
Toolbar_Clear,
|
2016-06-24 08:43:46 +00:00
|
|
|
Toolbar_Add_BP,
|
|
|
|
Toolbar_Add_MC,
|
2018-04-12 05:56:15 +00:00
|
|
|
Toolbar_Load,
|
|
|
|
Toolbar_Save,
|
2016-06-24 08:43:46 +00:00
|
|
|
Num_Bitmaps
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
2018-04-12 05:56:15 +00:00
|
|
|
ID_DELETE = 0,
|
2016-06-24 08:43:46 +00:00
|
|
|
ID_CLEAR,
|
|
|
|
ID_ADDBP,
|
|
|
|
ID_ADDMC,
|
|
|
|
ID_LOAD,
|
2018-04-12 05:56:15 +00:00
|
|
|
ID_SAVE,
|
|
|
|
ID_NUM
|
2016-06-24 08:43:46 +00:00
|
|
|
};
|
|
|
|
|
2018-04-12 05:56:15 +00:00
|
|
|
void InitializeThemedBitmaps()
|
|
|
|
{
|
|
|
|
wxSize bitmap_size = FromDIP(wxSize(24, 24));
|
|
|
|
SetToolBitmapSize(bitmap_size);
|
|
|
|
|
|
|
|
static const std::array<const char* const, Num_Bitmaps> m_image_names{
|
|
|
|
{"debugger_delete", "debugger_clear", "debugger_add_breakpoint", "debugger_add_memorycheck",
|
|
|
|
"debugger_load", "debugger_save"}};
|
|
|
|
|
|
|
|
for (std::size_t i = 0; i < m_image_names.size(); ++i)
|
|
|
|
{
|
|
|
|
m_Bitmaps[i] =
|
|
|
|
WxUtils::LoadScaledThemeBitmap(m_image_names[i], this, bitmap_size, wxDefaultSize,
|
|
|
|
WxUtils::LSI_SCALE_DOWN | WxUtils::LSI_ALIGN_CENTER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
wxBitmap m_Bitmaps[Num_Bitmaps];
|
2011-02-25 23:15:53 +00:00
|
|
|
};
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
CBreakPointWindow::CBreakPointWindow(CCodeWindow* _pCodeWindow, wxWindow* parent, wxWindowID id,
|
|
|
|
const wxString& title, const wxPoint& position,
|
|
|
|
const wxSize& size, long style)
|
|
|
|
: wxPanel(parent, id, position, size, style, title), m_pCodeWindow(_pCodeWindow)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
m_mgr.SetManagedWindow(this);
|
|
|
|
m_mgr.SetFlags(wxAUI_MGR_DEFAULT | wxAUI_MGR_LIVE_RESIZE);
|
|
|
|
|
|
|
|
m_BreakPointListView = new CBreakPointView(this, wxID_ANY);
|
|
|
|
m_BreakPointListView->Bind(wxEVT_LIST_ITEM_SELECTED, &CBreakPointWindow::OnSelectBP, this);
|
|
|
|
|
2018-04-12 05:56:15 +00:00
|
|
|
m_breakpointBar = new CBreakPointBar(this, wxID_ANY);
|
|
|
|
|
|
|
|
m_mgr.AddPane(m_breakpointBar, wxAuiPaneInfo()
|
|
|
|
.ToolbarPane()
|
|
|
|
.Top()
|
|
|
|
.LeftDockable(true)
|
|
|
|
.RightDockable(true)
|
|
|
|
.BottomDockable(false)
|
|
|
|
.Floatable(false));
|
2016-06-24 08:43:46 +00:00
|
|
|
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()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
m_mgr.UnInit();
|
2011-02-27 23:03:08 +00:00
|
|
|
}
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
void CBreakPointWindow::NotifyUpdate()
|
|
|
|
{
|
2016-10-03 07:29:50 +00:00
|
|
|
m_BreakPointListView->Repopulate();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2018-04-12 05:56:15 +00:00
|
|
|
void CBreakPointWindow::ReloadBitmaps()
|
|
|
|
{
|
|
|
|
m_breakpointBar->ReloadBitmaps();
|
|
|
|
}
|
|
|
|
|
2011-02-27 23:03:08 +00:00
|
|
|
void CBreakPointWindow::OnDelete(wxCommandEvent& WXUNUSED(event))
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +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
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
long Index = event.GetIndex();
|
|
|
|
if (Index >= 0)
|
|
|
|
{
|
|
|
|
u32 Address = (u32)m_BreakPointListView->GetItemData(Index);
|
|
|
|
if (m_pCodeWindow)
|
|
|
|
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
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
PowerPC::debug_interface.ClearAllBreakpoints();
|
|
|
|
PowerPC::debug_interface.ClearAllMemChecks();
|
2014-03-06 01:51:27 +00:00
|
|
|
|
2016-06-24 08:43:46 +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
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
BreakPointDlg bpDlg(this);
|
2017-01-02 20:39:02 +00:00
|
|
|
if (bpDlg.ShowModal() == wxID_OK)
|
|
|
|
{
|
|
|
|
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::OnAddMemoryCheck(wxCommandEvent& WXUNUSED(event))
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
MemoryCheckDlg memDlg(this);
|
2017-01-02 20:39:02 +00:00
|
|
|
if (memDlg.ShowModal() == wxID_OK)
|
|
|
|
{
|
|
|
|
NotifyUpdate();
|
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2011-02-27 23:03:08 +00:00
|
|
|
void CBreakPointWindow::Event_SaveAll(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
SaveAll();
|
2011-02-27 23:03:08 +00:00
|
|
|
}
|
|
|
|
|
2011-02-25 09:35:56 +00:00
|
|
|
void CBreakPointWindow::SaveAll()
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
// simply dump all to bp/mc files in a way we can read again
|
|
|
|
IniFile ini;
|
2016-10-29 12:42:43 +00:00
|
|
|
ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + SConfig::GetInstance().GetGameID() + ".ini",
|
2016-06-24 08:43:46 +00:00
|
|
|
false);
|
|
|
|
ini.SetLines("BreakPoints", PowerPC::breakpoints.GetStrings());
|
2016-10-06 14:46:09 +00:00
|
|
|
ini.SetLines("MemoryBreakPoints", PowerPC::memchecks.GetStrings());
|
2016-10-29 12:42:43 +00:00
|
|
|
ini.Save(File::GetUserPath(D_GAMESETTINGS_IDX) + SConfig::GetInstance().GetGameID() + ".ini");
|
2014-10-24 13:13:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CBreakPointWindow::Event_LoadAll(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
LoadAll();
|
|
|
|
return;
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
2009-09-02 21:00:45 +00:00
|
|
|
|
2014-10-24 13:13:53 +00:00
|
|
|
void CBreakPointWindow::LoadAll()
|
2011-02-25 09:35:56 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
IniFile ini;
|
|
|
|
BreakPoints::TBreakPointsStr newbps;
|
|
|
|
MemChecks::TMemChecksStr newmcs;
|
|
|
|
|
2016-10-29 12:42:43 +00:00
|
|
|
if (!ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + SConfig::GetInstance().GetGameID() + ".ini",
|
2016-06-24 08:43:46 +00:00
|
|
|
false))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ini.GetLines("BreakPoints", &newbps, false))
|
|
|
|
{
|
|
|
|
PowerPC::breakpoints.Clear();
|
|
|
|
PowerPC::breakpoints.AddFromStrings(newbps);
|
|
|
|
}
|
|
|
|
|
2016-10-06 14:46:09 +00:00
|
|
|
if (ini.GetLines("MemoryBreakPoints", &newmcs, false))
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
|
|
|
PowerPC::memchecks.Clear();
|
|
|
|
PowerPC::memchecks.AddFromStrings(newmcs);
|
|
|
|
}
|
|
|
|
|
|
|
|
NotifyUpdate();
|
2011-02-25 09:35:56 +00:00
|
|
|
}
|