debug: introduce SessionExitedEvent and SessionTerminatedEvent

fixes #5598
This commit is contained in:
isidor 2016-04-21 14:48:35 +02:00
parent 4922eb1800
commit 1697eccfb1
2 changed files with 24 additions and 10 deletions

View file

@ -283,7 +283,7 @@ export class DebugService implements debug.IDebugService {
this.toDisposeOnSessionEnd.push(this.session.onDidTerminateDebugee(event => {
aria.status(nls.localize('debuggingStopped', "Debugging stopped."));
if (this.session && this.session.getId() === (<any>event).sessionId) {
if (this.session && this.session.getId() === event.body.sessionId) {
if (event.body && typeof event.body.restart === 'boolean' && event.body.restart) {
this.restartSession().done(null, err => this.messageService.show(severity.Error, err.message));
} else {
@ -321,7 +321,7 @@ export class DebugService implements debug.IDebugService {
if (this.session.configuration.type === 'extensionHost' && this._state === debug.State.RunningNoDebug) {
ipc.send('vscode:closeExtensionHostWindow', this.contextService.getWorkspace().resource.fsPath);
}
if (this.session && this.session.getId() === (<any>event.body).sessionId) {
if (this.session && this.session.getId() === event.body.sessionId) {
this.onSessionEnd();
}
}));

View file

@ -22,6 +22,20 @@ import { IMessageService, CloseAction } from 'vs/platform/message/common/message
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { shell } from 'electron';
export interface SessionExitedEvent extends DebugProtocol.ExitedEvent {
body: {
exitCode: number,
sessionId: string
};
}
export interface SessionTerminatedEvent extends DebugProtocol.TerminatedEvent {
body: {
restart?: boolean,
sessionId: string
};
}
export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSession {
public restarted: boolean;
@ -40,8 +54,8 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes
private _onDidInitialize: Emitter<DebugProtocol.InitializedEvent>;
private _onDidStop: Emitter<DebugProtocol.StoppedEvent>;
private _onDidTerminateDebugee: Emitter<DebugProtocol.TerminatedEvent>;
private _onDidExitAdapter: Emitter<DebugProtocol.ExitedEvent>;
private _onDidTerminateDebugee: Emitter<SessionTerminatedEvent>;
private _onDidExitAdapter: Emitter<SessionExitedEvent>;
private _onDidContinue: Emitter<void>;
private _onDidThread: Emitter<DebugProtocol.ThreadEvent>;
private _onDidOutput: Emitter<DebugProtocol.OutputEvent>;
@ -63,8 +77,8 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes
this._onDidInitialize = new Emitter<DebugProtocol.InitializedEvent>();
this._onDidStop = new Emitter<DebugProtocol.StoppedEvent>();
this._onDidTerminateDebugee = new Emitter<DebugProtocol.TerminatedEvent>();
this._onDidExitAdapter = new Emitter<DebugProtocol.ExitedEvent>();
this._onDidTerminateDebugee = new Emitter<SessionTerminatedEvent>();
this._onDidExitAdapter = new Emitter<SessionExitedEvent>();
this._onDidContinue = new Emitter<void>();
this._onDidThread = new Emitter<DebugProtocol.ThreadEvent>();
this._onDidOutput = new Emitter<DebugProtocol.OutputEvent>();
@ -80,11 +94,11 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes
return this._onDidStop.event;
}
public get onDidTerminateDebugee(): Event<DebugProtocol.TerminatedEvent> {
public get onDidTerminateDebugee(): Event<SessionTerminatedEvent> {
return this._onDidTerminateDebugee.event;
}
public get onDidExitAdapter(): Event<DebugProtocol.ExitedEvent> {
public get onDidExitAdapter(): Event<SessionExitedEvent> {
return this._onDidExitAdapter.event;
}
@ -177,10 +191,10 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes
this._onDidBreakpoint.fire(<DebugProtocol.BreakpointEvent>event);
} else if (event.event === 'terminated') {
this.flowEventsCount++;
this._onDidTerminateDebugee.fire(event);
this._onDidTerminateDebugee.fire(<SessionTerminatedEvent>event);
} else if (event.event === 'exit') {
this.flowEventsCount++;
this._onDidExitAdapter.fire(<DebugProtocol.ExitedEvent>event);
this._onDidExitAdapter.fire(<SessionExitedEvent>event);
} else if (event.event === 'continued') {
this.flowEventsCount++;
this._onDidContinue.fire();