Skip to content

Commit

Permalink
Pass full function breakpoint options from plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
OccasionalDebugger committed May 3, 2024
1 parent 1451e4f commit 8ca50f2
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
9 changes: 8 additions & 1 deletion src/vs/workbench/api/browser/mainThreadDebugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,14 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
);
this.debugService.addBreakpoints(uri.revive(dto.uri), rawbps);
} else if (dto.type === 'function') {
this.debugService.addFunctionBreakpoint(dto.functionName, dto.id, dto.mode);
this.debugService.addFunctionBreakpoint({
name: dto.functionName,
mode: dto.mode,
condition: dto.condition,
hitCondition: dto.hitCondition,
enabled: dto.enabled,
logMessage: dto.logMessage
}, dto.id);
} else if (dto.type === 'data') {
this.debugService.addDataBreakpoint({
description: dto.label,
Expand Down
6 changes: 3 additions & 3 deletions src/vs/workbench/contrib/debug/browser/debugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import { DebugSession } from 'vs/workbench/contrib/debug/browser/debugSession';
import { DebugTaskRunner, TaskRunResult } from 'vs/workbench/contrib/debug/browser/debugTaskRunner';
import { CALLSTACK_VIEW_ID, CONTEXT_BREAKPOINTS_EXIST, CONTEXT_DEBUG_STATE, CONTEXT_DEBUG_TYPE, CONTEXT_DEBUG_UX, CONTEXT_DISASSEMBLY_VIEW_FOCUS, CONTEXT_HAS_DEBUGGED, CONTEXT_IN_DEBUG_MODE, DEBUG_MEMORY_SCHEME, DEBUG_SCHEME, IAdapterManager, IBreakpoint, IBreakpointData, IBreakpointUpdateData, ICompound, IConfig, IConfigurationManager, IDebugConfiguration, IDebugModel, IDebugService, IDebugSession, IDebugSessionOptions, IEnablement, IExceptionBreakpoint, IGlobalConfig, ILaunch, IStackFrame, IThread, IViewModel, REPL_VIEW_ID, State, VIEWLET_ID, debuggerDisabledMessage, getStateLabel } from 'vs/workbench/contrib/debug/common/debug';
import { DebugCompoundRoot } from 'vs/workbench/contrib/debug/common/debugCompoundRoot';
import { Breakpoint, DataBreakpoint, DebugModel, FunctionBreakpoint, IDataBreakpointOptions, IInstructionBreakpointOptions, InstructionBreakpoint } from 'vs/workbench/contrib/debug/common/debugModel';
import { Breakpoint, DataBreakpoint, DebugModel, FunctionBreakpoint, IDataBreakpointOptions, IFunctionBreakpointOptions, IInstructionBreakpointOptions, InstructionBreakpoint } from 'vs/workbench/contrib/debug/common/debugModel';
import { Source } from 'vs/workbench/contrib/debug/common/debugSource';
import { DebugStorage } from 'vs/workbench/contrib/debug/common/debugStorage';
import { DebugTelemetry } from 'vs/workbench/contrib/debug/common/debugTelemetry';
Expand Down Expand Up @@ -1073,8 +1073,8 @@ export class DebugService implements IDebugService {
return this.sendAllBreakpoints();
}

addFunctionBreakpoint(name?: string, id?: string, mode?: string): void {
this.model.addFunctionBreakpoint(name || '', id, mode);
addFunctionBreakpoint(opts?: IFunctionBreakpointOptions, id?: string): void {
this.model.addFunctionBreakpoint(opts ?? { name: '' }, id);
}

async updateFunctionBreakpoint(id: string, update: { name?: string; hitCondition?: string; condition?: string }): Promise<void> {
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/contrib/debug/common/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { ITelemetryEndpoint } from 'vs/platform/telemetry/common/telemetry';
import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { IEditorPane } from 'vs/workbench/common/editor';
import { DebugCompoundRoot } from 'vs/workbench/contrib/debug/common/debugCompoundRoot';
import { IDataBreakpointOptions, IInstructionBreakpointOptions } from 'vs/workbench/contrib/debug/common/debugModel';
import { IDataBreakpointOptions, IFunctionBreakpointOptions, IInstructionBreakpointOptions } from 'vs/workbench/contrib/debug/common/debugModel';
import { Source } from 'vs/workbench/contrib/debug/common/debugSource';
import { ITaskIdentifier } from 'vs/workbench/contrib/tasks/common/tasks';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
Expand Down Expand Up @@ -1150,7 +1150,7 @@ export interface IDebugService {
/**
* Adds a new function breakpoint for the given name.
*/
addFunctionBreakpoint(name?: string, id?: string, mode?: string): void;
addFunctionBreakpoint(opts?: IFunctionBreakpointOptions, id?: string): void;

/**
* Updates an already existing function breakpoint.
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/contrib/debug/common/debugModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1896,8 +1896,8 @@ export class DebugModel extends Disposable implements IDebugModel {
this._onDidChangeBreakpoints.fire({ changed: changed, sessionOnly: false });
}

addFunctionBreakpoint(functionName: string, id?: string, mode?: string): IFunctionBreakpoint {
const newFunctionBreakpoint = new FunctionBreakpoint({ name: functionName, mode }, id);
addFunctionBreakpoint(opts: IFunctionBreakpointOptions, id?: string): IFunctionBreakpoint {
const newFunctionBreakpoint = new FunctionBreakpoint(opts, id);
this.functionBreakpoints.push(newFunctionBreakpoint);
this._onDidChangeBreakpoints.fire({ added: [newFunctionBreakpoint], sessionOnly: false });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ suite('Debug - Breakpoints', () => {
});

test('function breakpoints', () => {
model.addFunctionBreakpoint('foo', '1');
model.addFunctionBreakpoint('bar', '2');
model.addFunctionBreakpoint({ name: 'foo' }, '1');
model.addFunctionBreakpoint({ name: 'bar' }, '2');
model.updateFunctionBreakpoint('1', { name: 'fooUpdated' });
model.updateFunctionBreakpoint('2', { name: 'barUpdated' });

Expand Down Expand Up @@ -380,7 +380,7 @@ suite('Debug - Breakpoints', () => {
assert.strictEqual(result.message, 'Data Breakpoint');
assert.strictEqual(result.icon.id, 'debug-breakpoint-data');

const functionBreakpoint = model.addFunctionBreakpoint('foo', '1');
const functionBreakpoint = model.addFunctionBreakpoint({ name: 'foo' }, '1');
result = getBreakpointMessageAndIcon(State.Stopped, true, functionBreakpoint, ls, model);
assert.strictEqual(result.message, 'Function Breakpoint');
assert.strictEqual(result.icon.id, 'debug-breakpoint-function');
Expand Down

0 comments on commit 8ca50f2

Please sign in to comment.