Move MemCheck functionality into the virtual DebugInterface class from the more general MemView class.

Give DSP LLE Debugger a wxAUI facelift and add memory view to dsp debugger.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5080 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Shawn Hoffman
2010-02-18 12:06:13 +00:00
parent d5c094df75
commit 63827c71c6
10 changed files with 253 additions and 315 deletions

View File

@ -15,82 +15,108 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Common.h" // Common
#include <iostream> // System
#include "Common.h"
#include <iostream>
#include <fstream>
#include <sstream>
#include <wx/artprov.h>
#include "DSPDebugWindow.h"
#include "DSPRegisterView.h"
#include "CodeView.h"
#include "MemoryView.h"
#include "../DSPSymbols.h"
// Define these here to avoid undefined symbols while still saving functionality
void Host_NotifyMapLoaded() {}
void Host_UpdateBreakPointView() {}
// Event table and class
BEGIN_EVENT_TABLE(DSPDebuggerLLE, wxFrame)
EVT_CLOSE(DSPDebuggerLLE::OnClose)
EVT_MENU_RANGE(ID_RUNTOOL, ID_STEPTOOL, DSPDebuggerLLE::OnChangeState)
EVT_MENU(ID_SHOWPCTOOL, DSPDebuggerLLE::OnShowPC)
EVT_TEXT(ID_ADDRBOX, DSPDebuggerLLE::OnAddrBoxChange)
EVT_LISTBOX(ID_SYMBOLLIST, DSPDebuggerLLE::OnSymbolListChange)
EVT_TEXT_ENTER(ID_ADDRBOX, DSPDebuggerLLE::OnAddrBoxChange)
EVT_LISTBOX(ID_SYMBOLLIST, DSPDebuggerLLE::OnSymbolListChange)
END_EVENT_TABLE()
DSPDebuggerLLE::DSPDebuggerLLE(wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint &position, const wxSize& size, long style)
: wxFrame(parent, id, title, position, size, style)
, m_CachedStepCounter(-1)
DSPDebuggerLLE::DSPDebuggerLLE(wxWindow* parent)
: wxFrame(parent, wxID_ANY, _("DSP LLE Debugger"),
wxDefaultPosition, wxSize(700, 800),
wxDEFAULT_FRAME_STYLE)
, m_CachedStepCounter(-1)
{
CreateGUIControls();
// notify wxAUI which frame to use
m_mgr.SetManagedWindow(this);
m_Toolbar = new wxAuiToolBar(this, ID_TOOLBAR,
wxDefaultPosition, wxDefaultSize, wxAUI_TB_HORZ_TEXT);
m_Toolbar->AddTool(ID_RUNTOOL, wxT("Pause"),
wxArtProvider::GetBitmap(wxART_TICK_MARK, wxART_OTHER, wxSize(10,10)));
m_Toolbar->AddTool(ID_STEPTOOL, wxT("Step"),
wxArtProvider::GetBitmap(wxART_GO_DOWN, wxART_OTHER, wxSize(10,10)));
m_Toolbar->AddTool(ID_SHOWPCTOOL, wxT("Show PC"),
wxArtProvider::GetBitmap(wxART_GO_TO_PARENT, wxART_OTHER, wxSize(10,10)));
m_Toolbar->AddSeparator();
m_Toolbar->AddControl(new wxTextCtrl(m_Toolbar, ID_ADDRBOX, wxEmptyString,
wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER));
m_Toolbar->Realize();
m_SymbolList = new wxListBox(this, ID_SYMBOLLIST, wxDefaultPosition,
wxSize(140, 100), 0, NULL, wxLB_SORT);
m_MainNotebook = new wxAuiNotebook(this, wxID_ANY,
wxDefaultPosition, wxDefaultSize,
wxAUI_NB_TOP | wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_MOVE);
wxPanel *code_panel = new wxPanel(m_MainNotebook, wxID_ANY);
wxBoxSizer *code_sizer = new wxBoxSizer(wxVERTICAL);
m_CodeView = new CCodeView(&debug_interface, &DSPSymbols::g_dsp_symbol_db, code_panel);
m_CodeView->SetPlain();
code_sizer->Add(m_CodeView, 1, wxALL | wxEXPAND);
code_panel->SetSizer(code_sizer);
code_sizer->SetSizeHints(code_panel);
m_MainNotebook->AddPage(code_panel, wxT("Disasm"), true);
wxPanel *mem_panel = new wxPanel(m_MainNotebook, wxID_ANY);
wxBoxSizer *mem_sizer = new wxBoxSizer(wxVERTICAL);
// TODO insert memViewer class
m_MemView = new CMemoryView(&debug_interface, mem_panel);
mem_sizer->Add(m_MemView, 1, wxALL | wxEXPAND);
mem_panel->SetSizer(mem_sizer);
mem_sizer->SetSizeHints(mem_panel);
m_MainNotebook->AddPage(mem_panel, wxT("Mem"));
m_Regs = new DSPRegisterView(this, ID_DSP_REGS);
// add the panes to the manager
m_mgr.AddPane(m_Toolbar, wxAuiPaneInfo().
ToolbarPane().Top().
LeftDockable(false).RightDockable(false));
m_mgr.AddPane(m_SymbolList, wxAuiPaneInfo().
Left().CloseButton(false).
Caption(wxT("Symbols")).Dockable(true));
m_mgr.AddPane(m_MainNotebook, wxAuiPaneInfo().
Name(wxT("m_MainNotebook")).Center().
CloseButton(false).MaximizeButton(true));
m_mgr.AddPane(m_Regs, wxAuiPaneInfo().Right().
CloseButton(false).Caption(wxT("Registers")).
Dockable(true));
UpdateState();
m_mgr.Update();
Show();
}
DSPDebuggerLLE::~DSPDebuggerLLE()
{
}
void DSPDebuggerLLE::CreateGUIControls()
{
// Basic settings
SetSize(700, 800);
this->SetSizeHints(700, 800);
this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
m_Toolbar = CreateToolBar(wxTB_NODIVIDER|wxTB_NOICONS|wxTB_HORZ_TEXT|wxTB_DOCKABLE, ID_TOOLBAR);
m_Toolbar->AddTool(ID_RUNTOOL, wxT("Run"), wxNullBitmap, wxEmptyString, wxITEM_NORMAL);
m_Toolbar->AddTool(ID_STEPTOOL, wxT("Step"), wxNullBitmap, wxT("Step Code "), wxITEM_NORMAL);
m_Toolbar->AddTool(ID_SHOWPCTOOL, wxT("Show Pc"), wxNullBitmap, wxT("Show where PC is"), wxITEM_NORMAL);
m_Toolbar->AddTool(ID_JUMPTOTOOL, wxT("Jump"), wxNullBitmap, wxT("Jump to a specific Address"), wxITEM_NORMAL);
m_Toolbar->AddSeparator();
m_Toolbar->AddControl(new wxTextCtrl(m_Toolbar, ID_ADDRBOX, _T("")));
m_Toolbar->Realize();
wxBoxSizer* sMain = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer* sizerLeft = new wxBoxSizer(wxVERTICAL);
sizerLeft->Add(m_SymbolList = new wxListBox(this, ID_SYMBOLLIST, wxDefaultPosition, wxSize(140, 100), 0, NULL, wxLB_SORT),
1, wxEXPAND);
m_CodeView = new CCodeView(&debug_interface, &DSPSymbols::g_dsp_symbol_db, this, ID_CODEVIEW);
m_CodeView->SetPlain();
sMain->Add(sizerLeft, 0, wxEXPAND, 0);
sMain->Add(m_CodeView, 4, wxEXPAND, 0);
wxStaticLine* m_staticline = new wxStaticLine(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL);
sMain->Add(m_staticline, 0, wxEXPAND|wxALL, 0);
m_Regs = new DSPRegisterView(this, ID_DSP_REGS);
sMain->Add(m_Regs, 0, wxEXPAND|wxALL, 5);
this->SetSizer(sMain);
this->Layout();
UpdateState();
m_mgr.UnInit();
}
void DSPDebuggerLLE::OnClose(wxCloseEvent& event)
@ -123,6 +149,7 @@ void DSPDebuggerLLE::OnChangeState(wxCommandEvent& event)
}
UpdateState();
m_mgr.Update();
}
void DSPDebuggerLLE::OnShowPC(wxCommandEvent& event)
@ -137,6 +164,7 @@ void DSPDebuggerLLE::Refresh()
UpdateDisAsmListView();
UpdateRegisterFlags();
UpdateState();
m_mgr.Update();
}
void DSPDebuggerLLE::FocusOnPC()
@ -147,12 +175,15 @@ void DSPDebuggerLLE::FocusOnPC()
void DSPDebuggerLLE::UpdateState()
{
if (DSPCore_GetState() == DSPCORE_RUNNING) {
m_Toolbar->FindById(ID_RUNTOOL)->SetLabel(wxT("Pause"));
m_Toolbar->FindById(ID_STEPTOOL)->Enable(false);
}
else {
m_Toolbar->FindById(ID_RUNTOOL)->SetLabel(wxT("Run"));
m_Toolbar->FindById(ID_STEPTOOL)->Enable(true);
m_Toolbar->SetToolLabel(ID_RUNTOOL, wxT("Pause"));
m_Toolbar->SetToolBitmap(ID_RUNTOOL,
wxArtProvider::GetBitmap(wxART_TICK_MARK, wxART_OTHER, wxSize(10,10)));
m_Toolbar->EnableTool(ID_STEPTOOL, false);
} else {
m_Toolbar->SetToolLabel(ID_RUNTOOL, wxT("Run"));
m_Toolbar->SetToolBitmap(ID_RUNTOOL,
wxArtProvider::GetBitmap(wxART_GO_FORWARD, wxART_OTHER, wxSize(10,10)));
m_Toolbar->EnableTool(ID_STEPTOOL, true);
}
m_Toolbar->Realize();
}
@ -201,12 +232,11 @@ void DSPDebuggerLLE::OnSymbolListChange(wxCommandEvent& event)
void DSPDebuggerLLE::UpdateRegisterFlags()
{
}
void DSPDebuggerLLE::OnAddrBoxChange(wxCommandEvent& event)
{
wxTextCtrl* pAddrCtrl = (wxTextCtrl*)GetToolBar()->FindControl(ID_ADDRBOX);
wxTextCtrl* pAddrCtrl = (wxTextCtrl*)m_Toolbar->FindControl(ID_ADDRBOX);
wxString txt = pAddrCtrl->GetValue();
std::string text(txt.mb_str());
@ -220,16 +250,32 @@ void DSPDebuggerLLE::OnAddrBoxChange(wxCommandEvent& event)
else
pAddrCtrl->SetBackgroundColour(*wxRED);
}
event.Skip(1);
event.Skip();
}
bool DSPDebuggerLLE::JumpToAddress(u16 addr)
{
int new_line = DSPSymbols::Addr2Line(addr);
if (new_line >= 0) {
m_CodeView->Center(new_line);
return true;
} else {
return false;
int page = m_MainNotebook->GetSelection();
if (page == 0)
{
// Center on valid instruction in IRAM/IROM
int new_line = DSPSymbols::Addr2Line(addr);
if (new_line >= 0) {
m_CodeView->Center(new_line);
return true;
}
}
else if (page == 1)
{
// Center on any location in any valid ROM/RAM
int seg = addr >> 12;
if (seg == 0 || seg == 1 ||
seg == 8 || seg == 0xf)
{
m_MemView->Center(addr);
return true;
}
}
return false;
}

View File

@ -33,6 +33,7 @@
#include <wx/sizer.h>
#include <wx/listctrl.h>
#include <wx/statline.h>
#include <wx/aui/aui.h>
#include "disassemble.h"
#include "DSPInterpreter.h"
@ -41,17 +42,12 @@
class DSPRegisterView;
class CCodeView;
class CMemoryView;
class DSPDebuggerLLE : public wxFrame
{
public:
DSPDebuggerLLE(wxWindow *parent,
wxWindowID id = wxID_ANY,
const wxString &title = wxT("DSP LLE Debugger"),
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE);
DSPDebuggerLLE(wxWindow *parent);
virtual ~DSPDebuggerLLE();
void Refresh();
@ -61,36 +57,13 @@ private:
enum
{
// Toolbar
ID_TOOLBAR = 1000,
ID_RUNTOOL,
ID_STEPTOOL,
ID_SHOWPCTOOL,
ID_ADDRBOX,
ID_JUMPTOTOOL,
ID_DISASMDUMPTOOL,
ID_CHECK_ASSERTINT,
ID_CHECK_HALT,
ID_CHECK_INIT,
ID_SYMBOLLIST,
// Code view
ID_CODEVIEW,
// Register View
ID_DSP_REGS,
};
// Disasm listctrl columns
enum
{
COLUMN_BP,
COLUMN_FUNCTION,
COLUMN_ADDRESS,
COLUMN_MNEMONIC,
COLUMN_OPCODE,
COLUMN_EXT,
COLUMN_PARAM,
ID_DSP_REGS
};
DSPDebugInterface debug_interface;
@ -103,10 +76,13 @@ private:
void UpdateState();
// GUI items
wxToolBar* m_Toolbar;
wxAuiManager m_mgr;
wxAuiToolBar* m_Toolbar;
CCodeView* m_CodeView;
CMemoryView* m_MemView;
DSPRegisterView* m_Regs;
wxListBox* m_SymbolList;
wxAuiNotebook* m_MainNotebook;
void OnClose(wxCloseEvent& event);
void OnChangeState(wxCommandEvent& event);
@ -118,7 +94,6 @@ private:
bool JumpToAddress(u16 addr);
void CreateGUIControls();
void FocusOnPC();
void UnselectAll();
};