提交 673bf004 编写于 作者: I isidor

Revert "debug: send events to adapter in a queue. Step requests cancel all pending requests"

This reverts commit 259ff5f9.
上级 3a440172
......@@ -1224,7 +1224,7 @@ export class DebugService implements debug.IDebugService {
const sendBreakpointsToSession = (session: debug.ISession): TPromise<void> => {
const raw = <RawDebugSession>session.raw;
if (!raw.initialised) {
if (!raw.readyForBreakpoints) {
return TPromise.as(null);
}
......@@ -1274,7 +1274,7 @@ export class DebugService implements debug.IDebugService {
private sendFunctionBreakpoints(session?: debug.ISession): TPromise<void> {
const sendFunctionBreakpointsToSession = (session: debug.ISession): TPromise<void> => {
const raw = <RawDebugSession>session.raw;
if (!raw.initialised || !raw.capabilities.supportsFunctionBreakpoints) {
if (!raw.readyForBreakpoints || !raw.capabilities.supportsFunctionBreakpoints) {
return TPromise.as(null);
}
......@@ -1299,7 +1299,7 @@ export class DebugService implements debug.IDebugService {
private sendExceptionBreakpoints(session?: debug.ISession): TPromise<void> {
const sendExceptionBreakpointsToSession = (session: debug.ISession): TPromise<any> => {
const raw = <RawDebugSession>session.raw;
if (!raw.initialised || this.model.getExceptionBreakpoints().length === 0) {
if (!raw.readyForBreakpoints || this.model.getExceptionBreakpoints().length === 0) {
return TPromise.as(null);
}
......
......@@ -17,7 +17,6 @@ import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { formatPII } from 'vs/workbench/parts/debug/common/debugUtils';
import { SocketDebugAdapter } from 'vs/workbench/parts/debug/node/debugAdapter';
import { Queue } from 'vs/base/common/async';
export interface SessionExitedEvent extends debug.DebugEvent {
......@@ -39,12 +38,12 @@ export class RawDebugSession implements debug.IRawSession {
private debugAdapter: debug.IDebugAdapter;
public emittedStopped: boolean;
public initialised: boolean;
public readyForBreakpoints: boolean;
private cachedInitServerP: TPromise<void>;
private startTime: number;
public disconnected: boolean;
private requestQueue = new Queue();
private sentPromises: TPromise<DebugProtocol.Response>[];
private _capabilities: DebugProtocol.Capabilities;
private allThreadsContinued: boolean;
......@@ -71,26 +70,9 @@ export class RawDebugSession implements debug.IRawSession {
@IOutputService private outputService: IOutputService
) {
this.emittedStopped = false;
this.initialised = false;
this.readyForBreakpoints = false;
this.allThreadsContinued = true;
this.requestQueue.queue(() => {
if (this.cachedInitServerP) {
return this.cachedInitServerP;
}
const startSessionP = this.startSession();
this.cachedInitServerP = startSessionP.then(() => {
this.startTime = new Date().getTime();
}, err => {
this.cachedInitServerP = null;
return TPromise.wrapError(err);
});
return this.cachedInitServerP;
});
this.sentPromises = [];
this._onDidInitialize = new Emitter<DebugProtocol.InitializedEvent>();
this._onDidStop = new Emitter<DebugProtocol.StoppedEvent>();
......@@ -153,6 +135,24 @@ export class RawDebugSession implements debug.IRawSession {
return this._onDidEvent.event;
}
private initServer(): TPromise<void> {
if (this.cachedInitServerP) {
return this.cachedInitServerP;
}
const startSessionP = this.startSession();
this.cachedInitServerP = startSessionP.then(() => {
this.startTime = new Date().getTime();
}, err => {
this.cachedInitServerP = null;
return TPromise.wrapError(err);
});
return this.cachedInitServerP;
}
private startSession(): TPromise<void> {
return this._debugger.createDebugAdapter(this.root, this.outputService, this.debugServerPort).then(debugAdapter => {
......@@ -173,7 +173,7 @@ export class RawDebugSession implements debug.IRawSession {
}
private send<R extends DebugProtocol.Response>(command: string, args: any, cancelOnDisconnect = true): TPromise<R> {
return this.requestQueue.queue(() => {
return this.initServer().then(() => {
const promise = this.internalSend<R>(command, args).then(response => response, (errorResponse: DebugProtocol.ErrorResponse) => {
const error = errorResponse && errorResponse.body ? errorResponse.body.error : null;
const errorMessage = errorResponse ? errorResponse.message : '';
......@@ -208,6 +208,9 @@ export class RawDebugSession implements debug.IRawSession {
return errors.isPromiseCanceledError(errorResponse) ? undefined : TPromise.wrapError<R>(new Error(userMessage));
});
if (cancelOnDisconnect) {
this.sentPromises.push(promise);
}
return promise;
});
}
......@@ -230,7 +233,7 @@ export class RawDebugSession implements debug.IRawSession {
event.sessionId = this.id;
if (event.event === 'initialized') {
this.initialised = true;
this.readyForBreakpoints = true;
this._onDidInitialize.fire(event);
} else if (event.event === 'capabilities' && event.body) {
const capabilites = (<DebugProtocol.CapabilitiesEvent>event).body.capabilities;
......@@ -282,17 +285,7 @@ export class RawDebugSession implements debug.IRawSession {
return this.send('attach', args).then(response => this.readCapabilities(response));
}
private clearRequestQueue(): void {
// If the debug session is initialitised it is fine to clear all pending requests
// This is mostly done by "step" requests which change the state of the debuggee
// Thus canceling other requests like "variables" and "evaluate" makes snese
if (this.initialised) {
this.requestQueue.cancel();
}
}
public next(args: DebugProtocol.NextArguments): TPromise<DebugProtocol.NextResponse> {
this.clearRequestQueue();
return this.send('next', args).then(response => {
this.fireFakeContinued(args.threadId);
return response;
......@@ -300,7 +293,6 @@ export class RawDebugSession implements debug.IRawSession {
}
public stepIn(args: DebugProtocol.StepInArguments): TPromise<DebugProtocol.StepInResponse> {
this.clearRequestQueue();
return this.send('stepIn', args).then(response => {
this.fireFakeContinued(args.threadId);
return response;
......@@ -308,7 +300,6 @@ export class RawDebugSession implements debug.IRawSession {
}
public stepOut(args: DebugProtocol.StepOutArguments): TPromise<DebugProtocol.StepOutResponse> {
this.clearRequestQueue();
return this.send('stepOut', args).then(response => {
this.fireFakeContinued(args.threadId);
return response;
......@@ -316,7 +307,6 @@ export class RawDebugSession implements debug.IRawSession {
}
public continue(args: DebugProtocol.ContinueArguments): TPromise<DebugProtocol.ContinueResponse> {
this.clearRequestQueue();
return this.send<DebugProtocol.ContinueResponse>('continue', args).then(response => {
if (response && response.body && response.body.allThreadsContinued !== undefined) {
this.allThreadsContinued = response.body.allThreadsContinued;
......@@ -339,7 +329,6 @@ export class RawDebugSession implements debug.IRawSession {
}
public restartFrame(args: DebugProtocol.RestartFrameArguments, threadId: number): TPromise<DebugProtocol.RestartFrameResponse> {
this.clearRequestQueue();
return this.send('restartFrame', args).then(response => {
this.fireFakeContinued(threadId);
return response;
......@@ -351,12 +340,17 @@ export class RawDebugSession implements debug.IRawSession {
}
public disconnect(restart = false, force = false): TPromise<DebugProtocol.DisconnectResponse> {
this.clearRequestQueue();
if (this.disconnected && force) {
return this.stopServer();
}
// Cancel all sent promises on disconnect so debug trees are not left in a broken state #3666.
// Give a 1s timeout to give a chance for some promises to complete.
setTimeout(() => {
this.sentPromises.forEach(p => p && p.cancel());
this.sentPromises = [];
}, 1000);
if (this.debugAdapter && !this.disconnected) {
// point of no return: from now on don't report any errors
this.disconnected = true;
......@@ -411,7 +405,6 @@ export class RawDebugSession implements debug.IRawSession {
}
public stepBack(args: DebugProtocol.StepBackArguments): TPromise<DebugProtocol.StepBackResponse> {
this.clearRequestQueue();
return this.send('stepBack', args).then(response => {
if (response.body === undefined) {
this.fireFakeContinued(args.threadId);
......@@ -421,7 +414,6 @@ export class RawDebugSession implements debug.IRawSession {
}
public reverseContinue(args: DebugProtocol.ReverseContinueArguments): TPromise<DebugProtocol.ReverseContinueResponse> {
this.clearRequestQueue();
return this.send('reverseContinue', args).then(response => {
if (response.body === undefined) {
this.fireFakeContinued(args.threadId);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册