From 3fe08d6af27b7809e2758a167e01d95c8cfde705 Mon Sep 17 00:00:00 2001 From: isidor Date: Fri, 11 Dec 2015 09:42:25 +0100 Subject: [PATCH] debug: introduce id to session. --- .../parts/debug/electron-browser/debugService.ts | 9 ++++----- src/vs/workbench/parts/debug/node/v8Protocol.ts | 8 ++++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/vs/workbench/parts/debug/electron-browser/debugService.ts b/src/vs/workbench/parts/debug/electron-browser/debugService.ts index 5e33926f896..9903aa7b511 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugService.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugService.ts @@ -270,12 +270,11 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService })); this.toDispose.push(this.session.addListener2(debug.SessionEvents.DEBUGEE_TERMINATED, (event: DebugProtocol.TerminatedEvent) => { - if (this.session) { + if (this.session && this.session.getId() === (event).sessionId) { this.session.disconnect().done(null, errors.onUnexpectedError); } })); - this.toDispose.push(this.session.addListener2(debug.SessionEvents.OUTPUT, (event: DebugProtocol.OutputEvent) => { if (event.body && typeof event.body.output === 'string' && event.body.output.length > 0) { this.onOutput(event); @@ -785,9 +784,9 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService if (!this.session) { return Promise.as(null); } - - var enabledExBreakpoints = this.model.getExceptionBreakpoints().filter(exb => exb.enabled); - return this.session.setExceptionBreakpoints({ filters: enabledExBreakpoints.map(exb => exb.name) }); + + var enabledExBreakpoints = this.model.getExceptionBreakpoints().filter(exb => exb.enabled); + return this.session.setExceptionBreakpoints({ filters: enabledExBreakpoints.map(exb => exb.name) }); } private onFileChanges(fileChangesEvent: FileChangesEvent): void { diff --git a/src/vs/workbench/parts/debug/node/v8Protocol.ts b/src/vs/workbench/parts/debug/node/v8Protocol.ts index 76c166d3f6c..34726c57acb 100644 --- a/src/vs/workbench/parts/debug/node/v8Protocol.ts +++ b/src/vs/workbench/parts/debug/node/v8Protocol.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import stream = require('stream'); +import uuid = require('vs/base/common/uuid'); import ee = require('vs/base/common/eventEmitter'); import { Promise, TPromise } from 'vs/base/common/winjs.base'; import debug = require('vs/workbench/parts/debug/common/debug'); @@ -18,6 +19,7 @@ export class V8Protocol extends ee.EventEmitter { private sequence: number; private pendingRequests: { [id: number]: (e: DebugProtocol.Response) => void; }; private rawData: Buffer; + private id: string; private contentLength: number; constructor() { @@ -28,6 +30,7 @@ export class V8Protocol extends ee.EventEmitter { this.contentLength = -1; this.pendingRequests = {}; this.rawData = new Buffer(0); + this.id = uuid.generateUuid(); } public emit(eventType: string, data?: any): void { @@ -38,10 +41,15 @@ export class V8Protocol extends ee.EventEmitter { eventType === debug.SessionEvents.DEBUGEE_TERMINATED || eventType === debug.SessionEvents.SERVER_EXIT) { this.flowEventsCount++; } + data.sessionId = this.getId(); super.emit(eventType, data); } + public getId(): string { + return this.id; + } + protected connect(readable: stream.Readable, writable: stream.Writable): void { this.outputStream = writable; -- GitLab