提交 a08885ec 编写于 作者: I isidor

debug: polish IRawDebugSession

上级 29ff5de6
......@@ -282,7 +282,7 @@ export class DebugEditorModelManager implements IWorkbenchContribution {
}
return result ? result :
!session || session.capabilities.supportsConditionalBreakpoints ? {
!session || session.configuration.capabilities.supportsConditionalBreakpoints ? {
glyphMarginClassName: 'debug-breakpoint-conditional-glyph',
hoverMessage: breakpoint.condition,
stickiness: editorcommon.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges
......
......@@ -126,7 +126,7 @@ export class DebugHoverWidget implements editorbrowser.IContentWidget {
private getExpression(namesToFind: string[]): TPromise<Expression> {
const session = this.debugService.getActiveSession();
const focusedStackFrame = this.debugService.getViewModel().getFocusedStackFrame();
if (session.capabilities.supportsEvaluateForHovers) {
if (session.configuration.capabilities.supportsEvaluateForHovers) {
return evaluateExpression(session, focusedStackFrame, new Expression(namesToFind.join('.'), true), 'hover');
}
......
......@@ -56,8 +56,19 @@ export interface IExpression extends ITreeElement, IExpressionContainer {
}
export interface IThread extends ITreeElement {
/**
* Id of the thread generated by the debug adapter backend.
*/
threadId: number;
/**
* Name of the thread.
*/
name: string;
/**
* Information about the current thread stop event. Null if thread is not stopped.
*/
stoppedDetails: IRawStoppedDetails;
/**
......@@ -237,9 +248,8 @@ export interface IRawAdapter extends IRawEnvAdapter {
}
export interface IRawDebugSession extends ee.EventEmitter {
getType(): string;
isAttach: boolean;
capabilities: DebugProtocol.Capabilites;
configuration: { type: string, isAttach: boolean, capabilities: DebugProtocol.Capabilites };
disconnect(restart?: boolean, force?: boolean): TPromise<DebugProtocol.DisconnectResponse>;
next(args: DebugProtocol.NextArguments): TPromise<DebugProtocol.NextResponse>;
......
......@@ -137,7 +137,7 @@ export class RestartDebugAction extends AbstractDebugAction {
this.toDispose.push(this.debugService.onDidChangeState(() => {
const session = this.debugService.getActiveSession();
if (session) {
this.updateLabel(session.isAttach ? RestartDebugAction.RECONNECT_LABEL : RestartDebugAction.LABEL);
this.updateLabel(session.configuration.isAttach ? RestartDebugAction.RECONNECT_LABEL : RestartDebugAction.LABEL);
}
}));
}
......@@ -212,7 +212,7 @@ export class StopDebugAction extends AbstractDebugAction {
this.toDispose.push(this.debugService.onDidChangeState(() => {
const session = this.debugService.getActiveSession();
if (session) {
this.updateLabel(session.isAttach ? StopDebugAction.DISCONNECT_LABEL : StopDebugAction.LABEL);
this.updateLabel(session.configuration.isAttach ? StopDebugAction.DISCONNECT_LABEL : StopDebugAction.LABEL);
}
}));
}
......@@ -493,7 +493,7 @@ export class CopyValueAction extends AbstractDebugAction {
if (this.value instanceof model.Variable) {
const frameId = this.debugService.getViewModel().getFocusedStackFrame().frameId;
const session = this.debugService.getActiveSession();
return session.evaluate({ expression: model.getFullExpressionName(this.value, session.getType()), frameId }).then(result => {
return session.evaluate({ expression: model.getFullExpressionName(this.value, session.configuration.type), frameId }).then(result => {
clipboard.writeText(result.body.result);
}, err => clipboard.writeText(this.value.value));
}
......@@ -644,7 +644,7 @@ export class AddToWatchExpressionsAction extends AbstractDebugAction {
}
public run(): TPromise<any> {
return this.debugService.addWatchExpression(model.getFullExpressionName(this.expression, this.debugService.getActiveSession().getType()));
return this.debugService.addWatchExpression(model.getFullExpressionName(this.expression, this.debugService.getActiveSession().configuration.type));
}
}
......
......@@ -151,7 +151,7 @@ export class DebugService implements debug.IDebugService {
// from this point on we require an active session
let session = this.getActiveSession();
if (!session || session.getType() !== 'extensionHost') {
if (!session || session.configuration.type !== 'extensionHost') {
return; // we are only intersted if we have an active debug session for extensionHost
}
......@@ -232,7 +232,7 @@ export class DebugService implements debug.IDebugService {
this.toDisposeOnSessionEnd.push(this.session.addListener2(debug.SessionEvents.INITIALIZED, (event: DebugProtocol.InitializedEvent) => {
aria.status(nls.localize('debuggingStarted', "Debugging started."));
this.sendAllBreakpoints().then(() => {
if (this.session.capabilities.supportsConfigurationDoneRequest) {
if (this.session.configuration.capabilities.supportsConfigurationDoneRequest) {
this.session.configurationDone().done(null, errors.onUnexpectedError);
}
});
......@@ -327,7 +327,7 @@ export class DebugService implements debug.IDebugService {
this.toDisposeOnSessionEnd.push(this.session.addListener2(debug.SessionEvents.SERVER_EXIT, event => {
// 'Run without debugging' mode VSCode must terminate the extension host. More details: #3905
if (this.session.getType() === 'extensionHost' && this.state === debug.State.RunningNoDebug) {
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() === event.sessionId) {
......@@ -604,7 +604,7 @@ export class DebugService implements debug.IDebugService {
return TPromise.wrapError(new Error(nls.localize('debugAdapterCrash', "Debug adapter process has terminated unexpectedly")));
}
this.model.setExceptionBreakpoints(this.session.capabilities.exceptionBreakpointFilters);
this.model.setExceptionBreakpoints(this.session.configuration.capabilities.exceptionBreakpointFilters);
return configuration.request === 'attach' ? this.session.attach(configuration) : this.session.launch(configuration);
}).then((result: DebugProtocol.Response) => {
if (changeViewState) {
......@@ -682,7 +682,7 @@ export class DebugService implements debug.IDebugService {
private rawAttach(port: number): TPromise<any> {
if (this.session) {
if (!this.session.isAttach) {
if (!this.session.configuration.isAttach) {
return this.session.attach({ port });
}
......@@ -719,7 +719,7 @@ export class DebugService implements debug.IDebugService {
if (this.session) {
const bpsExist = this.model.getBreakpoints().length > 0;
this.telemetryService.publicLog('debugSessionStop', {
type: this.session.getType(),
type: this.session.configuration.type,
success: this.session.emittedStopped || !bpsExist,
sessionLengthInSeconds: this.session.getLengthInSeconds(),
breakpointCount: this.model.getBreakpoints().length,
......@@ -875,7 +875,7 @@ export class DebugService implements debug.IDebugService {
}
private sendFunctionBreakpoints(): TPromise<void> {
if (!this.session || !this.session.readyForBreakpoints || !this.session.capabilities.supportsFunctionBreakpoints) {
if (!this.session || !this.session.readyForBreakpoints || !this.session.configuration.capabilities.supportsFunctionBreakpoints) {
return TPromise.as(null);
}
......
......@@ -22,15 +22,17 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { shell } from 'electron';
export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSession {
public restarted: boolean;
private serverProcess: cp.ChildProcess;
private socket: net.Socket = null;
private cachedInitServer: TPromise<void>;
private startTime: number;
private stopServerPending: boolean;
private sentPromises: TPromise<DebugProtocol.Response>[];
public isAttach: boolean;
public restarted: boolean;
public capabilities: DebugProtocol.Capabilites;
private isAttach: boolean;
private capabilities: DebugProtocol.Capabilites;
constructor(
private messageService: IMessageService,
......@@ -40,7 +42,6 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes
private telemtryAdapter: AIAdapter
) {
super();
this.capabilities = {};
this.sentPromises = [];
}
......@@ -87,9 +88,17 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes
});
}
public get configuration(): { type: string, isAttach: boolean, capabilities: DebugProtocol.Capabilites } {
return {
type: this.adapter.type,
isAttach: this.isAttach,
capabilities: this.capabilities || {}
};
}
public initialize(args: DebugProtocol.InitializeRequestArguments): TPromise<DebugProtocol.InitializeResponse> {
return this.send('initialize', args).then(response => {
this.capabilities = response.body || this.capabilities;
this.capabilities = response.body;
return response;
});
}
......@@ -206,10 +215,6 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes
return (new Date().getTime() - this.startTime) / 1000;
}
public getType(): string {
return this.adapter.type;
}
private connectServer(port: number): TPromise<void> {
return new TPromise<void>((c, e) => {
this.socket = net.createConnection(port, '127.0.0.1', () => {
......
......@@ -126,11 +126,13 @@ export class MockDebugService implements debug.IDebugService {
class MockRawSession extends ee.EventEmitter implements debug.IRawDebugSession {
public isAttach: boolean = false;
public capabilities: DebugProtocol.Capabilites;
public getType(): string {
return null;
public get configuration(): { type: string, isAttach: boolean, capabilities: DebugProtocol.Capabilites } {
return {
type: 'mock',
isAttach: false,
capabilities: {}
};
}
public disconnect(restart?: boolean, force?: boolean): TPromise<DebugProtocol.DisconnectResponse> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册