From e308ef59f5fd4c67e98c4766fd85a7887f592a13 Mon Sep 17 00:00:00 2001 From: Kingcom Date: Sat, 17 Aug 2013 11:18:03 +0200 Subject: [PATCH] Add step out feature and button --- Windows/Debugger/Debugger_Disasm.cpp | 44 +++++++++++++++++++++++++++ Windows/Debugger/Debugger_Disasm.h | 1 + Windows/ppsspp.rc | Bin 41358 -> 41782 bytes Windows/resource.h | Bin 22578 -> 22760 bytes 4 files changed, 45 insertions(+) diff --git a/Windows/Debugger/Debugger_Disasm.cpp b/Windows/Debugger/Debugger_Disasm.cpp index c135be9cd4..126aa77ffa 100644 --- a/Windows/Debugger/Debugger_Disasm.cpp +++ b/Windows/Debugger/Debugger_Disasm.cpp @@ -293,6 +293,40 @@ void CDisasm::stepOver() UpdateDialog(); } +void CDisasm::stepOut() +{ + auto threads = GetThreadsInfo(); + + u32 entry, stackTop; + for (size_t i = 0; i < threads.size(); i++) + { + if (threads[i].isCurrent) + { + entry = threads[i].entrypoint; + stackTop = threads[i].initialStack; + break; + } + } + + auto frames = MIPSStackWalk::Walk(cpu->GetPC(),cpu->GetRegValue(0,31),cpu->GetRegValue(0,29),entry,stackTop); + if (frames.size() < 2) return; + u32 breakpointAddress = frames[1].pc; + + // If the current PC is on a breakpoint, the user doesn't want to do nothing. + CBreakPoints::SetSkipFirst(currentMIPS->pc); + + CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); + ptr->setDontRedraw(true); + + SetDebugMode(false); + CBreakPoints::AddBreakPoint(breakpointAddress,true); + _dbg_update_(); + Core_EnableStepping(false); + Sleep(1); + ptr->gotoAddr(breakpointAddress); + UpdateDialog(); +} + void CDisasm::runToLine() { CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); @@ -411,6 +445,10 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) if (GetFocus() == GetDlgItem(m_hDlg,IDC_DISASMVIEW)) runToLine(); break; + case ID_DEBUG_STEPOUT: + if (GetFocus() == GetDlgItem(m_hDlg,IDC_DISASMVIEW)) stepOut(); + break; + case IDC_SHOWVFPU: vfpudlg->Show(true); break; @@ -482,6 +520,10 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) case IDC_STEPOVER: stepOver(); break; + + case IDC_STEPOUT: + stepOut(); + break; case IDC_STEPHLE: { @@ -744,6 +786,7 @@ void CDisasm::SetDebugMode(bool _bDebug) EnableWindow( GetDlgItem(hDlg, IDC_STEP), TRUE); EnableWindow( GetDlgItem(hDlg, IDC_STEPOVER), TRUE); EnableWindow( GetDlgItem(hDlg, IDC_STEPHLE), TRUE); + EnableWindow( GetDlgItem(hDlg, IDC_STEPOUT), TRUE); CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); ptr->setDontRedraw(false); ptr->gotoPC(); @@ -763,6 +806,7 @@ void CDisasm::SetDebugMode(bool _bDebug) EnableWindow( GetDlgItem(hDlg, IDC_STEP), FALSE); EnableWindow( GetDlgItem(hDlg, IDC_STEPOVER), FALSE); EnableWindow( GetDlgItem(hDlg, IDC_STEPHLE), FALSE); + EnableWindow( GetDlgItem(hDlg, IDC_STEPOUT), FALSE); CtrlRegisterList *reglist = CtrlRegisterList::getFrom(GetDlgItem(m_hDlg,IDC_REGLIST)); reglist->redraw(); } diff --git a/Windows/Debugger/Debugger_Disasm.h b/Windows/Debugger/Debugger_Disasm.h index 6626ef2776..d5425ca2ea 100644 --- a/Windows/Debugger/Debugger_Disasm.h +++ b/Windows/Debugger/Debugger_Disasm.h @@ -45,6 +45,7 @@ private: void changeSubWindow(SubWindowType type); void stepInto(); void stepOver(); + void stepOut(); void runToLine(); public: int index; //helper diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index f23f2a791dcf01d856d22d5ec9227e21100c4d10..d98d7d2ac85e1494d1c1f5c9580221fa736a29ff 100644 GIT binary patch delta 190 zcmeA>%(U$o(}ohU$J317>p|`=UlEvmsEAr)I3E8G{*6g)tBtGMF+L VfN6ut5543k_i6ELex|vi900n$GV%Zb delta 84 zcmdmXjH&N1(}ohU%^c!u7$@Hm;+tH>zGkz46c0bMIfLb7dCfvrBL+htt5VB;vYVCx lvn7KGkX_1b!eB7@qgE`hC4(u04udfe8!{Mdj@G_i4gf$A7g+!R diff --git a/Windows/resource.h b/Windows/resource.h index e991def27e3c07aa8c29b34005ded16b39cb57eb..08b985bdf29419d0c202c0f99f698b67cc614647 100644 GIT binary patch delta 89 zcmdnAf$_yg#tn8-lXq~6O|488Q=f_ delta 35 rcmaE{k#W-o#tn8-lQqH=Ht&#PvD&;NM1XOknaJb@MZV2mVe^;(`?(C-