Add debug API for call stack selection changes (63943)#179132
Conversation
selection (microsoft#63943) Add debug.onDidChangeDebugFocus. May provide ids for session, thread, and stackFrame, as appropriate. Fixes: microsoft#63943 api should provide thread/stack frame id (paraphrasing)
listeners, and create separate contexts for each
This reverts commit c308bc3.
|
@microsoft-github-policy-service agree company="Coherent Logix" |
| export interface IThreadFocusDto { | ||
| kind: 'thread'; | ||
| threadId: number | undefined; | ||
| sessionId: string | undefined; |
There was a problem hiding this comment.
Can sessionId or threadId actually be undefined?
There was a problem hiding this comment.
currently, no, but i wanted to allow for it for the future? seemed easier to allow it now, than change to allow it later?
but i barely have any feeling about that, it seemed far-fetched that the 'thread' event should be used when there is no session, so i can make whatever change you suggest. thanks!
There was a problem hiding this comment.
Yeah, I'd rather just have it reflect whatever is possible now
There was a problem hiding this comment.
i've changed the sessionId to always be defined.
the threadId may still be undefined, both for thread and stackframe focus events.
| setFocus(stackFrame: IStackFrame | undefined, thread: IThread | undefined, session: IDebugSession | undefined, explicit: boolean): void { | ||
| const shouldEmitForStackFrame = this._focusedStackFrame !== stackFrame; | ||
| const shouldEmitForSession = this._focusedSession !== session; | ||
| // currently, it does not happen that shouldEmitForThread === true, but shouldEmitForStackFrame === false. |
There was a problem hiding this comment.
Sorry, I don't follow this comment. If I select a different thread under the same frame, I think I would expect it to fire for thread but not for stackframe, is that right?
There was a problem hiding this comment.
i don't understand; isn't it flipped, we select stack frames under threads?
there's two things: when you select a thread, the model always then sets the focus to a stack frame; you can't get a 'thread focused' event currently, but i wanted to allow for it. (I didn't want to introduce that yet, because its not required for my use case, and can be added later without changing this API).
Also, during my debugging, the stack frame comparison never was 'they do equal each other' because its using exact comparison, and they were always different objects. Didn't want to change due to risk, and also, the change was not needed to simply allow extensions to know about selection state.
Thanks for the comment - did this make sense? Wanted to make sure i understood your question before changing anything here.
There was a problem hiding this comment.
Yeah, I don't know what I was thinking, I looked at this for too long and got it mixed up in my head.
And re: the object comparison, I can look into it, but I would assume that object comparison should be ok, and we will for example create new stack frame objects on every step, and then it's a different frame and should fire the event.
There was a problem hiding this comment.
ok, thanks. i've removed this comment. the comment later about firing only stackframe or thread focus should be enough
| this._onDidFocusSession.fire(session); | ||
| } | ||
|
|
||
| // should not fire this if a stack frame focus is fired. |
There was a problem hiding this comment.
Does "this" mean the thread event?
There was a problem hiding this comment.
yes,made the comment more clear, thanks
| kind: 'thread'; | ||
|
|
||
| /** | ||
| * Id of the debug session (DAP id). |
There was a problem hiding this comment.
yep, ooops, fixed comment, thanks!
roblourens
left a comment
There was a problem hiding this comment.
Thanks for the PR, I think this is enough to get started. Having the multiple internal events, one per type, feels a bit weird, it seems like there should be one event for the focused thing in the callstack view. But that code was already partly there and I can clean it up later if needed.
for #63943
Adds a new API to the debug namespace to add listeners to selection changes to call stack selection changes.
This allows listeners to know when focus has changed, allowing additional custom debug views to show information for the selection context, just as the build-in views do (variables, etc).
This is additive; it does not change any existing APIs, and just taps into the current call stack selection.