Skip to content

Track function breakpoints to fix DAP replace semantics#21

Merged
derekparker merged 3 commits into
masterfrom
fix/dap-function-breakpoints
Jun 17, 2026
Merged

Track function breakpoints to fix DAP replace semantics#21
derekparker merged 3 commits into
masterfrom
fix/dap-function-breakpoints

Conversation

@derekparker

Copy link
Copy Markdown
Member

DAP's SetFunctionBreakpointsRequest replaces all function breakpoints on each call. Previously, setting a new function breakpoint would silently remove any existing ones.

Add a functionBreakpoints slice to debuggerSession that tracks all active function breakpoints, with helper methods to add, remove, and clear them. All callers now go through these helpers to maintain the full list.

Also includes minor cleanups:

  • Use strings.Builder instead of string concatenation in tests
  • Use strings.SplitSeq and strings.Cut where appropriate
  • Fix DebugParams struct field alignment

derekparker and others added 3 commits June 2, 2026 15:38
DAP's SetFunctionBreakpointsRequest replaces all function breakpoints
on each call. Previously, setting a new function breakpoint would
silently remove any existing ones.

Add a `functionBreakpoints` slice to `debuggerSession` that tracks
all active function breakpoints, with helper methods to add, remove,
and clear them. All callers now go through these helpers to maintain
the full list.

Also includes minor cleanups:
- Use strings.Builder instead of string concatenation in tests
- Use strings.SplitSeq and strings.Cut where appropriate
- Fix DebugParams struct field alignment
Adds five new tests to verify the DAP spec compliance for line breakpoints:

- TestLineBreakpointTracking: Validates that multiple breakpoints in the
  same file are correctly tracked and both are hit during execution

- TestClearSpecificLineBreakpoint: Tests clearing individual line
  breakpoints via file+line while preserving other breakpoints in the
  same file

- TestMultipleFilesLineBreakpoints: Confirms that breakpoints across
  different files are tracked independently

- TestClearAllBreakpointsAcrossFiles: Verifies that clearing all
  breakpoints removes both line and function breakpoints across all files

- TestDuplicateLineBreakpoint: Ensures idempotency - setting the same
  breakpoint twice doesn't create duplicates

These tests validate the DAP replace semantics where each
setBreakpoints request sends the complete list of breakpoints for a
file, rather than incrementally adding/removing individual breakpoints.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Roll back tracked breakpoint list on DAP send failure in
  addFunctionBreakpoint and addLineBreakpoint to prevent state drift
  between the tracker and the adapter.

- Remove unverified breakpoints from both the tracked list and the
  adapter when the DAP response reports them as failed. Previously,
  phantom breakpoints were left in the tracked list.

- Support pending breakpoints (reason: 'pending') by keeping them in
  the tracked list and returning an informational message. This enables
  breakpoints on code in shared libraries or not-yet-loaded sources.

- Upgrade go-dap to latest main (d7a2259b058b) which adds the Reason
  field to dap.Breakpoint, enabling pending vs failed distinction.

- Fix TestClearAllBreakpointsAcrossFiles to use an executable line
  (line 10 instead of blank line 8).
@derekparker derekparker merged commit 5401543 into master Jun 17, 2026
1 check passed
@derekparker derekparker deleted the fix/dap-function-breakpoints branch June 17, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant