-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Ensure debug adapter request/response sequence numbers tally #14336
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
Changes from 2 commits
18140b7
a0901e8
1085adf
140d233
475e0d7
7c299ce
35d9f38
4c4e8d8
26096b0
dcf9b3f
455c76c
b4f0184
06803f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { DebugProtocol } from 'vscode-debugprotocol'; | ||
|
|
||
| export class DebugStackTraceTracker { | ||
| protected topMostFrameId = 0; | ||
| protected stackFrameRequestSequenceNumber: number = -1; // Keep track of the sequence number | ||
|
|
||
| public onDidSendMessage(message: DebugProtocol.Response) { | ||
| if ( | ||
| message.type === 'response' && | ||
| message.command === 'stackTrace' && | ||
| message.body.stackFrames[0] && | ||
| message.request_seq === this.stackFrameRequestSequenceNumber | ||
| ) { | ||
| // This should be the top frame. We need to use this to compute the value of a variable | ||
| this.topMostFrameId = message.body.stackFrames[0].id; | ||
|
Author
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. This feels inconsistent because this state is only needed in debuggerVariables.ts, but here I've made it shared, and the equivalent state for debugLocationTracker.ts still lives in that class and not here. Wanted people's thoughts on whether I should either
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. I vote for 1. 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. This class's job is to track the list of stack frames. That shouldn't be done elsewhere. I'd say you could probably put almost all (if not all) of the code from the DebugLocationTracker here. Isn't the DebuggerVariable class really just a subclass of something that's tracking stack frames? 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. Meaning you'd have this class hierarchy instead: DebugVariables extends DebugLocationTracker
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. Given the name / function of this class as I read it #1 makes more sense. |
||
| } | ||
| } | ||
|
|
||
| public onWillReceiveMessage(message: DebugProtocol.Request) { | ||
| if (message.type === 'request' && message.command === 'stackTrace' && message.arguments.startFrame === 0) { | ||
|
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. From the specification this is not quite right I believe. Looks like startFrame === 0 or startFrame not being defined means to fetch everything. I think this might not handle the undefined case.
Author
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. Good catch, I missed that when looking at the spec. Thank you! |
||
| // VSCode sometimes sends multiple stackTrace requests. The true topmost frame is determined | ||
| // based on the response to a stackTrace request where the startFrame is 0 (i.e. this request | ||
| // retrieves all frames). Here, remember the sequence number of the outgoing request whose | ||
| // startFrame === 0, and update this.topMostFrameId only when we receive the response with a | ||
| // matching sequence number. | ||
| this.stackFrameRequestSequenceNumber = message.seq; | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need
implements DebugAdapterTracker?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, because DebugLocationTracker has other custom message handling besides what is handled in the base class, so it still needs to be able to intercept DAP messages via
onDidSendMessageandonWillReceiveMessage.