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

Lazily update frames of all threads in all-stop mode #6869

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/debug/src/browser/debug-session.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ export class DebugSession implements CompositeTreeElement {
}
}),
this.on('stopped', async ({ body }) => {
// Update thread list
await this.updateThreads(body);

// Update current thread's frames immediately
await this.updateFrames();
}),
this.on('thread', ({ body: { reason, threadId } }) => {
Expand Down Expand Up @@ -221,6 +224,9 @@ export class DebugSession implements CompositeTreeElement {
this.fireDidChange();
if (thread) {
this.toDisposeOnCurrentThread.push(thread.onDidChanged(() => this.fireDidChange()));

// If this thread is missing stack frame information, then load that.
this.updateFrames();
}
}

Expand Down Expand Up @@ -465,7 +471,7 @@ export class DebugSession implements CompositeTreeElement {

protected async updateFrames(): Promise<void> {
const thread = this._currentThread;
if (!thread || thread.frameCount) {
if (!thread || thread.pendingFrameCount || thread.frameCount) {
return;
}
if (this.capabilities.supportsDelayedStackTraceLoading) {
Expand Down
7 changes: 7 additions & 0 deletions packages/debug/src/browser/model/debug-thread.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ export class DebugThread extends DebugThreadData implements TreeElement {
}

protected pendingFetch = Promise.resolve<DebugStackFrame[]>([]);
protected _pendingFetchCount: number = 0;
async fetchFrames(levels: number = 20): Promise<DebugStackFrame[]> {
this._pendingFetchCount += 1;
return this.pendingFetch = this.pendingFetch.then(async () => {
try {
const start = this.frameCount;
Expand All @@ -149,9 +151,14 @@ export class DebugThread extends DebugThreadData implements TreeElement {
} catch (e) {
console.error(e);
return [];
} finally {
this._pendingFetchCount -= 1;
}
});
}
get pendingFrameCount(): number {
return this._pendingFetchCount;
}
protected async doFetchFrames(startFrame: number, levels: number): Promise<DebugProtocol.StackFrame[]> {
try {
const response = await this.session.sendRequest('stackTrace',
Expand Down