setBreakpoint
Set a breakpoint at a specified file and line number to pause program execution. Optionally add a condition to trigger the breakpoint only when true.
Instructions
Set a breakpoint in the debugged program
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | ID of the debug session | |
| file | Yes | File path where to set the breakpoint | |
| line | Yes | Line number for the breakpoint | |
| condition | No | Optional condition for the breakpoint |
Implementation Reference
- src/handlers/control.ts:15-37 (handler)The actual handler for the 'setBreakpoint' tool. It extracts file, line, and condition arguments, sends a 'CreateBreakpoint' command to Delve via the session, creates a Breakpoint object, stores it in the session's breakpoints map, and returns a success message.
case "setBreakpoint": { const { file, line, condition } = args; const response = await sendDelveCommand(session, "CreateBreakpoint", { file, line, cond: condition }); const bp: Breakpoint = { id: response.id, file, line, condition }; session.breakpoints.set(bp.id, bp); return { content: [{ type: "text", text: `Set breakpoint ${bp.id} at ${file}:${line}` }] }; } - src/server.ts:136-397 (registration)Tool registration in ListToolsRequestSchema. Defines the 'setBreakpoint' tool with its name, description, and inputSchema (sessionId, file, line required; condition optional).
// Control tools { name: "setBreakpoint", description: "Set a breakpoint in the debugged program", inputSchema: { type: "object", properties: { sessionId: { type: "string", description: "ID of the debug session" }, file: { type: "string", description: "File path where to set the breakpoint" }, line: { type: "number", description: "Line number for the breakpoint" }, condition: { type: "string", description: "Optional condition for the breakpoint" } }, required: ["sessionId", "file", "line"] } }, { name: "removeBreakpoint", description: "Remove a breakpoint", inputSchema: { type: "object", properties: { sessionId: { type: "string", description: "ID of the debug session" }, breakpointId: { type: "number", description: "ID of the breakpoint to remove" } }, required: ["sessionId", "breakpointId"] } }, { name: "continue", description: "Continue program execution", inputSchema: { type: "object", properties: { sessionId: { type: "string", description: "ID of the debug session" } }, required: ["sessionId"] } }, { name: "next", description: "Step over to next line", inputSchema: { type: "object", properties: { sessionId: { type: "string", description: "ID of the debug session" } }, required: ["sessionId"] } }, { name: "step", description: "Step into function call", inputSchema: { type: "object", properties: { sessionId: { type: "string", description: "ID of the debug session" } }, required: ["sessionId"] } }, { name: "stepout", description: "Step out of current function", inputSchema: { type: "object", properties: { sessionId: { type: "string", description: "ID of the debug session" } }, required: ["sessionId"] } }, { name: "variables", description: "List local variables in current scope", inputSchema: { type: "object", properties: { sessionId: { type: "string", description: "ID of the debug session" } }, required: ["sessionId"] } }, { name: "evaluate", description: "Evaluate an expression in current scope", inputSchema: { type: "object", properties: { sessionId: { type: "string", description: "ID of the debug session" }, expr: { type: "string", description: "Expression to evaluate" } }, required: ["sessionId", "expr"] } }, // Advanced debug tools { name: "core", description: "Examine a core dump", inputSchema: { type: "object", properties: { executable: { type: "string", description: "Path to the executable that produced the core dump" }, corePath: { type: "string", description: "Path to the core dump file" } }, required: ["executable", "corePath"] } }, { name: "dap", description: "Start a DAP (Debug Adapter Protocol) server", inputSchema: { type: "object", properties: { clientAddr: { type: "string", description: "Optional address where DAP client is waiting for connection" } } } }, { name: "replay", description: "Replay an rr trace", inputSchema: { type: "object", properties: { tracePath: { type: "string", description: "Path to the rr trace directory" }, onProcess: { type: "number", description: "Optional PID to pass to rr" } }, required: ["tracePath"] } }, { name: "trace", description: "Trace program execution", inputSchema: { type: "object", properties: { regexp: { type: "string", description: "Regular expression to match functions to trace" }, pkg: { type: "string", description: "Package to trace (defaults to .)" }, ebpf: { type: "boolean", description: "Use eBPF for tracing (experimental)" }, stack: { type: "number", description: "Show stack trace with given depth" }, pid: { type: "number", description: "Pid to attach to" } }, required: ["regexp"] } }, // Configuration tools { name: "version", description: "Get Delve version information", inputSchema: { type: "object", properties: {} } }, { name: "setBackend", description: "Set the backend for debugging", inputSchema: { type: "object", properties: { backend: { type: "string", description: "Backend to use (default, native, lldb, or rr)", enum: ["default", "native", "lldb", "rr"] } }, required: ["backend"] } }, { name: "configureLogging", description: "Configure debug logging", inputSchema: { type: "object", properties: { components: { type: "array", items: { type: "string", enum: ["debugger", "gdbwire", "lldbout", "debuglineerr", "rpc", "dap", "fncall", "minidump", "stack"] }, description: "Components to enable logging for" }, destination: { type: "string", description: "Log destination (file path or file descriptor)" } }, required: ["components"] } } ] }; }); - src/server.ts:399-421 (registration)CallToolRequestSchema handler that routes 'setBreakpoint' to handleControlCommands along with other control commands.
/** * Handler for debug tools */ server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; // Debug commands if (["debug", "attach", "exec", "test", "core", "dap", "replay", "trace"].includes(name)) { return handleDebugCommands(name, args); } // Control commands if (["setBreakpoint", "removeBreakpoint", "continue", "next", "step", "stepout", "variables", "evaluate"].includes(name)) { return handleControlCommands(name, args); } // Configuration commands if (["setBackend", "configureLogging", "version"].includes(name)) { return handleConfigCommands(name, args); } throw new Error("Unknown tool"); }); - src/types.ts:6-11 (schema)Breakpoint type definition used by the setBreakpoint handler. Defines id, file, line, and optional condition fields.
export interface Breakpoint { id: number; file: string; line: number; condition?: string; } - src/session.ts:69-72 (helper)The sendDelveCommand helper function used by the setBreakpoint handler to send the 'CreateBreakpoint' API command to the Delve debugger session.
export async function sendDelveCommand(session: DebugSession, command: string, args: any = {}): Promise<any> { const { stdout } = await exec(`curl -s -X POST http://localhost:${session.port}/api/v2/${command} -d '${JSON.stringify(args)}'`); return JSON.parse(stdout); }