gdb_attach
Attach to a running process using session ID and process ID to enable debugging with GDB commands, facilitating real-time analysis and troubleshooting.
Instructions
Attach to a running process
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pid | Yes | Process ID to attach to | |
| sessionId | Yes | GDB session ID |
Implementation Reference
- src/index.ts:659-699 (handler)The handler function that implements the gdb_attach tool logic: validates sessionId, attaches to the given PID using GDB 'attach' command via executeGdbCommand, and returns the output or error.private async handleGdbAttach(args: any) { const { sessionId, pid } = args; if (!activeSessions.has(sessionId)) { return { content: [ { type: 'text', text: `No active GDB session with ID: ${sessionId}` } ], isError: true }; } const session = activeSessions.get(sessionId)!; try { const output = await this.executeGdbCommand(session, `attach ${pid}`); return { content: [ { type: 'text', text: `Attached to process ${pid}\n\nOutput:\n${output}` } ] }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: 'text', text: `Failed to attach to process: ${errorMessage}` } ], isError: true }; } }
- src/index.ts:143-160 (schema)The tool registration including name, description, and input schema defining sessionId (string) and pid (number) as required parameters.{ name: 'gdb_attach', description: 'Attach to a running process', inputSchema: { type: 'object', properties: { sessionId: { type: 'string', description: 'GDB session ID' }, pid: { type: 'number', description: 'Process ID to attach to' } }, required: ['sessionId', 'pid'] } },
- src/index.ts:369-370 (registration)The dispatch case in the CallToolRequestHandler switch statement that routes 'gdb_attach' calls to the handleGdbAttach method.case 'gdb_attach': return await this.handleGdbAttach(request.params.arguments);