Skip to main content
Glama

gdb_select_thread

Select a thread to set it as the active context for debugging, enabling subsequent backtrace, variable inspection, and expression evaluation commands to operate on that thread.

Instructions

Select a specific thread to make it the current thread. After selecting a thread, subsequent commands like gdb_get_backtrace, gdb_get_variables, and gdb_evaluate_expression will operate on this thread. Use gdb_get_threads to see available thread IDs. Requires session_id parameter (obtained from gdb_start_session).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
session_idYesSession ID from gdb_start_session
thread_idYesThread ID to select

Implementation Reference

  • The select_thread method on GDBSession executes the GDB/MI command '-thread-select <thread_id>' and returns the result with new-thread-id and frame info.
    def select_thread(self, thread_id: int) -> dict[str, Any]:
        """
        Select a specific thread to make it the current thread.
    
        Args:
            thread_id: Thread ID to select
    
        Returns:
            Dict with status and selected thread information
        """
        result = self.execute_command(f"-thread-select {thread_id}")
    
        if result["status"] == "error":
            return result
    
        mi_result = self._extract_mi_result(result) or {}
    
        return {
            "status": "success",
            "thread_id": thread_id,
            "new_thread_id": mi_result.get("new-thread-id"),
            "frame": mi_result.get("frame"),
        }
  • ThreadSelectArgs Pydantic model defines input schema with session_id (int) and thread_id (int) fields.
    class ThreadSelectArgs(BaseModel):
        session_id: int = Field(..., description="Session ID from gdb_start_session")
        thread_id: int = Field(..., description="Thread ID to select")
  • Tool registration in the tools list: defines the tool name 'gdb_select_thread', its description, and inputSchema using ThreadSelectArgs.
    Tool(
        name="gdb_select_thread",
        description=(
            "Select a specific thread to make it the current thread. "
            "After selecting a thread, subsequent commands like gdb_get_backtrace, "
            "gdb_get_variables, and gdb_evaluate_expression will operate on this thread. "
            "Use gdb_get_threads to see available thread IDs. "
            "Requires session_id parameter (obtained from gdb_start_session)."
        ),
        inputSchema=ThreadSelectArgs.model_json_schema(),
    ),
  • Handler dispatch in the tool execution loop: parses ThreadSelectArgs from arguments and calls session.select_thread(thread_id=...).
    elif name == "gdb_select_thread":
        thread_args: ThreadSelectArgs = ThreadSelectArgs(**arguments)
        result = session.select_thread(thread_id=thread_args.thread_id)
Behavior4/5

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

With no annotations, the description effectively conveys that selecting a thread affects later commands. It mentions the session_id requirement from gdb_start_session. No contradictions or missing critical behaviors.

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 two sentences, front-loaded with the primary action, and every sentence adds essential information without redundancy.

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

Completeness5/5

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

The description fully explains the tool's purpose, prerequisites, and effect on subsequent commands. For a simple selection tool with no output schema, it is complete.

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

Parameters4/5

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

Schema coverage is 100%, but the description adds value by linking session_id to gdb_start_session and thread_id to gdb_get_threads, providing context 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 the action 'select a specific thread' and the resource 'thread'. It is distinct from sibling tools like gdb_select_frame and gdb_get_threads.

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 explains when to use the tool (to change context for subsequent commands) and refers to gdb_get_threads for thread IDs. It does not explicitly say when not to use it, but the context is clear.

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