Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug: initial support of breakpoint modes #205251

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/vs/workbench/api/browser/mainThreadDebugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,15 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
column: l.character > 0 ? l.character + 1 : undefined, // a column value of 0 results in an omitted column attribute; see #46784
condition: l.condition,
hitCondition: l.hitCondition,
logMessage: l.logMessage
logMessage: l.logMessage,
mode: l.mode,
}
);
this.debugService.addBreakpoints(uri.revive(dto.uri), rawbps);
} else if (dto.type === 'function') {
this.debugService.addFunctionBreakpoint(dto.functionName, dto.id);
this.debugService.addFunctionBreakpoint(dto.functionName, dto.id, dto.mode);
} else if (dto.type === 'data') {
this.debugService.addDataBreakpoint(dto.label, dto.dataId, dto.canPersist, dto.accessTypes, dto.accessType);
this.debugService.addDataBreakpoint(dto.label, dto.dataId, dto.canPersist, dto.accessTypes, dto.accessType, dto.mode);
}
}
return Promise.resolve();
Expand Down
4 changes: 4 additions & 0 deletions src/vs/workbench/api/common/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2272,11 +2272,13 @@ export interface IBreakpointDto {
condition?: string;
hitCondition?: string;
logMessage?: string;
mode?: string;
}

export interface IFunctionBreakpointDto extends IBreakpointDto {
type: 'function';
functionName: string;
mode?: string;
}

