set_call_breakpoint
Set a breakpoint to pause PHP debugging when a specific function is called, enabling precise function-level debugging control.
Instructions
Set a breakpoint that triggers when a specific function is called. Can be set before a debug session starts.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| function_name | Yes | Function name to break on (e.g., 'myFunction' or 'MyClass::myMethod') | |
| session_id | No | Session ID |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"function_name": {
"description": "Function name to break on (e.g., 'myFunction' or 'MyClass::myMethod')",
"type": "string"
},
"session_id": {
"description": "Session ID",
"type": "string"
}
},
"required": [
"function_name"
],
"type": "object"
}
Implementation Reference
- src/tools/breakpoints.ts:231-298 (handler)The MCP tool handler for 'set_call_breakpoint'. Resolves the debug session by ID or uses active. If no session, adds as pending breakpoint. Otherwise, sets the call breakpoint on the session and returns JSON with success/breakpoint info or error.async ({ function_name, session_id }) => { const session = sessionManager.resolveSession(session_id); // If no active session, store as pending breakpoint if (!session) { const pendingBp = pendingBreakpoints.addCallBreakpoint(function_name); return { content: [ { type: 'text', text: JSON.stringify( { success: true, pending: true, message: 'Call breakpoint stored as pending - will be applied when a debug session connects', breakpoint: { id: pendingBp.id, type: 'call', function: function_name, enabled: pendingBp.enabled, }, }, null, 2 ), }, ], }; } try { const breakpoint = await session.setCallBreakpoint(function_name); return { content: [ { type: 'text', text: JSON.stringify( { success: true, breakpoint: { id: breakpoint.id, type: 'call', function: function_name, state: breakpoint.state, }, }, null, 2 ), }, ], }; } catch (error) { return { content: [ { type: 'text', text: JSON.stringify({ error: 'Failed to set call breakpoint', message: error instanceof Error ? error.message : String(error), }), }, ], }; } }
- src/tools/breakpoints.ts:223-230 (schema)Input schema for set_call_breakpoint tool using Zod: function_name (string, required), session_id (string, optional).{ function_name: z .string() .describe( "Function name to break on (e.g., 'myFunction' or 'MyClass::myMethod')" ), session_id: z.string().optional().describe('Session ID'), },
- src/tools/breakpoints.ts:220-299 (registration)Registration of the 'set_call_breakpoint' MCP tool on the McpServer within registerBreakpointTools function.server.tool( 'set_call_breakpoint', 'Set a breakpoint that triggers when a specific function is called. Can be set before a debug session starts.', { function_name: z .string() .describe( "Function name to break on (e.g., 'myFunction' or 'MyClass::myMethod')" ), session_id: z.string().optional().describe('Session ID'), }, async ({ function_name, session_id }) => { const session = sessionManager.resolveSession(session_id); // If no active session, store as pending breakpoint if (!session) { const pendingBp = pendingBreakpoints.addCallBreakpoint(function_name); return { content: [ { type: 'text', text: JSON.stringify( { success: true, pending: true, message: 'Call breakpoint stored as pending - will be applied when a debug session connects', breakpoint: { id: pendingBp.id, type: 'call', function: function_name, enabled: pendingBp.enabled, }, }, null, 2 ), }, ], }; } try { const breakpoint = await session.setCallBreakpoint(function_name); return { content: [ { type: 'text', text: JSON.stringify( { success: true, breakpoint: { id: breakpoint.id, type: 'call', function: function_name, state: breakpoint.state, }, }, null, 2 ), }, ], }; } catch (error) { return { content: [ { type: 'text', text: JSON.stringify({ error: 'Failed to set call breakpoint', message: error instanceof Error ? error.message : String(error), }), }, ], }; } } );
- src/session/session.ts:207-228 (helper)Core helper method in DebugSession that sends DBGP 'breakpoint_set -t call -m <function>' command to set the function call breakpoint.async setCallBreakpoint(functionName: string): Promise<Breakpoint> { const response = await this.connection.sendCommand('breakpoint_set', { t: 'call', m: functionName, }); if (response.error) { throw new Error(`Failed to set call breakpoint: ${response.error.message}`); } const result = this.connection.parseBreakpointSet(response); const breakpoint: Breakpoint = { id: result.id, type: 'call', state: 'enabled', function: functionName, }; this.breakpoints.set(breakpoint.id, breakpoint); return breakpoint; }
- Helper to add a pending call breakpoint before a session starts, stored with ID 'pending_N' and applied later.addCallBreakpoint(functionName: string): PendingBreakpoint { const id = `pending_${++this.breakpointIdCounter}`; const bp: PendingBreakpoint = { id, type: 'call', functionName, enabled: true, createdAt: new Date(), }; this.pendingBreakpoints.set(id, bp); logger.info(`Pending call breakpoint added: ${id} for ${functionName}`); this.emit('breakpointAdded', bp); return bp; }