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
| Name | Required | Description | Default |
|---|---|---|---|
| session_id | Yes | Session ID from gdb_start_session | |
| thread_id | Yes | Thread ID to select |
Implementation Reference
- src/gdb_mcp/gdb_interface.py:846-868 (handler)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"), } - src/gdb_mcp/server.py:158-161 (schema)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") - src/gdb_mcp/server.py:257-267 (registration)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(), ), - src/gdb_mcp/server.py:497-499 (handler)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)