Track function breakpoints to fix DAP replace semantics#21
Merged
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DAP's SetFunctionBreakpointsRequest replaces all function breakpoints on each call. Previously, setting a new function breakpoint would silently remove any existing ones.
Add a
functionBreakpointsslice todebuggerSessionthat 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: