Windows: Link debug build against debug wiiuse. Can't keep linking to the release...
[dolphin.git] / Source / Core / DebuggerWX / Src / CodeWindow.cpp
blobe0f7678964797bd262d24e9a1de4d478d7aabd18
1 // Copyright (C) 2003 Dolphin Project.
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, version 2.0.
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU General Public License 2.0 for more details.
12 // A copy of the GPL 2.0 should have been included with the program.
13 // If not, see http://www.gnu.org/licenses/
15 // Official SVN repository and contact information can be found at
16 // http://code.google.com/p/dolphin-emu/
18 // Include
19 #include "Common.h"
21 #include <wx/button.h>
22 #include <wx/textctrl.h>
23 #include <wx/textdlg.h>
24 #include <wx/listctrl.h>
25 #include <wx/thread.h>
26 #include <wx/mstream.h>
27 #include <wx/tipwin.h>
29 #include "Host.h"
31 #include "Debugger.h"
33 #include "RegisterWindow.h"
34 #include "BreakpointWindow.h"
35 #include "MemoryWindow.h"
36 #include "JitWindow.h"
38 #include "CodeWindow.h"
39 #include "CodeView.h"
41 #include "FileUtil.h"
42 #include "Core.h"
43 #include "HW/Memmap.h"
44 #include "HLE/HLE.h"
45 #include "Boot/Boot.h"
46 #include "LogManager.h"
47 #include "HW/CPU.h"
48 #include "PowerPC/PowerPC.h"
49 #include "Debugger/PPCDebugInterface.h"
50 #include "Debugger/Debugger_SymbolMap.h"
51 #include "PowerPC/PPCAnalyst.h"
52 #include "PowerPC/Profiler.h"
53 #include "PowerPC/PPCSymbolDB.h"
54 #include "PowerPC/SignatureDB.h"
55 #include "PowerPC/PPCTables.h"
56 #include "PowerPC/JitCommon/JitBase.h"
57 #include "PowerPC/JitCommon/JitCache.h" // for ClearCache()
59 #include "PluginManager.h"
60 #include "ConfigManager.h"
62 extern "C" // Bitmaps
64 #include "../resources/toolbar_play.c"
65 #include "../resources/toolbar_pause.c"
66 #include "../resources/toolbar_add_memorycheck.c"
67 #include "../resources/toolbar_delete.c"
68 #include "../resources/toolbar_add_breakpoint.c"
71 class CPluginInfo;
72 class CPluginManager;
74 // -------
75 // Main
77 BEGIN_EVENT_TABLE(CCodeWindow, wxPanel)
79 // Menu bar
80 EVT_MENU(IDM_AUTOMATICSTART, CCodeWindow::OnCPUMode) // Options
81 EVT_MENU(IDM_BOOTTOPAUSE, CCodeWindow::OnCPUMode)
82 EVT_MENU(IDM_FONTPICKER, CCodeWindow::OnChangeFont)
84 EVT_MENU(IDM_INTERPRETER, CCodeWindow::OnCPUMode) // Jit
85 EVT_MENU(IDM_JITNOBLOCKCACHE, CCodeWindow::OnCPUMode)
87 EVT_MENU(IDM_JITOFF, CCodeWindow::OnCPUMode)
88 EVT_MENU(IDM_JITLSOFF, CCodeWindow::OnCPUMode)
89 EVT_MENU(IDM_JITLSLXZOFF, CCodeWindow::OnCPUMode)
90 EVT_MENU(IDM_JITLSLWZOFF, CCodeWindow::OnCPUMode)
91 EVT_MENU(IDM_JITLSLBZXOFF, CCodeWindow::OnCPUMode)
92 EVT_MENU(IDM_JITLSFOFF, CCodeWindow::OnCPUMode)
93 EVT_MENU(IDM_JITLSPOFF, CCodeWindow::OnCPUMode)
94 EVT_MENU(IDM_JITFPOFF, CCodeWindow::OnCPUMode)
95 EVT_MENU(IDM_JITIOFF, CCodeWindow::OnCPUMode)
96 EVT_MENU(IDM_JITPOFF, CCodeWindow::OnCPUMode)
97 EVT_MENU(IDM_JITSROFF, CCodeWindow::OnCPUMode)
99 EVT_MENU(IDM_CLEARCODECACHE, CCodeWindow::OnJitMenu)
100 EVT_MENU(IDM_LOGINSTRUCTIONS, CCodeWindow::OnJitMenu)
101 EVT_MENU(IDM_SEARCHINSTRUCTION, CCodeWindow::OnJitMenu)
103 EVT_MENU(IDM_CLEARSYMBOLS, CCodeWindow::OnSymbolsMenu)
104 EVT_MENU(IDM_LOADMAPFILE, CCodeWindow::OnSymbolsMenu)
105 EVT_MENU(IDM_SCANFUNCTIONS, CCodeWindow::OnSymbolsMenu)
106 EVT_MENU(IDM_SAVEMAPFILE, CCodeWindow::OnSymbolsMenu)
107 EVT_MENU(IDM_SAVEMAPFILEWITHCODES, CCodeWindow::OnSymbolsMenu)
108 EVT_MENU(IDM_CREATESIGNATUREFILE, CCodeWindow::OnSymbolsMenu)
109 EVT_MENU(IDM_USESIGNATUREFILE, CCodeWindow::OnSymbolsMenu)
110 EVT_MENU(IDM_PATCHHLEFUNCTIONS, CCodeWindow::OnSymbolsMenu)
111 EVT_MENU(IDM_RENAME_SYMBOLS, CCodeWindow::OnSymbolsMenu)
113 EVT_MENU(IDM_PROFILEBLOCKS, CCodeWindow::OnProfilerMenu)
114 EVT_MENU(IDM_WRITEPROFILE, CCodeWindow::OnProfilerMenu)
116 // Toolbar
117 EVT_MENU(IDM_STEP, CCodeWindow::OnCodeStep)
118 EVT_MENU(IDM_STEPOVER, CCodeWindow::OnCodeStep)
119 EVT_MENU(IDM_TOGGLE_BREAKPOINT, CCodeWindow::OnCodeStep)
120 EVT_MENU(IDM_SKIP, CCodeWindow::OnCodeStep)
121 EVT_MENU(IDM_SETPC, CCodeWindow::OnCodeStep)
122 EVT_MENU(IDM_GOTOPC, CCodeWindow::OnCodeStep)
123 EVT_TEXT(IDM_ADDRBOX, CCodeWindow::OnAddrBoxChange)
125 // Other
126 EVT_LISTBOX(ID_SYMBOLLIST, CCodeWindow::OnSymbolListChange)
127 EVT_LISTBOX(ID_CALLSTACKLIST, CCodeWindow::OnCallstackListChange)
128 EVT_LISTBOX(ID_CALLERSLIST, CCodeWindow::OnCallersListChange)
129 EVT_LISTBOX(ID_CALLSLIST, CCodeWindow::OnCallsListChange)
131 EVT_HOST_COMMAND(wxID_ANY, CCodeWindow::OnHostMessage)
133 END_EVENT_TABLE()
135 // Class
136 CCodeWindow::CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter, CFrame *parent,
137 wxWindowID id, const wxPoint& position, const wxSize& size, long style, const wxString& name)
138 : wxPanel((wxWindow*)parent, id, position, size, style, name)
139 , Parent(parent)
140 , m_RegisterWindow(NULL)
141 , m_BreakpointWindow(NULL)
142 , m_MemoryWindow(NULL)
143 , m_JitWindow(NULL)
144 , codeview(NULL)
146 InitBitmaps();
148 CreateGUIControls(_LocalCoreStartupParameter);
150 // Connect keyboard
151 wxTheApp->Connect(wxID_ANY, wxEVT_KEY_DOWN,
152 wxKeyEventHandler(CCodeWindow::OnKeyDown),
153 (wxObject*)0, this);
156 wxMenuBar *CCodeWindow::GetMenuBar()
158 return Parent->GetMenuBar();
161 wxAuiToolBar *CCodeWindow::GetToolBar()
163 return Parent->m_ToolBarDebug;
166 // ----------
167 // Events
169 void CCodeWindow::OnKeyDown(wxKeyEvent& event)
171 if (event.GetKeyCode() == WXK_SPACE && event.GetModifiers() == wxMOD_NONE)
172 SingleStep();
173 else
174 event.Skip();
177 void CCodeWindow::OnHostMessage(wxCommandEvent& event)
179 switch (event.GetId())
181 case IDM_NOTIFYMAPLOADED:
182 NotifyMapLoaded();
183 break;
185 case IDM_UPDATEDISASMDIALOG:
186 Update();
187 if (codeview) codeview->Center(PC);
188 if (m_RegisterWindow) m_RegisterWindow->NotifyUpdate();
189 break;
191 case IDM_UPDATEBREAKPOINTS:
192 Update();
193 if (m_BreakpointWindow) m_BreakpointWindow->NotifyUpdate();
194 break;
198 // The Play, Stop, Step, Skip, Go to PC and Show PC buttons go here
199 void CCodeWindow::OnCodeStep(wxCommandEvent& event)
201 switch (event.GetId())
203 case IDM_STEP:
204 SingleStep();
205 break;
207 case IDM_STEPOVER:
208 StepOver();
209 break;
211 case IDM_TOGGLE_BREAKPOINT:
212 ToggleBreakpoint();
213 break;
215 case IDM_SKIP:
216 PC += 4;
217 Update();
218 break;
220 case IDM_SETPC:
221 PC = codeview->GetSelection();
222 Update();
223 break;
225 case IDM_GOTOPC:
226 JumpToAddress(PC);
227 break;
230 UpdateButtonStates();
231 // Update all toolbars in the aui manager
232 Parent->UpdateGUI();
235 void CCodeWindow::JumpToAddress(u32 _Address)
237 codeview->Center(_Address);
238 UpdateLists();
241 void CCodeWindow::OnCodeViewChange(wxCommandEvent &event)
243 UpdateLists();
246 void CCodeWindow::OnAddrBoxChange(wxCommandEvent& event)
248 if (!GetToolBar()) return;
250 wxTextCtrl* pAddrCtrl = (wxTextCtrl*)GetToolBar()->FindControl(IDM_ADDRBOX);
251 wxString txt = pAddrCtrl->GetValue();
253 std::string text(txt.mb_str());
254 text = StripSpaces(text);
255 if (text.size() == 8)
257 u32 addr;
258 sscanf(text.c_str(), "%08x", &addr);
259 JumpToAddress(addr);
262 event.Skip(1);
265 void CCodeWindow::OnCallstackListChange(wxCommandEvent& event)
267 int index = callstack->GetSelection();
268 if (index >= 0)
270 u32 address = (u32)(u64)(callstack->GetClientData(index));
271 if (address)
272 JumpToAddress(address);
276 void CCodeWindow::OnCallersListChange(wxCommandEvent& event)
278 int index = callers->GetSelection();
279 if (index >= 0)
281 u32 address = (u32)(u64)(callers->GetClientData(index));
282 if (address)
283 JumpToAddress(address);
287 void CCodeWindow::OnCallsListChange(wxCommandEvent& event)
289 int index = calls->GetSelection();
290 if (index >= 0)
292 u32 address = (u32)(u64)(calls->GetClientData(index));
293 if (address)
294 JumpToAddress(address);
298 void CCodeWindow::SingleStep()
300 if (CCPU::IsStepping())
302 CCPU::StepOpcode(&sync_event);
303 wxThread::Sleep(20);
304 // need a short wait here
305 JumpToAddress(PC);
306 Update();
307 Host_UpdateLogDisplay();
311 void CCodeWindow::StepOver()
313 if (CCPU::IsStepping())
315 UGeckoInstruction inst = Memory::Read_Instruction(PC);
316 if (inst.LK)
318 PowerPC::breakpoints.Add(PC + 4, true);
319 CCPU::EnableStepping(false);
320 JumpToAddress(PC);
321 Update();
323 else
324 SingleStep();
326 UpdateButtonStates();
327 // Update all toolbars in the aui manager
328 Parent->UpdateGUI();
332 void CCodeWindow::ToggleBreakpoint()
334 if (CCPU::IsStepping())
336 if (codeview) codeview->ToggleBreakpoint(codeview->GetSelection());
337 Update();
341 void CCodeWindow::UpdateLists()
343 callers->Clear();
344 u32 addr = codeview->GetSelection();
345 Symbol *symbol = g_symbolDB.GetSymbolFromAddr(addr);
346 if (!symbol)
347 return;
348 for (int i = 0; i < (int)symbol->callers.size(); i++)
350 u32 caller_addr = symbol->callers[i].callAddress;
351 Symbol *caller_symbol = g_symbolDB.GetSymbolFromAddr(caller_addr);
352 if (caller_symbol)
354 int idx = callers->Append(wxString::FromAscii(StringFromFormat
355 ("< %s (%08x)", caller_symbol->name.c_str(), caller_addr).c_str()));
356 callers->SetClientData(idx, (void*)caller_addr);
360 calls->Clear();
361 for (int i = 0; i < (int)symbol->calls.size(); i++)
363 u32 call_addr = symbol->calls[i].function;
364 Symbol *call_symbol = g_symbolDB.GetSymbolFromAddr(call_addr);
365 if (call_symbol)
367 int idx = calls->Append(wxString::FromAscii(StringFromFormat
368 ("> %s (%08x)", call_symbol->name.c_str(), call_addr).c_str()));
369 calls->SetClientData(idx, (void*)call_addr);
374 void CCodeWindow::UpdateCallstack()
376 if (Core::GetState() == Core::CORE_STOPPING) return;
378 callstack->Clear();
380 std::vector<Dolphin_Debugger::CallstackEntry> stack;
382 bool ret = Dolphin_Debugger::GetCallstack(stack);
384 for (size_t i = 0; i < stack.size(); i++)
386 int idx = callstack->Append(wxString::FromAscii(stack[i].Name.c_str()));
387 callstack->SetClientData(idx, (void*)(u64)stack[i].vAddress);
390 if (!ret)
391 callstack->Append(wxString::FromAscii("invalid callstack"));
394 void CCodeWindow::CreateGUIControls(const SCoreStartupParameter& _LocalCoreStartupParameter)
396 // Configure the code window
397 wxBoxSizer* sizerBig = new wxBoxSizer(wxHORIZONTAL);
398 wxBoxSizer* sizerLeft = new wxBoxSizer(wxVERTICAL);
400 DebugInterface* di = &PowerPC::debug_interface;
402 codeview = new CCodeView(di, &g_symbolDB, this, ID_CODEVIEW);
403 sizerBig->Add(sizerLeft, 2, wxEXPAND);
404 sizerBig->Add(codeview, 5, wxEXPAND);
406 sizerLeft->Add(callstack = new wxListBox(this, ID_CALLSTACKLIST,
407 wxDefaultPosition, wxSize(90, 100)), 0, wxEXPAND);
408 sizerLeft->Add(symbols = new wxListBox(this, ID_SYMBOLLIST,
409 wxDefaultPosition, wxSize(90, 100), 0, NULL, wxLB_SORT), 1, wxEXPAND);
410 sizerLeft->Add(calls = new wxListBox(this, ID_CALLSLIST, wxDefaultPosition,
411 wxSize(90, 100), 0, NULL, wxLB_SORT), 0, wxEXPAND);
412 sizerLeft->Add(callers = new wxListBox(this, ID_CALLERSLIST, wxDefaultPosition,
413 wxSize(90, 100), 0, NULL, wxLB_SORT), 0, wxEXPAND);
415 SetSizer(sizerBig);
417 sizerLeft->SetSizeHints(this);
418 sizerLeft->Fit(this);
419 sizerBig->SetSizeHints(this);
420 sizerBig->Fit(this);
422 sync_event.Init();
425 // Create CPU Mode menus
426 void CCodeWindow::CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParameter,
427 wxMenuBar *pMenuBar)
429 // CPU Mode
430 wxMenu* pCoreMenu = new wxMenu;
432 wxMenuItem* interpreter = pCoreMenu->Append(IDM_INTERPRETER, _T("&Interpreter core")
433 , wxString::FromAscii("This is necessary to get break points"
434 " and stepping to work as explained in the Developer Documentation. But it can be very"
435 " slow, perhaps slower than 1 fps.")
436 , wxITEM_CHECK);
437 interpreter->Check(_LocalCoreStartupParameter.iCPUCore == 0);
438 pCoreMenu->AppendSeparator();
440 pCoreMenu->Append(IDM_JITBLOCKLINKING, _T("&JIT Block Linking off"),
441 _T("Provide safer execution by not linking the JIT blocks."),
442 wxITEM_CHECK);
444 pCoreMenu->Append(IDM_JITNOBLOCKCACHE, _T("&Disable JIT Cache"),
445 _T("Avoid any involuntary JIT cache clearing, this may prevent Zelda TP from crashing.")
446 _T(" [This option must be selected before a game is started.]"),
447 wxITEM_CHECK);
448 pCoreMenu->Append(IDM_CLEARCODECACHE, _T("&Clear JIT cache"));
450 pCoreMenu->AppendSeparator();
451 pCoreMenu->Append(IDM_LOGINSTRUCTIONS, _T("&Log JIT instruction coverage"));
452 pCoreMenu->Append(IDM_SEARCHINSTRUCTION, _T("&Search for an op"));
454 pCoreMenu->AppendSeparator();
455 pCoreMenu->Append(IDM_JITOFF, _T("&JIT off (JIT core)"),
456 _T("Turn off all JIT functions, but still use the JIT core from Jit.cpp"),
457 wxITEM_CHECK);
458 pCoreMenu->Append(IDM_JITLSOFF, _T("&JIT LoadStore off"),
459 wxEmptyString, wxITEM_CHECK);
460 pCoreMenu->Append(IDM_JITLSLBZXOFF, _T(" &JIT LoadStore lbzx off"),
461 wxEmptyString, wxITEM_CHECK);
462 pCoreMenu->Append(IDM_JITLSLXZOFF, _T(" &JIT LoadStore lXz off"),
463 wxEmptyString, wxITEM_CHECK);
464 pCoreMenu->Append(IDM_JITLSLWZOFF, _T(" &JIT LoadStore lwz off"),
465 wxEmptyString, wxITEM_CHECK);
466 pCoreMenu->Append(IDM_JITLSFOFF, _T("&JIT LoadStore Floating off"),
467 wxEmptyString, wxITEM_CHECK);
468 pCoreMenu->Append(IDM_JITLSPOFF, _T("&JIT LoadStore Paired off"),
469 wxEmptyString, wxITEM_CHECK);
470 pCoreMenu->Append(IDM_JITFPOFF, _T("&JIT FloatingPoint off"),
471 wxEmptyString, wxITEM_CHECK);
472 pCoreMenu->Append(IDM_JITIOFF, _T("&JIT Integer off"),
473 wxEmptyString, wxITEM_CHECK);
474 pCoreMenu->Append(IDM_JITPOFF, _T("&JIT Paired off"),
475 wxEmptyString, wxITEM_CHECK);
476 pCoreMenu->Append(IDM_JITSROFF, _T("&JIT SystemRegisters off"),
477 wxEmptyString, wxITEM_CHECK);
479 pMenuBar->Append(pCoreMenu, _T("&JIT"));
482 // Debug Menu
483 wxMenu* pDebugMenu = new wxMenu;
485 pDebugMenu->Append(IDM_STEP, _T("Step &Into\tF11"));
486 pDebugMenu->Append(IDM_STEPOVER, _T("Step &Over\tF10"));
487 pDebugMenu->Append(IDM_TOGGLE_BREAKPOINT, _T("Toggle &Breakpoint\tF9"));
489 pMenuBar->Append(pDebugMenu, _T("&Debug"));
491 CreateMenuSymbols(pMenuBar);
494 void CCodeWindow::CreateMenuOptions(wxMenu* pMenu)
496 wxMenuItem* boottopause = pMenu->Append(IDM_BOOTTOPAUSE, _T("Boot to pause"),
497 wxT("Start the game directly instead of booting to pause"), wxITEM_CHECK);
498 boottopause->Check(bBootToPause);
500 wxMenuItem* automaticstart = pMenu->Append(IDM_AUTOMATICSTART, _T("&Automatic start")
501 , wxString::FromAscii(
502 "Automatically load the Default ISO when Dolphin starts, or the last game you loaded,"
503 " if you have not given it an elf file with the --elf command line. [This can be"
504 " convenient if you are bug-testing with a certain game and want to rebuild"
505 " and retry it several times, either with changes to Dolphin or if you are"
506 " developing a homebrew game.]")
507 , wxITEM_CHECK);
508 automaticstart->Check(bAutomaticStart);
510 pMenu->Append(IDM_FONTPICKER, _T("&Font..."), wxEmptyString, wxITEM_NORMAL);
513 // CPU Mode and JIT Menu
514 void CCodeWindow::OnCPUMode(wxCommandEvent& event)
516 switch (event.GetId())
518 case IDM_INTERPRETER:
519 PowerPC::SetMode(UseInterpreter() ? PowerPC::MODE_INTERPRETER : PowerPC::MODE_JIT);
520 break;
521 case IDM_BOOTTOPAUSE:
522 bBootToPause = !bBootToPause;
523 return;
524 case IDM_AUTOMATICSTART:
525 bAutomaticStart = !bAutomaticStart;
526 return;
527 case IDM_JITOFF:
528 Core::g_CoreStartupParameter.bJITOff = event.IsChecked();
529 break;
530 case IDM_JITLSOFF:
531 Core::g_CoreStartupParameter.bJITLoadStoreOff = event.IsChecked();
532 break;
533 case IDM_JITLSLXZOFF:
534 Core::g_CoreStartupParameter.bJITLoadStorelXzOff = event.IsChecked();
535 break;
536 case IDM_JITLSLWZOFF:
537 Core::g_CoreStartupParameter.bJITLoadStorelwzOff = event.IsChecked();
538 break;
539 case IDM_JITLSLBZXOFF:
540 Core::g_CoreStartupParameter.bJITLoadStorelbzxOff = event.IsChecked();
541 break;
542 case IDM_JITLSFOFF:
543 Core::g_CoreStartupParameter.bJITLoadStoreFloatingOff = event.IsChecked();
544 break;
545 case IDM_JITLSPOFF:
546 Core::g_CoreStartupParameter.bJITLoadStorePairedOff = event.IsChecked();
547 break;
548 case IDM_JITFPOFF:
549 Core::g_CoreStartupParameter.bJITFloatingPointOff = event.IsChecked();
550 break;
551 case IDM_JITIOFF:
552 Core::g_CoreStartupParameter.bJITIntegerOff = event.IsChecked();
553 break;
554 case IDM_JITPOFF:
555 Core::g_CoreStartupParameter.bJITPairedOff = event.IsChecked();
556 break;
557 case IDM_JITSROFF:
558 Core::g_CoreStartupParameter.bJITSystemRegistersOff = event.IsChecked();
559 break;
562 // Clear the JIT cache to enable these changes
563 if (jit)
565 jit->ClearCache();
567 // Update
568 UpdateButtonStates();
571 void CCodeWindow::OnJitMenu(wxCommandEvent& event)
573 switch (event.GetId())
575 case IDM_LOGINSTRUCTIONS:
576 PPCTables::LogCompiledInstructions();
577 break;
579 case IDM_CLEARCODECACHE:
580 jit->ClearCache();
581 break;
583 case IDM_SEARCHINSTRUCTION:
585 wxString str;
586 str = wxGetTextFromUser(_(""), wxT("Op?"), wxEmptyString, this);
587 for (u32 addr = 0x80000000; addr < 0x80100000; addr += 4)
589 const char *name = PPCTables::GetInstructionName(Memory::ReadUnchecked_U32(addr));
590 if (name && !strcmp((const char *)str.mb_str(), name))
592 std::string mb_str(str.mb_str());
593 NOTICE_LOG(POWERPC, "Found %s at %08x", mb_str.c_str(), addr);
596 break;
601 // Shortcuts
602 bool CCodeWindow::UseInterpreter()
604 return GetMenuBar()->IsChecked(IDM_INTERPRETER);
607 bool CCodeWindow::BootToPause()
609 return GetMenuBar()->IsChecked(IDM_BOOTTOPAUSE);
612 bool CCodeWindow::AutomaticStart()
614 return GetMenuBar()->IsChecked(IDM_AUTOMATICSTART);
617 bool CCodeWindow::JITNoBlockCache()
619 return GetMenuBar()->IsChecked(IDM_JITNOBLOCKCACHE);
622 bool CCodeWindow::JITBlockLinking()
624 return GetMenuBar()->IsChecked(IDM_JITBLOCKLINKING);
627 // Toolbar
628 void CCodeWindow::InitBitmaps()
630 // load original size 48x48
631 m_Bitmaps[Toolbar_DebugGo] = wxGetBitmapFromMemory(toolbar_play_png);
632 m_Bitmaps[Toolbar_Step] = wxGetBitmapFromMemory(toolbar_add_breakpoint_png);
633 m_Bitmaps[Toolbar_StepOver] = wxGetBitmapFromMemory(toolbar_add_memcheck_png);
634 m_Bitmaps[Toolbar_Skip] = wxGetBitmapFromMemory(toolbar_add_memcheck_png);
635 m_Bitmaps[Toolbar_GotoPC] = wxGetBitmapFromMemory(toolbar_add_memcheck_png);
636 m_Bitmaps[Toolbar_SetPC] = wxGetBitmapFromMemory(toolbar_add_memcheck_png);
637 m_Bitmaps[Toolbar_DebugPause] = wxGetBitmapFromMemory(toolbar_pause_png);
639 // scale to 24x24 for toolbar
640 for (size_t n = Toolbar_DebugGo; n < ToolbarDebugBitmapMax; n++)
641 m_Bitmaps[n] = wxBitmap(m_Bitmaps[n].ConvertToImage().Scale(24, 24));
644 void CCodeWindow::PopulateToolbar(wxAuiToolBar* toolBar)
646 int w = m_Bitmaps[Toolbar_DebugGo].GetWidth(),
647 h = m_Bitmaps[Toolbar_DebugGo].GetHeight();
649 toolBar->SetToolBitmapSize(wxSize(w, h));
650 toolBar->AddTool(IDM_STEP, _T("Step"), m_Bitmaps[Toolbar_Step]);
651 toolBar->AddTool(IDM_STEPOVER, _T("Step Over"), m_Bitmaps[Toolbar_StepOver]);
652 toolBar->AddTool(IDM_SKIP, _T("Skip"), m_Bitmaps[Toolbar_Skip]);
653 toolBar->AddSeparator();
654 toolBar->AddTool(IDM_GOTOPC, _T("Show PC"), m_Bitmaps[Toolbar_GotoPC]);
655 toolBar->AddTool(IDM_SETPC, _T("Set PC"), m_Bitmaps[Toolbar_SetPC]);
656 toolBar->AddSeparator();
657 toolBar->AddControl(new wxTextCtrl(toolBar, IDM_ADDRBOX, _T("")));
659 toolBar->Realize();
662 // Update GUI
663 void CCodeWindow::Update()
665 if (!codeview) return;
667 codeview->Refresh();
668 UpdateCallstack();
669 UpdateButtonStates();
671 // Do not automatically show the current PC position when a breakpoint is hit or
672 // when we pause since this can be called at other times too.
673 //codeview->Center(PC);
676 void CCodeWindow::UpdateButtonStates()
678 bool Initialized = (Core::GetState() != Core::CORE_UNINITIALIZED);
679 bool Pause = (Core::GetState() == Core::CORE_PAUSE);
680 bool Stepping = CCPU::IsStepping();
681 wxAuiToolBar* ToolBar = GetToolBar();
683 // Toolbar
684 if (!ToolBar) return;
686 if (!Initialized)
688 ToolBar->EnableTool(IDM_STEPOVER, false);
689 ToolBar->EnableTool(IDM_SKIP, false);
691 else
693 if (!Stepping)
695 ToolBar->EnableTool(IDM_STEPOVER, false);
696 ToolBar->EnableTool(IDM_SKIP, false);
698 else
700 ToolBar->EnableTool(IDM_STEPOVER, true);
701 ToolBar->EnableTool(IDM_SKIP, true);
705 ToolBar->EnableTool(IDM_STEP, Initialized && Stepping);
707 if (ToolBar) ToolBar->Realize();
709 // Menu bar
710 // ------------------
711 GetMenuBar()->Enable(IDM_INTERPRETER, Pause); // CPU Mode
713 GetMenuBar()->Enable(IDM_JITNOBLOCKCACHE, !Initialized);
715 GetMenuBar()->Enable(IDM_JITOFF, Pause);
716 GetMenuBar()->Enable(IDM_JITLSOFF, Pause);
717 GetMenuBar()->Enable(IDM_JITLSLXZOFF, Pause);
718 GetMenuBar()->Enable(IDM_JITLSLWZOFF, Pause);
719 GetMenuBar()->Enable(IDM_JITLSLBZXOFF, Pause);
720 GetMenuBar()->Enable(IDM_JITLSFOFF, Pause);
721 GetMenuBar()->Enable(IDM_JITLSPOFF, Pause);
722 GetMenuBar()->Enable(IDM_JITFPOFF, Pause);
723 GetMenuBar()->Enable(IDM_JITIOFF, Pause);
724 GetMenuBar()->Enable(IDM_JITPOFF, Pause);
725 GetMenuBar()->Enable(IDM_JITSROFF, Pause);
727 GetMenuBar()->Enable(IDM_CLEARCODECACHE, Pause); // JIT Menu
728 GetMenuBar()->Enable(IDM_SEARCHINSTRUCTION, Initialized);
730 GetMenuBar()->Enable(IDM_CLEARSYMBOLS, Initialized); // Symbols menu
731 GetMenuBar()->Enable(IDM_SCANFUNCTIONS, Initialized);
732 GetMenuBar()->Enable(IDM_LOADMAPFILE, Initialized);
733 GetMenuBar()->Enable(IDM_SAVEMAPFILE, Initialized);
734 GetMenuBar()->Enable(IDM_SAVEMAPFILEWITHCODES, Initialized);
735 GetMenuBar()->Enable(IDM_CREATESIGNATUREFILE, Initialized);
736 GetMenuBar()->Enable(IDM_RENAME_SYMBOLS, Initialized);
737 GetMenuBar()->Enable(IDM_USESIGNATUREFILE, Initialized);
738 GetMenuBar()->Enable(IDM_PATCHHLEFUNCTIONS, Initialized);
740 // Update Fonts
741 callstack->SetFont(DebuggerFont);
742 symbols->SetFont(DebuggerFont);
743 callers->SetFont(DebuggerFont);
744 calls->SetFont(DebuggerFont);