diff --git a/Core/Debugger/Breakpoints.cpp b/Core/Debugger/Breakpoints.cpp index 7f83026abe..cf0aecb864 100644 --- a/Core/Debugger/Breakpoints.cpp +++ b/Core/Debugger/Breakpoints.cpp @@ -28,7 +28,7 @@ static FixedSizeUnorderedSet m_iBreakPoints; std::vector CBreakPoints::MemChecks; -u32 CBreakPoints::m_iBreakOnCount = 0; +u32 CBreakPoints::breakSkipFirstAt_ = 0; MemCheck::MemCheck(void) { @@ -129,15 +129,6 @@ MemCheck *CBreakPoints::GetMemCheck(u32 address, int size) return 0; } -bool CBreakPoints::IsBreakOnCount(u32 _iCount) -{ - if ((_iCount == m_iBreakOnCount) && - (m_iBreakOnCount != 0)) - return true; - - return false; -} - void CBreakPoints::AddBreakPoint(u32 _iAddress, bool temp) { if (!IsAddressBreakPoint(_iAddress)) diff --git a/Core/Debugger/Breakpoints.h b/Core/Debugger/Breakpoints.h index 4e0b4ce8bf..9bc4957220 100644 --- a/Core/Debugger/Breakpoints.h +++ b/Core/Debugger/Breakpoints.h @@ -57,7 +57,7 @@ private: enum { MAX_NUMBER_OF_CALLSTACK_ENTRIES = 16384}; enum { MAX_NUMBER_OF_BREAKPOINTS = 16}; - static u32 m_iBreakOnCount; + static u32 breakSkipFirstAt_; public: // WARNING: Not used in interpreter or HLE, only jit CPU memory access. @@ -89,6 +89,9 @@ public: static int GetNumBreakpoints(); static BreakPoint GetBreakpoint(int i); static int GetBreakpointAddress(int i); + + static void SetSkipFirst(u32 pc) { breakSkipFirstAt_ = pc; } + static u32 CheckSkipFirst() { u32 pc = breakSkipFirstAt_; breakSkipFirstAt_ = 0; return pc; } }; diff --git a/Core/MIPS/x86/Jit.cpp b/Core/MIPS/x86/Jit.cpp index 01e4ed3f8d..28396d0616 100644 --- a/Core/MIPS/x86/Jit.cpp +++ b/Core/MIPS/x86/Jit.cpp @@ -59,8 +59,12 @@ std::pair flip_pair(const std::pair &p) return std::pair(p.second, p.first); } -void JitBreakpoint() +u32 JitBreakpoint() { + // Should we skip this breakpoint? + if (CBreakPoints::CheckSkipFirst() == currentMIPS->pc) + return 0; + Core_EnableStepping(true); host->SetDebugMode(true); @@ -84,6 +88,8 @@ void JitBreakpoint() NOTICE_LOG(JIT, "Top ops compiled to interpreter: %s", message.c_str()); } + + return 1; } static void JitLogMiss(u32 op) @@ -442,8 +448,12 @@ bool Jit::CheckJitBreakpoint(u32 addr, int downcountOffset) MOV(32, M(&mips_->pc), Imm32(js.compilerPC)); ABI_CallFunction((void *)&JitBreakpoint); + // If 0, the conditional breakpoint wasn't taken. + CMP(32, R(EAX), Imm32(0)); + FixupBranch skip = J_CC(CC_Z); WriteDowncount(downcountOffset); JMP(asm_.dispatcherCheckCoreState, true); + SetJumpTarget(skip); return true; } diff --git a/Core/MIPS/x86/Jit.h b/Core/MIPS/x86/Jit.h index 42deb55b7b..47546c1ea8 100644 --- a/Core/MIPS/x86/Jit.h +++ b/Core/MIPS/x86/Jit.h @@ -33,8 +33,8 @@ namespace MIPSComp { -// This is called when Jit hits a breakpoint. -void JitBreakpoint(); +// This is called when Jit hits a breakpoint. Returns 1 when hit. +u32 JitBreakpoint(); struct JitOptions { diff --git a/Windows/Debugger/Debugger_Disasm.cpp b/Windows/Debugger/Debugger_Disasm.cpp index c52931b166..71b802431d 100644 --- a/Windows/Debugger/Debugger_Disasm.cpp +++ b/Windows/Debugger/Debugger_Disasm.cpp @@ -500,6 +500,10 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) case IDC_GO: { lastTicks = CoreTiming::GetTicks(); + + // If the current PC is on a breakpoint, the user doesn't want to do nothing. + CBreakPoints::SetSkipFirst(currentMIPS->pc); + SetDebugMode(false); Core_EnableStepping(false); } @@ -510,6 +514,9 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) 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_(); @@ -524,6 +531,9 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) 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); + const char* dis = cpu->disasm(cpu->GetPC(),4); const char* pos = strstr(dis,"->$"); const char* reg = strstr(dis,"->"); @@ -574,6 +584,13 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) case IDC_STEPHLE: { + 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); + hleDebugBreak(); SetDebugMode(false); _dbg_update_();