From babfe39bb73757136eeaa9c0ef1be5490124ee35 Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Mon, 10 Jul 2023 11:21:15 -0700 Subject: [PATCH] Don't call fireSimulatedContinuedEvent if the debug adapter sent a Stopped event before the response of the next/stepIn/etc request (#187215) * Don't call fireSimulatedContinuedEvent if the debug adapter sent a Stopped event before the response of the next/stepIn/etc request Fix #185785 * Fix typo --- .../contrib/debug/browser/rawDebugSession.ts | 42 +++++++++++++++---- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/src/vs/workbench/contrib/debug/browser/rawDebugSession.ts b/src/vs/workbench/contrib/debug/browser/rawDebugSession.ts index db8cd73120e..c7201795adf 100644 --- a/src/vs/workbench/contrib/debug/browser/rawDebugSession.ts +++ b/src/vs/workbench/contrib/debug/browser/rawDebugSession.ts @@ -76,6 +76,7 @@ export class RawDebugSession implements IDisposable { // DA events private readonly _onDidExitAdapter = new Emitter(); private debugAdapter: IDebugAdapter | null; + private stoppedSinceLastStep = false; private toDispose: IDisposable[] = []; @@ -122,6 +123,7 @@ export class RawDebugSession implements IDisposable { break; case 'stopped': this.didReceiveStoppedEvent = true; // telemetry: remember that debugger stopped successfully + this.stoppedSinceLastStep = true; this._onDidStop.fire(event); break; case 'continued': @@ -326,29 +328,41 @@ export class RawDebugSession implements IDisposable { } async next(args: DebugProtocol.NextArguments): Promise { + this.stoppedSinceLastStep = false; const response = await this.send('next', args); - this.fireSimulatedContinuedEvent(args.threadId); + if (!this.stoppedSinceLastStep) { + this.fireSimulatedContinuedEvent(args.threadId); + } return response; } async stepIn(args: DebugProtocol.StepInArguments): Promise { + this.stoppedSinceLastStep = false; const response = await this.send('stepIn', args); - this.fireSimulatedContinuedEvent(args.threadId); + if (!this.stoppedSinceLastStep) { + this.fireSimulatedContinuedEvent(args.threadId); + } return response; } async stepOut(args: DebugProtocol.StepOutArguments): Promise { + this.stoppedSinceLastStep = false; const response = await this.send('stepOut', args); - this.fireSimulatedContinuedEvent(args.threadId); + if (!this.stoppedSinceLastStep) { + this.fireSimulatedContinuedEvent(args.threadId); + } return response; } async continue(args: DebugProtocol.ContinueArguments): Promise { + this.stoppedSinceLastStep = false; const response = await this.send('continue', args); if (response && response.body && response.body.allThreadsContinued !== undefined) { this.allThreadsContinued = response.body.allThreadsContinued; } - this.fireSimulatedContinuedEvent(args.threadId, this.allThreadsContinued); + if (!this.stoppedSinceLastStep) { + this.fireSimulatedContinuedEvent(args.threadId, this.allThreadsContinued); + } return response; } @@ -380,8 +394,11 @@ export class RawDebugSession implements IDisposable { async restartFrame(args: DebugProtocol.RestartFrameArguments, threadId: number): Promise { if (this.capabilities.supportsRestartFrame) { + this.stoppedSinceLastStep = false; const response = await this.send('restartFrame', args); - this.fireSimulatedContinuedEvent(threadId); + if (!this.stoppedSinceLastStep) { + this.fireSimulatedContinuedEvent(threadId); + } return response; } return Promise.reject(new Error('restartFrame not supported')); @@ -484,8 +501,11 @@ export class RawDebugSession implements IDisposable { async stepBack(args: DebugProtocol.StepBackArguments): Promise { if (this.capabilities.supportsStepBack) { + this.stoppedSinceLastStep = false; const response = await this.send('stepBack', args); - this.fireSimulatedContinuedEvent(args.threadId); + if (!this.stoppedSinceLastStep) { + this.fireSimulatedContinuedEvent(args.threadId); + } return response; } return Promise.reject(new Error('stepBack not supported')); @@ -493,8 +513,11 @@ export class RawDebugSession implements IDisposable { async reverseContinue(args: DebugProtocol.ReverseContinueArguments): Promise { if (this.capabilities.supportsStepBack) { + this.stoppedSinceLastStep = false; const response = await this.send('reverseContinue', args); - this.fireSimulatedContinuedEvent(args.threadId); + if (!this.stoppedSinceLastStep) { + this.fireSimulatedContinuedEvent(args.threadId); + } return response; } return Promise.reject(new Error('reverseContinue not supported')); @@ -509,8 +532,11 @@ export class RawDebugSession implements IDisposable { async goto(args: DebugProtocol.GotoArguments): Promise { if (this.capabilities.supportsGotoTargetsRequest) { + this.stoppedSinceLastStep = false; const response = await this.send('goto', args); - this.fireSimulatedContinuedEvent(args.threadId); + if (!this.stoppedSinceLastStep) { + this.fireSimulatedContinuedEvent(args.threadId); + } return response; }