From 97ea0362af2964fa1213d72d292203255cd02b3e Mon Sep 17 00:00:00 2001 From: John Peterson Date: Thu, 27 Aug 2009 16:08:43 +0000 Subject: GUI: Renamed a file git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4081 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DebuggerWX/DebuggerWX.vcproj | 4 +- Source/Core/DebuggerWX/Src/CodeWindow.cpp | 516 ++++++++++---------- Source/Core/DebuggerWX/Src/CodeWindowFunctions.cpp | 535 +++++++++++++++++++++ Source/Core/DebuggerWX/Src/CodeWindowSJP.cpp | 534 -------------------- Source/Core/DebuggerWX/Src/SConscript | 2 +- 5 files changed, 786 insertions(+), 805 deletions(-) create mode 100644 Source/Core/DebuggerWX/Src/CodeWindowFunctions.cpp delete mode 100644 Source/Core/DebuggerWX/Src/CodeWindowSJP.cpp (limited to 'Source/Core/DebuggerWX') diff --git a/Source/Core/DebuggerWX/DebuggerWX.vcproj b/Source/Core/DebuggerWX/DebuggerWX.vcproj index ec9919c3df..356b733449 100644 --- a/Source/Core/DebuggerWX/DebuggerWX.vcproj +++ b/Source/Core/DebuggerWX/DebuggerWX.vcproj @@ -1,7 +1,7 @@ GetMenuBar(); @@ -206,6 +193,9 @@ wxAuiToolBar *CCodeWindow::GetToolBar() ///////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////////////////// +// Events +// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ void CCodeWindow::OnKeyDown(wxKeyEvent& event) { if ((event.GetKeyCode() == WXK_SPACE) && Parent->IsActive()) @@ -249,6 +239,185 @@ void CCodeWindow::OnHostMessage(wxCommandEvent& event) } } +// The Play, Stop, Step, Skip, Go to PC and Show PC buttons go here +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 ... + if (CCPU::IsStepping()) + { + CCPU::EnableStepping(false); + } + else + { + CCPU::EnableStepping(true); // Break + Host_UpdateLogDisplay(); + } + wxThread::Sleep(20); + JumpToAddress(PC); + Update(); + } + break; + + case IDM_STEP: + SingleCPUStep(); + break; + + case IDM_STEPOVER: + CCPU::EnableStepping(true); // TODO: Huh? + break; + + case IDM_SKIP: + PC += 4; + Update(); + break; + + case IDM_SETPC: + PC = codeview->GetSelection(); + Update(); + break; + + case IDM_GOTOPC: + JumpToAddress(PC); + break; + } + + UpdateButtonStates(); + // Update all toolbars in the aui manager + Parent->UpdateGUI(); +} + + +void CCodeWindow::JumpToAddress(u32 _Address) +{ + codeview->Center(_Address); + UpdateLists(); +} + + +void CCodeWindow::OnCodeViewChange(wxCommandEvent &event) +{ + //PanicAlert("boo"); + UpdateLists(); +} + +void CCodeWindow::OnAddrBoxChange(wxCommandEvent& event) +{ + ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener(); + Console->Log(LogTypes::LNOTICE, StringFromFormat( + "GetToolBar():%i\n", GetToolBar()).c_str()); + + if (!GetToolBar()) return; + + wxTextCtrl* pAddrCtrl = (wxTextCtrl*)GetToolBar()->FindControl(IDM_ADDRBOX); + wxString txt = pAddrCtrl->GetValue(); + + std::string text(txt.mb_str()); + text = StripSpaces(text); + if (text.size() == 8) + { + u32 addr; + sscanf(text.c_str(), "%08x", &addr); + JumpToAddress(addr); + } + + event.Skip(1); +} + +void CCodeWindow::OnCallstackListChange(wxCommandEvent& event) +{ + int index = callstack->GetSelection(); + if (index >= 0) { + u32 address = (u32)(u64)(callstack->GetClientData(index)); + if (address) + JumpToAddress(address); + } +} + +void CCodeWindow::OnCallersListChange(wxCommandEvent& event) +{ + int index = callers->GetSelection(); + if (index >= 0) { + u32 address = (u32)(u64)(callers->GetClientData(index)); + if (address) + JumpToAddress(address); + } +} + +void CCodeWindow::OnCallsListChange(wxCommandEvent& event) +{ + int index = calls->GetSelection(); + if (index >= 0) { + u32 address = (u32)(u64)(calls->GetClientData(index)); + if (address) + JumpToAddress(address); + } +} + +void CCodeWindow::SingleCPUStep() +{ + CCPU::StepOpcode(&sync_event); + // if (CCPU::IsStepping()) + // sync_event.Wait(); + wxThread::Sleep(20); + // need a short wait here + JumpToAddress(PC); + Update(); + Host_UpdateLogDisplay(); +} + +void CCodeWindow::UpdateLists() +{ + callers->Clear(); + u32 addr = codeview->GetSelection(); + Symbol *symbol = g_symbolDB.GetSymbolFromAddr(addr); + if (!symbol) + return; + for (int i = 0; i < (int)symbol->callers.size(); i++) + { + u32 caller_addr = symbol->callers[i].callAddress; + Symbol *caller_symbol = g_symbolDB.GetSymbolFromAddr(caller_addr); + if (caller_symbol) { + int idx = callers->Append(wxString::FromAscii(StringFromFormat("< %s (%08x)", caller_symbol->name.c_str(), caller_addr).c_str())); + callers->SetClientData(idx, (void*)caller_addr); + } + } + + calls->Clear(); + for (int i = 0; i < (int)symbol->calls.size(); i++) + { + u32 call_addr = symbol->calls[i].function; + Symbol *call_symbol = g_symbolDB.GetSymbolFromAddr(call_addr); + if (call_symbol) { + int idx = calls->Append(wxString::FromAscii(StringFromFormat("> %s (%08x)", call_symbol->name.c_str(), call_addr).c_str())); + calls->SetClientData(idx, (void*)call_addr); + } + } +} + +void CCodeWindow::UpdateCallstack() +{ + callstack->Clear(); + + std::vector stack; + + if (Dolphin_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 + { + callstack->Append(wxString::FromAscii("invalid callstack")); + } +} +///////////////////////////////////////////////////////////////////////////////////////////////////////// // Load these settings before CreateGUIControls() @@ -374,8 +543,10 @@ void CCodeWindow::CreateGUIControls(const SCoreStartupParameter& _LocalCoreStart } +///////////////////////////////////////////////////////////////////////////////////////////////////// +// Menus +// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ // Create CPU Mode and Views menus - void CCodeWindow::CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParameter, wxMenuBar * _pMenuBar) { // Create menu @@ -469,84 +640,7 @@ void CCodeWindow::CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParam } - -// Toolbar and bitmaps for the toolbar - -void CCodeWindow::InitBitmaps() -{ - // load original size 48x48 - m_Bitmaps[Toolbar_DebugGo] = wxGetBitmapFromMemory(toolbar_play_png); - 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); - m_Bitmaps[Toolbar_DebugPause] = wxGetBitmapFromMemory(toolbar_pause_png); - - // scale to 16x16 for toolbar - for (size_t n = Toolbar_DebugGo; n < ToolbarDebugBitmapMax; n++) - { - m_Bitmaps[n] = wxBitmap(m_Bitmaps[n].ConvertToImage().Scale(16, 16)); - } -} - - -void CCodeWindow::PopulateToolbar(wxAuiToolBar* toolBar) -{ - int w = m_Bitmaps[Toolbar_DebugGo].GetWidth(), - h = m_Bitmaps[Toolbar_DebugGo].GetHeight(); - - toolBar->SetToolBitmapSize(wxSize(w, h)); - 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]); - toolBar->AddSeparator(); - toolBar->AddTool(IDM_GOTOPC, _T("Show PC"), m_Bitmaps[Toolbar_GotoPC]); - toolBar->AddTool(IDM_SETPC, _T("Set PC"), m_Bitmaps[Toolbar_SetPC]); - 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(); -} - - - - -// Shortcuts - -bool CCodeWindow::UseInterpreter() -{ - return GetMenuBar()->IsChecked(IDM_INTERPRETER); -} - -bool CCodeWindow::BootToPause() -{ - return GetMenuBar()->IsChecked(IDM_BOOTTOPAUSE); -} - -bool CCodeWindow::AutomaticStart() -{ - return GetMenuBar()->IsChecked(IDM_AUTOMATICSTART); -} - -bool CCodeWindow::UnlimitedJITCache() -{ - return GetMenuBar()->IsChecked(IDM_JITUNLIMITED); -} - -bool CCodeWindow::JITBlockLinking() -{ - return GetMenuBar()->IsChecked(IDM_JITBLOCKLINKING); -} - - - - // CPU Mode and JIT Menu - void CCodeWindow::OnCPUMode(wxCommandEvent& event) { switch (event.GetId()) @@ -587,6 +681,28 @@ void CCodeWindow::OnCPUMode(wxCommandEvent& event) jit.ClearCache(); } + +// Shortcuts +bool CCodeWindow::UseInterpreter() +{ + return GetMenuBar()->IsChecked(IDM_INTERPRETER); +} +bool CCodeWindow::BootToPause() +{ + return GetMenuBar()->IsChecked(IDM_BOOTTOPAUSE); +} +bool CCodeWindow::AutomaticStart() +{ + return GetMenuBar()->IsChecked(IDM_AUTOMATICSTART); +} +bool CCodeWindow::UnlimitedJITCache() +{ + return GetMenuBar()->IsChecked(IDM_JITUNLIMITED); +} +bool CCodeWindow::JITBlockLinking() +{ + return GetMenuBar()->IsChecked(IDM_JITBLOCKLINKING); +} void CCodeWindow::OnJitMenu(wxCommandEvent& event) { switch (event.GetId()) @@ -610,190 +726,57 @@ void CCodeWindow::OnJitMenu(wxCommandEvent& event) } } } +///////////////////////////////////////////////////////////////////////////////////////////////////////// -// Events - - -// The Play, Stop, Step, Skip, Go to PC and Show PC buttons all go here - -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 ... - if (CCPU::IsStepping()) - { - CCPU::EnableStepping(false); - } - else - { - CCPU::EnableStepping(true); // Break - Host_UpdateLogDisplay(); - } - wxThread::Sleep(20); - JumpToAddress(PC); - Update(); - } - break; - - case IDM_STEP: - SingleCPUStep(); - break; - - case IDM_STEPOVER: - CCPU::EnableStepping(true); // TODO: Huh? - break; - - case IDM_SKIP: - PC += 4; - Update(); - break; - - case IDM_SETPC: - PC = codeview->GetSelection(); - Update(); - break; - - case IDM_GOTOPC: - JumpToAddress(PC); - break; - } - - UpdateButtonStates(); - // Update all toolbars in the aui manager - Parent->UpdateGUI(); -} - - -void CCodeWindow::JumpToAddress(u32 _Address) -{ - codeview->Center(_Address); - UpdateLists(); -} - - -void CCodeWindow::OnCodeViewChange(wxCommandEvent &event) -{ - //PanicAlert("boo"); - UpdateLists(); -} - -void CCodeWindow::OnAddrBoxChange(wxCommandEvent& event) +///////////////////////////////////////////////////////////////////////////////////////////////////////// +// Toolbar +// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ +void CCodeWindow::InitBitmaps() { - ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener(); - Console->Log(LogTypes::LNOTICE, StringFromFormat( - "GetToolBar():%i\n", GetToolBar()).c_str()); - - if (!GetToolBar()) return; - - wxTextCtrl* pAddrCtrl = (wxTextCtrl*)GetToolBar()->FindControl(IDM_ADDRBOX); - wxString txt = pAddrCtrl->GetValue(); + // load original size 48x48 + m_Bitmaps[Toolbar_DebugGo] = wxGetBitmapFromMemory(toolbar_play_png); + 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); + m_Bitmaps[Toolbar_DebugPause] = wxGetBitmapFromMemory(toolbar_pause_png); - std::string text(txt.mb_str()); - text = StripSpaces(text); - if (text.size() == 8) + // scale to 16x16 for toolbar + for (size_t n = Toolbar_DebugGo; n < ToolbarDebugBitmapMax; n++) { - u32 addr; - sscanf(text.c_str(), "%08x", &addr); - JumpToAddress(addr); - } - - event.Skip(1); -} - -void CCodeWindow::OnCallstackListChange(wxCommandEvent& event) -{ - int index = callstack->GetSelection(); - if (index >= 0) { - u32 address = (u32)(u64)(callstack->GetClientData(index)); - if (address) - JumpToAddress(address); - } -} - -void CCodeWindow::OnCallersListChange(wxCommandEvent& event) -{ - int index = callers->GetSelection(); - if (index >= 0) { - u32 address = (u32)(u64)(callers->GetClientData(index)); - if (address) - JumpToAddress(address); + m_Bitmaps[n] = wxBitmap(m_Bitmaps[n].ConvertToImage().Scale(16, 16)); } } -void CCodeWindow::OnCallsListChange(wxCommandEvent& event) -{ - int index = calls->GetSelection(); - if (index >= 0) { - u32 address = (u32)(u64)(calls->GetClientData(index)); - if (address) - JumpToAddress(address); - } -} -void CCodeWindow::SingleCPUStep() +void CCodeWindow::PopulateToolbar(wxAuiToolBar* toolBar) { - CCPU::StepOpcode(&sync_event); - // if (CCPU::IsStepping()) - // sync_event.Wait(); - wxThread::Sleep(20); - // need a short wait here - JumpToAddress(PC); - Update(); - Host_UpdateLogDisplay(); -} + int w = m_Bitmaps[Toolbar_DebugGo].GetWidth(), + h = m_Bitmaps[Toolbar_DebugGo].GetHeight(); -void CCodeWindow::UpdateLists() -{ - callers->Clear(); - u32 addr = codeview->GetSelection(); - Symbol *symbol = g_symbolDB.GetSymbolFromAddr(addr); - if (!symbol) - return; - for (int i = 0; i < (int)symbol->callers.size(); i++) - { - u32 caller_addr = symbol->callers[i].callAddress; - Symbol *caller_symbol = g_symbolDB.GetSymbolFromAddr(caller_addr); - if (caller_symbol) { - int idx = callers->Append(wxString::FromAscii(StringFromFormat("< %s (%08x)", caller_symbol->name.c_str(), caller_addr).c_str())); - callers->SetClientData(idx, (void*)caller_addr); - } - } + toolBar->SetToolBitmapSize(wxSize(w, h)); + 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]); + toolBar->AddSeparator(); + toolBar->AddTool(IDM_GOTOPC, _T("Show PC"), m_Bitmaps[Toolbar_GotoPC]); + toolBar->AddTool(IDM_SETPC, _T("Set PC"), m_Bitmaps[Toolbar_SetPC]); + toolBar->AddSeparator(); + toolBar->AddControl(new wxTextCtrl(toolBar, IDM_ADDRBOX, _T(""))); - calls->Clear(); - for (int i = 0; i < (int)symbol->calls.size(); i++) - { - u32 call_addr = symbol->calls[i].function; - Symbol *call_symbol = g_symbolDB.GetSymbolFromAddr(call_addr); - if (call_symbol) { - int idx = calls->Append(wxString::FromAscii(StringFromFormat("> %s (%08x)", call_symbol->name.c_str(), call_addr).c_str())); - calls->SetClientData(idx, (void*)call_addr); - } - } + // after adding the buttons to the toolbar, must call Realize() to reflect + // the changes + toolBar->Realize(); } +///////////////////////////////////////////////////////////////////////////////////////////////////////// -void CCodeWindow::UpdateCallstack() -{ - callstack->Clear(); - - std::vector stack; - if (Dolphin_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 - { - callstack->Append(wxString::FromAscii("invalid callstack")); - } -} +///////////////////////////////////////////////////////////////////////////////////////////////////////// +// Update GUI +// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ void CCodeWindow::Update() { @@ -806,9 +789,6 @@ void CCodeWindow::Update() // codeview->Center(PC); } - -// Update GUI - void CCodeWindow::UpdateButtonStates() { bool Initialized = (Core::GetState() != Core::CORE_UNINITIALIZED); @@ -885,7 +865,7 @@ void CCodeWindow::RecreateToolbar(wxAuiToolBar * toolBar) SetToolBar(NULL); - long style = TOOLBAR_STYLE; + long style = wxTB_FLAT | wxTB_DOCKABLE | wxTB_TEXT; style &= ~(wxTB_HORIZONTAL | wxTB_VERTICAL | wxTB_BOTTOM | wxTB_RIGHT | wxTB_HORZ_LAYOUT | wxTB_TOP); wxToolBar* theToolBar = CreateToolBar(style, ID_TOOLBAR_DEBUG); @@ -941,4 +921,4 @@ void CCodeWindow::OnStatusBar_(wxUpdateUIEvent& event) //if(event.GetId() != IDM_ADDRBOX) DoTip(wxEmptyString); #endif } - +///////////////////////////////////////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/Source/Core/DebuggerWX/Src/CodeWindowFunctions.cpp b/Source/Core/DebuggerWX/Src/CodeWindowFunctions.cpp new file mode 100644 index 0000000000..be8b177b27 --- /dev/null +++ b/Source/Core/DebuggerWX/Src/CodeWindowFunctions.cpp @@ -0,0 +1,535 @@ +// Copyright (C) 2003 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 +// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯ +#include "Common.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +// ugly that this lib included code from the main +#include "../../DolphinWX/Src/WxUtils.h" + +#include "Host.h" + +#include "Debugger.h" +#include "DebuggerUIUtil.h" + +#include "RegisterWindow.h" +#include "BreakpointWindow.h" +#include "MemoryWindow.h" +#include "JitWindow.h" +#include "FileUtil.h" + +#include "CodeWindow.h" +#include "CodeView.h" + +#include "Core.h" +#include "HLE/HLE.h" +#include "Boot/Boot.h" +#include "LogManager.h" +#include "HW/CPU.h" +#include "PowerPC/PowerPC.h" +#include "Debugger/PPCDebugInterface.h" +#include "Debugger/Debugger_SymbolMap.h" +#include "PowerPC/PPCAnalyst.h" +#include "PowerPC/Profiler.h" +#include "PowerPC/PPCSymbolDB.h" +#include "PowerPC/SignatureDB.h" +#include "PowerPC/PPCTables.h" +#include "PowerPC/Jit64/Jit.h" +#include "PowerPC/JitCommon/JitCache.h" // for ClearCache() + +#include "PluginManager.h" +#include "ConfigManager.h" + + +extern "C" // Bitmaps +{ + #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" +} +///////////////////////////////////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////////////////////////////////// +// Symbols, JIT, Profiler +// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ +void CCodeWindow::CreateSymbolsMenu() +{ + wxMenu *pSymbolsMenu = new wxMenu; + pSymbolsMenu->Append(IDM_CLEARSYMBOLS, _T("&Clear symbols")); + // pSymbolsMenu->Append(IDM_CLEANSYMBOLS, _T("&Clean symbols (zz)")); + pSymbolsMenu->Append(IDM_SCANFUNCTIONS, _T("&Generate symbol map")); + pSymbolsMenu->AppendSeparator(); + pSymbolsMenu->Append(IDM_LOADMAPFILE, _T("&Load symbol map")); + pSymbolsMenu->Append(IDM_SAVEMAPFILE, _T("&Save symbol map")); + pSymbolsMenu->AppendSeparator(); + pSymbolsMenu->Append(IDM_SAVEMAPFILEWITHCODES, _T("Save code"), + wxString::FromAscii("Save the entire disassembled code. This may take a several seconds" + " and may require between 50 and 100 MB of hard drive space. It will only save code" + " that are in the first 4 MB of memory, if you are debugging a game that load .rel" + " files with code to memory you may want to increase that to perhaps 8 MB, you can do" + " that from SymbolDB::SaveMap().") + ); + + pSymbolsMenu->AppendSeparator(); + pSymbolsMenu->Append(IDM_CREATESIGNATUREFILE, _T("&Create signature file...")); + pSymbolsMenu->Append(IDM_USESIGNATUREFILE, _T("&Use signature file...")); + pSymbolsMenu->AppendSeparator(); + pSymbolsMenu->Append(IDM_PATCHHLEFUNCTIONS, _T("&Patch HLE functions")); + pSymbolsMenu->Append(IDM_RENAME_SYMBOLS, _T("&Rename symbols from file...")); + pMenuBar->Append(pSymbolsMenu, _T("&Symbols")); + + wxMenu *pJitMenu = new wxMenu; + pJitMenu->Append(IDM_CLEARCODECACHE, _T("&Clear code cache")); + pJitMenu->Append(IDM_LOGINSTRUCTIONS, _T("&Log JIT instruction coverage")); + pJitMenu->Append(IDM_SEARCHINSTRUCTION, _T("&Search for an op")); + pMenuBar->Append(pJitMenu, _T("&JIT")); + + wxMenu *pProfilerMenu = new wxMenu; + pProfilerMenu->Append(IDM_PROFILEBLOCKS, _T("&Profile blocks"), wxEmptyString, wxITEM_CHECK); + pProfilerMenu->AppendSeparator(); + pProfilerMenu->Append(IDM_WRITEPROFILE, _T("&Write to profile.txt, show")); + pMenuBar->Append(pProfilerMenu, _T("&Profiler")); +} + + +void CCodeWindow::OnProfilerMenu(wxCommandEvent& event) +{ + if (Core::GetState() == Core::CORE_RUN) { + event.Skip(); + return; + } + switch (event.GetId()) + { + case IDM_PROFILEBLOCKS: + jit.ClearCache(); + Profiler::g_ProfileBlocks = GetMenuBar()->IsChecked(IDM_PROFILEBLOCKS); + break; + case IDM_WRITEPROFILE: + Profiler::WriteProfileResults("profiler.txt"); + WxUtils::Launch("profiler.txt"); + break; + } +} + +void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event) +{ + if (Core::GetState() == Core::CORE_UNINITIALIZED) + { + // TODO: disable menu items instead :P + return; + } + std::string mapfile = CBoot::GenerateMapFilename(); + switch (event.GetId()) + { + case IDM_CLEARSYMBOLS: + g_symbolDB.Clear(); + Host_NotifyMapLoaded(); + break; + case IDM_CLEANSYMBOLS: + g_symbolDB.Clear("zz"); + Host_NotifyMapLoaded(); + break; + case IDM_SCANFUNCTIONS: + { + PPCAnalyst::FindFunctions(0x80000000, 0x80400000, &g_symbolDB); + SignatureDB db; + if (db.Load((File::GetSysDirectory() + TOTALDB).c_str())) + db.Apply(&g_symbolDB); + + // HLE::PatchFunctions(); + NotifyMapLoaded(); + break; + } + case IDM_LOADMAPFILE: + if (!File::Exists(mapfile.c_str())) + { + g_symbolDB.Clear(); + PPCAnalyst::FindFunctions(0x81300000, 0x81800000, &g_symbolDB); + SignatureDB db; + if (db.Load((File::GetSysDirectory() + TOTALDB).c_str())) + db.Apply(&g_symbolDB); + } else { + g_symbolDB.LoadMap(mapfile.c_str()); + } + HLE::PatchFunctions(); + NotifyMapLoaded(); + break; + case IDM_SAVEMAPFILE: + g_symbolDB.SaveMap(mapfile.c_str()); + break; + case IDM_SAVEMAPFILEWITHCODES: + g_symbolDB.SaveMap(mapfile.c_str(), true); + break; + + case IDM_RENAME_SYMBOLS: + { + wxString path = wxFileSelector( + _T("Apply signature file"), wxEmptyString, wxEmptyString, wxEmptyString, + _T("Dolphin Symbole Rename File (*.sym)|*.sym;"), wxFD_OPEN | wxFD_FILE_MUST_EXIST, + this); + if (path) + { + FILE *f = fopen(path.mb_str(), "r"); + if (!f) + return; + + bool started = false; + while (!feof(f)) + { + char line[512]; + fgets(line, 511, f); + if (strlen(line) < 4) + continue; + + u32 address, type; + char name[512]; + sscanf(line, "%08x %02i %s", &address, &type, name); + + Symbol *symbol = g_symbolDB.GetSymbolFromAddr(address); + if (symbol) { + symbol->name = line+12; + } + } + fclose(f); + Host_NotifyMapLoaded(); + } + } + break; + + case IDM_CREATESIGNATUREFILE: + { + wxTextEntryDialog input_prefix(this, wxString::FromAscii("Only export symbols with prefix:"), wxGetTextFromUserPromptStr, _T(".")); + if (input_prefix.ShowModal() == wxID_OK) { + std::string prefix(input_prefix.GetValue().mb_str()); + + wxString path = wxFileSelector( + _T("Save signature as"), wxEmptyString, wxEmptyString, wxEmptyString, + _T("Dolphin Signature File (*.dsy)|*.dsy;"), wxFD_SAVE, + this); + if (path) { + SignatureDB db; + db.Initialize(&g_symbolDB, prefix.c_str()); + std::string filename(path.mb_str()); // PPCAnalyst::SaveSignatureDB( + db.Save(path.mb_str()); + } + } + } + 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.mb_str()); + db.Apply(&g_symbolDB); + } + } + NotifyMapLoaded(); + break; + case IDM_PATCHHLEFUNCTIONS: + HLE::PatchFunctions(); + Update(); + break; + } +} + + +void CCodeWindow::NotifyMapLoaded() +{ + g_symbolDB.FillInCallers(); + //symbols->Show(false); // hide it for faster filling + symbols->Freeze(); // HyperIris: wx style fast filling + symbols->Clear(); + for (PPCSymbolDB::XFuncMap::iterator iter = g_symbolDB.GetIterator(); iter != g_symbolDB.End(); iter++) + { + int idx = symbols->Append(wxString::FromAscii(iter->second.name.c_str())); + symbols->SetClientData(idx, (void*)&iter->second); + } + symbols->Thaw(); + //symbols->Show(true); + Update(); +} + + +void CCodeWindow::OnSymbolListChange(wxCommandEvent& event) +{ + int index = symbols->GetSelection(); + if (index >= 0) { + Symbol* pSymbol = static_cast(symbols->GetClientData(index)); + if (pSymbol != NULL) + { + if(pSymbol->type == Symbol::SYMBOL_DATA) + { + if(m_MemoryWindow && m_MemoryWindow->IsVisible()) + m_MemoryWindow->JumpToAddress(pSymbol->address); + } + else + { + JumpToAddress(pSymbol->address); + } + } + } +} + +void CCodeWindow::OnSymbolListContextMenu(wxContextMenuEvent& event) +{ +} + + +// Change the global DebuggerFont +void CCodeWindow::OnChangeFont(wxCommandEvent& event) +{ + wxFontData data; + data.SetInitialFont(GetFont()); + + wxFontDialog dialog(this, data); + if ( dialog.ShowModal() == wxID_OK ) + DebuggerFont = dialog.GetFontData().GetChosenFont(); +} +///////////////////////////////////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////////////////////////////////// +// Toogle windows +// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ +wxWindow * CCodeWindow::GetNootebookPage(wxString Name) +{ + if (!Parent->m_NB[0] || !Parent->m_NB[1]) return NULL; + + for(u32 i = 0; i <= Parent->m_NB[0]->GetPageCount(); i++) + { + if (Parent->m_NB[0]->GetPageText(i).IsSameAs(Name)) return Parent->m_NB[0]->GetPage(i); + } + for(u32 i = 0; i <= Parent->m_NB[1]->GetPageCount(); i++) + { + if (Parent->m_NB[1]->GetPageText(i).IsSameAs(Name)) return Parent->m_NB[1]->GetPage(i); + } + return NULL; +} +wxWindow * CCodeWindow::GetWxWindow(wxString Name) +{ + #ifdef _WIN32 + HWND hWnd = ::FindWindow(NULL, Name.c_str()); + if (hWnd) + { + wxWindow * Win = new wxWindow(); + Win->SetHWND((WXHWND)hWnd); + Win->AdoptAttributesFromHWND(); + return Win; + } + else + #endif + if (Parent->FindWindowByName(Name)) + { + return Parent->FindWindowByName(Name); + } + else if (Parent->FindWindowByLabel(Name)) + { + return Parent->FindWindowByLabel(Name); + } + else if (GetNootebookPage(Name)) + { + return GetNootebookPage(Name); + } + else + return NULL; +} +int CCodeWindow::Limit(int i, int Low, int High) +{ + if (i < Low) return Low; + if (i > High) return High; + return i; +} +void CCodeWindow::OpenPages() +{ + ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener(); + Console->Log(LogTypes::LNOTICE, StringFromFormat( + "OpenPages:%i %i\n", iRegisterWindow, iBreakpointWindow).c_str()); + + if (bRegisterWindow) Parent->DoToggleWindow(IDM_REGISTERWINDOW, bRegisterWindow); + if (bBreakpointWindow) Parent->DoToggleWindow(IDM_BREAKPOINTWINDOW, bBreakpointWindow); + if (bMemoryWindow) Parent->DoToggleWindow(IDM_MEMORYWINDOW, bMemoryWindow); + if (bJitWindow) Parent->DoToggleWindow(IDM_JITWINDOW, bJitWindow); + if (bSoundWindow) Parent->DoToggleWindow(IDM_SOUNDWINDOW, bSoundWindow); + if (bVideoWindow) Parent->DoToggleWindow(IDM_VIDEOWINDOW, bVideoWindow); +} +void CCodeWindow::OnToggleWindow(wxCommandEvent& event) +{ + Parent->DoToggleWindow(event.GetId(), GetMenuBar()->IsChecked(event.GetId())); +} +void CCodeWindow::OnToggleRegisterWindow(bool Show, int i) +{ + if (Show) + { + if (i < 0 || i > Parent->m_NB.size()-1) return; + if (m_RegisterWindow && Parent->m_NB[i]->GetPageIndex(m_RegisterWindow) != wxNOT_FOUND) return; + if (!m_RegisterWindow) m_RegisterWindow = new CRegisterWindow(Parent); + Parent->m_NB[i]->AddPage(m_RegisterWindow, wxT("Registers"), true, Parent->aNormalFile ); + } + else // hide + Parent->DoRemovePage (m_RegisterWindow); +} + +void CCodeWindow::OnToggleBreakPointWindow(bool Show, int i) +{ + if (Show) + { + if (i < 0 || i > Parent->m_NB.size()-1) return; + if (m_BreakpointWindow && Parent->m_NB[i]->GetPageIndex(m_BreakpointWindow) != wxNOT_FOUND) return; + if (!m_BreakpointWindow) m_BreakpointWindow = new CBreakPointWindow(this, Parent); + Parent->m_NB[i]->AddPage(m_BreakpointWindow, wxT("Breakpoints"), true, Parent->aNormalFile ); + } + else // hide + Parent->DoRemovePage(m_BreakpointWindow); +} + +void CCodeWindow::OnToggleJitWindow(bool Show, int i) +{ + if (Show) + { + if (i < 0 || i > Parent->m_NB.size()-1) return; + if (m_JitWindow && Parent->m_NB[i]->GetPageIndex(m_JitWindow) != wxNOT_FOUND) return; + if (!m_JitWindow) m_JitWindow = new CJitWindow(Parent); + Parent->m_NB[i]->AddPage(m_JitWindow, wxT("JIT"), true, Parent->aNormalFile ); + } + else // hide + Parent->DoRemovePage(m_JitWindow); +} + + +void CCodeWindow::OnToggleMemoryWindow(bool Show, int i) +{ + if (Show) + { + if (i < 0 || i > Parent->m_NB.size()-1) return; + if (m_MemoryWindow && Parent->m_NB[i]->GetPageIndex(m_MemoryWindow) != wxNOT_FOUND) return; + if (!m_MemoryWindow) m_MemoryWindow = new CMemoryWindow(Parent); + Parent->m_NB[i]->AddPage(m_MemoryWindow, wxT("Memory"), true, Parent->aNormalFile ); + } + else // hide + Parent->DoRemovePage(m_MemoryWindow); +} + +//Toggle Sound Debugging Window +void CCodeWindow::OnToggleSoundWindow(bool Show, int i) +{ + //ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener(); + + if (Show) + { + if (i < 0 || i > Parent->m_NB.size()-1) return; + #ifdef _WIN32 + wxWindow *Win = GetWxWindow(wxT("Sound")); + if (Win && Parent->m_NB[i]->GetPageIndex(Win) != wxNOT_FOUND) return; + + { + #endif + //Console->Log(LogTypes::LNOTICE, StringFromFormat("OpenDebug\n").c_str()); + CPluginManager::GetInstance().OpenDebug( + Parent->GetHandle(), + //GetHandle(), + SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin.c_str(), + PLUGIN_TYPE_DSP, true // DSP, show + ); + #ifdef _WIN32 + } + + Win = GetWxWindow(wxT("Sound")); + if (Win) + { + //Console->Log(LogTypes::LNOTICE, StringFromFormat("AddPage\n").c_str()); + Parent->m_NB[i]->AddPage(Win, wxT("Sound"), true, Parent->aNormalFile ); + } + #endif + } + else // hide + { + #ifdef _WIN32 + wxWindow *Win = GetWxWindow(wxT("Sound")); + Parent->DoRemovePage (Win, false); + #endif + // Close the sound dll that has an open debugger + CPluginManager::GetInstance().OpenDebug( + GetHandle(), + SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin.c_str(), + PLUGIN_TYPE_DSP, false // DSP, hide + ); + } +} + +// Toggle Video Debugging Window +void CCodeWindow::OnToggleVideoWindow(bool Show, int i) +{ + //GetMenuBar()->Check(event.GetId(), false); // Turn off + + if (Show) + { + if (i < 0 || i > Parent->m_NB.size()-1) return; + #ifdef _WIN32 + wxWindow *Win = GetWxWindow(wxT("Video")); + if (Win && Parent->m_NB[i]->GetPageIndex(Win) != wxNOT_FOUND) return; + + { + #endif + // Show and/or create the window + CPluginManager::GetInstance().OpenDebug( + Parent->GetHandle(), + SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin.c_str(), + PLUGIN_TYPE_VIDEO, true // Video, show + ); + #ifdef _WIN32 + } + + Win = GetWxWindow(wxT("Video")); + if (Win) Parent->m_NB[i]->AddPage(Win, wxT("Video"), true, Parent->aNormalFile ); + #endif + } + else // hide + { + #ifdef _WIN32 + wxWindow *Win = GetWxWindow(wxT("Video")); + Parent->DoRemovePage (Win, false); + #endif + // Close the video dll that has an open debugger + CPluginManager::GetInstance().OpenDebug( + GetHandle(), + SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin.c_str(), + PLUGIN_TYPE_VIDEO, false // Video, hide + ); + } +} + +///////////////////////////////////////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/Source/Core/DebuggerWX/Src/CodeWindowSJP.cpp b/Source/Core/DebuggerWX/Src/CodeWindowSJP.cpp deleted file mode 100644 index f4d51a7bf6..0000000000 --- a/Source/Core/DebuggerWX/Src/CodeWindowSJP.cpp +++ /dev/null @@ -1,534 +0,0 @@ -// Copyright (C) 2003 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/ - -///////////////////////////// -// What does SJP stand for??? - -////////////////////////////////////////////////////////////////////////////////////////// -// Include -// ¯¯¯¯¯¯¯¯¯¯ -#include "Common.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -// ugly that this lib included code from the main -#include "../../DolphinWX/Src/WxUtils.h" - -#include "Host.h" - -#include "Debugger.h" -#include "DebuggerUIUtil.h" - -#include "RegisterWindow.h" -#include "BreakpointWindow.h" -#include "MemoryWindow.h" -#include "JitWindow.h" -#include "FileUtil.h" - -#include "CodeWindow.h" -#include "CodeView.h" - -#include "Core.h" -#include "HLE/HLE.h" -#include "Boot/Boot.h" -#include "LogManager.h" -#include "HW/CPU.h" -#include "PowerPC/PowerPC.h" -#include "Debugger/PPCDebugInterface.h" -#include "Debugger/Debugger_SymbolMap.h" -#include "PowerPC/PPCAnalyst.h" -#include "PowerPC/Profiler.h" -#include "PowerPC/PPCSymbolDB.h" -#include "PowerPC/SignatureDB.h" -#include "PowerPC/PPCTables.h" -#include "PowerPC/Jit64/Jit.h" -#include "PowerPC/JitCommon/JitCache.h" // for ClearCache() - -#include "PluginManager.h" -#include "ConfigManager.h" - - -extern "C" // Bitmaps -{ - #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" -} -/////////////////////////////////// - - - -void CCodeWindow::CreateSymbolsMenu() -{ - wxMenu *pSymbolsMenu = new wxMenu; - pSymbolsMenu->Append(IDM_CLEARSYMBOLS, _T("&Clear symbols")); - // pSymbolsMenu->Append(IDM_CLEANSYMBOLS, _T("&Clean symbols (zz)")); - pSymbolsMenu->Append(IDM_SCANFUNCTIONS, _T("&Generate symbol map")); - pSymbolsMenu->AppendSeparator(); - pSymbolsMenu->Append(IDM_LOADMAPFILE, _T("&Load symbol map")); - pSymbolsMenu->Append(IDM_SAVEMAPFILE, _T("&Save symbol map")); - pSymbolsMenu->AppendSeparator(); - pSymbolsMenu->Append(IDM_SAVEMAPFILEWITHCODES, _T("Save code"), - wxString::FromAscii("Save the entire disassembled code. This may take a several seconds" - " and may require between 50 and 100 MB of hard drive space. It will only save code" - " that are in the first 4 MB of memory, if you are debugging a game that load .rel" - " files with code to memory you may want to increase that to perhaps 8 MB, you can do" - " that from SymbolDB::SaveMap().") - ); - - pSymbolsMenu->AppendSeparator(); - pSymbolsMenu->Append(IDM_CREATESIGNATUREFILE, _T("&Create signature file...")); - pSymbolsMenu->Append(IDM_USESIGNATUREFILE, _T("&Use signature file...")); - pSymbolsMenu->AppendSeparator(); - pSymbolsMenu->Append(IDM_PATCHHLEFUNCTIONS, _T("&Patch HLE functions")); - pSymbolsMenu->Append(IDM_RENAME_SYMBOLS, _T("&Rename symbols from file...")); - pMenuBar->Append(pSymbolsMenu, _T("&Symbols")); - - wxMenu *pJitMenu = new wxMenu; - pJitMenu->Append(IDM_CLEARCODECACHE, _T("&Clear code cache")); - pJitMenu->Append(IDM_LOGINSTRUCTIONS, _T("&Log JIT instruction coverage")); - pJitMenu->Append(IDM_SEARCHINSTRUCTION, _T("&Search for an op")); - pMenuBar->Append(pJitMenu, _T("&JIT")); - - wxMenu *pProfilerMenu = new wxMenu; - pProfilerMenu->Append(IDM_PROFILEBLOCKS, _T("&Profile blocks"), wxEmptyString, wxITEM_CHECK); - pProfilerMenu->AppendSeparator(); - pProfilerMenu->Append(IDM_WRITEPROFILE, _T("&Write to profile.txt, show")); - pMenuBar->Append(pProfilerMenu, _T("&Profiler")); -} - - -void CCodeWindow::OnProfilerMenu(wxCommandEvent& event) -{ - if (Core::GetState() == Core::CORE_RUN) { - event.Skip(); - return; - } - switch (event.GetId()) - { - case IDM_PROFILEBLOCKS: - jit.ClearCache(); - Profiler::g_ProfileBlocks = GetMenuBar()->IsChecked(IDM_PROFILEBLOCKS); - break; - case IDM_WRITEPROFILE: - Profiler::WriteProfileResults("profiler.txt"); - WxUtils::Launch("profiler.txt"); - break; - } -} - -void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event) -{ - if (Core::GetState() == Core::CORE_UNINITIALIZED) - { - // TODO: disable menu items instead :P - return; - } - std::string mapfile = CBoot::GenerateMapFilename(); - switch (event.GetId()) - { - case IDM_CLEARSYMBOLS: - g_symbolDB.Clear(); - Host_NotifyMapLoaded(); - break; - case IDM_CLEANSYMBOLS: - g_symbolDB.Clear("zz"); - Host_NotifyMapLoaded(); - break; - case IDM_SCANFUNCTIONS: - { - PPCAnalyst::FindFunctions(0x80000000, 0x80400000, &g_symbolDB); - SignatureDB db; - if (db.Load((File::GetSysDirectory() + TOTALDB).c_str())) - db.Apply(&g_symbolDB); - - // HLE::PatchFunctions(); - NotifyMapLoaded(); - break; - } - case IDM_LOADMAPFILE: - if (!File::Exists(mapfile.c_str())) - { - g_symbolDB.Clear(); - PPCAnalyst::FindFunctions(0x81300000, 0x81800000, &g_symbolDB); - SignatureDB db; - if (db.Load((File::GetSysDirectory() + TOTALDB).c_str())) - db.Apply(&g_symbolDB); - } else { - g_symbolDB.LoadMap(mapfile.c_str()); - } - HLE::PatchFunctions(); - NotifyMapLoaded(); - break; - case IDM_SAVEMAPFILE: - g_symbolDB.SaveMap(mapfile.c_str()); - break; - case IDM_SAVEMAPFILEWITHCODES: - g_symbolDB.SaveMap(mapfile.c_str(), true); - break; - - case IDM_RENAME_SYMBOLS: - { - wxString path = wxFileSelector( - _T("Apply signature file"), wxEmptyString, wxEmptyString, wxEmptyString, - _T("Dolphin Symbole Rename File (*.sym)|*.sym;"), wxFD_OPEN | wxFD_FILE_MUST_EXIST, - this); - if (path) - { - FILE *f = fopen(path.mb_str(), "r"); - if (!f) - return; - - bool started = false; - while (!feof(f)) - { - char line[512]; - fgets(line, 511, f); - if (strlen(line) < 4) - continue; - - u32 address, type; - char name[512]; - sscanf(line, "%08x %02i %s", &address, &type, name); - - Symbol *symbol = g_symbolDB.GetSymbolFromAddr(address); - if (symbol) { - symbol->name = line+12; - } - } - fclose(f); - Host_NotifyMapLoaded(); - } - } - break; - - case IDM_CREATESIGNATUREFILE: - { - wxTextEntryDialog input_prefix(this, wxString::FromAscii("Only export symbols with prefix:"), wxGetTextFromUserPromptStr, _T(".")); - if (input_prefix.ShowModal() == wxID_OK) { - std::string prefix(input_prefix.GetValue().mb_str()); - - wxString path = wxFileSelector( - _T("Save signature as"), wxEmptyString, wxEmptyString, wxEmptyString, - _T("Dolphin Signature File (*.dsy)|*.dsy;"), wxFD_SAVE, - this); - if (path) { - SignatureDB db; - db.Initialize(&g_symbolDB, prefix.c_str()); - std::string filename(path.mb_str()); // PPCAnalyst::SaveSignatureDB( - db.Save(path.mb_str()); - } - } - } - 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.mb_str()); - db.Apply(&g_symbolDB); - } - } - NotifyMapLoaded(); - break; - case IDM_PATCHHLEFUNCTIONS: - HLE::PatchFunctions(); - Update(); - break; - } -} - - -void CCodeWindow::NotifyMapLoaded() -{ - g_symbolDB.FillInCallers(); - //symbols->Show(false); // hide it for faster filling - symbols->Freeze(); // HyperIris: wx style fast filling - symbols->Clear(); - for (PPCSymbolDB::XFuncMap::iterator iter = g_symbolDB.GetIterator(); iter != g_symbolDB.End(); iter++) - { - int idx = symbols->Append(wxString::FromAscii(iter->second.name.c_str())); - symbols->SetClientData(idx, (void*)&iter->second); - } - symbols->Thaw(); - //symbols->Show(true); - Update(); -} - - -void CCodeWindow::OnSymbolListChange(wxCommandEvent& event) -{ - int index = symbols->GetSelection(); - if (index >= 0) { - Symbol* pSymbol = static_cast(symbols->GetClientData(index)); - if (pSymbol != NULL) - { - if(pSymbol->type == Symbol::SYMBOL_DATA) - { - if(m_MemoryWindow && m_MemoryWindow->IsVisible()) - m_MemoryWindow->JumpToAddress(pSymbol->address); - } - else - { - JumpToAddress(pSymbol->address); - } - } - } -} - -void CCodeWindow::OnSymbolListContextMenu(wxContextMenuEvent& event) -{ -} - - -// Change the global DebuggerFont -void CCodeWindow::OnChangeFont(wxCommandEvent& event) -{ - wxFontData data; - data.SetInitialFont(GetFont()); - - wxFontDialog dialog(this, data); - if ( dialog.ShowModal() == wxID_OK ) - DebuggerFont = dialog.GetFontData().GetChosenFont(); -} -///////////////////////////////////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////////////////////////////////// -// Toogle windows -// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ -wxWindow * CCodeWindow::GetNootebookPage(wxString Name) -{ - if (!Parent->m_NB[0] || !Parent->m_NB[1]) return NULL; - - for(u32 i = 0; i <= Parent->m_NB[0]->GetPageCount(); i++) - { - if (Parent->m_NB[0]->GetPageText(i).IsSameAs(Name)) return Parent->m_NB[0]->GetPage(i); - } - for(u32 i = 0; i <= Parent->m_NB[1]->GetPageCount(); i++) - { - if (Parent->m_NB[1]->GetPageText(i).IsSameAs(Name)) return Parent->m_NB[1]->GetPage(i); - } - return NULL; -} -wxWindow * CCodeWindow::GetWxWindow(wxString Name) -{ - #ifdef _WIN32 - HWND hWnd = ::FindWindow(NULL, Name.c_str()); - if (hWnd) - { - wxWindow * Win = new wxWindow(); - Win->SetHWND((WXHWND)hWnd); - Win->AdoptAttributesFromHWND(); - return Win; - } - else - #endif - if (Parent->FindWindowByName(Name)) - { - return Parent->FindWindowByName(Name); - } - else if (Parent->FindWindowByLabel(Name)) - { - return Parent->FindWindowByLabel(Name); - } - else if (GetNootebookPage(Name)) - { - return GetNootebookPage(Name); - } - else - return NULL; -} -int CCodeWindow::Limit(int i, int Low, int High) -{ - if (i < Low) return Low; - if (i > High) return High; - return i; -} -void CCodeWindow::OpenPages() -{ - ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener(); - Console->Log(LogTypes::LNOTICE, StringFromFormat( - "OpenPages:%i %i\n", iRegisterWindow, iBreakpointWindow).c_str()); - - if (bRegisterWindow) Parent->DoToggleWindow(IDM_REGISTERWINDOW, bRegisterWindow); - if (bBreakpointWindow) Parent->DoToggleWindow(IDM_BREAKPOINTWINDOW, bBreakpointWindow); - if (bMemoryWindow) Parent->DoToggleWindow(IDM_MEMORYWINDOW, bMemoryWindow); - if (bJitWindow) Parent->DoToggleWindow(IDM_JITWINDOW, bJitWindow); - if (bSoundWindow) Parent->DoToggleWindow(IDM_SOUNDWINDOW, bSoundWindow); - if (bVideoWindow) Parent->DoToggleWindow(IDM_VIDEOWINDOW, bVideoWindow); -} -void CCodeWindow::OnToggleWindow(wxCommandEvent& event) -{ - Parent->DoToggleWindow(event.GetId(), GetMenuBar()->IsChecked(event.GetId())); -} -void CCodeWindow::OnToggleRegisterWindow(bool Show, int i) -{ - if (Show) - { - if (i < 0 || i > Parent->m_NB.size()-1) return; - if (m_RegisterWindow && Parent->m_NB[i]->GetPageIndex(m_RegisterWindow) != wxNOT_FOUND) return; - if (!m_RegisterWindow) m_RegisterWindow = new CRegisterWindow(Parent); - Parent->m_NB[i]->AddPage(m_RegisterWindow, wxT("Registers"), true, Parent->aNormalFile ); - } - else // hide - Parent->DoRemovePage (m_RegisterWindow); -} - -void CCodeWindow::OnToggleBreakPointWindow(bool Show, int i) -{ - if (Show) - { - if (i < 0 || i > Parent->m_NB.size()-1) return; - if (m_BreakpointWindow && Parent->m_NB[i]->GetPageIndex(m_BreakpointWindow) != wxNOT_FOUND) return; - if (!m_BreakpointWindow) m_BreakpointWindow = new CBreakPointWindow(this, Parent); - Parent->m_NB[i]->AddPage(m_BreakpointWindow, wxT("Breakpoints"), true, Parent->aNormalFile ); - } - else // hide - Parent->DoRemovePage(m_BreakpointWindow); -} - -void CCodeWindow::OnToggleJitWindow(bool Show, int i) -{ - if (Show) - { - if (i < 0 || i > Parent->m_NB.size()-1) return; - if (m_JitWindow && Parent->m_NB[i]->GetPageIndex(m_JitWindow) != wxNOT_FOUND) return; - if (!m_JitWindow) m_JitWindow = new CJitWindow(Parent); - Parent->m_NB[i]->AddPage(m_JitWindow, wxT("JIT"), true, Parent->aNormalFile ); - } - else // hide - Parent->DoRemovePage(m_JitWindow); -} - - -void CCodeWindow::OnToggleMemoryWindow(bool Show, int i) -{ - if (Show) - { - if (i < 0 || i > Parent->m_NB.size()-1) return; - if (m_MemoryWindow && Parent->m_NB[i]->GetPageIndex(m_MemoryWindow) != wxNOT_FOUND) return; - if (!m_MemoryWindow) m_MemoryWindow = new CMemoryWindow(Parent); - Parent->m_NB[i]->AddPage(m_MemoryWindow, wxT("Memory"), true, Parent->aNormalFile ); - } - else // hide - Parent->DoRemovePage(m_MemoryWindow); -} - -//Toggle Sound Debugging Window -void CCodeWindow::OnToggleSoundWindow(bool Show, int i) -{ - //ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener(); - - if (Show) - { - if (i < 0 || i > Parent->m_NB.size()-1) return; - #ifdef _WIN32 - wxWindow *Win = GetWxWindow(wxT("Sound")); - if (Win && Parent->m_NB[i]->GetPageIndex(Win) != wxNOT_FOUND) return; - - { - #endif - //Console->Log(LogTypes::LNOTICE, StringFromFormat("OpenDebug\n").c_str()); - CPluginManager::GetInstance().OpenDebug( - Parent->GetHandle(), - //GetHandle(), - SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin.c_str(), - PLUGIN_TYPE_DSP, true // DSP, show - ); - #ifdef _WIN32 - } - - Win = GetWxWindow(wxT("Sound")); - if (Win) - { - //Console->Log(LogTypes::LNOTICE, StringFromFormat("AddPage\n").c_str()); - Parent->m_NB[i]->AddPage(Win, wxT("Sound"), true, Parent->aNormalFile ); - } - #endif - } - else // hide - { - #ifdef _WIN32 - wxWindow *Win = GetWxWindow(wxT("Sound")); - Parent->DoRemovePage (Win, false); - #endif - // Close the sound dll that has an open debugger - CPluginManager::GetInstance().OpenDebug( - GetHandle(), - SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin.c_str(), - PLUGIN_TYPE_DSP, false // DSP, hide - ); - } -} - -// Toggle Video Debugging Window -void CCodeWindow::OnToggleVideoWindow(bool Show, int i) -{ - //GetMenuBar()->Check(event.GetId(), false); // Turn off - - if (Show) - { - if (i < 0 || i > Parent->m_NB.size()-1) return; - #ifdef _WIN32 - wxWindow *Win = GetWxWindow(wxT("Video")); - if (Win && Parent->m_NB[i]->GetPageIndex(Win) != wxNOT_FOUND) return; - - { - #endif - // Show and/or create the window - CPluginManager::GetInstance().OpenDebug( - Parent->GetHandle(), - SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin.c_str(), - PLUGIN_TYPE_VIDEO, true // Video, show - ); - #ifdef _WIN32 - } - - Win = GetWxWindow(wxT("Video")); - if (Win) Parent->m_NB[i]->AddPage(Win, wxT("Video"), true, Parent->aNormalFile ); - #endif - } - else // hide - { - #ifdef _WIN32 - wxWindow *Win = GetWxWindow(wxT("Video")); - Parent->DoRemovePage (Win, false); - #endif - // Close the video dll that has an open debugger - CPluginManager::GetInstance().OpenDebug( - GetHandle(), - SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin.c_str(), - PLUGIN_TYPE_VIDEO, false // Video, hide - ); - } -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/Source/Core/DebuggerWX/Src/SConscript b/Source/Core/DebuggerWX/Src/SConscript index be39b14e37..4f18760bf2 100644 --- a/Source/Core/DebuggerWX/Src/SConscript +++ b/Source/Core/DebuggerWX/Src/SConscript @@ -10,7 +10,7 @@ files = [ "BreakpointView.cpp", "BreakpointWindow.cpp", "CodeWindow.cpp", - "CodeWindowSJP.cpp", + "CodeWindowFunctions.cpp", "MemoryCheckDlg.cpp", "MemoryWindow.cpp", "RegisterWindow.cpp", -- cgit v1.2.3