Skip to content
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

Add debug API for call stack selection changes (63943) #179132

Merged
merged 13 commits into from Apr 17, 2023

Conversation

mblout
Copy link
Contributor

@mblout mblout commented Apr 4, 2023

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.

@mblout
Copy link
Contributor Author

mblout commented Apr 4, 2023

@microsoft-github-policy-service agree company="Coherent Logix"

src/vs/workbench/api/browser/mainThreadDebugService.ts Outdated Show resolved Hide resolved
src/vs/workbench/api/browser/mainThreadDebugService.ts Outdated Show resolved Hide resolved
src/vs/workbench/api/common/extHost.protocol.ts Outdated Show resolved Hide resolved
export interface IThreadFocusDto {
kind: 'thread';
threadId: number | undefined;
sessionId: string | undefined;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can sessionId or threadId actually be undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'd rather just have it reflect whatever is possible now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've changed the sessionId to always be defined.
the threadId may still be undefined, both for thread and stackframe focus events.

@@ -74,6 +75,10 @@ export class ViewModel implements IViewModel {
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, thanks. i've removed this comment. the comment later about firing only stackframe or thread focus should be enough

@@ -98,16 +103,24 @@ export class ViewModel implements IViewModel {
if (shouldEmitForSession) {
this._onDidFocusSession.fire(session);
}

// should not fire this if a stack frame focus is fired.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does "this" mean the thread event?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes,made the comment more clear, thanks

kind: 'thread';

/**
* Id of the debug session (DAP id).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an id

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, ooops, fixed comment, thanks!

roblourens
roblourens previously approved these changes Apr 17, 2023
Copy link
Member

@roblourens roblourens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

connor4312
connor4312 previously approved these changes Apr 17, 2023
@roblourens roblourens dismissed stale reviews from connor4312 and themself via 012d5c5 April 17, 2023 17:59
@roblourens roblourens enabled auto-merge (squash) April 17, 2023 18:42
@roblourens roblourens merged commit 2de3b04 into microsoft:main Apr 17, 2023
7 checks passed
@roblourens roblourens added this to the April 2023 milestone Apr 17, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jun 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants