diff --git a/Windows/Debugger/CtrlDisAsmView.cpp b/Windows/Debugger/CtrlDisAsmView.cpp index 8416b4f3a2..c274a9ef3c 100644 --- a/Windows/Debugger/CtrlDisAsmView.cpp +++ b/Windows/Debugger/CtrlDisAsmView.cpp @@ -109,6 +109,7 @@ LRESULT CALLBACK CtrlDisAsmView::wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPA ccp->redraw(); break; case WM_KILLFOCUS: + ccp->controlHeld = false; ccp->hasFocus=false; ccp->redraw(); break; @@ -117,9 +118,6 @@ LRESULT CALLBACK CtrlDisAsmView::wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPA { switch (wParam) { - case VK_F9: - case VK_F10: - case VK_F11: case VK_TAB: return DLGC_WANTMESSAGE; default: @@ -592,18 +590,6 @@ void CtrlDisAsmView::onKeyDown(WPARAM wParam, LPARAM lParam) case VK_CONTROL: controlHeld = true; break; - case VK_F9: - if (debugger->GetPC() != curAddress) - { - SendMessage(GetParent(wnd),WM_DEB_RUNTOWPARAM,curAddress,0); - } - break; - case VK_F10: - SendMessage(GetParent(wnd),WM_COMMAND,IDC_STEPOVER,0); - return; - case VK_F11: - SendMessage(GetParent(wnd),WM_COMMAND,IDC_STEP,0); - return; case VK_SPACE: debugger->toggleBreakpoint(curAddress); break; diff --git a/Windows/Debugger/DebuggerShared.h b/Windows/Debugger/DebuggerShared.h index c0f8e38a1a..d5e8835e0a 100644 --- a/Windows/Debugger/DebuggerShared.h +++ b/Windows/Debugger/DebuggerShared.h @@ -4,8 +4,7 @@ extern HMENU g_hPopupMenus; -enum { WM_DEB_RUNTOWPARAM = WM_USER+2, - WM_DEB_GOTOWPARAM, +enum { WM_DEB_GOTOWPARAM = WM_USER+2, WM_DEB_GOTOADDRESSEDIT, WM_DEB_MAPLOADED, WM_DEB_TABPRESSED, diff --git a/Windows/Debugger/Debugger_Disasm.cpp b/Windows/Debugger/Debugger_Disasm.cpp index f4fde27c93..07db327299 100644 --- a/Windows/Debugger/Debugger_Disasm.cpp +++ b/Windows/Debugger/Debugger_Disasm.cpp @@ -226,6 +226,86 @@ void CDisasm::changeSubWindow(SubWindowType type) } } +void CDisasm::stepInto() +{ + if (Core_IsActive()) return; + + CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); + lastTicks = CoreTiming::GetTicks(); + + // If the current PC is on a breakpoint, the user doesn't want to do nothing. + CBreakPoints::SetSkipFirst(currentMIPS->pc); + + Core_DoSingleStep(); + Sleep(1); + _dbg_update_(); + ptr->gotoPC(); + UpdateDialog(); + vfpudlg->Update(); + + CtrlMemView::getFrom(GetDlgItem(m_hDlg,IDC_DEBUGMEMVIEW))->redraw(); + threadList->reloadThreads(); + stackTraceView->loadStackTrace(); + updateThreadLabel(false); +} + +void CDisasm::stepOver() +{ + if (Core_IsActive()) return; + + CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); + lastTicks = CoreTiming::GetTicks(); + + // If the current PC is on a breakpoint, the user doesn't want to do nothing. + CBreakPoints::SetSkipFirst(currentMIPS->pc); + + MIPSAnalyst::MipsOpcodeInfo info = MIPSAnalyst::GetOpcodeInfo(cpu,cpu->GetPC()); + ptr->setDontRedraw(true); + u32 breakpointAddress = cpu->GetPC()+cpu->getInstructionSize(0); + if (info.isBranch) + { + if (info.isConditional == false) + { + if (info.isLinkedBranch) // jal, jalr + { + // it's a function call with a delay slot - skip that too + breakpointAddress += cpu->getInstructionSize(0); + } else { // j, ... + // in case of absolute branches, set the breakpoint at the branch target + breakpointAddress = info.branchTarget; + } + } else { // beq, ... + // set breakpoint at branch target + breakpointAddress = info.branchTarget; + CBreakPoints::AddBreakPoint(breakpointAddress,true); + + // and after the delay slot + breakpointAddress = cpu->GetPC()+2*cpu->getInstructionSize(0); + } + } + + 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)); + u32 pos = ptr->getSelection(); + + lastTicks = CoreTiming::GetTicks(); + ptr->setDontRedraw(true); + SetDebugMode(false); + CBreakPoints::AddBreakPoint(pos,true); + _dbg_update_(); + Core_EnableStepping(false); +} + BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) { //if (!m_hDlg) return FALSE; @@ -298,6 +378,39 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) changeSubWindow(SUBWIN_STACKFRAMES); break; + case ID_DEBUG_ADDBREAKPOINT: + { + bool isRunning = Core_IsActive(); + if (isRunning) + { + SetDebugMode(true); + Core_EnableStepping(true); + Core_WaitInactive(200); + } + + BreakpointWindow bpw(m_hDlg,cpu); + if (bpw.exec()) bpw.addBreakpoint(); + + if (isRunning) + { + SetDebugMode(false); + Core_EnableStepping(false); + } + } + break; + + case ID_DEBUG_STEPOVER: + if (GetFocus() == GetDlgItem(m_hDlg,IDC_DISASMVIEW)) stepOver(); + break; + + case ID_DEBUG_STEPINTO: + if (GetFocus() == GetDlgItem(m_hDlg,IDC_DISASMVIEW)) stepInto(); + break; + + case ID_DEBUG_RUNTOLINE: + if (GetFocus() == GetDlgItem(m_hDlg,IDC_DISASMVIEW)) runToLine(); + break; + case IDC_SHOWVFPU: vfpudlg->Show(true); break; @@ -351,68 +464,11 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) break; case IDC_STEP: - { - if (Core_IsActive()) break; - lastTicks = CoreTiming::GetTicks(); - - // If the current PC is on a breakpoint, the user doesn't want to do nothing. - CBreakPoints::SetSkipFirst(currentMIPS->pc); - - Core_DoSingleStep(); - Sleep(1); - _dbg_update_(); - ptr->gotoPC(); - UpdateDialog(); - vfpudlg->Update(); - - CtrlMemView::getFrom(GetDlgItem(m_hDlg,IDC_DEBUGMEMVIEW))->redraw(); - threadList->reloadThreads(); - stackTraceView->loadStackTrace(); - updateThreadLabel(false); - } + stepInto(); break; case IDC_STEPOVER: - { - if (Core_IsActive()) break; - lastTicks = CoreTiming::GetTicks(); - - // If the current PC is on a breakpoint, the user doesn't want to do nothing. - CBreakPoints::SetSkipFirst(currentMIPS->pc); - - MIPSAnalyst::MipsOpcodeInfo info = MIPSAnalyst::GetOpcodeInfo(cpu,cpu->GetPC()); - ptr->setDontRedraw(true); - u32 breakpointAddress = cpu->GetPC()+cpu->getInstructionSize(0); - if (info.isBranch) - { - if (info.isConditional == false) - { - if (info.isLinkedBranch) // jal, jalr - { - // it's a function call with a delay slot - skip that too - breakpointAddress += cpu->getInstructionSize(0); - } else { // j, ... - // in case of absolute branches, set the breakpoint at the branch target - breakpointAddress = info.branchTarget; - } - } else { // beq, ... - // set breakpoint at branch target - breakpointAddress = info.branchTarget; - CBreakPoints::AddBreakPoint(breakpointAddress,true); - - // and after the delay slot - breakpointAddress = cpu->GetPC()+2*cpu->getInstructionSize(0); - } - } - - SetDebugMode(false); - CBreakPoints::AddBreakPoint(breakpointAddress,true); - _dbg_update_(); - Core_EnableStepping(false); - Sleep(1); - ptr->gotoAddr(breakpointAddress); - UpdateDialog(); - } + stepOver(); break; case IDC_STEPHLE: @@ -454,24 +510,7 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) break; case IDC_MEMCHECK: - { - bool isRunning = Core_IsActive(); - if (isRunning) - { - SetDebugMode(true); - Core_EnableStepping(true); - Core_WaitInactive(200); - } - - BreakpointWindow bpw(m_hDlg,cpu); - if (bpw.exec()) bpw.addBreakpoint(); - - if (isRunning) - { - SetDebugMode(false); - Core_EnableStepping(false); - } - } + SendMessage(m_hDlg,WM_COMMAND,ID_DEBUG_ADDBREAKPOINT,0); break; case IDC_UPDATECALLSTACK: { @@ -540,17 +579,7 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) case WM_DEB_MAPLOADED: NotifyMapLoaded(); break; - case WM_DEB_RUNTOWPARAM: - { - lastTicks = CoreTiming::GetTicks(); - CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); - ptr->setDontRedraw(true); - SetDebugMode(false); - CBreakPoints::AddBreakPoint(wParam,true); - _dbg_update_(); - Core_EnableStepping(false); - break; - } + case WM_DEB_GOTOWPARAM: { CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); diff --git a/Windows/Debugger/Debugger_Disasm.h b/Windows/Debugger/Debugger_Disasm.h index c8024cbf97..6626ef2776 100644 --- a/Windows/Debugger/Debugger_Disasm.h +++ b/Windows/Debugger/Debugger_Disasm.h @@ -43,6 +43,9 @@ private: void SavePosition(); void updateThreadLabel(bool clear); void changeSubWindow(SubWindowType type); + void stepInto(); + void stepOver(); + void runToLine(); public: int index; //helper diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index 9812544a31..586e4d0a39 100644 Binary files a/Windows/ppsspp.rc and b/Windows/ppsspp.rc differ diff --git a/Windows/resource.h b/Windows/resource.h index a1b87475b2..8eb3e5243b 100644 Binary files a/Windows/resource.h and b/Windows/resource.h differ