Skip to main content
Glama

gdb_stop_session

Stop an active GDB debugging session and release associated resources using the session ID obtained from starting a session.

Instructions

Stop the current GDB session and clean up resources. Requires session_id parameter (obtained from gdb_start_session).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
session_idYesSession ID from gdb_start_session

Implementation Reference

  • Tool registration for gdb_stop_session in the list_tools() function. Defines the tool name, description, and input schema (SessionIdArgs).
    Tool(
        name="gdb_stop_session",
        description=(
            "Stop the current GDB session and clean up resources. "
            "Requires session_id parameter (obtained from gdb_start_session)."
        ),
        inputSchema=SessionIdArgs.model_json_schema(),
    ),
  • Input schema (SessionIdArgs) used by gdb_stop_session. Requires only a session_id integer.
    class SessionIdArgs(BaseModel):
        """Arguments for tools that only need session_id."""
    
        session_id: int = Field(..., description="Session ID from gdb_start_session")
  • Handler logic for gdb_stop_session: calls session.stop() and then removes the session from the session manager.
    elif name == "gdb_stop_session":
        result = session.stop()
        session_manager.remove_session(session_id)
  • GDBSession.stop() method: terminates the GDB controller process, resets session state, and restores the original working directory if changed.
    def stop(self) -> dict[str, Any]:
        """Stop the GDB session."""
        if not self.controller:
            return {"status": "error", "message": "No active session"}
    
        try:
            self.controller.exit()
            self.controller = None
            self.is_running = False
            self.target_loaded = False
    
            # Restore original working directory if it was changed during start()
            if self.original_cwd:
                os.chdir(self.original_cwd)
                logger.info(f"Restored working directory to: {self.original_cwd}")
                self.original_cwd = None
    
            return {"status": "success", "message": "GDB session stopped"}
    
        except Exception as e:
            logger.error(f"Failed to stop GDB session: {e}")
            # Still try to restore working directory even if stop failed
            if self.original_cwd:
                try:
                    os.chdir(self.original_cwd)
                    logger.info(f"Restored working directory after error: {self.original_cwd}")
                    self.original_cwd = None
                except Exception as cwd_error:
                    logger.warning(f"Failed to restore working directory: {cwd_error}")
            return {"status": "error", "message": str(e)}
  • SessionManager.remove_session() method: removes the session from the internal sessions dict under a thread lock.
    def remove_session(self, session_id: int) -> bool:
        """
        Remove a GDB session by its ID.
    
        Args:
            session_id: The session ID to remove
    
        Returns:
            True if session was removed, False if it didn't exist
        """
        with self._lock:
            if session_id in self._sessions:
                del self._sessions[session_id]
                return True
            return False
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must cover behavioral traits. It mentions 'clean up resources,' implying side effects, but does not detail irreversibility, permissions, or what happens to ongoing debugging.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence that conveys all necessary information without wordiness. It is front-loaded and efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple termination tool with one parameter and no output schema, the description is mostly complete. It could mention return values or error conditions, but the core functionality is clear.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema already describes the session_id parameter with 100% coverage. The description only adds that it is obtained from gdb_start_session, which adds marginal value beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Stop the current GDB session and clean up resources,' which is a specific verb+resource combination. It is easily distinguished from sibling tools like gdb_interrupt or gdb_continue.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly mentions the prerequisite session_id from gdb_start_session, indicating when this tool should be used. However, it does not explicitly list alternatives or contexts where it should not be used.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/airfloats/gdb_mcp'

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