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
| Name | Required | Description | Default |
|---|---|---|---|
| session_id | Yes |
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)}" - modules/gdb/gdbTools.py:73-77 (handler)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" - modules/gdb/sessionManager.py:39-50 (handler)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 - modules/base/debuggerBase.py:47-50 (schema)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 - modules/debuggerFactory.py:85-102 (helper)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}")