export interface IDataBreakpointDto extends IBreakpointDto {
Expand All @@ -2286,6 +2288,7 @@ export interface IDataBreakpointDto extends IBreakpointDto {
label: string;
accessTypes?: DebugProtocol.DataBreakpointAccessType[];
accessType: DebugProtocol.DataBreakpointAccessType;
mode?: string;
}

export interface ISourceBreakpointDto extends IBreakpointDto {
Expand All @@ -2312,6 +2315,7 @@ export interface ISourceMultiBreakpointDto {
logMessage?: string;
line: number;
character: number;
mode?: string;
}[];
}

Expand Down
12 changes: 7 additions & 5 deletions src/vs/workbench/api/common/extHostDebugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,8 @@ export abstract class ExtHostDebugServiceBase implements IExtHostDebugService, E
hitCondition: bp.hitCondition,
logMessage: bp.logMessage,
line: bp.location.range.start.line,
character: bp.location.range.start.character
character: bp.location.range.start.character,
mode: bp.mode,
});
} else if (bp instanceof FunctionBreakpoint) {
dtos.push({
Expand All @@ -437,7 +438,8 @@ export abstract class ExtHostDebugServiceBase implements IExtHostDebugService, E
hitCondition: bp.hitCondition,
logMessage: bp.logMessage,
condition: bp.condition,
functionName: bp.functionName
functionName: bp.functionName,
mode: bp.mode,
});
}
}
Expand Down Expand Up @@ -713,12 +715,12 @@ export abstract class ExtHostDebugServiceBase implements IExtHostDebugService, E
if (id && !this._breakpoints.has(id)) {
let bp: Breakpoint;
if (bpd.type === 'function') {
bp = new FunctionBreakpoint(bpd.functionName, bpd.enabled, bpd.condition, bpd.hitCondition, bpd.logMessage);
bp = new FunctionBreakpoint(bpd.functionName, bpd.enabled, bpd.condition, bpd.hitCondition, bpd.logMessage, bpd.mode);
} else if (bpd.type === 'data') {
bp = new DataBreakpoint(bpd.label, bpd.dataId, bpd.canPersist, bpd.enabled, bpd.hitCondition, bpd.condition, bpd.logMessage);
bp = new DataBreakpoint(bpd.label, bpd.dataId, bpd.canPersist, bpd.enabled, bpd.hitCondition, bpd.condition, bpd.logMessage, bpd.mode);
} else {
const uri = URI.revive(bpd.uri);
bp = new SourceBreakpoint(new Location(uri, new Position(bpd.line, bpd.character)), bpd.enabled, bpd.condition, bpd.hitCondition, bpd.logMessage);
bp = new SourceBreakpoint(new Location(uri, new Position(bpd.line, bpd.character)), bpd.enabled, bpd.condition, bpd.hitCondition, bpd.logMessage, bpd.mode);
}
setBreakpointId(bp, id);
this._breakpoints.set(id, bp);
Expand Down
18 changes: 11 additions & 7 deletions src/vs/workbench/api/common/extHostTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2918,8 +2918,9 @@ export class Breakpoint {
readonly condition?: string;
readonly hitCondition?: string;
readonly logMessage?: string;
readonly mode?: string;

protected constructor(enabled?: boolean, condition?: string, hitCondition?: string, logMessage?: string) {
protected constructor(enabled?: boolean, condition?: string, hitCondition?: string, logMessage?: string, mode?: string) {
this.enabled = typeof enabled === 'boolean' ? enabled : true;
if (typeof condition === 'string') {
this.condition = condition;
Expand All @@ -2930,6 +2931,9 @@ export class Breakpoint {
if (typeof logMessage === 'string') {
this.logMessage = logMessage;
}
if (typeof mode === 'string') {
this.mode = mode;
}
}

get id(): string {
Expand All @@ -2944,8 +2948,8 @@ export class Breakpoint {
export class SourceBreakpoint extends Breakpoint {
readonly location: Location;

constructor(location: Location, enabled?: boolean, condition?: string, hitCondition?: string, logMessage?: string) {
super(enabled, condition, hitCondition, logMessage);
constructor(location: Location, enabled?: boolean, condition?: string, hitCondition?: string, logMessage?: string, mode?: string) {
super(enabled, condition, hitCondition, logMessage, mode);
if (location === null) {
throw illegalArgument('location');
}
Expand All @@ -2957,8 +2961,8 @@ export class SourceBreakpoint extends Breakpoint {
export class FunctionBreakpoint extends Breakpoint {
readonly functionName: string;

constructor(functionName: string, enabled?: boolean, condition?: string, hitCondition?: string, logMessage?: string) {
super(enabled, condition, hitCondition, logMessage);
constructor(functionName: string, enabled?: boolean, condition?: string, hitCondition?: string, logMessage?: string, mode?: string) {
super(enabled, condition, hitCondition, logMessage, mode);
this.functionName = functionName;
}
}
Expand All @@ -2969,8 +2973,8 @@ export class DataBreakpoint extends Breakpoint {
readonly dataId: string;
readonly canPersist: boolean;

constructor(label: string, dataId: string, canPersist: boolean, enabled?: boolean, condition?: string, hitCondition?: string, logMessage?: string) {
super(enabled, condition, hitCondition, logMessage);
constructor(label: string, dataId: string, canPersist: boolean, enabled?: boolean, condition?: string, hitCondition?: string, logMessage?: string, mode?: string) {
super(enabled, condition, hitCondition, logMessage, mode);
if (!dataId) {
throw illegalArgument('dataId');
}
Expand Down
53 changes: 47 additions & 6 deletions src/vs/workbench/contrib/debug/browser/breakpointWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,12 @@ export class BreakpointWidget extends ZoneWidget implements IPrivateBreakpointWi
private selectBreakpointContainer!: HTMLElement;
private input!: IActiveCodeEditor;
private selectBreakpointBox!: SelectBox;
private selectModeBox?: SelectBox;
private toDispose: lifecycle.IDisposable[];
private conditionInput = '';
private hitCountInput = '';
private logMessageInput = '';
private modeInput?: DebugProtocol.BreakpointMode;
private breakpoint: IBreakpoint | undefined;
private context: Context;
private heightInPx: number | undefined;
Expand Down Expand Up @@ -216,6 +218,8 @@ export class BreakpointWidget extends ZoneWidget implements IPrivateBreakpointWi
this.updateContextInput();
});

this.createModesInput(container);

this.inputContainer = $('.inputContainer');
this.createBreakpointInput(dom.append(container, this.inputContainer));

Expand All @@ -232,6 +236,33 @@ export class BreakpointWidget extends ZoneWidget implements IPrivateBreakpointWi
setTimeout(() => this.focusInput(), 150);
}

private createModesInput(container: HTMLElement) {
const modes = this.debugService.getModel().getBreakpointModes('source');
if (modes.length <= 1) {
return;
}

const sb = this.selectModeBox = new SelectBox(
[
{ text: nls.localize('bpMode', 'Mode'), isDisabled: true },
...modes.map(mode => ({ text: mode.label, description: mode.description })),
],
modes.findIndex(m => m.mode === this.breakpoint?.mode) + 1,
this.contextViewService,
defaultSelectBoxStyles,
);
this.toDispose.push(sb);
this.toDispose.push(sb.onDidSelect(e => {
this.modeInput = modes[e.index - 1];
}));

const modeWrapper = $('.select-mode-container');
const selectionWrapper = $('.select-box-container');
dom.append(modeWrapper, selectionWrapper);
sb.render(selectionWrapper);
dom.append(container, modeWrapper);
}

private createTriggerBreakpointInput(container: HTMLElement) {
const breakpoints = this.debugService.getModel().getBreakpoints().filter(bp => bp !== this.breakpoint);

Expand Down Expand Up @@ -404,10 +435,12 @@ export class BreakpointWidget extends ZoneWidget implements IPrivateBreakpointWi
if (success) {
// if there is already a breakpoint on this location - remove it.

let condition = this.breakpoint && this.breakpoint.condition;
let hitCondition = this.breakpoint && this.breakpoint.hitCondition;
let logMessage = this.breakpoint && this.breakpoint.logMessage;
let triggeredBy = this.breakpoint && this.breakpoint.triggeredBy;
let condition = this.breakpoint?.condition;
let hitCondition = this.breakpoint?.hitCondition;
let logMessage = this.breakpoint?.logMessage;
let triggeredBy = this.breakpoint?.triggeredBy;
let mode = this.breakpoint?.mode;
let modeLabel = this.breakpoint?.modeLabel;

this.rememberInput();

Expand All @@ -420,6 +453,10 @@ export class BreakpointWidget extends ZoneWidget implements IPrivateBreakpointWi
if (this.logMessageInput || this.context === Context.LOG_MESSAGE) {
logMessage = this.logMessageInput;
}
if (this.selectModeBox) {
mode = this.modeInput?.mode;
modeLabel = this.modeInput?.label;
}
if (this.context === Context.TRIGGER_POINT) {
// currently, trigger points don't support additional conditions:
condition = undefined;
Expand All @@ -434,7 +471,9 @@ export class BreakpointWidget extends ZoneWidget implements IPrivateBreakpointWi
condition,
hitCondition,
logMessage,
triggeredBy
triggeredBy,
mode,
modeLabel,
});
this.debugService.updateBreakpoints(this.breakpoint.originalUri, data, false).then(undefined, onUnexpectedError);
} else {
Expand All @@ -447,7 +486,9 @@ export class BreakpointWidget extends ZoneWidget implements IPrivateBreakpointWi
condition,
hitCondition,
logMessage,
triggeredBy
triggeredBy,
mode,
modeLabel,
}]);
}
}
Expand Down