Skip to main content
Glama

gdb_select_frame

Select a stack frame by number to focus the GDB debugging session on that frame's context. Frame 0 is innermost; higher numbers are outer frames. After selecting, commands inspect variables and evaluate expressions within that frame.

Instructions

Select a specific stack frame to make it the current frame. Frame 0 is the innermost (current) frame, higher numbers are outer frames. After selecting a frame, commands like gdb_get_variables and gdb_evaluate_expression will operate in the context of that frame. Use gdb_get_backtrace to see available frames and their numbers. Requires session_id parameter (obtained from gdb_start_session).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
session_idYesSession ID from gdb_start_session
frame_numberYesFrame number (0 is current/innermost frame)

Implementation Reference

  • The GDBSession.select_frame() method sends GDB/MI command '-stack-select-frame' to select a stack frame, then retrieves frame info with '-stack-info-frame' and returns the result with frame number and details.
    def select_frame(self, frame_number: int) -> dict[str, Any]:
        """
        Select a specific stack frame to make it the current frame.
    
        Args:
            frame_number: Frame number (0 is innermost/current frame)
    
        Returns:
            Dict with status and frame information
        """
        result = self.execute_command(f"-stack-select-frame {frame_number}")
    
        if result["status"] == "error":
            return result
    
        # Get info about the selected frame
        frame_info_result = self.execute_command("-stack-info-frame")
    
        if frame_info_result["status"] == "error":
            return {
                "status": "success",
                "frame_number": frame_number,
                "message": f"Frame {frame_number} selected",
            }
    
        mi_result = self._extract_mi_result(frame_info_result) or {}
        frame_info = mi_result.get("frame", {})
    
        return {
            "status": "success",
            "frame_number": frame_number,
            "frame": frame_info,
        }
  • Pydantic model for gdb_select_frame input validation, requiring session_id and frame_number.
    class FrameSelectArgs(BaseModel):
        session_id: int = Field(..., description="Session ID from gdb_start_session")
        frame_number: int = Field(..., description="Frame number (0 is current/innermost frame)")
  • MCP Tool registration for gdb_select_frame with description and input schema reference.
    Tool(
        name="gdb_select_frame",
        description=(
            "Select a specific stack frame to make it the current frame. "
            "Frame 0 is the innermost (current) frame, higher numbers are outer frames. "
            "After selecting a frame, commands like gdb_get_variables and gdb_evaluate_expression "
            "will operate in the context of that frame. "
            "Use gdb_get_backtrace to see available frames and their numbers. "
            "Requires session_id parameter (obtained from gdb_start_session)."
        ),
        inputSchema=FrameSelectArgs.model_json_schema(),
    ),
  • MCP tool call handler that parses arguments via FrameSelectArgs and delegates to session.select_frame().
    elif name == "gdb_select_frame":
        frame_args: FrameSelectArgs = FrameSelectArgs(**arguments)
        result = session.select_frame(frame_number=frame_args.frame_number)
Behavior3/5

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

No annotations are provided, so the description must convey behavioral traits. It discloses that selecting a frame changes the context for commands like gdb_get_variables and gdb_evaluate_expression. However, it does not mention error handling (e.g., invalid frame number) or side effects like modifying GDB state beyond context change.

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 concise with four sentences, each serving a clear purpose: stating the action, defining frame numbering, explaining the effect, and listing prerequisites. No redundant information, and key details are front-loaded.

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?

Given no annotations and no output schema, the description covers the essential aspects: purpose, parameter semantics, usage context, and prerequisite. It could mention potential errors, but for a simple selection tool, the completeness is adequate.

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%, so baseline is 3. The description adds value by explaining the frame_number parameter in context (0=innermost) and specifying that session_id must come from gdb_start_session. This enhances understanding beyond the schema's brief descriptions.

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 tool selects a specific stack frame to be the current frame, distinguishing it from sibling tools like gdb_get_frame_info and gdb_get_backtrace. It specifies the verb 'select' and the resource 'stack frame', with clear differentiation from listing or inspecting frames.

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 provides usage guidance by explaining frame numbering (0 innermost), the effect on subsequent commands, and how to obtain frame numbers via gdb_get_backtrace. It also mentions the prerequisite session_id. However, it does not explicitly state when not to use this tool.

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