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_REGISTERWINDOW
, CCodeWindow::OnToggleWindow
) // View
104 EVT_MENU(IDM_BREAKPOINTWINDOW
, CCodeWindow::OnToggleWindow
)
105 EVT_MENU(IDM_MEMORYWINDOW
, CCodeWindow::OnToggleWindow
)
106 EVT_MENU(IDM_JITWINDOW
, CCodeWindow::OnToggleWindow
)
107 EVT_MENU(IDM_SOUNDWINDOW
, CCodeWindow::OnToggleWindow
)
108 EVT_MENU(IDM_VIDEOWINDOW
, CCodeWindow::OnToggleWindow
)
110 EVT_MENU(IDM_CLEARSYMBOLS
, CCodeWindow::OnSymbolsMenu
)
111 EVT_MENU(IDM_LOADMAPFILE
, CCodeWindow::OnSymbolsMenu
)
112 EVT_MENU(IDM_SCANFUNCTIONS
, CCodeWindow::OnSymbolsMenu
)
113 EVT_MENU(IDM_SAVEMAPFILE
, CCodeWindow::OnSymbolsMenu
)
114 EVT_MENU(IDM_SAVEMAPFILEWITHCODES
, CCodeWindow::OnSymbolsMenu
)
115 EVT_MENU(IDM_CREATESIGNATUREFILE
, CCodeWindow::OnSymbolsMenu
)
116 EVT_MENU(IDM_USESIGNATUREFILE
, CCodeWindow::OnSymbolsMenu
)
117 EVT_MENU(IDM_PATCHHLEFUNCTIONS
, CCodeWindow::OnSymbolsMenu
)
118 EVT_MENU(IDM_RENAME_SYMBOLS
, CCodeWindow::OnSymbolsMenu
)
120 EVT_MENU(IDM_PROFILEBLOCKS
, CCodeWindow::OnProfilerMenu
)
121 EVT_MENU(IDM_WRITEPROFILE
, CCodeWindow::OnProfilerMenu
)
124 EVT_MENU(IDM_STEP
, CCodeWindow::OnCodeStep
)
125 EVT_MENU(IDM_STEPOVER
, CCodeWindow::OnCodeStep
)
126 EVT_MENU(IDM_SKIP
, CCodeWindow::OnCodeStep
)
127 EVT_MENU(IDM_SETPC
, CCodeWindow::OnCodeStep
)
128 EVT_MENU(IDM_GOTOPC
, CCodeWindow::OnCodeStep
)
129 EVT_TEXT(IDM_ADDRBOX
, CCodeWindow::OnAddrBoxChange
)
132 EVT_LISTBOX(ID_SYMBOLLIST
, CCodeWindow::OnSymbolListChange
)
133 EVT_LISTBOX(ID_CALLSTACKLIST
, CCodeWindow::OnCallstackListChange
)
134 EVT_LISTBOX(ID_CALLERSLIST
, CCodeWindow::OnCallersListChange
)
135 EVT_LISTBOX(ID_CALLSLIST
, CCodeWindow::OnCallsListChange
)
137 EVT_HOST_COMMAND(wxID_ANY
, CCodeWindow::OnHostMessage
)
142 CCodeWindow::CCodeWindow(const SCoreStartupParameter
& _LocalCoreStartupParameter
, CFrame
*parent
,
143 wxWindowID id
, const wxPoint
& position
, const wxSize
& size
, long style
, const wxString
& name
)
144 : wxPanel((wxWindow
*)parent
, id
, position
, size
, style
, name
)
146 , m_RegisterWindow(NULL
)
147 , m_BreakpointWindow(NULL
)
148 , m_MemoryWindow(NULL
)
154 CreateGUIControls(_LocalCoreStartupParameter
);
157 wxTheApp
->Connect(wxID_ANY
, wxEVT_KEY_DOWN
,
158 wxKeyEventHandler(CCodeWindow::OnKeyDown
),
162 wxMenuBar
*CCodeWindow::GetMenuBar()
164 return Parent
->GetMenuBar();
167 wxAuiToolBar
*CCodeWindow::GetToolBar()
169 return Parent
->m_ToolBarDebug
;
175 void CCodeWindow::OnKeyDown(wxKeyEvent
& event
)
179 if ((event
.GetKeyCode() == WXK_SPACE
) && Parent
->IsActive()) SingleCPUStep();
182 void CCodeWindow::OnHostMessage(wxCommandEvent
& event
)
184 switch (event
.GetId())
186 case IDM_NOTIFYMAPLOADED
:
190 case IDM_UPDATEDISASMDIALOG
:
192 if (codeview
) codeview
->Center(PC
);
193 if (m_RegisterWindow
) m_RegisterWindow
->NotifyUpdate();
196 case IDM_UPDATEBREAKPOINTS
:
198 if (m_BreakpointWindow
) m_BreakpointWindow
->NotifyUpdate();
203 // The Play, Stop, Step, Skip, Go to PC and Show PC buttons go here
204 void CCodeWindow::OnCodeStep(wxCommandEvent
& event
)
206 switch (event
.GetId())
213 CCPU::EnableStepping(true); // TODO: Huh?
222 PC
= codeview
->GetSelection();
231 UpdateButtonStates();
232 // Update all toolbars in the aui manager
236 void CCodeWindow::JumpToAddress(u32 _Address
)
238 codeview
->Center(_Address
);
242 void CCodeWindow::OnCodeViewChange(wxCommandEvent
&event
)
247 void CCodeWindow::OnAddrBoxChange(wxCommandEvent
& event
)
249 if (!GetToolBar()) return;
251 wxTextCtrl
* pAddrCtrl
= (wxTextCtrl
*)GetToolBar()->FindControl(IDM_ADDRBOX
);
252 wxString txt
= pAddrCtrl
->GetValue();
254 std::string
text(txt
.mb_str());
255 text
= StripSpaces(text
);
256 if (text
.size() == 8)
259 sscanf(text
.c_str(), "%08x", &addr
);
266 void CCodeWindow::OnCallstackListChange(wxCommandEvent
& event
)
268 int index
= callstack
->GetSelection();
271 u32 address
= (u32
)(u64
)(callstack
->GetClientData(index
));
273 JumpToAddress(address
);
277 void CCodeWindow::OnCallersListChange(wxCommandEvent
& event
)
279 int index
= callers
->GetSelection();
282 u32 address
= (u32
)(u64
)(callers
->GetClientData(index
));
284 JumpToAddress(address
);
288 void CCodeWindow::OnCallsListChange(wxCommandEvent
& event
)
290 int index
= calls
->GetSelection();
293 u32 address
= (u32
)(u64
)(calls
->GetClientData(index
));
295 JumpToAddress(address
);
299 void CCodeWindow::SingleCPUStep()
301 CCPU::StepOpcode(&sync_event
);
303 // need a short wait here
306 Host_UpdateLogDisplay();
309 void CCodeWindow::UpdateLists()
312 u32 addr
= codeview
->GetSelection();
313 Symbol
*symbol
= g_symbolDB
.GetSymbolFromAddr(addr
);
316 for (int i
= 0; i
< (int)symbol
->callers
.size(); i
++)
318 u32 caller_addr
= symbol
->callers
[i
].callAddress
;
319 Symbol
*caller_symbol
= g_symbolDB
.GetSymbolFromAddr(caller_addr
);
322 int idx
= callers
->Append(wxString::FromAscii(StringFromFormat
323 ("< %s (%08x)", caller_symbol
->name
.c_str(), caller_addr
).c_str()));
324 callers
->SetClientData(idx
, (void*)caller_addr
);
329 for (int i
= 0; i
< (int)symbol
->calls
.size(); i
++)
331 u32 call_addr
= symbol
->calls
[i
].function
;
332 Symbol
*call_symbol
= g_symbolDB
.GetSymbolFromAddr(call_addr
);
335 int idx
= calls
->Append(wxString::FromAscii(StringFromFormat
336 ("> %s (%08x)", call_symbol
->name
.c_str(), call_addr
).c_str()));
337 calls
->SetClientData(idx
, (void*)call_addr
);
342 void CCodeWindow::UpdateCallstack()
344 if (Core::GetState() == Core::CORE_STOPPING
) return;
348 std::vector
<Dolphin_Debugger::CallstackEntry
> stack
;
350 bool ret
= Dolphin_Debugger::GetCallstack(stack
);
352 for (size_t i
= 0; i
< stack
.size(); i
++)
354 int idx
= callstack
->Append(wxString::FromAscii(stack
[i
].Name
.c_str()));
355 callstack
->SetClientData(idx
, (void*)(u64
)stack
[i
].vAddress
);
359 callstack
->Append(wxString::FromAscii("invalid callstack"));
362 void CCodeWindow::CreateGUIControls(const SCoreStartupParameter
& _LocalCoreStartupParameter
)
364 // Configure the code window
365 wxBoxSizer
* sizerBig
= new wxBoxSizer(wxHORIZONTAL
);
366 wxBoxSizer
* sizerLeft
= new wxBoxSizer(wxVERTICAL
);
368 DebugInterface
* di
= &PowerPC::debug_interface
;
370 codeview
= new CCodeView(di
, &g_symbolDB
, this, ID_CODEVIEW
);
371 sizerBig
->Add(sizerLeft
, 2, wxEXPAND
);
372 sizerBig
->Add(codeview
, 5, wxEXPAND
);
374 sizerLeft
->Add(callstack
= new wxListBox(this, ID_CALLSTACKLIST
,
375 wxDefaultPosition
, wxSize(90, 100)), 0, wxEXPAND
);
376 sizerLeft
->Add(symbols
= new wxListBox(this, ID_SYMBOLLIST
,
377 wxDefaultPosition
, wxSize(90, 100), 0, NULL
, wxLB_SORT
), 1, wxEXPAND
);
378 sizerLeft
->Add(calls
= new wxListBox(this, ID_CALLSLIST
, wxDefaultPosition
,
379 wxSize(90, 100), 0, NULL
, wxLB_SORT
), 0, wxEXPAND
);
380 sizerLeft
->Add(callers
= new wxListBox(this, ID_CALLERSLIST
, wxDefaultPosition
,
381 wxSize(90, 100), 0, NULL
, wxLB_SORT
), 0, wxEXPAND
);
385 sizerLeft
->SetSizeHints(this);
386 sizerLeft
->Fit(this);
387 sizerBig
->SetSizeHints(this);
393 // Create CPU Mode menus
394 void CCodeWindow::CreateMenu(const SCoreStartupParameter
& _LocalCoreStartupParameter
,
395 wxMenuBar
* _pMenuBar
)
397 pMenuBar
= _pMenuBar
;
400 wxMenu
* pCoreMenu
= new wxMenu
;
402 wxMenuItem
* interpreter
= pCoreMenu
->Append(IDM_INTERPRETER
, _T("&Interpreter core")
403 , wxString::FromAscii("This is necessary to get break points"
404 " and stepping to work as explained in the Developer Documentation. But it can be very"
405 " slow, perhaps slower than 1 fps.")
407 interpreter
->Check(_LocalCoreStartupParameter
.iCPUCore
== 0);
408 pCoreMenu
->AppendSeparator();
410 jitblocklinking
= pCoreMenu
->Append(IDM_JITBLOCKLINKING
, _T("&JIT Block Linking off"),
411 _T("Provide safer execution by not linking the JIT blocks."),
414 jitnoblockcache
= pCoreMenu
->Append(IDM_JITNOBLOCKCACHE
, _T("&Disable JIT Cache"),
415 _T("Avoid any involuntary JIT cache clearing, this may prevent Zelda TP from crashing.")
416 _T(" [This option must be selected before a game is started.]"),
418 pCoreMenu
->Append(IDM_CLEARCODECACHE
, _T("&Clear JIT cache"));
420 pCoreMenu
->AppendSeparator();
421 pCoreMenu
->Append(IDM_LOGINSTRUCTIONS
, _T("&Log JIT instruction coverage"));
422 pCoreMenu
->Append(IDM_SEARCHINSTRUCTION
, _T("&Search for an op"));
424 pCoreMenu
->AppendSeparator();
425 jitoff
= pCoreMenu
->Append(IDM_JITOFF
, _T("&JIT off (JIT core)"),
426 _T("Turn off all JIT functions, but still use the JIT core from Jit.cpp"),
428 jitlsoff
= pCoreMenu
->Append(IDM_JITLSOFF
, _T("&JIT LoadStore off"),
429 wxEmptyString
, wxITEM_CHECK
);
430 jitlslbzxoff
= pCoreMenu
->Append(IDM_JITLSLBZXOFF
, _T(" &JIT LoadStore lbzx off"),
431 wxEmptyString
, wxITEM_CHECK
);
432 jitlslxzoff
= pCoreMenu
->Append(IDM_JITLSLXZOFF
, _T(" &JIT LoadStore lXz off"),
433 wxEmptyString
, wxITEM_CHECK
);
434 jitlslwzoff
= pCoreMenu
->Append(IDM_JITLSLWZOFF
, _T(" &JIT LoadStore lwz off"),
435 wxEmptyString
, wxITEM_CHECK
);
436 jitlspoff
= pCoreMenu
->Append(IDM_JITLSFOFF
, _T("&JIT LoadStore Floating off"),
437 wxEmptyString
, wxITEM_CHECK
);
438 jitlsfoff
= pCoreMenu
->Append(IDM_JITLSPOFF
, _T("&JIT LoadStore Paired off"),
439 wxEmptyString
, wxITEM_CHECK
);
440 jitfpoff
= pCoreMenu
->Append(IDM_JITFPOFF
, _T("&JIT FloatingPoint off"),
441 wxEmptyString
, wxITEM_CHECK
);
442 jitioff
= pCoreMenu
->Append(IDM_JITIOFF
, _T("&JIT Integer off"),
443 wxEmptyString
, wxITEM_CHECK
);
444 jitpoff
= pCoreMenu
->Append(IDM_JITPOFF
, _T("&JIT Paired off"),
445 wxEmptyString
, wxITEM_CHECK
);
446 jitsroff
= pCoreMenu
->Append(IDM_JITSROFF
, _T("&JIT SystemRegisters off"),
447 wxEmptyString
, wxITEM_CHECK
);
449 pMenuBar
->Append(pCoreMenu
, _T("&JIT"));
455 void CCodeWindow::CreateMenuView(wxMenuBar
* _pMenuBar
, wxMenu
* _pMenu
)
457 wxMenuItem
* pRegister
= _pMenu
->Append(IDM_REGISTERWINDOW
, _T("&Registers"),
458 wxEmptyString
, wxITEM_CHECK
);
459 pRegister
->Check(bRegisterWindow
);
460 wxMenuItem
* pBreakPoints
= _pMenu
->Append(IDM_BREAKPOINTWINDOW
, _T("&BreakPoints"),
461 wxEmptyString
, wxITEM_CHECK
);
462 pBreakPoints
->Check(bBreakpointWindow
);
463 wxMenuItem
* pMemory
= _pMenu
->Append(IDM_MEMORYWINDOW
, _T("&Memory"),
464 wxEmptyString
, wxITEM_CHECK
);
465 pMemory
->Check(bMemoryWindow
);
466 wxMenuItem
* pJit
= _pMenu
->Append(IDM_JITWINDOW
, _T("&Jit"),
467 wxEmptyString
, wxITEM_CHECK
);
468 pJit
->Check(bJitWindow
);
469 wxMenuItem
* pSound
= _pMenu
->Append(IDM_SOUNDWINDOW
, _T("&Sound"),
470 wxEmptyString
, wxITEM_CHECK
);
471 pSound
->Check(bSoundWindow
);
472 wxMenuItem
* pVideo
= _pMenu
->Append(IDM_VIDEOWINDOW
, _T("&Video"),
473 wxEmptyString
, wxITEM_CHECK
);
474 pVideo
->Check(bVideoWindow
);
477 void CCodeWindow::CreateMenuOptions(wxMenuBar
* _pMenuBar
, wxMenu
* _pMenu
)
479 wxMenuItem
* boottopause
= _pMenu
->Append(IDM_BOOTTOPAUSE
, _T("Boot to pause"),
480 wxT("Start the game directly instead of booting to pause"), wxITEM_CHECK
);
481 boottopause
->Check(bBootToPause
);
483 wxMenuItem
* automaticstart
= _pMenu
->Append(IDM_AUTOMATICSTART
, _T("&Automatic start")
484 , wxString::FromAscii(
485 "Automatically load the Default ISO when Dolphin starts, or the last game you loaded,"
486 " if you have not given it an elf file with the --elf command line. [This can be"
487 " convenient if you are bug-testing with a certain game and want to rebuild"
488 " and retry it several times, either with changes to Dolphin or if you are"
489 " developing a homebrew game.]")
491 automaticstart
->Check(bAutomaticStart
);
493 _pMenu
->Append(IDM_FONTPICKER
, _T("&Font..."), wxEmptyString
, wxITEM_NORMAL
);
496 // CPU Mode and JIT Menu
497 void CCodeWindow::OnCPUMode(wxCommandEvent
& event
)
499 switch (event
.GetId())
501 case IDM_INTERPRETER
:
502 PowerPC::SetMode(UseInterpreter() ? PowerPC::MODE_INTERPRETER
: PowerPC::MODE_JIT
);
504 case IDM_BOOTTOPAUSE
:
505 bBootToPause
= !bBootToPause
;
507 case IDM_AUTOMATICSTART
:
508 bAutomaticStart
= !bAutomaticStart
;
511 Core::g_CoreStartupParameter
.bJITOff
= event
.IsChecked();
514 Core::g_CoreStartupParameter
.bJITLoadStoreOff
= event
.IsChecked();
516 case IDM_JITLSLXZOFF
:
517 Core::g_CoreStartupParameter
.bJITLoadStorelXzOff
= event
.IsChecked();
519 case IDM_JITLSLWZOFF
:
520 Core::g_CoreStartupParameter
.bJITLoadStorelwzOff
= event
.IsChecked();
522 case IDM_JITLSLBZXOFF
:
523 Core::g_CoreStartupParameter
.bJITLoadStorelbzxOff
= event
.IsChecked();
526 Core::g_CoreStartupParameter
.bJITLoadStoreFloatingOff
= event
.IsChecked();
529 Core::g_CoreStartupParameter
.bJITLoadStorePairedOff
= event
.IsChecked();
532 Core::g_CoreStartupParameter
.bJITFloatingPointOff
= event
.IsChecked();
535 Core::g_CoreStartupParameter
.bJITIntegerOff
= event
.IsChecked();
538 Core::g_CoreStartupParameter
.bJITPairedOff
= event
.IsChecked();
541 Core::g_CoreStartupParameter
.bJITSystemRegistersOff
= event
.IsChecked();
545 // Clear the JIT cache to enable these changes
548 UpdateButtonStates();
551 void CCodeWindow::OnJitMenu(wxCommandEvent
& event
)
553 switch (event
.GetId())
555 case IDM_LOGINSTRUCTIONS
:
556 PPCTables::LogCompiledInstructions();
559 case IDM_CLEARCODECACHE
:
563 case IDM_SEARCHINSTRUCTION
:
566 str
= wxGetTextFromUser(_(""), wxT("Op?"), wxEmptyString
, this);
567 for (u32 addr
= 0x80000000; addr
< 0x80100000; addr
+= 4)
569 const char *name
= PPCTables::GetInstructionName(Memory::ReadUnchecked_U32(addr
));
570 if (name
&& !strcmp((const char *)str
.mb_str(), name
))
572 std::string
mb_str(str
.mb_str());
573 NOTICE_LOG(POWERPC
, "Found %s at %08x", mb_str
.c_str(), addr
);
582 bool CCodeWindow::UseInterpreter()
584 return GetMenuBar()->IsChecked(IDM_INTERPRETER
);
587 bool CCodeWindow::BootToPause()
589 return GetMenuBar()->IsChecked(IDM_BOOTTOPAUSE
);
592 bool CCodeWindow::AutomaticStart()
594 return GetMenuBar()->IsChecked(IDM_AUTOMATICSTART
);
597 bool CCodeWindow::JITNoBlockCache()
599 return GetMenuBar()->IsChecked(IDM_JITNOBLOCKCACHE
);
602 bool CCodeWindow::JITBlockLinking()
604 return GetMenuBar()->IsChecked(IDM_JITBLOCKLINKING
);
608 void CCodeWindow::InitBitmaps()
610 // load original size 48x48
611 m_Bitmaps
[Toolbar_DebugGo
] = wxGetBitmapFromMemory(toolbar_play_png
);
612 m_Bitmaps
[Toolbar_Step
] = wxGetBitmapFromMemory(toolbar_add_breakpoint_png
);
613 m_Bitmaps
[Toolbar_StepOver
] = wxGetBitmapFromMemory(toolbar_add_memcheck_png
);
614 m_Bitmaps
[Toolbar_Skip
] = wxGetBitmapFromMemory(toolbar_add_memcheck_png
);
615 m_Bitmaps
[Toolbar_GotoPC
] = wxGetBitmapFromMemory(toolbar_add_memcheck_png
);
616 m_Bitmaps
[Toolbar_SetPC
] = wxGetBitmapFromMemory(toolbar_add_memcheck_png
);
617 m_Bitmaps
[Toolbar_DebugPause
] = wxGetBitmapFromMemory(toolbar_pause_png
);
619 // scale to 24x24 for toolbar
620 for (size_t n
= Toolbar_DebugGo
; n
< ToolbarDebugBitmapMax
; n
++)
621 m_Bitmaps
[n
] = wxBitmap(m_Bitmaps
[n
].ConvertToImage().Scale(24, 24));
624 void CCodeWindow::PopulateToolbar(wxAuiToolBar
* toolBar
)
626 int w
= m_Bitmaps
[Toolbar_DebugGo
].GetWidth(),
627 h
= m_Bitmaps
[Toolbar_DebugGo
].GetHeight();
629 toolBar
->SetToolBitmapSize(wxSize(w
, h
));
630 toolBar
->AddTool(IDM_STEP
, _T("Step"), m_Bitmaps
[Toolbar_Step
]);
631 toolBar
->AddTool(IDM_STEPOVER
, _T("Step Over"), m_Bitmaps
[Toolbar_StepOver
]);
632 toolBar
->AddTool(IDM_SKIP
, _T("Skip"), m_Bitmaps
[Toolbar_Skip
]);
633 toolBar
->AddSeparator();
634 toolBar
->AddTool(IDM_GOTOPC
, _T("Show PC"), m_Bitmaps
[Toolbar_GotoPC
]);
635 toolBar
->AddTool(IDM_SETPC
, _T("Set PC"), m_Bitmaps
[Toolbar_SetPC
]);
636 toolBar
->AddSeparator();
637 toolBar
->AddControl(new wxTextCtrl(toolBar
, IDM_ADDRBOX
, _T("")));
643 void CCodeWindow::Update()
645 if (!codeview
) return;
649 UpdateButtonStates();
651 // Do not automatically show the current PC position when a breakpoint is hit or
652 // when we pause since this can be called at other times too.
653 //codeview->Center(PC);
656 void CCodeWindow::UpdateButtonStates()
658 bool Initialized
= (Core::GetState() != Core::CORE_UNINITIALIZED
);
659 bool Pause
= (Core::GetState() == Core::CORE_PAUSE
);
660 bool Stepping
= CCPU::IsStepping();
661 wxAuiToolBar
* ToolBar
= GetToolBar();
664 if (!ToolBar
) return;
668 ToolBar
->EnableTool(IDM_STEPOVER
, false);
669 ToolBar
->EnableTool(IDM_SKIP
, false);
675 ToolBar
->EnableTool(IDM_STEPOVER
, false);
676 ToolBar
->EnableTool(IDM_SKIP
, false);
680 ToolBar
->EnableTool(IDM_STEPOVER
, true);
681 ToolBar
->EnableTool(IDM_SKIP
, true);
685 ToolBar
->EnableTool(IDM_STEP
, Initialized
&& Stepping
);
687 if (ToolBar
) ToolBar
->Realize();
690 // ------------------
691 GetMenuBar()->Enable(IDM_INTERPRETER
, Pause
); // CPU Mode
693 GetMenuBar()->Enable(IDM_JITNOBLOCKCACHE
, !Initialized
);
695 GetMenuBar()->Enable(IDM_JITOFF
, Pause
);
696 GetMenuBar()->Enable(IDM_JITLSOFF
, Pause
);
697 GetMenuBar()->Enable(IDM_JITLSLXZOFF
, Pause
);
698 GetMenuBar()->Enable(IDM_JITLSLWZOFF
, Pause
);
699 GetMenuBar()->Enable(IDM_JITLSLBZXOFF
, Pause
);
700 GetMenuBar()->Enable(IDM_JITLSFOFF
, Pause
);
701 GetMenuBar()->Enable(IDM_JITLSPOFF
, Pause
);
702 GetMenuBar()->Enable(IDM_JITFPOFF
, Pause
);
703 GetMenuBar()->Enable(IDM_JITIOFF
, Pause
);
704 GetMenuBar()->Enable(IDM_JITPOFF
, Pause
);
705 GetMenuBar()->Enable(IDM_JITSROFF
, Pause
);
707 GetMenuBar()->Enable(IDM_CLEARCODECACHE
, Pause
); // JIT Menu
708 GetMenuBar()->Enable(IDM_SEARCHINSTRUCTION
, Initialized
);
710 GetMenuBar()->Enable(IDM_CLEARSYMBOLS
, Initialized
); // Symbols menu
711 GetMenuBar()->Enable(IDM_SCANFUNCTIONS
, Initialized
);
712 GetMenuBar()->Enable(IDM_LOADMAPFILE
, Initialized
);
713 GetMenuBar()->Enable(IDM_SAVEMAPFILE
, Initialized
);
714 GetMenuBar()->Enable(IDM_SAVEMAPFILEWITHCODES
, Initialized
);
715 GetMenuBar()->Enable(IDM_CREATESIGNATUREFILE
, Initialized
);
716 GetMenuBar()->Enable(IDM_RENAME_SYMBOLS
, Initialized
);
717 GetMenuBar()->Enable(IDM_USESIGNATUREFILE
, Initialized
);
718 GetMenuBar()->Enable(IDM_PATCHHLEFUNCTIONS
, Initialized
);
721 callstack
->SetFont(DebuggerFont
);
722 symbols
->SetFont(DebuggerFont
);
723 callers
->SetFont(DebuggerFont
);
724 calls
->SetFont(DebuggerFont
);