From 219a5078e86ad05cdc90a91a41a337be2eb8e679 Mon Sep 17 00:00:00 2001 From: skidau Date: Wed, 15 Oct 2014 20:04:23 +1100 Subject: Added a "Step Out" (aka "Step return") function to the debugger. Conflicts: Source/Core/DolphinWX/Debugger/CodeWindow.h --- Source/Core/DolphinWX/Debugger/CodeWindow.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'Source/Core/DolphinWX/Debugger/CodeWindow.cpp') diff --git a/Source/Core/DolphinWX/Debugger/CodeWindow.cpp b/Source/Core/DolphinWX/Debugger/CodeWindow.cpp index 94ca897a7b..f10421e860 100644 --- a/Source/Core/DolphinWX/Debugger/CodeWindow.cpp +++ b/Source/Core/DolphinWX/Debugger/CodeWindow.cpp @@ -180,6 +180,10 @@ void CCodeWindow::OnCodeStep(wxCommandEvent& event) StepOver(); break; + case IDM_STEPOUT: + StepOut(); + break; + case IDM_TOGGLE_BREAKPOINT: ToggleBreakpoint(); break; @@ -320,6 +324,21 @@ void CCodeWindow::StepOver() } } +void CCodeWindow::StepOut() +{ + if (CCPU::IsStepping()) + { + PowerPC::breakpoints.Add(LR, true); + CCPU::EnableStepping(false); + JumpToAddress(PC); + Update(); + + UpdateButtonStates(); + // Update all toolbars in the aui manager + Parent->UpdateGUI(); + } +} + void CCodeWindow::ToggleBreakpoint() { if (CCPU::IsStepping()) @@ -443,6 +462,7 @@ void CCodeWindow::CreateMenu(const SCoreStartupParameter& core_startup_parameter pDebugMenu->Append(IDM_STEP, _("Step &Into\tF11")); pDebugMenu->Append(IDM_STEPOVER, _("Step &Over\tF10")); + pDebugMenu->Append(IDM_STEPOUT, _("Step O&ut\tSHIFT+F11")); pDebugMenu->Append(IDM_TOGGLE_BREAKPOINT, _("Toggle &Breakpoint\tF9")); pDebugMenu->AppendSeparator(); @@ -607,6 +627,7 @@ void CCodeWindow::InitBitmaps() // load original size 48x48 m_Bitmaps[Toolbar_Step] = wxGetBitmapFromMemory(toolbar_add_breakpoint_png); m_Bitmaps[Toolbar_StepOver] = wxGetBitmapFromMemory(toolbar_add_memcheck_png); + m_Bitmaps[Toolbar_StepOut] = 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); @@ -624,6 +645,7 @@ void CCodeWindow::PopulateToolbar(wxToolBar* toolBar) toolBar->SetToolBitmapSize(wxSize(w, h)); WxUtils::AddToolbarButton(toolBar, IDM_STEP, _("Step"), m_Bitmaps[Toolbar_Step], _("Step into the next instruction")); WxUtils::AddToolbarButton(toolBar, IDM_STEPOVER, _("Step Over"), m_Bitmaps[Toolbar_StepOver], _("Step over the next instruction")); + WxUtils::AddToolbarButton(toolBar, IDM_STEPOUT, _("Step Out"), m_Bitmaps[Toolbar_StepOut], _("Step out of the current function")); WxUtils::AddToolbarButton(toolBar, IDM_SKIP, _("Skip"), m_Bitmaps[Toolbar_Skip], _("Skips the next instruction completely")); toolBar->AddSeparator(); WxUtils::AddToolbarButton(toolBar, IDM_GOTOPC, _("Show PC"), m_Bitmaps[Toolbar_GotoPC], _("Go to the current instruction")); @@ -660,6 +682,7 @@ void CCodeWindow::UpdateButtonStates() if (!Initialized) { ToolBar->EnableTool(IDM_STEPOVER, false); + ToolBar->EnableTool(IDM_STEPOUT, false); ToolBar->EnableTool(IDM_SKIP, false); } else @@ -667,11 +690,13 @@ void CCodeWindow::UpdateButtonStates() if (!Stepping) { ToolBar->EnableTool(IDM_STEPOVER, false); + ToolBar->EnableTool(IDM_STEPOUT, false); ToolBar->EnableTool(IDM_SKIP, false); } else { ToolBar->EnableTool(IDM_STEPOVER, true); + ToolBar->EnableTool(IDM_STEPOUT, true); ToolBar->EnableTool(IDM_SKIP, true); } } -- cgit v1.2.3 From df37649b9f8499ec732b7511e7fed2b075ef7781 Mon Sep 17 00:00:00 2001 From: skidau Date: Sat, 18 Oct 2014 11:02:26 +1100 Subject: Changed the step over routine to a single stepping version that steps until a blr is encountered. Cleared out all temporary breakpoints on each step to prevent phantom breakpoints from stopping the debugger. --- Source/Core/DolphinWX/Debugger/CodeWindow.cpp | 38 +++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'Source/Core/DolphinWX/Debugger/CodeWindow.cpp') diff --git a/Source/Core/DolphinWX/Debugger/CodeWindow.cpp b/Source/Core/DolphinWX/Debugger/CodeWindow.cpp index f10421e860..c6ad04e8b7 100644 --- a/Source/Core/DolphinWX/Debugger/CodeWindow.cpp +++ b/Source/Core/DolphinWX/Debugger/CodeWindow.cpp @@ -37,6 +37,7 @@ #include "Core/Debugger/PPCDebugInterface.h" #include "Core/HW/CPU.h" #include "Core/HW/Memmap.h" +#include "Core/HW/SystemTimers.h" #include "Core/PowerPC/Gekko.h" #include "Core/PowerPC/JitInterface.h" #include "Core/PowerPC/PowerPC.h" @@ -292,6 +293,7 @@ void CCodeWindow::SingleStep() { if (CCPU::IsStepping()) { + PowerPC::breakpoints.ClearAllTemporary(); JitInterface::InvalidateICache(PC, 4, true); CCPU::StepOpcode(&sync_event); wxThread::Sleep(20); @@ -305,6 +307,7 @@ void CCodeWindow::StepOver() { if (CCPU::IsStepping()) { + PowerPC::breakpoints.ClearAllTemporary(); UGeckoInstruction inst = Memory::Read_Instruction(PC); if (inst.LK) { @@ -328,8 +331,39 @@ void CCodeWindow::StepOut() { if (CCPU::IsStepping()) { - PowerPC::breakpoints.Add(LR, true); - CCPU::EnableStepping(false); + PowerPC::breakpoints.ClearAllTemporary(); + + // Keep stepping until the next blr or timeout after one second + u64 timeout = SystemTimers::GetTicksPerSecond(); + u64 steps = 0; + PowerPC::CoreMode oldMode = PowerPC::GetMode(); + PowerPC::SetMode(PowerPC::MODE_INTERPRETER); + UGeckoInstruction inst = Memory::Read_Instruction(PC); + GekkoOPInfo *opinfo = GetOpInfo(inst); + while (inst.hex != 0x4e800020 && steps < timeout) // check for blr + { + if (inst.LK) + { + // Step over branches + u32 next_pc = PC + 4; + while (PC != next_pc && steps < timeout) + { + PowerPC::SingleStep(); + ++steps; + } + } + else + { + PowerPC::SingleStep(); + ++steps; + } + inst = Memory::Read_Instruction(PC); + opinfo = GetOpInfo(inst); + } + + PowerPC::SingleStep(); + PowerPC::SetMode(oldMode); + JumpToAddress(PC); Update(); -- cgit v1.2.3 From 613cae613a8c2ac34dd823f875ac4a6a0059db38 Mon Sep 17 00:00:00 2001 From: skidau Date: Sun, 19 Oct 2014 21:45:40 +1100 Subject: Added a RAM Watch window to the debugger Conflicts: Source/Core/Core/HW/Memmap.cpp Source/Core/Core/HW/Memmap.h Source/Core/DolphinWX/Debugger/CodeWindow.h --- Source/Core/DolphinWX/Debugger/CodeWindow.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Source/Core/DolphinWX/Debugger/CodeWindow.cpp') diff --git a/Source/Core/DolphinWX/Debugger/CodeWindow.cpp b/Source/Core/DolphinWX/Debugger/CodeWindow.cpp index c6ad04e8b7..b34dfa29b5 100644 --- a/Source/Core/DolphinWX/Debugger/CodeWindow.cpp +++ b/Source/Core/DolphinWX/Debugger/CodeWindow.cpp @@ -52,6 +52,7 @@ #include "DolphinWX/Debugger/DebuggerUIUtil.h" #include "DolphinWX/Debugger/JitWindow.h" #include "DolphinWX/Debugger/RegisterWindow.h" +#include "DolphinWX/Debugger/WatchWindow.h" extern "C" // Bitmaps { @@ -93,6 +94,7 @@ CCodeWindow::CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter : wxPanel(parent, id, position, size, style, name) , Parent(parent) , m_RegisterWindow(nullptr) + , m_WatchWindow(nullptr) , m_BreakpointWindow(nullptr) , m_MemoryWindow(nullptr) , m_JitWindow(nullptr) @@ -152,6 +154,7 @@ void CCodeWindow::OnHostMessage(wxCommandEvent& event) Update(); if (codeview) codeview->Center(PC); if (m_RegisterWindow) m_RegisterWindow->NotifyUpdate(); + if (m_WatchWindow) m_WatchWindow->NotifyUpdate(); break; case IDM_UPDATEBREAKPOINTS: -- cgit v1.2.3 From 290e1bed378d570667eb66170986696ca207d2d6 Mon Sep 17 00:00:00 2001 From: skidau Date: Fri, 24 Oct 2014 12:57:17 +1100 Subject: Disable block linking while debugger stepping or if there are breakpoints --- Source/Core/DolphinWX/Debugger/CodeWindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/DolphinWX/Debugger/CodeWindow.cpp') 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); -- cgit v1.2.3 From 4570dd7eeb9033c0e349d3a9f0126f24010b0699 Mon Sep 17 00:00:00 2001 From: skidau Date: Sun, 26 Oct 2014 23:23:45 +1100 Subject: Fixed a crash that would occur if a new watch were added by entering a watch name. Code style updates. --- Source/Core/DolphinWX/Debugger/CodeWindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/DolphinWX/Debugger/CodeWindow.cpp') diff --git a/Source/Core/DolphinWX/Debugger/CodeWindow.cpp b/Source/Core/DolphinWX/Debugger/CodeWindow.cpp index 481240c498..35678e43dd 100644 --- a/Source/Core/DolphinWX/Debugger/CodeWindow.cpp +++ b/Source/Core/DolphinWX/Debugger/CodeWindow.cpp @@ -342,7 +342,7 @@ void CCodeWindow::StepOut() PowerPC::CoreMode oldMode = PowerPC::GetMode(); PowerPC::SetMode(PowerPC::MODE_INTERPRETER); UGeckoInstruction inst = Memory::Read_Instruction(PC); - GekkoOPInfo *opinfo = GetOpInfo(inst); + GekkoOPInfo* opinfo = GetOpInfo(inst); while (inst.hex != 0x4e800020 && steps < timeout) // check for blr { if (inst.LK) -- cgit v1.2.3