mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
added first iteration of breakpoint view for the debugger
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@21 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
77
Source/Core/DebuggerWX/src/BreakpointView.cpp
Normal file
77
Source/Core/DebuggerWX/src/BreakpointView.cpp
Normal file
@ -0,0 +1,77 @@
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// 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/
|
||||
|
||||
#include "Debugger.h"
|
||||
#include "Common.h"
|
||||
|
||||
#include "BreakpointView.h"
|
||||
#include "Debugger/Debugger_BreakPoints.h"
|
||||
#include "Debugger/Debugger_SymbolMap.h"
|
||||
|
||||
BEGIN_EVENT_TABLE(CBreakPointView, wxListCtrl)
|
||||
|
||||
END_EVENT_TABLE()
|
||||
|
||||
CBreakPointView::CBreakPointView(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
|
||||
: wxListCtrl(parent, id, pos, size, style)
|
||||
{
|
||||
SetFont(wxFont(9, wxSWISS, wxNORMAL, wxNORMAL, false, wxT("Segoe UI")));
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CBreakPointView::Update()
|
||||
{
|
||||
ClearAll();
|
||||
|
||||
InsertColumn(0, wxT("Active"), wxLIST_FORMAT_LEFT, 50);
|
||||
InsertColumn(1, wxT("Type"), wxLIST_FORMAT_LEFT, 50);
|
||||
InsertColumn(2, wxT("Function"), wxLIST_FORMAT_CENTER, 200);
|
||||
|
||||
const CBreakPoints::TBreakPoints& rBreakPoints = CBreakPoints::GetBreakPoints();
|
||||
for (size_t i=0; i<rBreakPoints.size(); i++)
|
||||
{
|
||||
const TBreakPoint& rBP = rBreakPoints[i];
|
||||
if (!rBP.bTemporary)
|
||||
{
|
||||
int Item = InsertItem(0, rBP.bOn ? "on" : " ");
|
||||
SetItem(Item, 1, "BP");
|
||||
|
||||
Debugger::XSymbolIndex index = Debugger::FindSymbol(rBP.iAddress);
|
||||
if (index > 0)
|
||||
{
|
||||
SetItem(Item, 2, Debugger::GetDescription(rBP.iAddress));
|
||||
}
|
||||
else
|
||||
{
|
||||
char szBuffer[32];
|
||||
sprintf(szBuffer, "0x%08x", rBP.iAddress);
|
||||
SetItem(Item, 2, szBuffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void CBreakPointView::DeleteCurrentSelection()
|
||||
{
|
||||
|
||||
}
|
41
Source/Core/DebuggerWX/src/BreakpointView.h
Normal file
41
Source/Core/DebuggerWX/src/BreakpointView.h
Normal file
@ -0,0 +1,41 @@
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// 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/
|
||||
|
||||
#ifndef __BREAKPOINTVIEW_h__
|
||||
#define __BREAKPOINTVIEW_h__
|
||||
|
||||
#include <wx/listctrl.h>
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
class CBreakPointView
|
||||
: public wxListCtrl
|
||||
{
|
||||
public:
|
||||
|
||||
CBreakPointView(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style);
|
||||
|
||||
void Update();
|
||||
|
||||
void DeleteCurrentSelection();
|
||||
|
||||
private:
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#endif
|
160
Source/Core/DebuggerWX/src/BreakpointWindow.cpp
Normal file
160
Source/Core/DebuggerWX/src/BreakpointWindow.cpp
Normal file
@ -0,0 +1,160 @@
|
||||
//__________________________________________________________________________________________________
|
||||
// F|RES and ector 2003-2008
|
||||
//
|
||||
|
||||
#include "Debugger.h"
|
||||
#include "BreakPointWindow.h"
|
||||
#include "BreakpointView.h"
|
||||
|
||||
#include "wx/mstream.h"
|
||||
|
||||
extern "C" {
|
||||
#include "../resources/toolbar_add_breakpoint.c"
|
||||
#include "../resources/toolbar_add_memorycheck.c"
|
||||
#include "../resources/toolbar_delete.c"
|
||||
}
|
||||
|
||||
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_ADD_BREAKPOINT, CBreakPointWindow::OnAddBreakPoint)
|
||||
EVT_MENU(IDM_ADD_MEMORYCHECK, CBreakPointWindow::OnAddMemoryCheck)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
#define wxGetBitmapFromMemory(name) _wxGetBitmapFromMemory(name, sizeof(name))
|
||||
inline wxBitmap _wxGetBitmapFromMemory(const unsigned char* data, int length)
|
||||
{
|
||||
wxMemoryInputStream is(data, length);
|
||||
return(wxBitmap(wxImage(is, wxBITMAP_TYPE_ANY, -1), -1));
|
||||
}
|
||||
|
||||
|
||||
CBreakPointWindow::CBreakPointWindow(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style)
|
||||
: wxFrame(parent, id, title, position, size, style)
|
||||
, m_BreakPointListView(NULL)
|
||||
{
|
||||
InitBitmaps();
|
||||
|
||||
CreateGUIControls();
|
||||
|
||||
// Create the toolbar
|
||||
RecreateToolbar();
|
||||
|
||||
}
|
||||
|
||||
|
||||
CBreakPointWindow::~CBreakPointWindow()
|
||||
{}
|
||||
|
||||
|
||||
void
|
||||
CBreakPointWindow::CreateGUIControls()
|
||||
{
|
||||
SetTitle(wxT("Breakpoints"));
|
||||
SetIcon(wxNullIcon);
|
||||
SetSize(8, 8, 400, 370);
|
||||
Center();
|
||||
|
||||
m_BreakPointListView = new CBreakPointView(this, ID_BPS, wxDefaultPosition, GetSize(),
|
||||
wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT | wxLC_SINGLE_SEL | wxLC_SORT_ASCENDING);
|
||||
|
||||
NotifyUpdate();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CBreakPointWindow::PopulateToolbar(wxToolBar* toolBar)
|
||||
{
|
||||
int w = m_Bitmaps[Toolbar_Delete].GetWidth(),
|
||||
h = m_Bitmaps[Toolbar_Delete].GetHeight();
|
||||
|
||||
toolBar->SetToolBitmapSize(wxSize(w, h));
|
||||
toolBar->AddTool(IDM_DELETE, _T("Delete"), m_Bitmaps[Toolbar_Delete], _T("Refresh"));
|
||||
toolBar->AddSeparator();
|
||||
toolBar->AddTool(IDM_ADD_BREAKPOINT, _T("BP"), m_Bitmaps[Toolbar_Add_BreakPoint], _T("Open file..."));
|
||||
toolBar->AddTool(IDM_ADD_MEMORYCHECK, _T("MemCheck"), m_Bitmaps[Toolbar_Add_Memcheck], _T("Refresh"));
|
||||
|
||||
// after adding the buttons to the toolbar, must call Realize() to reflect
|
||||
// the changes
|
||||
toolBar->Realize();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CBreakPointWindow::RecreateToolbar()
|
||||
{
|
||||
// delete and recreate the toolbar
|
||||
wxToolBarBase* toolBar = GetToolBar();
|
||||
long style = toolBar ? toolBar->GetWindowStyle() : TOOLBAR_STYLE;
|
||||
|
||||
delete toolBar;
|
||||
SetToolBar(NULL);
|
||||
|
||||
style &= ~(wxTB_HORIZONTAL | wxTB_VERTICAL | wxTB_BOTTOM | wxTB_RIGHT | wxTB_HORZ_LAYOUT | wxTB_TOP);
|
||||
wxToolBar* theToolBar = CreateToolBar(style, ID_TOOLBAR);
|
||||
|
||||
PopulateToolbar(theToolBar);
|
||||
SetToolBar(theToolBar);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CBreakPointWindow::InitBitmaps()
|
||||
{
|
||||
// load orignal size 48x48
|
||||
m_Bitmaps[Toolbar_Delete] = wxGetBitmapFromMemory(toolbar_delete_png);
|
||||
m_Bitmaps[Toolbar_Add_BreakPoint] = wxGetBitmapFromMemory(toolbar_add_breakpoint_png);
|
||||
m_Bitmaps[Toolbar_Add_Memcheck] = wxGetBitmapFromMemory(toolbar_add_memcheck_png);
|
||||
|
||||
// scale to 24x24 for toolbar
|
||||
for (size_t n = Toolbar_Delete; n < WXSIZEOF(m_Bitmaps); n++)
|
||||
{
|
||||
m_Bitmaps[n] = wxBitmap(m_Bitmaps[n].ConvertToImage().Scale(16, 16));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CBreakPointWindow::OnClose(wxCloseEvent& /*event*/)
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
|
||||
|
||||
void CBreakPointWindow::NotifyUpdate()
|
||||
{
|
||||
if (m_BreakPointListView != NULL)
|
||||
{
|
||||
m_BreakPointListView->Update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CBreakPointWindow::OnDelete(wxCommandEvent& event)
|
||||
{
|
||||
if (m_BreakPointListView)
|
||||
{
|
||||
m_BreakPointListView->DeleteCurrentSelection();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CBreakPointWindow::OnAddBreakPoint(wxCommandEvent& event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CBreakPointWindow::OnAddMemoryCheck(wxCommandEvent& event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
65
Source/Core/DebuggerWX/src/BreakpointWindow.h
Normal file
65
Source/Core/DebuggerWX/src/BreakpointWindow.h
Normal file
@ -0,0 +1,65 @@
|
||||
//__________________________________________________________________________________________________
|
||||
// F|RES and ector 2003-2008
|
||||
//
|
||||
|
||||
#ifndef __BREAKPOINTWINDOW_h__
|
||||
#define __BREAKPOINTWINDOW_h__
|
||||
|
||||
class CBreakPointView;
|
||||
|
||||
#undef BREAKPOINT_WINDOW_STYLE
|
||||
#define BREAKPOINT_WINDOW_STYLE wxCAPTION | wxSYSTEM_MENU | wxCLOSE_BOX | wxRESIZE_BORDER
|
||||
|
||||
class CBreakPointWindow
|
||||
: public wxFrame
|
||||
{
|
||||
private:
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
public:
|
||||
|
||||
CBreakPointWindow(wxWindow* parent, wxWindowID id = 1, const wxString& title = wxT("Breakpoints"),
|
||||
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(400, 250),
|
||||
long style = BREAKPOINT_WINDOW_STYLE);
|
||||
|
||||
virtual ~CBreakPointWindow();
|
||||
|
||||
void NotifyUpdate();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
enum
|
||||
{
|
||||
ID_TOOLBAR = 500,
|
||||
ID_BPS = 1002,
|
||||
IDM_DELETE,
|
||||
IDM_ADD_BREAKPOINT,
|
||||
IDM_ADD_MEMORYCHECK
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
Toolbar_Delete,
|
||||
Toolbar_Add_BreakPoint,
|
||||
Toolbar_Add_Memcheck,
|
||||
Bitmaps_max
|
||||
};
|
||||
|
||||
CBreakPointView* m_BreakPointListView;
|
||||
wxBitmap m_Bitmaps[Bitmaps_max];
|
||||
|
||||
void OnClose(wxCloseEvent& event);
|
||||
void CreateGUIControls();
|
||||
|
||||
void RecreateToolbar();
|
||||
void PopulateToolbar(wxToolBar* toolBar);
|
||||
void InitBitmaps();
|
||||
|
||||
void OnDelete(wxCommandEvent& event);
|
||||
void OnAddBreakPoint(wxCommandEvent& event);
|
||||
void OnAddMemoryCheck(wxCommandEvent& event);
|
||||
};
|
||||
|
||||
#endif
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include "RegisterWindow.h"
|
||||
#include "LogWindow.h"
|
||||
#include "BreakpointWindow.h"
|
||||
|
||||
#include "wx/button.h"
|
||||
#include "wx/textctrl.h"
|
||||
@ -62,7 +63,8 @@ enum
|
||||
IDM_INTERPRETER,
|
||||
IDM_DUALCORE,
|
||||
IDM_LOGWINDOW,
|
||||
IDM_REGISTERWINDOW
|
||||
IDM_REGISTERWINDOW,
|
||||
IDM_BREAKPOINTWINDOW
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(CCodeWindow, wxFrame)
|
||||
@ -78,6 +80,7 @@ EVT_LISTBOX(IDM_CALLSTACKLIST, CCodeWindow::OnCallstackListChange)
|
||||
EVT_HOST_COMMAND(wxID_ANY, CCodeWindow::OnHostMessage)
|
||||
EVT_MENU(IDM_LOGWINDOW, CCodeWindow::OnToggleLogWindow)
|
||||
EVT_MENU(IDM_REGISTERWINDOW, CCodeWindow::OnToggleRegisterWindow)
|
||||
EVT_MENU(IDM_BREAKPOINTWINDOW, CCodeWindow::OnToggleBreakPointWindow)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
@ -130,6 +133,9 @@ CCodeWindow::CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter
|
||||
m_RegisterWindow = new CRegisterWindow(this);
|
||||
m_RegisterWindow->Show(true);
|
||||
|
||||
m_BreakpointWindow = new CBreakPointWindow(this);
|
||||
m_BreakpointWindow->Show(true);
|
||||
|
||||
|
||||
UpdateButtonStates();
|
||||
}
|
||||
@ -162,6 +168,9 @@ void CCodeWindow::CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParam
|
||||
wxMenuItem* pRegister = pDebugDialogs->Append(IDM_REGISTERWINDOW, _T("&Registers"), wxEmptyString, wxITEM_CHECK);
|
||||
pRegister->Check(true);
|
||||
|
||||
wxMenuItem* pBreakPoints = pDebugDialogs->Append(IDM_BREAKPOINTWINDOW, _T("&BreakPoints"), wxEmptyString, wxITEM_CHECK);
|
||||
pBreakPoints->Check(true);
|
||||
|
||||
pMenuBar->Append(pDebugDialogs, _T("&Dialogs"));
|
||||
}
|
||||
|
||||
@ -420,6 +429,33 @@ void CCodeWindow::OnToggleRegisterWindow(wxCommandEvent& event)
|
||||
}
|
||||
}
|
||||
|
||||
void CCodeWindow::OnToggleBreakPointWindow(wxCommandEvent& event)
|
||||
{
|
||||
bool show = GetMenuBar()->IsChecked(event.GetId());
|
||||
|
||||
if (show)
|
||||
{
|
||||
if (!m_BreakpointWindow)
|
||||
{
|
||||
m_BreakpointWindow = new CBreakPointWindow(this);
|
||||
}
|
||||
|
||||
m_BreakpointWindow->Show(true);
|
||||
}
|
||||
else // hide
|
||||
{
|
||||
// If m_dialog is NULL, then possibly the system
|
||||
// didn't report the checked menu item status correctly.
|
||||
// It should be true just after the menu item was selected,
|
||||
// if there was no modeless dialog yet.
|
||||
wxASSERT(m_BreakpointWindow != NULL);
|
||||
|
||||
if (m_BreakpointWindow)
|
||||
{
|
||||
m_BreakpointWindow->Hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCodeWindow::OnHostMessage(wxCommandEvent& event)
|
||||
{
|
||||
@ -447,6 +483,16 @@ void CCodeWindow::OnHostMessage(wxCommandEvent& event)
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case IDM_UPDATEBREAKPOINTS:
|
||||
|
||||
if (m_BreakpointWindow)
|
||||
{
|
||||
m_BreakpointWindow->NotifyUpdate();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
class CRegisterWindow;
|
||||
class CLogWindow;
|
||||
class CBreakPointWindow;
|
||||
|
||||
class CCodeWindow
|
||||
: public wxFrame
|
||||
@ -54,6 +55,7 @@ class CCodeWindow
|
||||
// sub dialogs
|
||||
CLogWindow* m_logwindow;
|
||||
CRegisterWindow* m_RegisterWindow;
|
||||
CBreakPointWindow* m_BreakpointWindow;
|
||||
|
||||
CCodeView* codeview;
|
||||
wxListBox* callstack;
|
||||
@ -75,6 +77,7 @@ class CCodeWindow
|
||||
void OnAddrBoxChange(wxCommandEvent& event);
|
||||
|
||||
void OnToggleRegisterWindow(wxCommandEvent& event);
|
||||
void OnToggleBreakPointWindow(wxCommandEvent& event);
|
||||
void OnToggleLogWindow(wxCommandEvent& event);
|
||||
void OnHostMessage(wxCommandEvent& event);
|
||||
|
||||
|
Reference in New Issue
Block a user