Commit Graph
57 Commits
Author SHA1 Message Date
Henrik RydgårdandClaude Opus 5 35a91b757a Move the temporary breakpoint out of the user's breakpoint list
step-over, step-out and run-until plant a one-shot breakpoint at the address
they want execution to return to. Keeping it in breakPoints_ alongside the
user's own meant the two kept colliding:

- Adding a log-only user breakpoint at the same address hijacked the temporary
  one. AddBreakPoint() didn't match across temp-ness so both existed, and then
  ChangeBreakPoint() looked up "the first enabled breakpoint at this address" -
  a log-only breakpoint isn't enabled, so the temporary one won and had its
  action overwritten to log-only. It lost PAUSE and the step never came back.
- RemoveBreakPoint() erased up to two entries per address to catch an
  overlapping temporary one, so deleting either deleted both - including the
  interpreter's cleanup path in CheckExecBreakpoints() taking the user's
  breakpoint with it.
- ExecBreakPoint() handled one breakpoint per address, so with both at the same
  address only one of them did anything: the step completed but the user's log
  line never printed.
- Nothing dropped it when something *else* stopped us first, so an interrupted
  step left a breakpoint armed at an address nobody was waiting for anymore,
  which later fired as a phantom stop.

It's a single TempBreakPoint member now, invisible to the breakpoint lists and
untouched by user edits. One is enough: step over/out and cross-thread step into
all require the CPU to already be stepping and resume it immediately, so only
one can be in flight, and run-until now replaces rather than stacking (two
pending run-untils had no coherent meaning, and the loser stayed armed).

Behavior follows what other debuggers do. Both breakpoints at an address are
evaluated independently and their actions combine, so a log-only breakpoint
logs without stopping and still lets the step finish. Core_Break() drops the
temporary breakpoint on any stop, whatever the reason - the same way gdb deletes
its step-resume breakpoint and lldb discards the thread plan.

Two things to be careful of, both covered by the new TempBreakpoints test:
HasBreakPoints() has to account for it, or the interpreter's checked run loop
and the JIT skip breakpoint checking entirely and a step with no user
breakpoints set never returns; and IsAddressBreakPoint() (user-facing, for the
lists and disassembly markers) is now separate from NeedsBreakCheckAt() (what
the JIT frontends and interpreter ask), since only the latter should see it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
2026-08-17 00:29:26 +02:00
Henrik RydgårdandClaude Opus 5 0c510ca62e Add BreakpointManager::ChangeBreakPointAddress, use it from the ImDebugger
ChangeBreakPointAddress() moves the breakpoint keeping its action, condition and
log format, invalidates both ends, refuses to land on an existing breakpoint,
and resets the hit count since it belonged to the old address. The edit form now
works on a copy of the address and commits on deactivation rather than per
keystroke, so typing one address doesn't churn through every prefix of it.

The breakpoint edit form assigned straight to bp.addr and then invalidated the
icache at "bp.addr - 4, 8" - which by then is the *new* address - need both.

Also clear the selection after Delete in both edit forms - the reference into
the vector is dangling from that point on. Harmless today, but only because
nothing happens to touch it below.

Covered by a new Breakpoints unit test (verified to fail without the duplicate
check and the hit reset).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
2026-08-17 00:28:39 +02:00
Henrik Rydgård 0e15445b54 Fix memchecks 2026-08-16 23:09:15 +02:00
Henrik Rydgård 8d0d601b5b Clean up how the instruction cache is invalidated from the breakpoint manager 2026-08-16 18:10:02 +02:00
Henrik Rydgård f3d31846bb Enable breakpoint processing when stepping 2026-08-16 17:37:05 +02:00
Henrik Rydgård c457dbbd2f Debugger breakpoints: Rename "Result" to "Action" 2026-08-16 16:59:54 +02:00
Henrik Rydgård 1848262bea Style 2026-08-16 13:33:26 +02:00
Henrik RydgårdandClaude Sonnet 5 3edea91c8e Debugger: track hit counts on address breakpoints, expose via cpu.breakpoint.list
BreakPoint (cpu.breakpoint.*) had no hit-count tracking at all, unlike
MemCheck (memory.breakpoint.*), which already tracks numHits. This made it
genuinely hard to tell "this breakpoint is never being reached" apart from
"it's being reached but I'm not seeing the log/pause where I'm looking" -
directly informed by repeatedly hitting exactly that ambiguity while
debugging the VSH boot path this session (see docs/VSHBootInvestigation.md).

Added BreakPoint::numHits, incremented in BreakpointManager::ExecBreakPoint()
whenever a breakpoint's address is hit and any condition passes (matching
MemCheck::Apply()'s existing semantics - counts real triggers, not just
"execution passed through here"). Exposed as a new "hits" field in
cpu.breakpoint.list's response.

