Skip to content

Commit

Permalink
[debug] Lazily update frames of all threads in all-stop mode
Browse files Browse the repository at this point in the history
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 <samuel.frylmark@ericsson.com>
  • Loading branch information
sfrylmark committed Feb 6, 2020
1 parent 0c01098 commit f5867d6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
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

0 comments on commit f5867d6

Please sign in to comment.