diff --git a/Source/Project64/UserInterface/Debugger/Debugger-Commands.cpp b/Source/Project64/UserInterface/Debugger/Debugger-Commands.cpp index 61dcff941..d282ac000 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-Commands.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-Commands.cpp @@ -74,6 +74,7 @@ LRESULT CDebugCommandsView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARA m_PCEdit.Attach(GetDlgItem(IDC_PC_EDIT)); m_ViewPCButton.Attach(GetDlgItem(IDC_VIEWPC_BTN)); m_StepButton.Attach(GetDlgItem(IDC_STEP_BTN)); + m_StepOverButton.Attach(GetDlgItem(IDC_STEPOVER_BTN)); m_SkipButton.Attach(GetDlgItem(IDC_SKIP_BTN)); m_GoButton.Attach(GetDlgItem(IDC_GO_BTN)); m_RegisterTabs.Attach(GetDlgItem(IDC_REG_TABS)); @@ -101,6 +102,7 @@ LRESULT CDebugCommandsView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARA // Setup View PC button m_ViewPCButton.EnableWindow(FALSE); m_StepButton.EnableWindow(FALSE); + m_StepOverButton.EnableWindow(FALSE); m_SkipButton.EnableWindow(FALSE); m_GoButton.EnableWindow(FALSE); @@ -126,6 +128,7 @@ LRESULT CDebugCommandsView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARA { m_ViewPCButton.EnableWindow(TRUE); m_StepButton.EnableWindow(TRUE); + m_StepOverButton.EnableWindow(TRUE); m_SkipButton.EnableWindow(TRUE); m_GoButton.EnableWindow(TRUE); } @@ -153,6 +156,7 @@ LRESULT CDebugCommandsView::OnDestroy(void) m_GoButton.Detach(); m_SkipButton.Detach(); m_StepButton.Detach(); + m_StepOverButton.Detach(); m_ViewPCButton.Detach(); m_PCEdit.Detach(); m_AddressEdit.Detach(); @@ -172,9 +176,7 @@ void CDebugCommandsView::InterceptKeyDown(WPARAM wParam, LPARAM /*lParam*/) m_StepEvent.Trigger(); } break; - case VK_F3: - // reserved step over - break; + case VK_F3: CPUStepOver(); break; case VK_F4: CPUResume(); break; } } @@ -487,6 +489,7 @@ void CDebugCommandsView::ShowAddress(uint32_t address, bool top) // Disable buttons m_ViewPCButton.EnableWindow(FALSE); m_StepButton.EnableWindow(FALSE); + m_StepOverButton.EnableWindow(FALSE); m_SkipButton.EnableWindow(FALSE); m_GoButton.EnableWindow(FALSE); @@ -516,6 +519,7 @@ void CDebugCommandsView::ShowAddress(uint32_t address, bool top) // Enable buttons m_ViewPCButton.EnableWindow(TRUE); m_StepButton.EnableWindow(TRUE); + m_StepOverButton.EnableWindow(TRUE); m_SkipButton.EnableWindow(TRUE); m_GoButton.EnableWindow(TRUE); @@ -1085,6 +1089,32 @@ void CDebugCommandsView::CPUResume() } } +void CDebugCommandsView::CPUStepOver() +{ + if (g_MMU == NULL) + { + return; + } + + COpInfo opInfo; + g_MMU->LW_VAddr(g_Reg->m_PROGRAM_COUNTER, opInfo.m_OpCode.Hex); + + if (opInfo.IsJAL()) + { + // put temp BP on return address and resume + m_Breakpoints->AddExecution(g_Reg->m_PROGRAM_COUNTER + 8, true); + CPUResume(); + } + else + { + // normal step + if (WaitingForStep()) + { + m_StepEvent.Trigger(); + } + } +} + LRESULT CDebugCommandsView::OnBackButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) { if (m_HistoryIndex > 0) @@ -1145,6 +1175,12 @@ LRESULT CDebugCommandsView::OnStepButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWN return FALSE; } +LRESULT CDebugCommandsView::OnStepOverButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) +{ + CPUStepOver(); + return FALSE; +} + LRESULT CDebugCommandsView::OnSkipButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) { CPUSkip(); @@ -1497,12 +1533,14 @@ void CDebugCommandsView::WaitingForStepChanged(void) m_Debugger->Debug_RefreshStackWindow(); m_Debugger->Debug_RefreshStackTraceWindow(); m_StepButton.EnableWindow(true); + m_StepOverButton.EnableWindow(true); m_GoButton.EnableWindow(true); m_AddressEdit.SetFocus(); } else { m_StepButton.EnableWindow(false); + m_StepOverButton.EnableWindow(false); m_GoButton.EnableWindow(false); } } diff --git a/Source/Project64/UserInterface/Debugger/Debugger-Commands.h b/Source/Project64/UserInterface/Debugger/Debugger-Commands.h index 47157f8e5..fc4883c25 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-Commands.h +++ b/Source/Project64/UserInterface/Debugger/Debugger-Commands.h @@ -103,6 +103,7 @@ private: COMMAND_HANDLER(ID_POPUPMENU_RUNTO, BN_CLICKED, OnPopupmenuRunTo) COMMAND_HANDLER(IDC_GO_BTN, BN_CLICKED, OnGoButton) COMMAND_HANDLER(IDC_STEP_BTN, BN_CLICKED, OnStepButton) + COMMAND_HANDLER(IDC_STEPOVER_BTN, BN_CLICKED, OnStepOverButton) COMMAND_HANDLER(IDC_SKIP_BTN, BN_CLICKED, OnSkipButton) COMMAND_HANDLER(IDC_CLEARBP_BTN, BN_CLICKED, OnClearBPButton) COMMAND_HANDLER(IDC_ADDBP_BTN, BN_CLICKED, OnAddBPButton) @@ -150,6 +151,7 @@ private: BEGIN_TOOLTIP_MAP() TOOLTIP(IDC_SKIP_BTN, "Skip (F1)") TOOLTIP(IDC_STEP_BTN, "Step (F2)") + TOOLTIP(IDC_STEP_BTN, "Step Over (F3)") TOOLTIP(IDC_GO_BTN, "Go (F4)") TOOLTIP(IDC_ADDBP_BTN, "Add breakpoint...") TOOLTIP(IDC_RMBP_BTN, "Remove selected breakpoint") @@ -176,6 +178,7 @@ private: LRESULT OnPopupmenuRunTo(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled); LRESULT OnGoButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled); LRESULT OnStepButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled); + LRESULT OnStepOverButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled); LRESULT OnSkipButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled); LRESULT OnClearBPButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled); LRESULT OnAddBPButton(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled); @@ -229,6 +232,7 @@ private: void CPUSkip(); void CPUResume(); + void CPUStepOver(); void WaitingForStepChanged(void); void SteppingOpsChanged(void); @@ -265,6 +269,7 @@ private: CButton m_ViewPCButton; CButton m_StepButton; + CButton m_StepOverButton; CButton m_SkipButton; CButton m_GoButton; diff --git a/Source/Project64/UserInterface/Debugger/OpInfo.h b/Source/Project64/UserInterface/Debugger/OpInfo.h index 252ec5f84..bba22f505 100644 --- a/Source/Project64/UserInterface/Debugger/OpInfo.h +++ b/Source/Project64/UserInterface/Debugger/OpInfo.h @@ -80,6 +80,11 @@ public: return false; } + bool IsJAL() + { + return (m_OpCode.op == R4300i_JAL || (m_OpCode.op == R4300i_SPECIAL && m_OpCode.funct == R4300i_SPECIAL_JALR)); + } + bool IsBranch() { uint32_t op = m_OpCode.op; diff --git a/Source/Project64/UserInterface/UIResources.rc b/Source/Project64/UserInterface/UIResources.rc index 4fc7414e9..ce280bcbe 100644 --- a/Source/Project64/UserInterface/UIResources.rc +++ b/Source/Project64/UserInterface/UIResources.rc @@ -683,9 +683,10 @@ BEGIN PUSHBUTTON "‹",IDC_BACK_BTN,286,1,11,15,WS_DISABLED PUSHBUTTON "›",IDC_FORWARD_BTN,298,1,11,15,WS_DISABLED PUSHBUTTON "...",IDC_SYMBOLS_BTN,357,1,17,15 - PUSHBUTTON "Skip",IDC_SKIP_BTN,380,1,35,15,WS_DISABLED - PUSHBUTTON "Step",IDC_STEP_BTN,416,1,35,15,WS_DISABLED - PUSHBUTTON "Go",IDC_GO_BTN,452,1,35,15,WS_DISABLED + PUSHBUTTON "Skip",IDC_SKIP_BTN,376,1,27,15,WS_DISABLED + PUSHBUTTON "Step",IDC_STEP_BTN,404,1,27,15,WS_DISABLED + PUSHBUTTON "St.Ovr", IDC_STEPOVER_BTN, 432, 1, 27, 15, WS_DISABLED + PUSHBUTTON "Go",IDC_GO_BTN,460,1,27,15,WS_DISABLED LTEXT "PC",IDC_PC_STATIC,292,24,8,9 EDITTEXT IDC_PC_EDIT,303,22,44,12,ES_UPPERCASE | ES_AUTOHSCROLL,WS_EX_RIGHT PUSHBUTTON "View",IDC_VIEWPC_BTN,348,22,30,13,WS_DISABLED @@ -1840,9 +1841,11 @@ BEGIN 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 100 + 0, 0, 0, 100, + 0, 0, 0, 0 END + ///////////////////////////////////////////////////////////////////////////// // // Dialog Info diff --git a/Source/Project64/UserInterface/resource.h b/Source/Project64/UserInterface/resource.h index 46ab7ffc7..5c87a4f7a 100644 --- a/Source/Project64/UserInterface/resource.h +++ b/Source/Project64/UserInterface/resource.h @@ -292,6 +292,7 @@ #define IDC_STEP_BTN 1119 #define IDC_ADDSYMBOL_BTN 1119 #define IDC_NOTES 1120 +#define IDC_STEPOVER_BTN 1120 #define IDC_CHEAT_LIST 1121 #define IDC_CHEAT_NAME 1122 #define IDC_DELAY_SI 1123