Verified live via PPSSPPHeadless + wsdbg: hits reads 0 before the CPU
resumes, 1 after the breakpoint fires once. UnitTest.exe all: 49/49 passed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
2026-08-14 11:04:32 +02:00
Henrik RydgårdandClaude Sonnet 5 db2d248b4a Rename GPRBreakpoint/gprBreakpoint to RegBreakpoint/regBreakpoint
The struct and its API only handle GPR indices today, but the naming
should stay general since this is expected to grow to cover other
register files too (e.g. FPU registers like $f10). Pure rename - no
behavior change:

- Core/Debugger/Breakpoints.{h,cpp}: RegBreakpoint struct, all
  BreakpointManager Add/Remove/Change/Get/Exec/Has/Find*RegBreakpoint*
  methods, regBreakpoints_/regBreakpointMask_ members.
- Core/Core.{h,cpp}: BreakReason::RegBreakpoint, "cpu.regBreakpoint"
  break-reason string.
- Core/Debugger/WebSocket/BreakpointSubscriber.{h,cpp}: WebSocket
  events cpu.gprBreakpoint.* -> cpu.regBreakpoint.*, matching
  Add/Update/Remove/List handlers and params struct.
- Core/MIPS/MIPSTables.cpp: local variable names in the interpreter's
  per-instruction breakpoint check.
- docs/WebSocketDebugger.md updated to match.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
2026-08-13 16:09:51 +02:00
Henrik RydgårdandClaude Sonnet 5 75174af77b Add GPR write breakpoints (break when a register is written, anywhere)
New debugging primitive: break whenever any instruction writes to a
given general-purpose register (0-31), regardless of which address
executes the write. Requested for continuing the reboot.bin trace,
where the actual blocker is "what sets $s3 to this bad value", not
"what happens at a specific address" - existing address/memory
breakpoints can't express that directly.

- GPRBreakpoint (Core/Debugger/Breakpoints.h) mirrors the existing
  BreakPoint/MemCheck shape (result/condition/logFormat/hit count),
  keyed by register index instead of address/range.
- BreakpointManager keeps a u32 bitmask (bit i = register i has an
  active breakpoint) alongside the GPRBreakpoint vector, so the
  interpreter loop can test "would this write trip anything" with a
  single shift+and against a value already cached in a local.
- RunUntilDowncountZeroWithChecks (Core/MIPS/MIPSTables.cpp) computes
  the about-to-be-written register from the current instruction's
  OUT_RT/OUT_RD/OUT_RA flags (GetGPRWriteTarget()) and checks it
  against the mask, same convention as the existing memcheck handling
  right above it (checked before the instruction executes, bails via
  CORE_STEPPING_CPU without running it if tripped).
- New BreakReason::GPRBreakpoint ("cpu.gprBreakpoint") for Core_Break.
- WebSocket API: cpu.gprBreakpoint.add/update/remove/list, accepting
  either a 0-31 'register' index or a case-insensitive 'name' (e.g.
  "s3"), documented in docs/WebSocketDebugger.md.

