Skip to main content
Glama
sbergeron42

gdb-multiarch-mcp

by sbergeron42

gdb_get_variables

Retrieve local variables from a specific stack frame during Nintendo Switch debugging with gdb-multiarch.

Instructions

Get local variables for a stack frame.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
thread_idNoThread ID (None for current)
frameNoFrame number (0 is current)

Implementation Reference

  • The implementation of get_variables which interacts with GDB/MI via commands -thread-select, -stack-select-frame, and -stack-list-variables.
    def get_variables(self, thread_id: Optional[int] = None, frame: int = 0) -> dict[str, Any]:
        """
        Get local variables for a specific frame.
    
        Args:
            thread_id: Thread ID (None for current)
            frame: Frame number (0 is current frame)
    
        Returns:
            Dict with variable information
        """
        # Switch thread if needed
        if thread_id is not None:
            thread_result = self.execute_command(f"-thread-select {thread_id}")
            if thread_result.get("status") == "error":
                return thread_result
    
        # Select frame
        frame_result = self.execute_command(f"-stack-select-frame {frame}")
        if frame_result.get("status") == "error":
            return frame_result
    
        # Get variables
        result = self.execute_command("-stack-list-variables --simple-values")
    
        if result["status"] == "error":
            return result
    
        mi_result = self._extract_mi_result(result) or {}
        variables = mi_result.get("variables", [])
    
        return {"status": "success", "thread_id": thread_id, "frame": frame, "variables": variables}
  • Tool registration for gdb_get_variables in the MCP server.
    Tool(
        name="gdb_get_variables",
        description="Get local variables for a stack frame.",
        inputSchema=GetVariablesArgs.model_json_schema(),
    ),
  • The tool handler branch that calls session.get_variables.
    elif name == "gdb_get_variables":
        a = GetVariablesArgs(**arguments)
        result = session.get_variables(thread_id=a.thread_id, frame=a.frame)

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/sbergeron42/gdb-multiarch-mcp'

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