Closed haneefdm closed 2 years ago
What frame do you want your expression evaluated in? Ideally VS Code would expose a way to obtain the current frame. I opened an issue on them long ago, but it is still active: https://github.com/microsoft/vscode/issues/63943
Hello, @gregg-miskelly I am looking for answers/guidance myself. No one right answer given I have gdb as the debugger.
The letter/spirit of the DAP says, to evaluate in the global scope. Not sure how to do that in gdb though (maybe I missed that)
Ideally VS Code would expose a way to obtain the current frame
Wouldn't that be nice :-) I wanted an event that clients could subscribe to. The Watch/Variable windows always evaluate according to the selected frame. I just wanted the same luxury for other clients
In the end, I want to see if we can figure out together what frameId === undefined
means. Maybe we can get that documented in the DAP in cases where there is no definition of global
scope?
I don't think there is a way to both make this work in VS Code (until https://github.com/microsoft/vscode/issues/63943 is fixed) and also strictly adhere to the DAP.
I think there are two possible paths forward:
evaluate
requests from extensions must hack around the VS Code limitation by guessing that if frame id is missing, this indicates a request to evaluate in the 'current' frame, where a debug adapter can guess (possibly incorrectly) what the current frame is by keeping an internal variable which is set thusly:
stopped
event is sent: remember the top frame idscopes
request is received: remember the requested frameWhen a stopped event is sent: remember the top frame id When a scopes request is received: remember the requested frame
AFAIK, this would be inaccurate and seem random as the scopes request is not repeated and users can jump around, so not clear which frame it would be after a while. I was thinking that if the frameId is missing, we could always apply the request to top frame of the stopped-thread-id. At least that would be consistent.
I can volunteer to try and submit a PR for https://github.com/microsoft/vscode/issues/63943 but its likelihood of getting accepted is pretty low don't you think? It's been there since 2018. We always get referred back to using the tracker mechanism.
If they don't repeat scopes
then I don't see how we can really make this work at all. I don't know how open VS Code would be to accepting a PR. But I think it is the only way to accomplish what you are trying to do.
@gregg-miskelly I can positively confirm that the scopes is cached by VSCode and only called once. So, there is not much to hang our hat on.
Neither of us are honouring the DAP spec for an undefined frameId and it will remain so.
/**
* Evaluate the expression in the scope of this stack frame. If not specified,
* the expression is evaluated in the global scope.
*/
frameId?: number;
I will close this Issue and and get it out of your queue.
I am trying to figure out how best to evaluate expressions as a client and what to do with
frameId
during an evaluateAccording to the DAP, if
frameId
is undefined, then means global scopeIf
frameId
is undefined, I get this and the debug session actually ends/hangs (as in not much works afterward and the only thing that works is Ending the session) -- that should be a separate issue.Yes, I can make a request for a stackTrace and then use any one of the frameId's, but that is extra, unnecessary work for clients.
Note that I am using the context as
hover
as I wasn't sure which one would be more appropriate. Should I be using something else? I am using this for memory views and RTOS views discussed hereWe ourselves end up using the current scope when no frameId is specified. But with a warning which we are thinking of removing. I do not know how to specify global scope in gdb machine interface. We know current-scope could be anything depending on what transpired before.
I want us to provide some compatible interface on how to deal with outliers. Please let me know what we should do and I can duplicate that in my DA
Cc: @benmcmorran