Interpreter-only for now, deliberately.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
2026-08-13 11:35:29 +02:00
Henrik RydgårdandClaude Sonnet 5 180becf883 BreakpointManager: remove internal locking, now redundant
Every caller either runs on the CPU thread already, routes mutations
through Core_RunOnCPUThread, or holds g_frameMutex for reads - audited
across WebSocket subscribers, the legacy Win32 debugger, ImDebugger, and
the JIT/interpreter backends. Also renames GetMemCheckLocked to
FindMemCheckInRange since it no longer implies a lock is held.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hqm11k99viLfbJm2MkH4BH
2026-08-08 17:22:12 +02:00
Henrik Rydgård 1f4d3b3b04 Minor code cleanup 2026-05-10 21:46:13 +02:00
Henrik Rydgård 2bfe327dbd Expose PSPThread in the same manner 2025-03-31 10:24:03 +02:00
Henrik Rydgård 4989ec61d9 BreakpointManager: Safer and simpler updates. 2025-03-03 13:59:42 +01:00
Henrik Rydgård 20a17a0e8d Reorganize DebugInterface etc a bit.
KernelThreadDebugInterface no longer has a useless copy of a MIPSDebugInterface.
2024-12-12 18:54:46 +01:00
Henrik Rydgård 20c4649963 Fix step over, other stepping issues 2024-11-25 19:02:17 +01:00
Henrik Rydgård 3cba1135d5 Add basic breakpoint editing window. Need UI refinement 2024-11-25 00:23:28 +01:00
Henrik Rydgård 7992ff4627 Make CBreakpoints an object 2024-11-25 00:22:53 +01:00
Herman Semenov 17ecee1715 Fixed return copies from functions and const ref params 2024-04-02 18:37:00 +03:00
Unknown W. Brackets c47e88529d Debugger: Add memory check conditions.
Currently, this isn't exposed anywhere.
2023-04-12 01:07:56 -07:00
Unknown W. Brackets 0f5859510e x86jit: Simplify memcheck handling.
Now it's mostly the same as the other jits.
2023-04-12 01:07:48 -07:00
Unknown W. Brackets e73474e590 Debugger: Cache memcheck ranges.
Rebuilding these can be a bit slow each time, speed up jit compilation by
caching them.
2023-04-05 17:13:00 -07:00
Unknown W. Brackets 0f79afa172 interp: Support memory breakpoints too. 2022-11-13 17:45:43 -08:00
Unknown W. Brackets 76cf4dbf12 interp: Allow breakpoints in release mode. 2022-11-13 16:52:40 -08:00
Unknown W. Brackets ee71ef961f Debugger: Keep char *s for memchecks. 2021-02-20 16:16:43 -08:00
Unknown W. Brackets 44a0c54538 Debugger: Log access reason on memory breakpoint. 2021-02-15 15:01:23 -08:00
Unknown W. Brackets b114656321 Debugger: Allow conditions on threadID/moduleID.
And now step over/out/into can tie to the correct thread.
2018-06-08 06:59:18 -07:00
Unknown W. Brackets b2cc4a0965 Debugger: Add memory breakpoint management. 2018-06-08 06:59:18 -07:00
Unknown W. Brackets 6cf24b34fc Debugger: Add thread safety to breakpoints. 2018-06-08 06:59:18 -07:00
Unknown W. Brackets eb4b59b530 arm64jit: Enable breakpoints.
Memory breakpoints not yet really tested.
2018-06-06 17:31:56 -07:00
Unknown W. Brackets 3c8cc5ab64 Debugger: Fix initialization issues.
Sometimes temp breakpoints had log set by accident.
2018-06-06 17:31:56 -07:00
Unknown W. Brackets 747a6ec524 Debugger: Add custom log expressions.
Similar to Visual Studio, just use {a1} to log the value of register a1.
Supports anything the expression parser supports.
2016-08-04 13:29:22 -07:00
Unknown W. Brackets e4ca124b0e Debugger: Add custom breakpoint log message. 2016-08-04 13:07:56 -07:00
Unknown W. Brackets 9972e5b10a Debugger: Allow logging on CPU breakpoints. 2016-08-04 12:39:29 -07:00
Unknown W. Brackets a9ad0cd471 Debugger: Make breakpoint actions more generic. 2016-08-04 12:02:44 -07:00
Unknown W. Brackets 4578c3cb54 jit-ir: Implement memory breakpoints.
These generally work, but likely delay slots will make downcount slightly
off, and won't resume when you hit run again without manually stepping
through them.
2016-07-02 16:38:30 -07:00
Unknown W. Brackets 9cb1151b67 x86jit: Disable replacements w/ breakpoints inside.
This does alter graphics (memcpys won't fire anymore), but it also means
breakpoints work which is nice.
2015-01-18 21:26:37 -08:00
Unknown W. Brackets fe2b62c27d Make the "on change" checkbox for memchecks work.
But, for now, only on sw and similar instructions, the rest don't work
yet and just always break.
2014-01-26 11:57:39 -08:00
Henrik Rydgård 00c32ddadb Mostly get rid of including "Globals.h" 2013-12-30 10:17:11 +01:00
Unknown W. Brackets da20bda729 Make memchecks ignore cached/uncached memory.
You usually want both.
2013-10-27 13:15:12 -07:00
Unknown W. Brackets 7349de55d1 Fix some initialization/sprintf warnings. 2013-09-01 01:15:07 -07:00
Kingcom 0eeebf5221 -display disabled breakpoints with separate icon
-toggling disabled breakpoints will enable them
-confirmation on toggling breakpoints with a custom condition
2013-07-10 10:56:03 +02:00
Kingcom 2521a88207 Use ChangeBreakPointAddCond function 2013-07-02 17:43:34 +02:00
Kingcom c41b08f9e2 Add expression parser to breakpoints 2013-07-02 11:51:29 +02:00
Unknown W. Brackets f3e27ad9dd Ensure only the very next instruction is skipped. 2013-06-30 16:35:49 -07:00
Unknown W. Brackets 9d8bdee089 Buffer the breakpoints in UI to avoid overflows. 2013-06-30 16:35:48 -07:00
Unknown W. Brackets 9209a30d9b Add skeleton for conditional breakpoints. 2013-06-30 16:35:47 -07:00
Unknown W. Brackets 6bd4383a8a Give memchecks/breakpoints a consistent interface.
Removes the limit on max breakpoints, and makes everything use accessors
for both that look roughly the same.
2013-06-30 15:16:58 -07:00
Unknown W. Brackets 609f8d6340 Allow hitting Go on a breakpoint to continue.
Doesn't work for branches though, because of delay slots.
2013-06-29 11:23:24 -07:00
Kingcom d4214af710 Breakpoint list at the bottom of the disassembly window 2013-06-27 21:07:49 +02:00