Skip to main content
Glama

gdb_terminate

Stop a debugging session in GDB to end program analysis and free system resources.

Instructions

Terminate a GDB debugging session.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
session_idYes

Implementation Reference

  • server.py:88-94 (handler)
    MCP tool handler function 'gdb_terminate' decorated with @mcp.tool(). This is the main entry point that calls _get_gdb_tools().terminate_session(session_id).
    @mcp.tool()
    def gdb_terminate(session_id: str) -> str:
        """Terminate a GDB debugging session."""
        try:
            return _get_gdb_tools().terminate_session(session_id)
        except Exception as e:
            return f"Error: {str(e)}"
  • Concrete implementation of terminate_session in GDBTools class. Calls sessionManager.terminate_session(session_id) and returns success/error message with error handling via @handle_gdb_errors decorator.
    @handle_gdb_errors("terminating session")
    def terminate_session(self, session_id: str) -> str:
        if self.sessionManager.terminate_session(session_id):
            return f"GDB session '{session_id}' terminated successfully"
        return f"GDB session '{session_id}' not found"
  • Core session termination logic in GDBSessionManager. Terminates GDB process by calling gdb.exit(), removes session from dictionary, and returns True/False based on success.
    def terminate_session(self, session_id: str) -> bool:
        if session_id not in self.sessions:
            return False
        try:
            gdb = self.sessions[session_id]
            gdb.exit()
            del self.sessions[session_id]
            logger.info(f"Terminated GDB session: {session_id}")
            return True
        except Exception as e:
            logger.error(f"Failed to terminate GDB session: {e}")
            return False
  • Abstract method definition for terminate_session in DebuggerTools base class. Defines the interface contract that all debugger tool implementations must follow.
    @abstractmethod
    def terminate_session(self, session_id: str) -> str:
        """Terminate a debugging session."""
        pass
  • Factory method create_tools() that instantiates GDBTools with a GDBSessionManager. Called by _get_gdb_tools() in server.py to create the debugger tools instance.
    def create_tools(debugger_type: Optional[str] = None) -> Tuple[DebuggerTools, str]:
        """
        Create debugger tools.
        
        Args:
            debugger_type: 'gdb', 'lldb', or None for auto-detection
            
        Returns:
            Tuple of (tools, actual_debugger_type)
        """
        session_manager, actual_type = DebuggerFactory.create_session_manager(debugger_type)
        
        if actual_type == 'gdb':
            return GDBTools(session_manager), 'gdb'
        elif actual_type == 'lldb':
            return LLDBTools(session_manager), 'lldb'
        
        raise RuntimeError(f"Unknown debugger type: {actual_type}")

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/smadi0x86/GDB-MCP'

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