2008-07-12 17:40:22 +00:00
|
|
|
// 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/
|
|
|
|
|
2008-08-23 03:48:40 +00:00
|
|
|
#include "wx/button.h"
|
|
|
|
#include "wx/textctrl.h"
|
2008-08-23 15:15:25 +00:00
|
|
|
#include "wx/textdlg.h"
|
2008-08-23 03:48:40 +00:00
|
|
|
#include "wx/listctrl.h"
|
|
|
|
#include "wx/thread.h"
|
|
|
|
#include "wx/mstream.h"
|
|
|
|
|
|
|
|
// ugly that this lib included code from the main
|
|
|
|
#include "../../DolphinWX/src/Globals.h"
|
|
|
|
|
2008-08-21 17:22:55 +00:00
|
|
|
#include "IniFile.h"
|
|
|
|
#include "Host.h"
|
|
|
|
|
2008-07-12 17:40:22 +00:00
|
|
|
#include "Debugger.h"
|
|
|
|
|
|
|
|
#include "RegisterWindow.h"
|
|
|
|
#include "LogWindow.h"
|
2008-07-17 20:08:01 +00:00
|
|
|
#include "BreakpointWindow.h"
|
2008-07-21 18:42:44 +00:00
|
|
|
#include "MemoryWindow.h"
|
2008-08-21 17:22:55 +00:00
|
|
|
#include "JitWindow.h"
|
2008-07-12 17:40:22 +00:00
|
|
|
|
|
|
|
#include "CodeWindow.h"
|
2008-07-21 18:42:44 +00:00
|
|
|
#include "CodeView.h"
|
2008-08-21 17:22:55 +00:00
|
|
|
|
2008-08-23 15:15:25 +00:00
|
|
|
#include "FileUtil.h"
|
2008-08-21 17:22:55 +00:00
|
|
|
#include "Core.h"
|
2008-08-23 15:15:25 +00:00
|
|
|
#include "Boot/Boot.h"
|
2008-08-21 17:22:55 +00:00
|
|
|
#include "LogManager.h"
|
2008-07-12 17:40:22 +00:00
|
|
|
#include "HW/CPU.h"
|
|
|
|
#include "PowerPC/PowerPC.h"
|
|
|
|
#include "Debugger/PPCDebugInterface.h"
|
|
|
|
#include "Debugger/Debugger_SymbolMap.h"
|
2008-08-09 16:56:24 +00:00
|
|
|
#include "PowerPC/PPCAnalyst.h"
|
2008-08-24 18:50:51 +00:00
|
|
|
#include "PowerPC/SymbolDB.h"
|
2008-08-24 15:46:08 +00:00
|
|
|
#include "PowerPC/SignatureDB.h"
|
2008-08-23 09:20:36 +00:00
|
|
|
#include "PowerPC/PPCTables.h"
|
2008-08-13 20:48:27 +00:00
|
|
|
#include "PowerPC/Jit64/Jit.h"
|
|
|
|
#include "PowerPC/Jit64/JitCache.h"
|
2008-07-12 17:40:22 +00:00
|
|
|
|
2008-07-24 09:39:56 +00:00
|
|
|
extern "C" {
|
2008-07-24 13:40:07 +00:00
|
|
|
#include "../resources/toolbar_play.c"
|
|
|
|
#include "../resources/toolbar_pause.c"
|
|
|
|
#include "../resources/toolbar_add_memorycheck.c"
|
|
|
|
#include "../resources/toolbar_delete.c"
|
|
|
|
#include "../resources/toolbar_add_breakpoint.c"
|
2008-07-24 09:39:56 +00:00
|
|
|
}
|
2008-07-12 17:40:22 +00:00
|
|
|
|
2008-07-24 09:39:56 +00:00
|
|
|
static const long TOOLBAR_STYLE = wxTB_FLAT | wxTB_DOCKABLE | wxTB_TEXT;
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(CCodeWindow, wxFrame)
|
2008-07-20 15:12:12 +00:00
|
|
|
EVT_LISTBOX(IDM_SYMBOLLIST, CCodeWindow::OnSymbolListChange)
|
2008-07-17 22:19:57 +00:00
|
|
|
EVT_LISTBOX(IDM_CALLSTACKLIST, CCodeWindow::OnCallstackListChange)
|
2008-08-24 20:25:36 +00:00
|
|
|
EVT_LISTBOX(IDM_CALLERSLIST, CCodeWindow::OnCallersListChange)
|
|
|
|
EVT_LISTBOX(IDM_CALLSLIST, CCodeWindow::OnCallsListChange)
|
2008-07-17 22:19:57 +00:00
|
|
|
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)
|
2008-07-21 18:42:44 +00:00
|
|
|
EVT_MENU(IDM_MEMORYWINDOW, CCodeWindow::OnToggleMemoryWindow)
|
2008-08-09 16:56:24 +00:00
|
|
|
|
2008-08-24 18:50:51 +00:00
|
|
|
EVT_MENU(IDM_CLEARSYMBOLS, CCodeWindow::OnSymbolsMenu)
|
|
|
|
EVT_MENU(IDM_LOADMAPFILE, CCodeWindow::OnSymbolsMenu)
|
2008-08-09 16:56:24 +00:00
|
|
|
EVT_MENU(IDM_SCANFUNCTIONS, CCodeWindow::OnSymbolsMenu)
|
2008-08-10 18:21:16 +00:00
|
|
|
EVT_MENU(IDM_SAVEMAPFILE, CCodeWindow::OnSymbolsMenu)
|
2008-08-24 15:46:08 +00:00
|
|
|
EVT_MENU(IDM_CREATESIGNATUREFILE, CCodeWindow::OnSymbolsMenu)
|
|
|
|
EVT_MENU(IDM_USESIGNATUREFILE, CCodeWindow::OnSymbolsMenu)
|
2008-08-23 09:20:36 +00:00
|
|
|
|
|
|
|
EVT_MENU(IDM_CLEARCODECACHE, CCodeWindow::OnJitMenu)
|
|
|
|
EVT_MENU(IDM_LOGINSTRUCTIONS, CCodeWindow::OnJitMenu)
|
2008-07-24 09:39:56 +00:00
|
|
|
// toolbar
|
|
|
|
EVT_MENU(IDM_DEBUG_GO, CCodeWindow::OnCodeStep)
|
|
|
|
EVT_MENU(IDM_STEP, CCodeWindow::OnCodeStep)
|
|
|
|
EVT_MENU(IDM_STEPOVER, CCodeWindow::OnCodeStep)
|
|
|
|
EVT_MENU(IDM_SKIP, CCodeWindow::OnCodeStep)
|
|
|
|
EVT_MENU(IDM_SETPC, CCodeWindow::OnCodeStep)
|
|
|
|
EVT_MENU(IDM_GOTOPC, CCodeWindow::OnCodeStep)
|
|
|
|
EVT_TEXT(IDM_ADDRBOX, CCodeWindow::OnAddrBoxChange)
|
2008-08-24 20:25:36 +00:00
|
|
|
|
|
|
|
EVT_COMMAND(IDM_CODEVIEW, wxEVT_CODEVIEW_CHANGE, CCodeWindow::OnCodeViewChange)
|
2008-07-12 17:40:22 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2008-07-24 09:39:56 +00:00
|
|
|
#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));
|
|
|
|
}
|
|
|
|
|
2008-07-12 17:40:22 +00:00
|
|
|
|
|
|
|
CCodeWindow::CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter, wxWindow* parent, wxWindowID id,
|
|
|
|
const wxString& title, const wxPoint& pos, const wxSize& size, long style)
|
|
|
|
: wxFrame(parent, id, title, pos, size, style)
|
|
|
|
, m_RegisterWindow(NULL)
|
2008-07-24 13:40:07 +00:00
|
|
|
, m_LogWindow(NULL)
|
2008-07-17 21:46:34 +00:00
|
|
|
{
|
2008-07-24 09:39:56 +00:00
|
|
|
InitBitmaps();
|
2008-07-12 17:40:22 +00:00
|
|
|
|
2008-07-24 09:39:56 +00:00
|
|
|
CreateGUIControls(_LocalCoreStartupParameter);
|
2008-07-12 17:40:22 +00:00
|
|
|
|
2008-07-24 09:39:56 +00:00
|
|
|
// Create the toolbar
|
|
|
|
RecreateToolbar();
|
2008-07-12 17:40:22 +00:00
|
|
|
|
|
|
|
UpdateButtonStates();
|
2008-07-17 21:46:34 +00:00
|
|
|
|
2008-07-24 13:40:07 +00:00
|
|
|
wxTheApp->Connect(wxID_ANY, wxEVT_KEY_DOWN,
|
|
|
|
wxKeyEventHandler(CCodeWindow::OnKeyDown),
|
|
|
|
(wxObject*)0, this);
|
|
|
|
|
2008-07-24 09:39:56 +00:00
|
|
|
// load ini...
|
2008-07-24 13:40:07 +00:00
|
|
|
IniFile file;
|
|
|
|
file.Load("Debugger.ini");
|
2008-07-17 21:46:34 +00:00
|
|
|
|
2008-07-24 13:40:07 +00:00
|
|
|
this->Load(file);
|
2008-07-24 14:12:09 +00:00
|
|
|
if (m_BreakpointWindow) m_BreakpointWindow->Load(file);
|
|
|
|
if (m_LogWindow) m_LogWindow->Load(file);
|
|
|
|
if (m_RegisterWindow) m_RegisterWindow->Load(file);
|
|
|
|
if (m_MemoryWindow) m_MemoryWindow->Load(file);
|
2008-07-24 13:40:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CCodeWindow::~CCodeWindow()
|
|
|
|
{
|
2008-07-24 09:39:56 +00:00
|
|
|
IniFile file;
|
|
|
|
file.Load("Debugger.ini");
|
2008-07-17 21:46:34 +00:00
|
|
|
|
2008-07-24 13:40:07 +00:00
|
|
|
this->Save(file);
|
2008-07-24 14:12:09 +00:00
|
|
|
if (m_BreakpointWindow) m_BreakpointWindow->Save(file);
|
|
|
|
if (m_LogWindow) m_LogWindow->Save(file);
|
|
|
|
if (m_RegisterWindow) m_RegisterWindow->Save(file);
|
|
|
|
if (m_MemoryWindow) m_MemoryWindow->Save(file);
|
2008-07-24 13:40:07 +00:00
|
|
|
|
|
|
|
file.Save("Debugger.ini");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CCodeWindow::Load( IniFile &file )
|
|
|
|
{
|
|
|
|
int x,y,w,h;
|
2008-07-24 09:39:56 +00:00
|
|
|
file.Get("Code", "x", &x, GetPosition().x);
|
|
|
|
file.Get("Code", "y", &y, GetPosition().y);
|
|
|
|
file.Get("Code", "w", &w, GetSize().GetWidth());
|
|
|
|
file.Get("Code", "h", &h, GetSize().GetHeight());
|
|
|
|
this->SetSize(x, y, w, h);
|
2008-07-24 13:40:07 +00:00
|
|
|
}
|
2008-07-17 21:46:34 +00:00
|
|
|
|
2008-07-21 18:42:44 +00:00
|
|
|
|
2008-07-24 13:40:07 +00:00
|
|
|
void CCodeWindow::Save(IniFile &file) const
|
|
|
|
{
|
|
|
|
file.Set("Code", "x", GetPosition().x);
|
|
|
|
file.Set("Code", "y", GetPosition().y);
|
|
|
|
file.Set("Code", "w", GetSize().GetWidth());
|
|
|
|
file.Set("Code", "h", GetSize().GetHeight());
|
2008-07-17 21:46:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-24 09:39:56 +00:00
|
|
|
void CCodeWindow::CreateGUIControls(const SCoreStartupParameter& _LocalCoreStartupParameter)
|
|
|
|
{
|
|
|
|
CreateMenu(_LocalCoreStartupParameter);
|
|
|
|
|
|
|
|
wxBoxSizer* sizerBig = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
wxBoxSizer* sizerLeft = new wxBoxSizer(wxVERTICAL);
|
|
|
|
|
|
|
|
DebugInterface* di = new PPCDebugInterface();
|
|
|
|
|
2008-08-24 20:25:36 +00:00
|
|
|
codeview = new CCodeView(di, this, IDM_CODEVIEW);
|
2008-07-24 09:39:56 +00:00
|
|
|
sizerBig->Add(sizerLeft, 2, wxEXPAND);
|
|
|
|
sizerBig->Add(codeview, 5, wxEXPAND);
|
|
|
|
|
2008-08-24 18:50:51 +00:00
|
|
|
sizerLeft->Add(callstack = new wxListBox(this, IDM_CALLSTACKLIST, wxDefaultPosition, wxSize(90, 100)), 0, wxEXPAND);
|
|
|
|
sizerLeft->Add(symbols = new wxListBox(this, IDM_SYMBOLLIST, wxDefaultPosition, wxSize(90, 100), 0, NULL, wxLB_SORT), 1, wxEXPAND);
|
2008-08-24 20:25:36 +00:00
|
|
|
sizerLeft->Add(calls = new wxListBox(this, IDM_CALLSLIST, wxDefaultPosition, wxSize(90, 100), 0, NULL, wxLB_SORT), 0, wxEXPAND);
|
|
|
|
sizerLeft->Add(callers = new wxListBox(this, IDM_CALLERSLIST, wxDefaultPosition, wxSize(90, 100), 0, NULL, wxLB_SORT), 0, wxEXPAND);
|
2008-08-24 18:50:51 +00:00
|
|
|
|
2008-07-24 09:39:56 +00:00
|
|
|
SetSizer(sizerBig);
|
|
|
|
|
|
|
|
sizerLeft->SetSizeHints(this);
|
|
|
|
sizerLeft->Fit(this);
|
|
|
|
sizerBig->SetSizeHints(this);
|
|
|
|
sizerBig->Fit(this);
|
|
|
|
|
|
|
|
sync_event.Init();
|
|
|
|
|
|
|
|
// additional dialogs
|
|
|
|
if (IsLoggingActivated())
|
|
|
|
{
|
2008-07-24 13:40:07 +00:00
|
|
|
m_LogWindow = new CLogWindow(this);
|
|
|
|
m_LogWindow->Show(true);
|
2008-07-24 09:39:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_RegisterWindow = new CRegisterWindow(this);
|
|
|
|
m_RegisterWindow->Show(true);
|
|
|
|
|
|
|
|
m_BreakpointWindow = new CBreakPointWindow(this, this);
|
|
|
|
m_BreakpointWindow->Show(true);
|
|
|
|
|
|
|
|
m_MemoryWindow = new CMemoryWindow(this);
|
|
|
|
m_MemoryWindow->Show(true);
|
2008-08-21 17:22:55 +00:00
|
|
|
|
|
|
|
m_JitWindow = new CJitWindow(this);
|
|
|
|
m_JitWindow->Show(true);
|
2008-07-24 09:39:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-12 17:40:22 +00:00
|
|
|
void CCodeWindow::CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParameter)
|
|
|
|
{
|
|
|
|
wxMenuBar* pMenuBar = new wxMenuBar(wxMB_DOCKABLE);
|
|
|
|
|
|
|
|
{
|
2008-08-09 16:56:24 +00:00
|
|
|
wxMenu* pCoreMenu = new wxMenu;
|
|
|
|
wxMenuItem* interpreter = pCoreMenu->Append(IDM_INTERPRETER, _T("&Interpreter"), wxEmptyString, wxITEM_CHECK);
|
2008-07-12 17:40:22 +00:00
|
|
|
interpreter->Check(!_LocalCoreStartupParameter.bUseDynarec);
|
|
|
|
|
2008-07-16 12:19:14 +00:00
|
|
|
// wxMenuItem* dualcore = pDebugMenu->Append(IDM_DUALCORE, _T("&DualCore"), wxEmptyString, wxITEM_CHECK);
|
|
|
|
// dualcore->Check(_LocalCoreStartupParameter.bUseDualCore);
|
2008-07-12 17:40:22 +00:00
|
|
|
|
2008-08-09 16:56:24 +00:00
|
|
|
pMenuBar->Append(pCoreMenu, _T("&Core Startup"));
|
2008-07-12 17:40:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
wxMenu* pDebugDialogs = new wxMenu;
|
|
|
|
|
|
|
|
if (IsLoggingActivated())
|
|
|
|
{
|
|
|
|
wxMenuItem* pLogWindow = pDebugDialogs->Append(IDM_LOGWINDOW, _T("&LogManager"), wxEmptyString, wxITEM_CHECK);
|
|
|
|
pLogWindow->Check(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
wxMenuItem* pRegister = pDebugDialogs->Append(IDM_REGISTERWINDOW, _T("&Registers"), wxEmptyString, wxITEM_CHECK);
|
|
|
|
pRegister->Check(true);
|
|
|
|
|
2008-07-17 20:08:01 +00:00
|
|
|
wxMenuItem* pBreakPoints = pDebugDialogs->Append(IDM_BREAKPOINTWINDOW, _T("&BreakPoints"), wxEmptyString, wxITEM_CHECK);
|
|
|
|
pBreakPoints->Check(true);
|
|
|
|
|
2008-07-21 18:42:44 +00:00
|
|
|
wxMenuItem* pMemory = pDebugDialogs->Append(IDM_MEMORYWINDOW, _T("&Memory"), wxEmptyString, wxITEM_CHECK);
|
|
|
|
pMemory->Check(true);
|
|
|
|
pMenuBar->Append(pDebugDialogs, _T("&Views"));
|
2008-07-12 17:40:22 +00:00
|
|
|
}
|
|
|
|
|
2008-08-09 16:56:24 +00:00
|
|
|
{
|
|
|
|
wxMenu *pSymbolsMenu = new wxMenu;
|
2008-08-24 18:50:51 +00:00
|
|
|
pSymbolsMenu->Append(IDM_CLEARSYMBOLS, _T("&Clear symbols"));
|
|
|
|
pSymbolsMenu->Append(IDM_SCANFUNCTIONS, _T("&Generate symbol map"));
|
|
|
|
pSymbolsMenu->AppendSeparator();
|
|
|
|
pSymbolsMenu->Append(IDM_LOADMAPFILE, _T("&Load symbol map"));
|
2008-08-23 15:15:25 +00:00
|
|
|
pSymbolsMenu->Append(IDM_SAVEMAPFILE, _T("&Save symbol map"));
|
2008-08-24 15:46:08 +00:00
|
|
|
pSymbolsMenu->AppendSeparator();
|
|
|
|
pSymbolsMenu->Append(IDM_CREATESIGNATUREFILE, _T("&Create signature file..."));
|
|
|
|
pSymbolsMenu->Append(IDM_USESIGNATUREFILE, _T("&Use signature file..."));
|
2008-08-09 16:56:24 +00:00
|
|
|
pMenuBar->Append(pSymbolsMenu, _T("&Symbols"));
|
|
|
|
}
|
2008-08-13 20:48:27 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
wxMenu *pJitMenu = new wxMenu;
|
|
|
|
pJitMenu->Append(IDM_CLEARCODECACHE, _T("&Clear code cache"));
|
2008-08-23 09:20:36 +00:00
|
|
|
pJitMenu->Append(IDM_LOGINSTRUCTIONS, _T("&Log JIT instruction coverage"));
|
2008-08-13 20:48:27 +00:00
|
|
|
pMenuBar->Append(pJitMenu, _T("&JIT"));
|
|
|
|
}
|
|
|
|
|
2008-07-12 17:40:22 +00:00
|
|
|
SetMenuBar(pMenuBar);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CCodeWindow::UseInterpreter()
|
|
|
|
{
|
|
|
|
return(GetMenuBar()->IsChecked(IDM_INTERPRETER));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CCodeWindow::UseDualCore()
|
|
|
|
{
|
|
|
|
return(GetMenuBar()->IsChecked(IDM_DUALCORE));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-13 20:48:27 +00:00
|
|
|
void CCodeWindow::OnJitMenu(wxCommandEvent& event)
|
|
|
|
{
|
|
|
|
switch (event.GetId())
|
|
|
|
{
|
|
|
|
case IDM_CLEARCODECACHE:
|
|
|
|
Jit64::ClearCache();
|
|
|
|
break;
|
2008-08-23 09:20:36 +00:00
|
|
|
case IDM_LOGINSTRUCTIONS:
|
|
|
|
PPCTables::LogCompiledInstructions();
|
|
|
|
break;
|
2008-08-13 20:48:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-09 16:56:24 +00:00
|
|
|
void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event)
|
|
|
|
{
|
|
|
|
if (Core::GetState() == Core::CORE_UNINITIALIZED)
|
|
|
|
{
|
|
|
|
// TODO: disable menu items instead :P
|
|
|
|
return;
|
|
|
|
}
|
2008-08-23 15:15:25 +00:00
|
|
|
std::string mapfile = CBoot::GenerateMapFilename();
|
2008-08-09 16:56:24 +00:00
|
|
|
switch (event.GetId())
|
|
|
|
{
|
2008-08-24 18:50:51 +00:00
|
|
|
case IDM_CLEARSYMBOLS:
|
|
|
|
g_symbolDB.Clear();
|
|
|
|
Host_NotifyMapLoaded();
|
|
|
|
break;
|
2008-08-09 16:56:24 +00:00
|
|
|
case IDM_SCANFUNCTIONS:
|
2008-08-24 18:50:51 +00:00
|
|
|
{
|
|
|
|
PPCAnalyst::FindFunctions(0x80000000, 0x80400000, &g_symbolDB);
|
|
|
|
SignatureDB db;
|
|
|
|
if (db.Load("data/totaldb.dsy"))
|
|
|
|
db.Apply(&g_symbolDB);
|
|
|
|
Host_NotifyMapLoaded();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case IDM_LOADMAPFILE:
|
2008-08-23 15:15:25 +00:00
|
|
|
if (!File::Exists(mapfile))
|
2008-08-10 18:21:16 +00:00
|
|
|
{
|
2008-08-24 18:50:51 +00:00
|
|
|
g_symbolDB.Clear();
|
|
|
|
PPCAnalyst::FindFunctions(0x80000000, 0x80400000, &g_symbolDB);
|
2008-08-24 15:46:08 +00:00
|
|
|
SignatureDB db;
|
|
|
|
if (db.Load("data/totaldb.dsy"))
|
2008-08-24 18:50:51 +00:00
|
|
|
db.Apply(&g_symbolDB);
|
2008-08-23 15:15:25 +00:00
|
|
|
} else {
|
2008-08-24 18:50:51 +00:00
|
|
|
g_symbolDB.LoadMap(mapfile.c_str());
|
2008-08-10 18:21:16 +00:00
|
|
|
}
|
2008-08-24 15:46:08 +00:00
|
|
|
Host_NotifyMapLoaded();
|
2008-08-10 18:21:16 +00:00
|
|
|
break;
|
|
|
|
case IDM_SAVEMAPFILE:
|
2008-08-24 18:50:51 +00:00
|
|
|
g_symbolDB.SaveMap(mapfile.c_str());
|
2008-08-10 18:21:16 +00:00
|
|
|
break;
|
2008-08-24 15:46:08 +00:00
|
|
|
case IDM_CREATESIGNATUREFILE:
|
|
|
|
{
|
|
|
|
wxString path = wxFileSelector(
|
|
|
|
_T("Save signature as"), wxEmptyString, wxEmptyString, wxEmptyString,
|
|
|
|
_T("Dolphin Signature File (*.dsy)|*.dsy;"), wxFD_SAVE,
|
|
|
|
this);
|
|
|
|
if (path) {
|
|
|
|
SignatureDB db;
|
2008-08-24 18:50:51 +00:00
|
|
|
db.Initialize(&g_symbolDB);
|
2008-08-24 15:46:08 +00:00
|
|
|
std::string filename(path.ToAscii()); // PPCAnalyst::SaveSignatureDB(
|
|
|
|
db.Save(path.ToAscii());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDM_USESIGNATUREFILE:
|
|
|
|
{
|
|
|
|
wxString path = wxFileSelector(
|
|
|
|
_T("Apply signature file"), wxEmptyString, wxEmptyString, wxEmptyString,
|
|
|
|
_T("Dolphin Signature File (*.dsy)|*.dsy;"), wxFD_OPEN | wxFD_FILE_MUST_EXIST,
|
|
|
|
this);
|
|
|
|
if (path) {
|
|
|
|
SignatureDB db;
|
|
|
|
db.Load(path.ToAscii());
|
2008-08-24 18:50:51 +00:00
|
|
|
db.Apply(&g_symbolDB);
|
2008-08-24 15:46:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Host_NotifyMapLoaded();
|
|
|
|
break;
|
2008-08-09 16:56:24 +00:00
|
|
|
}
|
|
|
|
}
|
2008-07-17 21:46:34 +00:00
|
|
|
|
2008-07-12 17:40:22 +00:00
|
|
|
void CCodeWindow::OnCodeStep(wxCommandEvent& event)
|
|
|
|
{
|
|
|
|
switch (event.GetId())
|
|
|
|
{
|
|
|
|
case IDM_DEBUG_GO:
|
|
|
|
{
|
|
|
|
// [F|RES] prolly we should disable the other buttons in go mode too ...
|
2008-08-24 20:25:36 +00:00
|
|
|
JumpToAddress(PC);
|
2008-07-12 17:40:22 +00:00
|
|
|
|
|
|
|
if (CCPU::IsStepping())
|
|
|
|
{
|
|
|
|
CCPU::EnableStepping(false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CCPU::EnableStepping(true);
|
|
|
|
Host_UpdateLogDisplay();
|
|
|
|
}
|
|
|
|
|
|
|
|
Update();
|
|
|
|
}
|
2008-08-23 15:15:25 +00:00
|
|
|
break;
|
2008-07-12 17:40:22 +00:00
|
|
|
|
|
|
|
case IDM_STEP:
|
2008-07-24 13:40:07 +00:00
|
|
|
SingleCPUStep();
|
|
|
|
|
2008-07-12 17:40:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_STEPOVER:
|
|
|
|
CCPU::EnableStepping(true);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_SKIP:
|
|
|
|
PC += 4;
|
|
|
|
Update();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_SETPC:
|
|
|
|
PC = codeview->GetSelection();
|
|
|
|
Update();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_GOTOPC:
|
2008-08-24 20:25:36 +00:00
|
|
|
JumpToAddress(PC);
|
2008-07-12 17:40:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdateButtonStates();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-24 20:25:36 +00:00
|
|
|
void CCodeWindow::JumpToAddress(u32 _Address)
|
|
|
|
{
|
|
|
|
codeview->Center(_Address);
|
|
|
|
UpdateLists();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CCodeWindow::UpdateLists()
|
|
|
|
{
|
|
|
|
callers->Clear();
|
|
|
|
u32 addr = codeview->GetSelection();
|
|
|
|
Symbol *symbol = g_symbolDB.GetSymbolFromAddr(addr);
|
|
|
|
if (!symbol)
|
|
|
|
return;
|
|
|
|
for (int i = 0; i < symbol->callers.size(); i++)
|
|
|
|
{
|
|
|
|
u32 caller_addr = symbol->callers[i].callAddress;
|
|
|
|
Symbol *caller_symbol = g_symbolDB.GetSymbolFromAddr(caller_addr);
|
2008-08-24 20:32:46 +00:00
|
|
|
int idx = callers->Append(wxString::Format( _T("< %s (%08x)"), caller_symbol->name.c_str(), caller_addr));
|
2008-08-24 20:25:36 +00:00
|
|
|
callers->SetClientData(idx, (void*)caller_addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
calls->Clear();
|
|
|
|
for (int i = 0; i < symbol->calls.size(); i++)
|
|
|
|
{
|
|
|
|
u32 call_addr = symbol->calls[i].function;
|
|
|
|
Symbol *call_symbol = g_symbolDB.GetSymbolFromAddr(call_addr);
|
2008-08-24 20:32:46 +00:00
|
|
|
int idx = calls->Append(wxString::Format( _T("> %s (%08x)"), call_symbol->name.c_str(), call_addr));
|
2008-08-24 20:25:36 +00:00
|
|
|
calls->SetClientData(idx, (void*)call_addr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CCodeWindow::OnCodeViewChange(wxCommandEvent &event)
|
|
|
|
{
|
|
|
|
//PanicAlert("boo");
|
|
|
|
UpdateLists();
|
|
|
|
}
|
|
|
|
|
2008-07-12 17:40:22 +00:00
|
|
|
void CCodeWindow::OnAddrBoxChange(wxCommandEvent& event)
|
|
|
|
{
|
2008-07-24 09:39:56 +00:00
|
|
|
wxTextCtrl* pAddrCtrl = (wxTextCtrl*)GetToolBar()->FindControl(IDM_ADDRBOX);
|
|
|
|
wxString txt = pAddrCtrl->GetValue();
|
2008-07-12 17:40:22 +00:00
|
|
|
|
2008-08-24 20:32:46 +00:00
|
|
|
std::string text(txt.mb_str());
|
2008-08-24 20:25:36 +00:00
|
|
|
text = StripSpaces(text);
|
|
|
|
if (text.size() == 8)
|
2008-07-12 17:40:22 +00:00
|
|
|
{
|
|
|
|
u32 addr;
|
2008-08-24 20:25:36 +00:00
|
|
|
sscanf(text.c_str(), "%08x", &addr);
|
|
|
|
JumpToAddress(addr);
|
2008-07-12 17:40:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
event.Skip(1);
|
|
|
|
}
|
|
|
|
|
2008-08-24 20:25:36 +00:00
|
|
|
void CCodeWindow::OnCallstackListChange(wxCommandEvent& event)
|
|
|
|
{
|
|
|
|
int index = callstack->GetSelection();
|
|
|
|
u32 address = (u32)(u64)(callstack->GetClientData(index));
|
|
|
|
if (address)
|
|
|
|
JumpToAddress(address);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCodeWindow::OnCallersListChange(wxCommandEvent& event)
|
|
|
|
{
|
|
|
|
int index = callers->GetSelection();
|
|
|
|
u32 address = (u32)(u64)(callers->GetClientData(index));
|
|
|
|
if (address)
|
|
|
|
JumpToAddress(address);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCodeWindow::OnCallsListChange(wxCommandEvent& event)
|
|
|
|
{
|
|
|
|
int index = calls->GetSelection();
|
|
|
|
u32 address = (u32)(u64)(calls->GetClientData(index));
|
|
|
|
if (address)
|
|
|
|
JumpToAddress(address);
|
|
|
|
}
|
2008-07-12 17:40:22 +00:00
|
|
|
|
|
|
|
void CCodeWindow::Update()
|
|
|
|
{
|
|
|
|
codeview->Refresh();
|
|
|
|
callstack->Clear();
|
|
|
|
|
2008-08-24 15:46:08 +00:00
|
|
|
std::vector<Debugger::CallstackEntry> stack;
|
2008-07-12 17:40:22 +00:00
|
|
|
|
|
|
|
if (Debugger::GetCallstack(stack))
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < stack.size(); i++)
|
|
|
|
{
|
|
|
|
int idx = callstack->Append(wxString::FromAscii(stack[i].Name.c_str()));
|
|
|
|
callstack->SetClientData(idx, (void*)(u64)stack[i].vAddress);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-07-20 11:02:41 +00:00
|
|
|
callstack->Append(wxString::FromAscii("invalid callstack"));
|
2008-07-12 17:40:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
UpdateButtonStates();
|
|
|
|
Host_UpdateLogDisplay();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CCodeWindow::NotifyMapLoaded()
|
|
|
|
{
|
2008-08-24 20:25:36 +00:00
|
|
|
g_symbolDB.FillInCallers();
|
2008-07-12 17:40:22 +00:00
|
|
|
symbols->Show(false); // hide it for faster filling
|
|
|
|
symbols->Clear();
|
2008-08-24 18:50:51 +00:00
|
|
|
for (SymbolDB::XFuncMap::iterator iter = g_symbolDB.GetIterator(); iter != g_symbolDB.End(); iter++)
|
2008-07-12 17:40:22 +00:00
|
|
|
{
|
2008-08-24 19:47:10 +00:00
|
|
|
int idx = symbols->Append(wxString::FromAscii(iter->second.name.c_str()));
|
2008-08-24 18:50:51 +00:00
|
|
|
symbols->SetClientData(idx, (void*)&iter->second);
|
2008-07-12 17:40:22 +00:00
|
|
|
}
|
|
|
|
symbols->Show(true);
|
|
|
|
Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CCodeWindow::UpdateButtonStates()
|
|
|
|
{
|
2008-07-24 13:40:07 +00:00
|
|
|
wxToolBar* toolBar = GetToolBar();
|
2008-07-12 17:40:22 +00:00
|
|
|
if (Core::GetState() == Core::CORE_UNINITIALIZED)
|
|
|
|
{
|
2008-07-24 09:39:56 +00:00
|
|
|
toolBar->EnableTool(IDM_DEBUG_GO, false);
|
|
|
|
toolBar->EnableTool(IDM_STEP, false);
|
|
|
|
toolBar->EnableTool(IDM_STEPOVER, false);
|
|
|
|
toolBar->EnableTool(IDM_SKIP, false);
|
2008-07-12 17:40:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!CCPU::IsStepping())
|
|
|
|
{
|
2008-07-24 09:39:56 +00:00
|
|
|
toolBar->SetToolShortHelp(IDM_DEBUG_GO, _T("&Pause"));
|
2008-07-24 13:40:07 +00:00
|
|
|
toolBar->SetToolNormalBitmap(IDM_DEBUG_GO, m_Bitmaps[Toolbar_Pause]);
|
2008-07-24 09:39:56 +00:00
|
|
|
toolBar->EnableTool(IDM_DEBUG_GO, true);
|
|
|
|
toolBar->EnableTool(IDM_STEP, false);
|
|
|
|
toolBar->EnableTool(IDM_STEPOVER, false);
|
|
|
|
toolBar->EnableTool(IDM_SKIP, false);
|
2008-07-12 17:40:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-07-24 13:40:07 +00:00
|
|
|
toolBar->SetToolShortHelp(IDM_DEBUG_GO, _T("&Play"));
|
|
|
|
toolBar->SetToolNormalBitmap(IDM_DEBUG_GO, m_Bitmaps[Toolbar_DebugGo]);
|
2008-07-24 09:39:56 +00:00
|
|
|
toolBar->EnableTool(IDM_DEBUG_GO, true);
|
|
|
|
toolBar->EnableTool(IDM_STEP, true);
|
|
|
|
toolBar->EnableTool(IDM_STEPOVER, true);
|
|
|
|
toolBar->EnableTool(IDM_SKIP, true);
|
2008-07-12 17:40:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-20 15:12:12 +00:00
|
|
|
void CCodeWindow::OnSymbolListChange(wxCommandEvent& event)
|
2008-07-12 17:40:22 +00:00
|
|
|
{
|
|
|
|
int index = symbols->GetSelection();
|
2008-08-24 18:50:51 +00:00
|
|
|
Symbol* pSymbol = static_cast<Symbol *>(symbols->GetClientData(index));
|
2008-07-12 17:40:22 +00:00
|
|
|
|
|
|
|
if (pSymbol != NULL)
|
|
|
|
{
|
2008-08-24 20:25:36 +00:00
|
|
|
JumpToAddress(pSymbol->address);
|
2008-07-12 17:40:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-10 18:21:16 +00:00
|
|
|
void CCodeWindow::OnSymbolListContextMenu(wxContextMenuEvent& event)
|
|
|
|
{
|
|
|
|
int index = symbols->GetSelection();
|
|
|
|
}
|
|
|
|
|
2008-07-12 17:40:22 +00:00
|
|
|
|
|
|
|
void CCodeWindow::OnToggleLogWindow(wxCommandEvent& event)
|
|
|
|
{
|
|
|
|
if (IsLoggingActivated())
|
|
|
|
{
|
|
|
|
bool show = GetMenuBar()->IsChecked(event.GetId());
|
|
|
|
|
|
|
|
if (show)
|
|
|
|
{
|
2008-07-24 13:40:07 +00:00
|
|
|
if (!m_LogWindow)
|
2008-07-12 17:40:22 +00:00
|
|
|
{
|
2008-07-24 13:40:07 +00:00
|
|
|
m_LogWindow = new CLogWindow(this);
|
2008-07-12 17:40:22 +00:00
|
|
|
}
|
|
|
|
|
2008-07-24 13:40:07 +00:00
|
|
|
m_LogWindow->Show(true);
|
2008-07-12 17:40:22 +00:00
|
|
|
}
|
|
|
|
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.
|
2008-07-24 13:40:07 +00:00
|
|
|
wxASSERT(m_LogWindow != NULL);
|
2008-07-12 17:40:22 +00:00
|
|
|
|
2008-07-24 13:40:07 +00:00
|
|
|
if (m_LogWindow)
|
2008-07-12 17:40:22 +00:00
|
|
|
{
|
2008-07-24 13:40:07 +00:00
|
|
|
m_LogWindow->Hide();
|
2008-07-12 17:40:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CCodeWindow::OnToggleRegisterWindow(wxCommandEvent& event)
|
|
|
|
{
|
|
|
|
bool show = GetMenuBar()->IsChecked(event.GetId());
|
|
|
|
|
|
|
|
if (show)
|
|
|
|
{
|
|
|
|
if (!m_RegisterWindow)
|
|
|
|
{
|
|
|
|
m_RegisterWindow = new CRegisterWindow(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_RegisterWindow->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_RegisterWindow != NULL);
|
|
|
|
|
|
|
|
if (m_RegisterWindow)
|
|
|
|
{
|
|
|
|
m_RegisterWindow->Hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-17 20:08:01 +00:00
|
|
|
void CCodeWindow::OnToggleBreakPointWindow(wxCommandEvent& event)
|
|
|
|
{
|
|
|
|
bool show = GetMenuBar()->IsChecked(event.GetId());
|
|
|
|
|
|
|
|
if (show)
|
|
|
|
{
|
|
|
|
if (!m_BreakpointWindow)
|
|
|
|
{
|
2008-07-17 21:46:34 +00:00
|
|
|
m_BreakpointWindow = new CBreakPointWindow(this, this);
|
2008-07-17 20:08:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-07-12 17:40:22 +00:00
|
|
|
|
2008-07-21 18:42:44 +00:00
|
|
|
void CCodeWindow::OnToggleMemoryWindow(wxCommandEvent& event)
|
|
|
|
{
|
|
|
|
bool show = GetMenuBar()->IsChecked(event.GetId());
|
|
|
|
|
|
|
|
if (show)
|
|
|
|
{
|
|
|
|
if (!m_MemoryWindow)
|
|
|
|
{
|
|
|
|
m_MemoryWindow = new CMemoryWindow(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_MemoryWindow->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_MemoryWindow != NULL);
|
|
|
|
|
|
|
|
if (m_MemoryWindow)
|
|
|
|
{
|
|
|
|
m_MemoryWindow->Hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-08-09 16:56:24 +00:00
|
|
|
|
2008-07-12 17:40:22 +00:00
|
|
|
void CCodeWindow::OnHostMessage(wxCommandEvent& event)
|
|
|
|
{
|
|
|
|
switch (event.GetId())
|
|
|
|
{
|
|
|
|
case IDM_NOTIFYMAPLOADED:
|
|
|
|
NotifyMapLoaded();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_UPDATELOGDISPLAY:
|
|
|
|
|
2008-07-24 13:40:07 +00:00
|
|
|
if (m_LogWindow)
|
2008-07-12 17:40:22 +00:00
|
|
|
{
|
2008-07-24 13:40:07 +00:00
|
|
|
m_LogWindow->NotifyUpdate();
|
2008-07-12 17:40:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_UPDATEDISASMDIALOG:
|
|
|
|
Update();
|
|
|
|
|
|
|
|
if (m_RegisterWindow)
|
|
|
|
{
|
|
|
|
m_RegisterWindow->NotifyUpdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
2008-07-17 20:08:01 +00:00
|
|
|
|
|
|
|
case IDM_UPDATEBREAKPOINTS:
|
2008-07-17 21:46:34 +00:00
|
|
|
Update();
|
2008-07-17 20:08:01 +00:00
|
|
|
|
|
|
|
if (m_BreakpointWindow)
|
|
|
|
{
|
|
|
|
m_BreakpointWindow->NotifyUpdate();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2008-07-12 17:40:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-24 09:39:56 +00:00
|
|
|
void CCodeWindow::PopulateToolbar(wxToolBar* toolBar)
|
|
|
|
{
|
|
|
|
int w = m_Bitmaps[Toolbar_DebugGo].GetWidth(),
|
|
|
|
h = m_Bitmaps[Toolbar_DebugGo].GetHeight();
|
|
|
|
|
|
|
|
toolBar->SetToolBitmapSize(wxSize(w, h));
|
2008-08-09 16:56:24 +00:00
|
|
|
toolBar->AddTool(IDM_DEBUG_GO, _T("Play"), m_Bitmaps[Toolbar_DebugGo]);
|
|
|
|
toolBar->AddTool(IDM_STEP, _T("Step"), m_Bitmaps[Toolbar_Step]);
|
|
|
|
toolBar->AddTool(IDM_STEPOVER, _T("Step Over"), m_Bitmaps[Toolbar_StepOver]);
|
|
|
|
toolBar->AddTool(IDM_SKIP, _T("Skip"), m_Bitmaps[Toolbar_Skip]);
|
2008-07-24 09:39:56 +00:00
|
|
|
toolBar->AddSeparator();
|
2008-08-14 19:57:46 +00:00
|
|
|
toolBar->AddTool(IDM_GOTOPC, _T("Show PC"), m_Bitmaps[Toolbar_GotoPC]);
|
2008-08-09 16:56:24 +00:00
|
|
|
toolBar->AddTool(IDM_SETPC, _T("Set PC"), m_Bitmaps[Toolbar_SetPC]);
|
2008-07-24 09:39:56 +00:00
|
|
|
toolBar->AddSeparator();
|
|
|
|
toolBar->AddControl(new wxTextCtrl(toolBar, IDM_ADDRBOX, _T("")));
|
|
|
|
|
|
|
|
// after adding the buttons to the toolbar, must call Realize() to reflect
|
|
|
|
// the changes
|
|
|
|
toolBar->Realize();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CCodeWindow::RecreateToolbar()
|
|
|
|
{
|
|
|
|
// delete and recreate the toolbar
|
|
|
|
wxToolBarBase* toolBar = GetToolBar();
|
|
|
|
delete toolBar;
|
|
|
|
SetToolBar(NULL);
|
|
|
|
|
|
|
|
long style = TOOLBAR_STYLE;
|
|
|
|
style &= ~(wxTB_HORIZONTAL | wxTB_VERTICAL | wxTB_BOTTOM | wxTB_RIGHT | wxTB_HORZ_LAYOUT | wxTB_TOP);
|
|
|
|
wxToolBar* theToolBar = CreateToolBar(style, ID_TOOLBAR);
|
|
|
|
|
|
|
|
PopulateToolbar(theToolBar);
|
|
|
|
SetToolBar(theToolBar);
|
|
|
|
}
|
|
|
|
|
2008-07-12 17:40:22 +00:00
|
|
|
|
2008-07-24 09:39:56 +00:00
|
|
|
void CCodeWindow::InitBitmaps()
|
|
|
|
{
|
|
|
|
// load original size 48x48
|
2008-07-24 13:40:07 +00:00
|
|
|
m_Bitmaps[Toolbar_DebugGo] = wxGetBitmapFromMemory(toolbar_play_png);
|
2008-07-24 09:39:56 +00:00
|
|
|
m_Bitmaps[Toolbar_Step] = wxGetBitmapFromMemory(toolbar_add_breakpoint_png);
|
|
|
|
m_Bitmaps[Toolbar_StepOver] = wxGetBitmapFromMemory(toolbar_add_memcheck_png);
|
|
|
|
m_Bitmaps[Toolbar_Skip] = wxGetBitmapFromMemory(toolbar_add_memcheck_png);
|
|
|
|
m_Bitmaps[Toolbar_GotoPC] = wxGetBitmapFromMemory(toolbar_add_memcheck_png);
|
|
|
|
m_Bitmaps[Toolbar_SetPC] = wxGetBitmapFromMemory(toolbar_add_memcheck_png);
|
2008-07-24 13:40:07 +00:00
|
|
|
m_Bitmaps[Toolbar_Pause] = wxGetBitmapFromMemory(toolbar_pause_png);
|
2008-07-24 09:39:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
// scale to 16x16 for toolbar
|
|
|
|
for (size_t n = Toolbar_DebugGo; n < Bitmaps_max; n++)
|
|
|
|
{
|
|
|
|
m_Bitmaps[n] = wxBitmap(m_Bitmaps[n].ConvertToImage().Scale(16, 16));
|
|
|
|
}
|
|
|
|
}
|
2008-07-24 13:40:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
void CCodeWindow::OnKeyDown(wxKeyEvent& event)
|
|
|
|
{
|
2008-07-24 14:12:09 +00:00
|
|
|
if ((event.GetKeyCode() == WXK_SPACE) && IsActive())
|
2008-07-24 13:40:07 +00:00
|
|
|
{
|
|
|
|
SingleCPUStep();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CCodeWindow::SingleCPUStep()
|
|
|
|
{
|
|
|
|
CCPU::StepOpcode(&sync_event);
|
|
|
|
// if (CCPU::IsStepping())
|
|
|
|
// sync_event.Wait();
|
|
|
|
wxThread::Sleep(20);
|
|
|
|
// need a short wait here
|
2008-08-24 20:25:36 +00:00
|
|
|
JumpToAddress(PC);
|
2008-07-24 13:40:07 +00:00
|
|
|
Update();
|
|
|
|
Host_UpdateLogDisplay();
|
2008-08-23 03:48:40 +00:00
|
|
|
}
|