Skip to content

Commit

Permalink
rawDebugSession implements IDisposable
Browse files Browse the repository at this point in the history
  • Loading branch information
isidorn committed Sep 12, 2019
1 parent 96665b6 commit e490d7c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/vs/workbench/contrib/debug/browser/debugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,7 @@ export class DebugSession implements IDebugSession {
dispose(this.rawListeners);
if (this.raw) {
this.raw.disconnect();
this.raw.dispose();
}
this.raw = undefined;
this.model.clearThreads(this.getId(), true);
Expand Down
17 changes: 12 additions & 5 deletions src/vs/workbench/contrib/debug/browser/rawDebugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { URI } from 'vs/base/common/uri';
import { IProcessEnvironment } from 'vs/base/common/platform';
import { env as processEnv } from 'vs/base/common/process';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';

/**
* This interface represents a single command line argument split into a "prefix" and a "path" half.
Expand All @@ -37,7 +38,7 @@ interface ILaunchVSCodeArguments {
/**
* Encapsulates the DebugAdapter lifecycle and some idiosyncrasies of the Debug Adapter Protocol.
*/
export class RawDebugSession {
export class RawDebugSession implements IDisposable {

private allThreadsContinued = true;
private _readyForBreakpoints = false;
Expand Down Expand Up @@ -70,6 +71,8 @@ export class RawDebugSession {
private readonly _onDidExitAdapter: Emitter<AdapterEndEvent>;
private debugAdapter: IDebugAdapter | null;

private toDispose: IDisposable[] = [];

constructor(
debugAdapter: IDebugAdapter,
dbgr: IDebugger,
Expand All @@ -96,18 +99,18 @@ export class RawDebugSession {

this._onDidExitAdapter = new Emitter<AdapterEndEvent>();

this.debugAdapter.onError(err => {
this.toDispose.push(this.debugAdapter.onError(err => {
this.shutdown(err);
});
}));

this.debugAdapter.onExit(code => {
this.toDispose.push(this.debugAdapter.onExit(code => {
if (code !== 0) {
this.shutdown(new Error(`exit code: ${code}`));
} else {
// normal exit
this.shutdown();
}
});
}));

this.debugAdapter.onEvent(event => {
switch (event.event) {
Expand Down Expand Up @@ -698,4 +701,8 @@ export class RawDebugSession {
this.customTelemetryService.publicLog('debugProtocolErrorResponse', { error: telemetryMessage });
}
}

dispose(): void {
dispose(this.toDispose);
}
}

0 comments on commit e490d7c

Please sign in to comment.