Skip to main content
Glama

lldb_evaluate

Evaluate C/C++ expressions during debugging to inspect variables, call functions, and analyze program state in real-time.

Instructions

Evaluate a C/C++ expression in the debugger context.

Expressions can include: - Variable access: 'my_var', 'ptr->member' - Array indexing: 'array[5]' - Function calls: 'strlen(str)' - Casts: '(int*)ptr' - Arithmetic: 'x + y * 2' - sizeof: 'sizeof(MyStruct)' Args: params: EvaluateExpressionInput with expression and context Returns: str: Expression result with type information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Implementation Reference

  • The main handler function that evaluates C/C++ expressions in LLDB debugger context by creating a target, setting a breakpoint, running the program, executing the expression command, and formatting the output.
    async def lldb_evaluate(params: EvaluateExpressionInput) -> str: """Evaluate a C/C++ expression in the debugger context. Expressions can include: - Variable access: 'my_var', 'ptr->member' - Array indexing: 'array[5]' - Function calls: 'strlen(str)' - Casts: '(int*)ptr' - Arithmetic: 'x + y * 2' - sizeof: 'sizeof(MyStruct)' Args: params: EvaluateExpressionInput with expression and context Returns: str: Expression result with type information """ commands = [ f"target create {params.executable}", f"breakpoint set --name {params.breakpoint}", "run" + (" " + " ".join(params.args) if params.args else ""), f"expression {params.expression}", "quit", ] result = _run_lldb_script(commands) return f"## Expression: `{params.expression}`\n\n```\n{result['output'].strip()}\n```"
  • Pydantic input schema defining parameters for the lldb_evaluate tool: executable path, expression to evaluate, breakpoint for context, and optional args.
    class EvaluateExpressionInput(BaseModel): """Input for evaluating expressions.""" model_config = ConfigDict(str_strip_whitespace=True) executable: str = Field(..., description="Path to the executable", min_length=1) expression: str = Field( ..., description="C/C++ expression to evaluate (e.g., 'sizeof(int)', 'ptr->member', 'array[5]')", min_length=1, ) breakpoint: str = Field( ..., description="Breakpoint location for evaluation context", min_length=1 ) args: list[str] | None = Field( default=None, description="Command-line arguments to pass to the program" )
  • MCP decorator registering the lldb_evaluate tool with name and annotations indicating it's read-only, non-destructive, idempotent, etc.
    @mcp.tool( name="lldb_evaluate", annotations={ "title": "Evaluate Expression", "readOnlyHint": True, "destructiveHint": False, "idempotentHint": True, "openWorldHint": False, }, )

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/benpm/claude_lldb_mcp'

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