From f5867d6b1f0c256d191ea4fdf8a9855711773484 Mon Sep 17 00:00:00 2001 From: Samuel Frylmark Date: Thu, 9 Jan 2020 14:26:43 +0100 Subject: [PATCH] [debug] Lazily update frames of all threads in all-stop mode When a breakpoint occurs in a thread in all-stop mode, all other threads have outdated/missing stackframes which means no variables show up and can be inspected. This fixes the issue by marking each thread as potentially having "dirty" frames: frames that need to be re-fetched when the user selects them. Signed-off-by: Samuel Frylmark --- packages/debug/src/browser/debug-session.tsx | 8 +++++++- packages/debug/src/browser/model/debug-thread.tsx | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/debug/src/browser/debug-session.tsx b/packages/debug/src/browser/debug-session.tsx index 30cb93d9f00d0..d04990c67bbce 100644 --- a/packages/debug/src/browser/debug-session.tsx +++ b/packages/debug/src/browser/debug-session.tsx @@ -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 } }) => { @@ -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(); } } @@ -465,7 +471,7 @@ export class DebugSession implements CompositeTreeElement { protected async updateFrames(): Promise { const thread = this._currentThread; - if (!thread || thread.frameCount) { + if (!thread || thread.pendingFrameCount || thread.frameCount) { return; } if (this.capabilities.supportsDelayedStackTraceLoading) { diff --git a/packages/debug/src/browser/model/debug-thread.tsx b/packages/debug/src/browser/model/debug-thread.tsx index c5225bc202230..b9442b93128dd 100644 --- a/packages/debug/src/browser/model/debug-thread.tsx +++ b/packages/debug/src/browser/model/debug-thread.tsx @@ -140,7 +140,9 @@ export class DebugThread extends DebugThreadData implements TreeElement { } protected pendingFetch = Promise.resolve([]); + protected _pendingFetchCount: number = 0; async fetchFrames(levels: number = 20): Promise { + this._pendingFetchCount += 1; return this.pendingFetch = this.pendingFetch.then(async () => { try { const start = this.frameCount; @@ -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 { try { const response = await this.session.sendRequest('stackTrace',