2009-07-28 21:32:10 +00:00
|
|
|
// Copyright (C) 2003 Dolphin Project.
|
2008-12-08 05:30:24 +00:00
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official SVN repository and contact information can be found at
|
|
|
|
// http://code.google.com/p/dolphin-emu/
|
|
|
|
|
2010-12-05 15:36:08 +00:00
|
|
|
#include <wx/wx.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"
|
2008-12-20 14:00:33 +00:00
|
|
|
#include "Host.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"
|
|
|
|
}
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
typedef void (CBreakPointWindow::*toolbar_func)();
|
|
|
|
typedef std::map<long, toolbar_func> toolbar_m;
|
|
|
|
typedef std::pair<long, toolbar_func> toolbar_p;
|
|
|
|
toolbar_m toolbar_map;
|
|
|
|
|
|
|
|
class CBreakPointBar : public wxListCtrl
|
|
|
|
{
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
Toolbar_Delete,
|
|
|
|
Toolbar_Add_BP,
|
|
|
|
Toolbar_Add_MC,
|
|
|
|
Bitmaps_max
|
|
|
|
};
|
|
|
|
wxBitmap m_Bitmaps[Bitmaps_max];
|
|
|
|
|
|
|
|
public:
|
|
|
|
CBreakPointBar::CBreakPointBar(CBreakPointWindow* parent, const wxWindowID id,
|
|
|
|
const wxPoint& pos, const wxSize& size, long style)
|
|
|
|
: wxListCtrl((wxWindow*)parent, id, pos, size, style)
|
|
|
|
{
|
|
|
|
SetBackgroundColour(wxColour(0x555555));
|
|
|
|
SetForegroundColour(wxColour(0xffffff));
|
|
|
|
|
|
|
|
// load original size 48x48
|
|
|
|
wxMemoryInputStream st1(toolbar_delete_png, sizeof(toolbar_delete_png));
|
|
|
|
wxMemoryInputStream st2(toolbar_add_breakpoint_png, sizeof(toolbar_add_breakpoint_png));
|
|
|
|
wxMemoryInputStream st3(toolbar_add_memcheck_png, sizeof(toolbar_add_memcheck_png));
|
|
|
|
m_Bitmaps[Toolbar_Delete] = wxBitmap(wxImage(st1, wxBITMAP_TYPE_ANY, -1).Rescale(24,24), -1);
|
|
|
|
m_Bitmaps[Toolbar_Add_BP] = wxBitmap(wxImage(st2, wxBITMAP_TYPE_ANY, -1).Rescale(24,24), -1);
|
|
|
|
m_Bitmaps[Toolbar_Add_MC] = wxBitmap(wxImage(st3, wxBITMAP_TYPE_ANY, -1).Rescale(24,24), -1);
|
|
|
|
|
|
|
|
m_imageListNormal = new wxImageList(24, 24);
|
|
|
|
m_imageListNormal->Add(m_Bitmaps[Toolbar_Delete]);
|
|
|
|
m_imageListNormal->Add(m_Bitmaps[Toolbar_Add_BP]);
|
|
|
|
m_imageListNormal->Add(m_Bitmaps[Toolbar_Add_MC]);
|
|
|
|
SetImageList(m_imageListNormal, wxIMAGE_LIST_NORMAL);
|
|
|
|
|
|
|
|
toolbar_map.insert(toolbar_p(InsertItem(0, _("Delete"), 0), &CBreakPointWindow::OnDelete));
|
|
|
|
toolbar_map.insert(toolbar_p(InsertItem(1, _("Clear"), 0), &CBreakPointWindow::OnClear));
|
|
|
|
toolbar_map.insert(toolbar_p(InsertItem(2, _("+BP"), 1), &CBreakPointWindow::OnAddBreakPoint));
|
|
|
|
|
|
|
|
// just add memory breakpoints if you can use them
|
|
|
|
if (Memory::AreMemoryBreakpointsActivated())
|
|
|
|
{
|
|
|
|
toolbar_map.insert(toolbar_p(InsertItem(3, _("+MC"), 2), &CBreakPointWindow::OnAddMemoryCheck));
|
|
|
|
toolbar_map.insert(toolbar_p(InsertItem(4, _("Load"), 0), &CBreakPointWindow::LoadAll));
|
|
|
|
toolbar_map.insert(toolbar_p(InsertItem(5, _("Save"), 0), &CBreakPointWindow::SaveAll));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
toolbar_map.insert(toolbar_p(InsertItem(3, _("Load"), 0), &CBreakPointWindow::LoadAll));
|
|
|
|
toolbar_map.insert(toolbar_p(InsertItem(4, _("Save"), 0), &CBreakPointWindow::SaveAll));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
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)
|
|
|
|
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)
|
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)
|
2009-09-07 20:51:02 +00:00
|
|
|
: wxPanel(parent, id, position, size, style, title)
|
2008-12-08 05:30:24 +00:00
|
|
|
, m_BreakPointListView(NULL)
|
2010-07-26 03:46:14 +00:00
|
|
|
, m_pCodeWindow(_pCodeWindow)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
|
|
|
CreateGUIControls();
|
|
|
|
}
|
|
|
|
|
2011-02-25 09:35:56 +00:00
|
|
|
void CBreakPointWindow::OnClose(wxCloseEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
SaveAll();
|
|
|
|
}
|
|
|
|
|
2009-08-27 11:08:52 +00:00
|
|
|
void CBreakPointWindow::CreateGUIControls()
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
|
|
|
SetSize(8, 8, 400, 370);
|
|
|
|
Center();
|
|
|
|
|
2009-09-27 21:28:09 +00:00
|
|
|
m_BreakPointBar = new CBreakPointBar(this, ID_TOOLBAR, wxDefaultPosition, wxSize(0, 55),
|
|
|
|
wxLC_ICON | wxSUNKEN_BORDER | wxLC_SINGLE_SEL);
|
|
|
|
m_BreakPointListView = new CBreakPointView(this, ID_BPS, wxDefaultPosition, wxDefaultSize,
|
2008-12-08 05:30:24 +00:00
|
|
|
wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT | wxLC_SINGLE_SEL | wxLC_SORT_ASCENDING);
|
|
|
|
|
2009-09-27 21:28:09 +00:00
|
|
|
wxBoxSizer* sizerH = new wxBoxSizer(wxVERTICAL);
|
|
|
|
sizerH->Add(m_BreakPointBar, 0, wxALL | wxEXPAND);
|
2011-02-25 09:35:56 +00:00
|
|
|
sizerH->Add(m_BreakPointListView, 1, wxEXPAND);
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2009-09-27 21:28:09 +00:00
|
|
|
SetSizer(sizerH);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2011-02-25 09:35:56 +00:00
|
|
|
void CBreakPointWindow::OnSelectToolbar(wxListEvent& event)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2011-02-25 23:15:53 +00:00
|
|
|
(this->*toolbar_map[event.GetItem().GetId()])();
|
|
|
|
m_BreakPointBar->SetItemState(event.GetItem().GetId(), 0, wxLIST_STATE_SELECTED);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CBreakPointWindow::NotifyUpdate()
|
|
|
|
{
|
2011-02-25 09:35:56 +00:00
|
|
|
if (m_BreakPointListView)
|
|
|
|
m_BreakPointListView->Update();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2009-09-27 21:28:09 +00:00
|
|
|
void CBreakPointWindow::OnDelete()
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
|
|
|
if (m_BreakPointListView)
|
|
|
|
m_BreakPointListView->DeleteCurrentSelection();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
// modify
|
|
|
|
void CBreakPointWindow::OnRightClick(wxListEvent& event)
|
|
|
|
{
|
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2011-02-25 09:35:56 +00:00
|
|
|
// Clear all breakpoints and memchecks
|
2009-09-27 21:28:09 +00:00
|
|
|
void CBreakPointWindow::OnClear()
|
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
|
|
|
|
2009-09-27 21:28:09 +00:00
|
|
|
void CBreakPointWindow::OnAddBreakPoint()
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2009-08-27 11:08:52 +00:00
|
|
|
BreakPointDlg bpDlg(this, this);
|
2008-12-08 05:30:24 +00:00
|
|
|
bpDlg.ShowModal();
|
|
|
|
}
|
2010-07-26 03:46:14 +00:00
|
|
|
|
2011-02-25 09:35:56 +00:00
|
|
|
void CBreakPointWindow::OnAddMemoryCheck()
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
|
|
|
MemoryCheckDlg memDlg(this);
|
|
|
|
memDlg.ShowModal();
|
|
|
|
}
|
|
|
|
|
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-25 09:35:56 +00:00
|
|
|
void CBreakPointWindow::LoadAll()
|
|
|
|
{
|
|
|
|
IniFile ini;
|
|
|
|
BreakPoints::TBreakPointsStr newbps;
|
|
|
|
MemChecks::TMemChecksStr newmcs;
|
|
|
|
|
|
|
|
if (!ini.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX)))
|
|
|
|
return;
|
|
|
|
|
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();
|
|
|
|
}
|