From 3f0381cd6c9f8e85e5634317d7ba757a8c80fafd Mon Sep 17 00:00:00 2001 From: isidor Date: Tue, 9 Feb 2016 11:16:53 +0100 Subject: [PATCH] debug: surface function breakpoints --- .../parts/debug/browser/debugHover.ts | 1 - .../parts/debug/browser/debugViewer.ts | 4 +- .../parts/debug/browser/debugViewlet.ts | 2 +- src/vs/workbench/parts/debug/common/debug.ts | 1 + .../parts/debug/common/debugModel.ts | 4 +- .../debug/electron-browser/debugService.ts | 39 ++++++++++++------- .../parts/debug/node/rawDebugSession.ts | 4 ++ 7 files changed, 35 insertions(+), 20 deletions(-) diff --git a/src/vs/workbench/parts/debug/browser/debugHover.ts b/src/vs/workbench/parts/debug/browser/debugHover.ts index 0d7ed1c32e5..ed8e1d0e01d 100644 --- a/src/vs/workbench/parts/debug/browser/debugHover.ts +++ b/src/vs/workbench/parts/debug/browser/debugHover.ts @@ -86,7 +86,6 @@ export class DebugHoverWidget implements editorbrowser.IContentWidget { namesToFind.push(hoveringOver); namesToFind[0] = namesToFind[0].substring(namesToFind[0].lastIndexOf(' ') + 1); - this.getExpression(namesToFind).done(expression => { if (!expression || !expression.available) { this.hide(); diff --git a/src/vs/workbench/parts/debug/browser/debugViewer.ts b/src/vs/workbench/parts/debug/browser/debugViewer.ts index 3e80dc7c74c..db7906f647a 100644 --- a/src/vs/workbench/parts/debug/browser/debugViewer.ts +++ b/src/vs/workbench/parts/debug/browser/debugViewer.ts @@ -742,8 +742,8 @@ export class BreakpointsActionProvider implements renderer.IActionProvider { actions.push(this.instantiationService.createInstance(debugactions.DisableAllBreakpointsAction, debugactions.DisableAllBreakpointsAction.ID, debugactions.DisableAllBreakpointsAction.LABEL)); actions.push(new actionbar.Separator()); - // actions.push(this.instantiationService.createInstance(debugactions.AddFunctionBreakpointAction, debugactions.AddFunctionBreakpointAction.ID, debugactions.AddFunctionBreakpointAction.LABEL)); - // actions.push(new actionbar.Separator()); + actions.push(this.instantiationService.createInstance(debugactions.AddFunctionBreakpointAction, debugactions.AddFunctionBreakpointAction.ID, debugactions.AddFunctionBreakpointAction.LABEL)); + actions.push(new actionbar.Separator()); actions.push(this.instantiationService.createInstance(debugactions.ReapplyBreakpointsAction, debugactions.ReapplyBreakpointsAction.ID, debugactions.ReapplyBreakpointsAction.LABEL)); diff --git a/src/vs/workbench/parts/debug/browser/debugViewlet.ts b/src/vs/workbench/parts/debug/browser/debugViewlet.ts index acdfbfda9ec..a36432dd251 100644 --- a/src/vs/workbench/parts/debug/browser/debugViewlet.ts +++ b/src/vs/workbench/parts/debug/browser/debugViewlet.ts @@ -395,7 +395,7 @@ class BreakpointsView extends viewlet.AdaptiveCollapsibleViewletView { public getActions(): actions.IAction[] { return [ - // this.instantiationService.createInstance(debugactions.AddFunctionBreakpointAction, debugactions.AddFunctionBreakpointAction.ID, debugactions.AddFunctionBreakpointAction.LABEL), + this.instantiationService.createInstance(debugactions.AddFunctionBreakpointAction, debugactions.AddFunctionBreakpointAction.ID, debugactions.AddFunctionBreakpointAction.LABEL), this.instantiationService.createInstance(debugactions.ReapplyBreakpointsAction, debugactions.ReapplyBreakpointsAction.ID, debugactions.ReapplyBreakpointsAction.LABEL), this.instantiationService.createInstance(debugactions.ToggleBreakpointsActivatedAction, debugactions.ToggleBreakpointsActivatedAction.ID, debugactions.ToggleBreakpointsActivatedAction.LABEL), this.instantiationService.createInstance(debugactions.RemoveAllBreakpointsAction, debugactions.RemoveAllBreakpointsAction.ID, debugactions.RemoveAllBreakpointsAction.LABEL) diff --git a/src/vs/workbench/parts/debug/common/debug.ts b/src/vs/workbench/parts/debug/common/debug.ts index de0b12471b6..c07d984adcb 100644 --- a/src/vs/workbench/parts/debug/common/debug.ts +++ b/src/vs/workbench/parts/debug/common/debug.ts @@ -86,6 +86,7 @@ export interface IBreakpoint extends IEnablement { export interface IFunctionBreakpoint extends IEnablement { name: string; + verified: boolean; } export interface IExceptionBreakpoint extends IEnablement { diff --git a/src/vs/workbench/parts/debug/common/debugModel.ts b/src/vs/workbench/parts/debug/common/debugModel.ts index b2b41903754..43a961a3eb1 100644 --- a/src/vs/workbench/parts/debug/common/debugModel.ts +++ b/src/vs/workbench/parts/debug/common/debugModel.ts @@ -301,10 +301,10 @@ export class Breakpoint implements debug.IBreakpoint { export class FunctionBreakpoint implements debug.IFunctionBreakpoint { private id: string; - public error: boolean; + public verified: boolean; constructor(public name: string, public enabled: boolean) { - this.error = false; + this.verified = false; this.id = uuid.generateUuid(); } diff --git a/src/vs/workbench/parts/debug/electron-browser/debugService.ts b/src/vs/workbench/parts/debug/electron-browser/debugService.ts index 9528afdd24f..8a8fb94fcd8 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugService.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugService.ts @@ -226,7 +226,7 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService private registerSessionListeners(): void { this.toDispose.push(this.session.addListener2(debug.SessionEvents.INITIALIZED, (event: DebugProtocol.InitializedEvent) => - this.sendAllBreakpoints().then(() => this.sendExceptionBreakpoints()).then(() => { + this.sendAllBreakpoints().then(() => { if (this.session.capablities.supportsConfigurationDoneRequest) { this.session.configurationDone().done(null, errors.onUnexpectedError); } @@ -413,8 +413,7 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService const breakpoint = element; return this.sendBreakpoints(breakpoint.source.uri); } else if (element instanceof model.FunctionBreakpoint) { - return TPromise.as(null); - // TODO@Isidor send function breakpoints and return + return this.sendFunctionBreakpoints(); } return this.sendExceptionBreakpoints(); @@ -445,20 +444,17 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService public addFunctionBreakpoint(functionName?: string): TPromise { this.model.addFunctionBreakpoint(functionName); - // TODO@Isidor send updated function breakpoints - return TPromise.as(null); + return this.sendFunctionBreakpoints(); } public renameFunctionBreakpoint(id: string, newFunctionName: string): TPromise { this.model.renameFunctionBreakpoint(id, newFunctionName); - // TODO@Isidor send updated function breakpoints - return TPromise.as(null); + return this.sendFunctionBreakpoints(); } public removeFunctionBreakpoints(id?: string): TPromise { this.model.removeFunctionBreakpoints(id); - // TODO@Isidor send updated function breakpoints - return TPromise.as(null); + return this.sendFunctionBreakpoints(); } public addReplExpression(name: string): TPromise { @@ -784,12 +780,15 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService } public sendAllBreakpoints(): TPromise { - return TPromise.join(arrays.distinct(this.model.getBreakpoints(), bp => bp.source.uri.toString()).map(bp => this.sendBreakpoints(bp.source.uri))); + return TPromise.join(arrays.distinct(this.model.getBreakpoints(), bp => bp.source.uri.toString()).map(bp => this.sendBreakpoints(bp.source.uri))) + .then(() => this.sendFunctionBreakpoints()) + // send exception breakpoints at the end since some debug adapters rely on the order + .then(() => this.sendExceptionBreakpoints()); } private sendBreakpoints(modelUri: uri): TPromise { if (!this.session || !this.session.readyForBreakpoints) { - return TPromise.as(undefined); + return TPromise.as(null); } const breakpointsToSend = arrays.distinct( @@ -810,13 +809,25 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService }); } + private sendFunctionBreakpoints(): TPromise { + if (!this.session || !this.session.readyForBreakpoints) { + return TPromise.as(null); + } + + const breakpoints = this.model.getFunctionBreakpoints().filter(fbp => fbp.enabled); + return this.session.setFunctionBreakpoints({ breakpoints }).then(response => { + let index = 0; + breakpoints.forEach(bp => bp.verified = response.body.breakpoints[index++].verified); + }); + } + private sendExceptionBreakpoints(): TPromise { if (!this.session || !this.session.readyForBreakpoints) { - return TPromise.as(undefined); + return TPromise.as(null); } - const enabledExBreakpoints = this.model.getExceptionBreakpoints().filter(exb => exb.enabled); - return this.session.setExceptionBreakpoints({ filters: enabledExBreakpoints.map(exb => exb.name) }); + const enabledExceptionBps = this.model.getExceptionBreakpoints().filter(exb => exb.enabled); + return this.session.setExceptionBreakpoints({ filters: enabledExceptionBps.map(exb => exb.name) }); } private onFileChanges(fileChangesEvent: FileChangesEvent): void { diff --git a/src/vs/workbench/parts/debug/node/rawDebugSession.ts b/src/vs/workbench/parts/debug/node/rawDebugSession.ts index 128227d1e55..bb0c332875a 100644 --- a/src/vs/workbench/parts/debug/node/rawDebugSession.ts +++ b/src/vs/workbench/parts/debug/node/rawDebugSession.ts @@ -136,6 +136,10 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes return this.send('setBreakpoints', args); } + public setFunctionBreakpoints(args: DebugProtocol.SetFunctionBreakpointsArguments): TPromise { + return this.send('setFunctionBreakpoints', args); + } + public setExceptionBreakpoints(args: DebugProtocol.SetExceptionBreakpointsArguments): TPromise { return this.send('setExceptionBreakpoints', args); } -- GitLab