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/
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>
33 #include "RegisterWindow.h"
34 #include "BreakpointWindow.h"
35 #include "MemoryWindow.h"
36 #include "JitWindow.h"
38 #include "CodeWindow.h"
43 #include "HW/Memmap.h"
45 #include "Boot/Boot.h"
46 #include "LogManager.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"
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"
77 BEGIN_EVENT_TABLE(CCodeWindow
, wxPanel
)
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
)
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
)
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
)
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
)
140 , m_RegisterWindow(NULL
)
141 , m_BreakpointWindow(NULL
)
142 , m_MemoryWindow(NULL
)
148 CreateGUIControls(_LocalCoreStartupParameter
);
151 wxTheApp
->Connect(wxID_ANY
, wxEVT_KEY_DOWN
,
152 wxKeyEventHandler(CCodeWindow::OnKeyDown
),
156 wxMenuBar
*CCodeWindow::GetMenuBar()
158 return Parent
->GetMenuBar();
161 wxAuiToolBar
*CCodeWindow::GetToolBar()
163 return Parent
->m_ToolBarDebug
;
169 void CCodeWindow::OnKeyDown(wxKeyEvent
& event
)
171 if (event
.GetKeyCode() == WXK_SPACE
&& event
.GetModifiers() == wxMOD_NONE
)
177 void CCodeWindow::OnHostMessage(wxCommandEvent
& event
)
179 switch (event
.GetId())
181 case IDM_NOTIFYMAPLOADED
:
185 case IDM_UPDATEDISASMDIALOG
:
187 if (codeview
) codeview
->Center(PC
);
188 if (m_RegisterWindow
) m_RegisterWindow
->NotifyUpdate();
191 case IDM_UPDATEBREAKPOINTS
:
193 if (m_BreakpointWindow
) m_BreakpointWindow
->NotifyUpdate();
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())
211 case IDM_TOGGLE_BREAKPOINT
:
221 PC
= codeview
->GetSelection();
230 UpdateButtonStates();
231 // Update all toolbars in the aui manager
235 void CCodeWindow::JumpToAddress(u32 _Address
)
237 codeview
->Center(_Address
);
241 void CCodeWindow::OnCodeViewChange(wxCommandEvent
&event
)
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)
258 sscanf(text
.c_str(), "%08x", &addr
);
265 void CCodeWindow::OnCallstackListChange(wxCommandEvent
& event
)
267 int index
= callstack
->GetSelection();
270 u32 address
= (u32
)(u64
)(callstack
->GetClientData(index
));
272 JumpToAddress(address
);
276 void CCodeWindow::OnCallersListChange(wxCommandEvent
& event
)
278 int index
= callers
->GetSelection();
281 u32 address
= (u32
)(u64
)(callers
->GetClientData(index
));
283 JumpToAddress(address
);
287 void CCodeWindow::OnCallsListChange(wxCommandEvent
& event
)
289 int index
= calls
->GetSelection();
292 u32 address
= (u32
)(u64
)(calls
->GetClientData(index
));
294 JumpToAddress(address
);
298 void CCodeWindow::SingleStep()
300 if (CCPU::IsStepping())
302 CCPU::StepOpcode(&sync_event
);
304 // need a short wait here
307 Host_UpdateLogDisplay();
311 void CCodeWindow::StepOver()
313 if (CCPU::IsStepping())
315 UGeckoInstruction inst
= Memory::Read_Instruction(PC
);
318 PowerPC::breakpoints
.Add(PC
+ 4, true);
319 CCPU::EnableStepping(false);
326 UpdateButtonStates();
327 // Update all toolbars in the aui manager
332 void CCodeWindow::ToggleBreakpoint()
334 if (CCPU::IsStepping())
336 if (codeview
) codeview
->ToggleBreakpoint(codeview
->GetSelection());
341 void CCodeWindow::UpdateLists()
344 u32 addr
= codeview
->GetSelection();
345 Symbol
*symbol
= g_symbolDB
.GetSymbolFromAddr(addr
);
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
);
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
);
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
);
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;
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
);
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
);
417 sizerLeft
->SetSizeHints(this);
418 sizerLeft
->Fit(this);
419 sizerBig
->SetSizeHints(this);
425 // Create CPU Mode menus
426 void CCodeWindow::CreateMenu(const SCoreStartupParameter
& _LocalCoreStartupParameter
,
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.")
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."),
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.]"),
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"),
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"));
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.]")
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
);
521 case IDM_BOOTTOPAUSE
:
522 bBootToPause
= !bBootToPause
;
524 case IDM_AUTOMATICSTART
:
525 bAutomaticStart
= !bAutomaticStart
;
528 Core::g_CoreStartupParameter
.bJITOff
= event
.IsChecked();
531 Core::g_CoreStartupParameter
.bJITLoadStoreOff
= event
.IsChecked();
533 case IDM_JITLSLXZOFF
:
534 Core::g_CoreStartupParameter
.bJITLoadStorelXzOff
= event
.IsChecked();
536 case IDM_JITLSLWZOFF
:
537 Core::g_CoreStartupParameter
.bJITLoadStorelwzOff
= event
.IsChecked();
539 case IDM_JITLSLBZXOFF
:
540 Core::g_CoreStartupParameter
.bJITLoadStorelbzxOff
= event
.IsChecked();
543 Core::g_CoreStartupParameter
.bJITLoadStoreFloatingOff
= event
.IsChecked();
546 Core::g_CoreStartupParameter
.bJITLoadStorePairedOff
= event
.IsChecked();
549 Core::g_CoreStartupParameter
.bJITFloatingPointOff
= event
.IsChecked();
552 Core::g_CoreStartupParameter
.bJITIntegerOff
= event
.IsChecked();
555 Core::g_CoreStartupParameter
.bJITPairedOff
= event
.IsChecked();
558 Core::g_CoreStartupParameter
.bJITSystemRegistersOff
= event
.IsChecked();
562 // Clear the JIT cache to enable these changes
568 UpdateButtonStates();
571 void CCodeWindow::OnJitMenu(wxCommandEvent
& event
)
573 switch (event
.GetId())
575 case IDM_LOGINSTRUCTIONS
:
576 PPCTables::LogCompiledInstructions();
579 case IDM_CLEARCODECACHE
:
583 case IDM_SEARCHINSTRUCTION
:
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
);
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
);
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("")));
663 void CCodeWindow::Update()
665 if (!codeview
) return;
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();
684 if (!ToolBar
) return;
688 ToolBar
->EnableTool(IDM_STEPOVER
, false);
689 ToolBar
->EnableTool(IDM_SKIP
, false);
695 ToolBar
->EnableTool(IDM_STEPOVER
, false);
696 ToolBar
->EnableTool(IDM_SKIP
, false);
700 ToolBar
->EnableTool(IDM_STEPOVER
, true);
701 ToolBar
->EnableTool(IDM_SKIP
, true);
705 ToolBar
->EnableTool(IDM_STEP
, Initialized
&& Stepping
);
707 if (ToolBar
) ToolBar
->Realize();
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
);
741 callstack
->SetFont(DebuggerFont
);
742 symbols
->SetFont(DebuggerFont
);
743 callers
->SetFont(DebuggerFont
);
744 calls
->SetFont(DebuggerFont
);