Skip to main content
Glama
signal-slot

MCP GDB Server

by signal-slot

gdb_set_breakpoint

Set breakpoints during GDB debugging sessions by specifying a session ID and location, enabling precise control over code execution for debugging workflows.

Instructions

Set a breakpoint

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
conditionNoBreakpoint condition (optional)
locationYesBreakpoint location (e.g., function name, file:line)
sessionIdYesGDB session ID

Implementation Reference

  • The handler function that implements the gdb_set_breakpoint tool. It checks for an active GDB session, executes the 'break' command at the specified location, optionally sets a condition on the breakpoint by parsing the breakpoint number from output, and returns the result or error.
    private async handleGdbSetBreakpoint(args: any) {
      const { sessionId, location, condition } = 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 {
        // Set breakpoint
        let command = `break ${location}`;
        const output = await this.executeGdbCommand(session, command);
        
        // Set condition if provided
        let conditionOutput = '';
        if (condition) {
          // Extract breakpoint number from output (assumes format like "Breakpoint 1 at...")
          const match = output.match(/Breakpoint (\d+)/);
          if (match && match[1]) {
            const bpNum = match[1];
            const conditionCommand = `condition ${bpNum} ${condition}`;
            conditionOutput = await this.executeGdbCommand(session, conditionCommand);
          }
        }
        
        return {
          content: [
            {
              type: 'text',
              text: `Breakpoint set at: ${location}${condition ? ` with condition: ${condition}` : ''}\n\nOutput:\n${output}${conditionOutput ? '\n' + conditionOutput : ''}`
            }
          ]
        };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        return {
          content: [
            {
              type: 'text',
              text: `Failed to set breakpoint: ${errorMessage}`
            }
          ],
          isError: true
        };
      }
    }
  • The input schema for the gdb_set_breakpoint tool, defining the required parameters sessionId and location, and optional condition parameter.
    {
      name: 'gdb_set_breakpoint',
      description: 'Set a breakpoint',
      inputSchema: {
        type: 'object',
        properties: {
          sessionId: {
            type: 'string',
            description: 'GDB session ID'
          },
          location: {
            type: 'string',
            description: 'Breakpoint location (e.g., function name, file:line)'
          },
          condition: {
            type: 'string',
            description: 'Breakpoint condition (optional)'
          }
        },
        required: ['sessionId', 'location']
      }
    },
  • src/index.ts:373-374 (registration)
    The switch case in the CallToolRequestSchema handler that registers and routes calls to the gdb_set_breakpoint handler function.
    case 'gdb_set_breakpoint':
      return await this.handleGdbSetBreakpoint(request.params.arguments);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/signal-slot/mcp-gdb'

If you have feedback or need assistance with the MCP directory API, please join our Discord server