Skip to content

Commit babfe39

Browse files
authored
Don't call fireSimulatedContinuedEvent if the debug adapter sent a Stopped event before the response of the next/stepIn/etc request (microsoft#187215)
* Don't call fireSimulatedContinuedEvent if the debug adapter sent a Stopped event before the response of the next/stepIn/etc request Fix microsoft#185785 * Fix typo
1 parent 7dbc6ec commit babfe39

File tree

1 file changed

+34
-8
lines changed

1 file changed

+34
-8
lines changed

src/vs/workbench/contrib/debug/browser/rawDebugSession.ts

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export class RawDebugSession implements IDisposable {
7676
// DA events
7777
private readonly _onDidExitAdapter = new Emitter<AdapterEndEvent>();
7878
private debugAdapter: IDebugAdapter | null;
79+
private stoppedSinceLastStep = false;
7980

8081
private toDispose: IDisposable[] = [];
8182

@@ -122,6 +123,7 @@ export class RawDebugSession implements IDisposable {
122123
break;
123124
case 'stopped':
124125
this.didReceiveStoppedEvent = true; // telemetry: remember that debugger stopped successfully
126+
this.stoppedSinceLastStep = true;
125127
this._onDidStop.fire(<DebugProtocol.StoppedEvent>event);
126128
break;
127129
case 'continued':
@@ -326,29 +328,41 @@ export class RawDebugSession implements IDisposable {
326328
}
327329

328330
async next(args: DebugProtocol.NextArguments): Promise<DebugProtocol.NextResponse | undefined> {
331+
this.stoppedSinceLastStep = false;
329332
const response = await this.send('next', args);
330-
this.fireSimulatedContinuedEvent(args.threadId);
333+
if (!this.stoppedSinceLastStep) {
334+
this.fireSimulatedContinuedEvent(args.threadId);
335+
}
331336
return response;
332337
}
333338

334339
async stepIn(args: DebugProtocol.StepInArguments): Promise<DebugProtocol.StepInResponse | undefined> {
340+
this.stoppedSinceLastStep = false;
335341
const response = await this.send('stepIn', args);
336-
this.fireSimulatedContinuedEvent(args.threadId);
342+
if (!this.stoppedSinceLastStep) {
343+
this.fireSimulatedContinuedEvent(args.threadId);
344+
}
337345
return response;
338346
}
339347

340348
async stepOut(args: DebugProtocol.StepOutArguments): Promise<DebugProtocol.StepOutResponse | undefined> {
349+
this.stoppedSinceLastStep = false;
341350
const response = await this.send('stepOut', args);
342-
this.fireSimulatedContinuedEvent(args.threadId);
351+
if (!this.stoppedSinceLastStep) {
352+
this.fireSimulatedContinuedEvent(args.threadId);
353+
}
343354
return response;
344355
}
345356

346357
async continue(args: DebugProtocol.ContinueArguments): Promise<DebugProtocol.ContinueResponse | undefined> {
358+
this.stoppedSinceLastStep = false;
347359
const response = await this.send<DebugProtocol.ContinueResponse>('continue', args);
348360
if (response && response.body && response.body.allThreadsContinued !== undefined) {
349361
this.allThreadsContinued = response.body.allThreadsContinued;
350362
}
351-
this.fireSimulatedContinuedEvent(args.threadId, this.allThreadsContinued);
363+
if (!this.stoppedSinceLastStep) {
364+
this.fireSimulatedContinuedEvent(args.threadId, this.allThreadsContinued);
365+
}
352366

353367
return response;
354368
}
@@ -380,8 +394,11 @@ export class RawDebugSession implements IDisposable {
380394

381395
async restartFrame(args: DebugProtocol.RestartFrameArguments, threadId: number): Promise<DebugProtocol.RestartFrameResponse | undefined> {
382396
if (this.capabilities.supportsRestartFrame) {
397+
this.stoppedSinceLastStep = false;
383398
const response = await this.send('restartFrame', args);
384-
this.fireSimulatedContinuedEvent(threadId);
399+
if (!this.stoppedSinceLastStep) {
400+
this.fireSimulatedContinuedEvent(threadId);
401+
}
385402
return response;
386403
}
387404
return Promise.reject(new Error('restartFrame not supported'));
@@ -484,17 +501,23 @@ export class RawDebugSession implements IDisposable {
484501

485502
async stepBack(args: DebugProtocol.StepBackArguments): Promise<DebugProtocol.StepBackResponse | undefined> {
486503
if (this.capabilities.supportsStepBack) {
504+
this.stoppedSinceLastStep = false;
487505
const response = await this.send('stepBack', args);
488-
this.fireSimulatedContinuedEvent(args.threadId);
506+
if (!this.stoppedSinceLastStep) {
507+
this.fireSimulatedContinuedEvent(args.threadId);
508+
}
489509
return response;
490510
}
491511
return Promise.reject(new Error('stepBack not supported'));
492512
}
493513

494514
async reverseContinue(args: DebugProtocol.ReverseContinueArguments): Promise<DebugProtocol.ReverseContinueResponse | undefined> {
495515
if (this.capabilities.supportsStepBack) {
516+
this.stoppedSinceLastStep = false;
496517
const response = await this.send('reverseContinue', args);
497-
this.fireSimulatedContinuedEvent(args.threadId);
518+
if (!this.stoppedSinceLastStep) {
519+
this.fireSimulatedContinuedEvent(args.threadId);
520+
}
498521
return response;
499522
}
500523
return Promise.reject(new Error('reverseContinue not supported'));
@@ -509,8 +532,11 @@ export class RawDebugSession implements IDisposable {
509532

510533
async goto(args: DebugProtocol.GotoArguments): Promise<DebugProtocol.GotoResponse | undefined> {
511534
if (this.capabilities.supportsGotoTargetsRequest) {
535+
this.stoppedSinceLastStep = false;
512536
const response = await this.send('goto', args);
513-
this.fireSimulatedContinuedEvent(args.threadId);
537+
if (!this.stoppedSinceLastStep) {
538+
this.fireSimulatedContinuedEvent(args.threadId);
539+
}
514540
return response;
515541
}
516542

0 commit comments

Comments
 (0)