Skip to content

Commit c233bf8

Browse files
committed
add API to access DAP breakpoints; see microsoft#99716
1 parent 652a432 commit c233bf8

8 files changed

Lines changed: 61 additions & 0 deletions

File tree

src/vs/vscode.proposed.d.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,17 @@ declare module 'vscode' {
752752
compact?: boolean;
753753
}
754754

755+
/**
756+
* A DebugProtocolBreakpoint is an opaque stand-in type for the [Breakpoint](https://microsoft.github.io/debug-adapter-protocol/specification#Types_Breakpoint) type defined in the Debug Adapter Protocol.
757+
*/
758+
export interface DebugProtocolBreakpoint {
759+
// Properties: see details [here](https://microsoft.github.io/debug-adapter-protocol/specification#Types_Breakpoint).
760+
}
761+
762+
export interface DebugSession {
763+
getDebugProtocolBreakpoint(breakpoint: Breakpoint): DebugProtocolBreakpoint | undefined;
764+
}
765+
755766
// deprecated debug API
756767

757768
export interface DebugConfigurationProvider {

src/vs/workbench/api/browser/mainThreadDebugService.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,14 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
264264
return Promise.reject(new Error('debug session not found'));
265265
}
266266

267+
public $getDebugProtocolBreakpoint(sessionId: DebugSessionUUID, breakpoinId: string): Promise<DebugProtocol.Breakpoint | undefined> {
268+
const session = this.debugService.getModel().getSession(sessionId, true);
269+
if (session) {
270+
return Promise.resolve(session.getDebugProtocolBreakpoint(breakpoinId));
271+
}
272+
return Promise.reject(new Error('debug session not found'));
273+
}
274+
267275
public $stopDebugging(sessionId: DebugSessionUUID | undefined): Promise<void> {
268276
if (sessionId) {
269277
const session = this.debugService.getModel().getSession(sessionId, true);

src/vs/workbench/api/common/extHost.protocol.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,7 @@ export interface MainThreadDebugServiceShape extends IDisposable {
879879
$stopDebugging(sessionId: DebugSessionUUID | undefined): Promise<void>;
880880
$setDebugSessionName(id: DebugSessionUUID, name: string): void;
881881
$customDebugAdapterRequest(id: DebugSessionUUID, command: string, args: any): Promise<any>;
882+
$getDebugProtocolBreakpoint(id: DebugSessionUUID, breakpoinId: string): Promise<DebugProtocol.Breakpoint | undefined>;
882883
$appendDebugConsole(value: string): void;
883884
$startBreakpointEvents(): void;
884885
$registerBreakpoints(breakpoints: Array<ISourceMultiBreakpointDto | IFunctionBreakpointDto | IDataBreakpointDto>): Promise<void>;

src/vs/workbench/api/common/extHostDebugService.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,10 @@ export class ExtHostDebugSession implements vscode.DebugSession {
957957
public customRequest(command: string, args: any): Promise<any> {
958958
return this._debugServiceProxy.$customDebugAdapterRequest(this._id, command, args);
959959
}
960+
961+
public getDebugProtocolBreakpoint(breakpoint: vscode.Breakpoint): vscode.DebugProtocolBreakpoint | undefined {
962+
return this._debugServiceProxy.$getDebugProtocolBreakpoint(this._id, breakpoint.id);
963+
}
960964
}
961965

962966
export class ExtHostDebugConsole implements vscode.DebugConsole {

src/vs/workbench/contrib/debug/browser/debugSession.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,10 @@ export class DebugSession implements IDebugSession {
440440
return distinct(positions, p => `${p.lineNumber}:${p.column}`);
441441
}
442442

443+
getDebugProtocolBreakpoint(breakpointId: string): DebugProtocol.Breakpoint | undefined {
444+
return this.model.getDebugProtocolBreakpoint(breakpointId, this.getId());
445+
}
446+
443447
customRequest(request: string, args: any): Promise<DebugProtocol.Response> {
444448
if (!this.raw) {
445449
throw new Error(localize('noDebugAdapter', "No debug adapter, can not send '{0}'", request));

src/vs/workbench/contrib/debug/common/debug.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ export interface IDebugSession extends ITreeElement {
224224
sendDataBreakpoints(dbps: IDataBreakpoint[]): Promise<void>;
225225
sendExceptionBreakpoints(exbpts: IExceptionBreakpoint[]): Promise<void>;
226226
breakpointsLocations(uri: uri, lineNumber: number): Promise<IPosition[]>;
227+
getDebugProtocolBreakpoint(breakpointId: string): DebugProtocol.Breakpoint | undefined;
227228

228229
stackTrace(threadId: number, startFrame: number, levels: number, token: CancellationToken): Promise<DebugProtocol.StackTraceResponse>;
229230
exceptionInfo(threadId: number): Promise<IExceptionInfo | undefined>;

src/vs/workbench/contrib/debug/common/debugModel.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,27 @@ export abstract class BaseBreakpoint extends Enablement implements IBaseBreakpoi
597597
return data ? data.id : undefined;
598598
}
599599

600+
getDebugProtocolBreakpoint(sessionId: string): DebugProtocol.Breakpoint | undefined {
601+
const data = this.sessionData.get(sessionId);
602+
if (data) {
603+
const bp: DebugProtocol.Breakpoint = {
604+
id: data.id,
605+
verified: data.verified,
606+
message: data.message,
607+
source: data.source,
608+
line: data.line,
609+
column: data.column,
610+
endLine: data.endLine,
611+
endColumn: data.endColumn,
612+
instructionReference: data.instructionReference,
613+
offset: data.offset
614+
// TODO: copy additional debug adapter data
615+
};
616+
return bp;
617+
}
618+
return undefined;
619+
}
620+
600621
toJSON(): any {
601622
const result = Object.create(null);
602623
result.enabled = this.enabled;
@@ -1094,6 +1115,14 @@ export class DebugModel implements IDebugModel {
10941115
});
10951116
}
10961117

1118+
getDebugProtocolBreakpoint(breakpointId: string, sessionId: string): DebugProtocol.Breakpoint | undefined {
1119+
const bp = this.breakpoints.find(bp => bp.getId());
1120+
if (bp) {
1121+
return bp.getDebugProtocolBreakpoint(sessionId);
1122+
}
1123+
return undefined;
1124+
}
1125+
10971126
private sortAndDeDup(): void {
10981127
this.breakpoints = this.breakpoints.sort((first, second) => {
10991128
if (first.uri.toString() !== second.uri.toString()) {

src/vs/workbench/contrib/debug/test/common/mockDebug.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,9 @@ export class MockSession implements IDebugSession {
293293
sendExceptionBreakpoints(exbpts: IExceptionBreakpoint[]): Promise<void> {
294294
throw new Error('Method not implemented.');
295295
}
296+
getDebugProtocolBreakpoint(breakpointId: string): DebugProtocol.Breakpoint | undefined {
297+
throw new Error('Method not implemented.');
298+
}
296299
customRequest(request: string, args: any): Promise<DebugProtocol.Response> {
297300
throw new Error('Method not implemented.');
298301
}

0 commit comments

Comments
 (0)