-
Notifications
You must be signed in to change notification settings - Fork 87
debug: fallback to mark breakpoints verified on stopped/breakpoint events #1989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
amanthatdoescares
wants to merge
12
commits into
swiftlang:main
Choose a base branch
from
amanthatdoescares:fix/breakpoint-verified-fallback
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
953bdc6
debug: fallback to mark breakpoints verified on stopped/breakpoint ev…
amanthatdoescares 71fe19d
Apply suggestions from code review
amanthatdoescares a1ceb6e
Use location-based breakpoint filtering, add logger, normalize paths
amanthatdoescares 986a683
Changelog: normalize adapter source.path for breakpoint fallback
amanthatdoescares 4079504
Remove duplicate vscode-tmgrammar-test dependency
amanthatdoescares 42a6748
Remove duplicate license entry in package-lock.json
amanthatdoescares 9f1a63a
Update src/debugger/logTracker.ts
amanthatdoescares a745d3a
Refine breakpoint fallback handling
amanthatdoescares 5046758
Update changelog
amanthatdoescares 2aa099b
Update CHANGELOG to remove version 2.14.2
amanthatdoescares dc97cc4
Update CHANGELOG with new features and fixes
amanthatdoescares d51fdf1
Merge branch 'main' into fix/breakpoint-verified-fallback
amanthatdoescares File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,6 +114,8 @@ export class LoggingDebugAdapterTracker implements vscode.DebugAdapterTracker { | |
| return; | ||
| } | ||
|
|
||
| this.handleBreakpointFallback(debugMessage); | ||
|
|
||
| if (debugMessage.event === "exited" && debugMessage.body.exitCode) { | ||
| this.exitCode = debugMessage.body.exitCode; | ||
| this.exitHandler?.(debugMessage.body.exitCode); | ||
|
|
@@ -131,6 +133,102 @@ export class LoggingDebugAdapterTracker implements vscode.DebugAdapterTracker { | |
| } | ||
| } | ||
|
|
||
| private handleBreakpointFallback(rawMsg: unknown): void { | ||
| try { | ||
| // Minimal typed view of the event payload we care about. | ||
| type FrameLike = { source?: { path?: string }; line?: number }; | ||
| type BodyLike = { | ||
amanthatdoescares marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| exitCode?: number; | ||
| category?: string; | ||
| output?: string; | ||
| reason?: string; | ||
| thread?: { frames?: FrameLike[] }; | ||
| source?: { path?: string }; | ||
| line?: number; | ||
| }; | ||
|
|
||
| const msg = rawMsg as { type?: string; event?: string; body?: BodyLike | undefined }; | ||
| if (!msg || msg.type !== "event") { | ||
| return; | ||
| } | ||
|
|
||
| // Case A: stopped event with reason = "breakpoint" | ||
| if (msg.event === "stopped" && msg.body?.reason === "breakpoint") { | ||
| const frames = msg.body.thread?.frames; | ||
| if (!Array.isArray(frames) || frames.length === 0) { | ||
| return; | ||
| } | ||
|
|
||
| const top = frames[0]; | ||
| const sourcePath = top?.source?.path; | ||
| const line = top?.line; | ||
| if (!sourcePath || typeof line !== "number") { | ||
| return; | ||
| } | ||
|
|
||
| const bpLine0 = line - 1; // VS Code uses 0-based lines | ||
|
|
||
| const breakpoints = vscode.debug.breakpoints.filter( | ||
matthewbastien marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| b => b instanceof vscode.SourceBreakpoint | ||
amanthatdoescares marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) as vscode.SourceBreakpoint[]; | ||
|
|
||
| for (const bp of breakpoints) { | ||
| const loc = bp.location; | ||
| if (!loc) { | ||
matthewbastien marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| continue; | ||
| } | ||
| if (loc.uri.fsPath !== sourcePath) { | ||
amanthatdoescares marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| continue; | ||
| } | ||
| if (loc.range.start.line !== bpLine0) { | ||
| continue; | ||
| } | ||
|
|
||
| // Force a UI refresh so the breakpoint shows as installed. | ||
| vscode.debug.removeBreakpoints([bp]); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: Will this also trigger when the breakpoint is already resolved? It's probably not a huge issue, but I think we should be only doing this when the breakpoint that's being hit isn't marked as resolved. |
||
| vscode.debug.addBreakpoints([bp]); | ||
| break; | ||
| } | ||
| return; | ||
| } | ||
|
|
||
| // Case B: explicit "breakpoint" event that carries source+line info | ||
| if (msg.event === "breakpoint" && msg.body) { | ||
| const sourcePath = msg.body.source?.path; | ||
| const line = msg.body.line; | ||
| if (!sourcePath || typeof line !== "number") { | ||
| return; | ||
| } | ||
|
|
||
| const bpLine0 = line - 1; | ||
| const breakpoints = vscode.debug.breakpoints.filter( | ||
| b => b instanceof vscode.SourceBreakpoint | ||
| ) as vscode.SourceBreakpoint[]; | ||
|
|
||
| for (const bp of breakpoints) { | ||
| const loc = bp.location; | ||
| if (!loc) { | ||
| continue; | ||
| } | ||
| if (loc.uri.fsPath !== sourcePath) { | ||
| continue; | ||
| } | ||
| if (loc.range.start.line !== bpLine0) { | ||
| continue; | ||
| } | ||
|
|
||
| vscode.debug.removeBreakpoints([bp]); | ||
| vscode.debug.addBreakpoints([bp]); | ||
| break; | ||
| } | ||
| return; | ||
| } | ||
| } catch (err) { | ||
| // eslint-disable-next-line no-console | ||
| console.error("Breakpoint fallback error:", err); | ||
amanthatdoescares marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
|
||
| /** | ||
| * The debug adapter session is about to be stopped. Delete the session from | ||
| * the tracker | ||
|
|
||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.