From 290e1bed378d570667eb66170986696ca207d2d6 Mon Sep 17 00:00:00 2001 From: skidau Date: Fri, 24 Oct 2014 12:57:17 +1100 Subject: [PATCH] Disable block linking while debugger stepping or if there are breakpoints --- Source/Core/Core/PowerPC/Jit64/Jit.cpp | 31 ++- Source/Core/Core/PowerPC/Jit64/Jit.h | 3 + Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp | 30 ++- Source/Core/Core/PowerPC/Jit64IL/JitIL.h | 3 + Source/Core/DolphinWX/Debugger/CodeWindow.cpp | 2 +- Source/Core/DolphinWX/Debugger/CodeWindow.h | 180 +++++++++--------- 6 files changed, 144 insertions(+), 105 deletions(-) diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.cpp b/Source/Core/Core/PowerPC/Jit64/Jit.cpp index d091db4ff3..2a5757d726 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit.cpp @@ -174,13 +174,8 @@ bool Jit64::HandleFault(uintptr_t access_address, SContext* ctx) void Jit64::Init() { jo.optimizeStack = true; - jo.enableBlocklink = true; - if (SConfig::GetInstance().m_LocalCoreStartupParameter.bJITNoBlockLinking || - SConfig::GetInstance().m_LocalCoreStartupParameter.bMMU) - { - // TODO: support block linking with MMU - jo.enableBlocklink = false; - } + EnableBlockLink(); + jo.fpAccurateFcmp = SConfig::GetInstance().m_LocalCoreStartupParameter.bFPRF; jo.optimizeGatherPipe = true; jo.fastInterrupts = false; @@ -521,11 +516,19 @@ const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBloc if (SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableDebugging) { + // We can link blocks as long as we are not single stepping and there are no breakpoints here + EnableBlockLink(); + // Comment out the following to disable breakpoints (speed-up) if (!Profiler::g_ProfileBlocks) { if (GetState() == CPU_STEPPING) + { blockSize = 1; + + // Do not link this block to other blocks While single stepping + jo.enableBlocklink = false; + } Trace(); } } @@ -715,6 +718,9 @@ const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBloc if (SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableDebugging && breakpoints.IsAddressBreakPoint(ops[i].address) && GetState() != CPU_STEPPING) { + // Turn off block linking if there are breakpoints so that the Step Over command does not link this block. + jo.enableBlocklink = false; + gpr.Flush(); fpr.Flush(); @@ -856,3 +862,14 @@ u32 Jit64::CallerSavedRegistersInUse() } return result & ABI_ALL_CALLER_SAVED; } + +void Jit64::EnableBlockLink() +{ + jo.enableBlocklink = true; + if (SConfig::GetInstance().m_LocalCoreStartupParameter.bJITNoBlockLinking || + SConfig::GetInstance().m_LocalCoreStartupParameter.bMMU) + { + // TODO: support block linking with MMU + jo.enableBlocklink = false; + } +} diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.h b/Source/Core/Core/PowerPC/Jit64/Jit.h index 4dfbe56eb8..0cd48c5f57 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit.h +++ b/Source/Core/Core/PowerPC/Jit64/Jit.h @@ -64,6 +64,9 @@ public: ~Jit64() {} void Init() override; + + void EnableBlockLink(); + void Shutdown() override; bool HandleFault(uintptr_t access_address, SContext* ctx) override; diff --git a/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp b/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp index 5a82a796e2..0f37c63c10 100644 --- a/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp +++ b/Source/Core/Core/PowerPC/Jit64IL/JitIL.cpp @@ -244,13 +244,7 @@ namespace JitILProfiler void JitIL::Init() { jo.optimizeStack = true; - jo.enableBlocklink = true; - if (SConfig::GetInstance().m_LocalCoreStartupParameter.bJITNoBlockLinking || - SConfig::GetInstance().m_LocalCoreStartupParameter.bMMU) - { - // TODO: support block linking with MMU - jo.enableBlocklink = false; - } + EnableBlockLink(); jo.fpAccurateFcmp = false; jo.optimizeGatherPipe = true; @@ -509,11 +503,19 @@ const u8* JitIL::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBloc if (SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableDebugging) { + // We can link blocks as long as we are not single stepping and there are no breakpoints here + EnableBlockLink(); + // Comment out the following to disable breakpoints (speed-up) if (!Profiler::g_ProfileBlocks) { if (GetState() == CPU_STEPPING) + { blockSize = 1; + + // Do not link this block to other blocks While single stepping + jo.enableBlocklink = false; + } Trace(); } } @@ -648,6 +650,9 @@ const u8* JitIL::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBloc if (SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableDebugging && breakpoints.IsAddressBreakPoint(ops[i].address) && GetState() != CPU_STEPPING) { + // Turn off block linking if there are breakpoints so that the Step Over command does not link this block. + jo.enableBlocklink = false; + ibuild.EmitBreakPointCheck(ibuild.EmitIntConst(ops[i].address)); } @@ -702,3 +707,14 @@ const u8* JitIL::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBloc return normalEntry; } + +void JitIL::EnableBlockLink() +{ + jo.enableBlocklink = true; + if (SConfig::GetInstance().m_LocalCoreStartupParameter.bJITNoBlockLinking || + SConfig::GetInstance().m_LocalCoreStartupParameter.bMMU) + { + // TODO: support block linking with MMU + jo.enableBlocklink = false; + } +} diff --git a/Source/Core/Core/PowerPC/Jit64IL/JitIL.h b/Source/Core/Core/PowerPC/Jit64IL/JitIL.h index 8209cfc5a7..8afa6d9ae5 100644 --- a/Source/Core/Core/PowerPC/Jit64IL/JitIL.h +++ b/Source/Core/Core/PowerPC/Jit64IL/JitIL.h @@ -47,6 +47,9 @@ public: // Initialization, etc void Init() override; + + void EnableBlockLink(); + void Shutdown() override; // Jit! diff --git a/Source/Core/DolphinWX/Debugger/CodeWindow.cpp b/Source/Core/DolphinWX/Debugger/CodeWindow.cpp index b34dfa29b5..481240c498 100644 --- a/Source/Core/DolphinWX/Debugger/CodeWindow.cpp +++ b/Source/Core/DolphinWX/Debugger/CodeWindow.cpp @@ -310,10 +310,10 @@ void CCodeWindow::StepOver() { if (CCPU::IsStepping()) { - PowerPC::breakpoints.ClearAllTemporary(); UGeckoInstruction inst = Memory::Read_Instruction(PC); if (inst.LK) { + PowerPC::breakpoints.ClearAllTemporary(); PowerPC::breakpoints.Add(PC + 4, true); CCPU::EnableStepping(false); JumpToAddress(PC); diff --git a/Source/Core/DolphinWX/Debugger/CodeWindow.h b/Source/Core/DolphinWX/Debugger/CodeWindow.h index 26322b1b90..c0ac8650ca 100644 --- a/Source/Core/DolphinWX/Debugger/CodeWindow.h +++ b/Source/Core/DolphinWX/Debugger/CodeWindow.h @@ -36,113 +36,113 @@ class wxMenuBar; class CCodeWindow : public wxPanel { public: - CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter, - CFrame * parent, - wxWindowID id = wxID_ANY, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxTAB_TRAVERSAL | wxBORDER_NONE, + CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter, + CFrame * parent, + wxWindowID id = wxID_ANY, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxTAB_TRAVERSAL | wxBORDER_NONE, const wxString& name = _("Code")); - void Load(); - void Save(); + void Load(); + void Save(); - // Parent interaction - CFrame *Parent; - wxMenuBar * GetMenuBar(); - wxToolBar * GetToolBar(); - wxBitmap m_Bitmaps[ToolbarDebugBitmapMax]; + // Parent interaction + CFrame *Parent; + wxMenuBar * GetMenuBar(); + wxToolBar * GetToolBar(); + wxBitmap m_Bitmaps[ToolbarDebugBitmapMax]; - bool UseInterpreter(); - bool BootToPause(); - bool AutomaticStart(); - bool JITNoBlockCache(); - bool JITNoBlockLinking(); - bool JumpToAddress(u32 address); + bool UseInterpreter(); + bool BootToPause(); + bool AutomaticStart(); + bool JITNoBlockCache(); + bool JITNoBlockLinking(); + bool JumpToAddress(u32 address); - void Update() override; - void NotifyMapLoaded(); - void CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParameter, wxMenuBar *pMenuBar); - void CreateMenuOptions(wxMenu *pMenu); - void CreateMenuSymbols(wxMenuBar *pMenuBar); - void RecreateToolbar(wxToolBar*); - void PopulateToolbar(wxToolBar* toolBar); - void UpdateButtonStates(); - void OpenPages(); - void UpdateManager(); + void Update() override; + void NotifyMapLoaded(); + void CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParameter, wxMenuBar *pMenuBar); + void CreateMenuOptions(wxMenu *pMenu); + void CreateMenuSymbols(wxMenuBar *pMenuBar); + void RecreateToolbar(wxToolBar*); + void PopulateToolbar(wxToolBar* toolBar); + void UpdateButtonStates(); + void OpenPages(); + void UpdateManager(); - // Menu bar - // ------------------- - void OnCPUMode(wxCommandEvent& event); // CPU Mode menu - void OnJITOff(wxCommandEvent& event); + // Menu bar + // ------------------- + void OnCPUMode(wxCommandEvent& event); // CPU Mode menu + void OnJITOff(wxCommandEvent& event); - void ToggleCodeWindow(bool bShow); - void ToggleRegisterWindow(bool bShow); - void ToggleWatchWindow(bool bShow); - void ToggleBreakPointWindow(bool bShow); - void ToggleMemoryWindow(bool bShow); - void ToggleJitWindow(bool bShow); - void ToggleSoundWindow(bool bShow); - void ToggleVideoWindow(bool bShow); + void ToggleCodeWindow(bool bShow); + void ToggleRegisterWindow(bool bShow); + void ToggleWatchWindow(bool bShow); + void ToggleBreakPointWindow(bool bShow); + void ToggleMemoryWindow(bool bShow); + void ToggleJitWindow(bool bShow); + void ToggleSoundWindow(bool bShow); + void ToggleVideoWindow(bool bShow); - void OnChangeFont(wxCommandEvent& event); + void OnChangeFont(wxCommandEvent& event); - void OnCodeStep(wxCommandEvent& event); - void OnAddrBoxChange(wxCommandEvent& event); - void OnSymbolsMenu(wxCommandEvent& event); - void OnJitMenu(wxCommandEvent& event); - void OnProfilerMenu(wxCommandEvent& event); + void OnCodeStep(wxCommandEvent& event); + void OnAddrBoxChange(wxCommandEvent& event); + void OnSymbolsMenu(wxCommandEvent& event); + void OnJitMenu(wxCommandEvent& event); + void OnProfilerMenu(wxCommandEvent& event); - // Sub dialogs - CRegisterWindow* m_RegisterWindow; - CWatchWindow* m_WatchWindow; - CBreakPointWindow* m_BreakpointWindow; - CMemoryWindow* m_MemoryWindow; - CJitWindow* m_JitWindow; - DSPDebuggerLLE* m_SoundWindow; - GFXDebuggerPanel* m_VideoWindow; + // Sub dialogs + CRegisterWindow* m_RegisterWindow; + CWatchWindow* m_WatchWindow; + CBreakPointWindow* m_BreakpointWindow; + CMemoryWindow* m_MemoryWindow; + CJitWindow* m_JitWindow; + DSPDebuggerLLE* m_SoundWindow; + GFXDebuggerPanel* m_VideoWindow; - // Settings - bool bAutomaticStart; bool bBootToPause; - bool bShowOnStart[IDM_VIDEOWINDOW - IDM_LOGWINDOW + 1]; - int iNbAffiliation[IDM_CODEWINDOW - IDM_LOGWINDOW + 1]; + // Settings + bool bAutomaticStart; bool bBootToPause; + bool bShowOnStart[IDM_VIDEOWINDOW - IDM_LOGWINDOW + 1]; + int iNbAffiliation[IDM_CODEWINDOW - IDM_LOGWINDOW + 1]; private: - enum - { - // Debugger GUI Objects - ID_CODEVIEW, - ID_CALLSTACKLIST, - ID_CALLERSLIST, - ID_CALLSLIST, - ID_SYMBOLLIST - }; + enum + { + // Debugger GUI Objects + ID_CODEVIEW, + ID_CALLSTACKLIST, + ID_CALLERSLIST, + ID_CALLSLIST, + ID_SYMBOLLIST + }; - void OnSymbolListChange(wxCommandEvent& event); - void OnSymbolListContextMenu(wxContextMenuEvent& event); - void OnCallstackListChange(wxCommandEvent& event); - void OnCallersListChange(wxCommandEvent& event); - void OnCallsListChange(wxCommandEvent& event); - void OnCodeViewChange(wxCommandEvent &event); - void OnHostMessage(wxCommandEvent& event); + void OnSymbolListChange(wxCommandEvent& event); + void OnSymbolListContextMenu(wxContextMenuEvent& event); + void OnCallstackListChange(wxCommandEvent& event); + void OnCallersListChange(wxCommandEvent& event); + void OnCallsListChange(wxCommandEvent& event); + void OnCodeViewChange(wxCommandEvent &event); + void OnHostMessage(wxCommandEvent& event); - // Debugger functions - void SingleStep(); - void StepOver(); - void StepOut(); - void ToggleBreakpoint(); + // Debugger functions + void SingleStep(); + void StepOver(); + void StepOut(); + void ToggleBreakpoint(); - void UpdateLists(); - void UpdateCallstack(); + void UpdateLists(); + void UpdateCallstack(); - void InitBitmaps(); + void InitBitmaps(); - CCodeView* codeview; - wxListBox* callstack; - wxListBox* symbols; - wxListBox* callers; - wxListBox* calls; - Common::Event sync_event; + CCodeView* codeview; + wxListBox* callstack; + wxListBox* symbols; + wxListBox* callers; + wxListBox* calls; + Common::Event sync_event; - DECLARE_EVENT_TABLE() + DECLARE_EVENT_TABLE() };