Skip to main content
Glama

lldb_run

Execute a program under debugger control to analyze runtime behavior. Loads executable, sets breakpoints, runs code, and returns program state including backtrace and variables for debugging C/C++ applications.

Instructions

Run a program under the debugger with optional breakpoints.

This tool:
1. Loads the executable
2. Sets any specified breakpoints
3. Runs the program (optionally stopping at entry)
4. Returns the state when stopped

Args:
    params: RunProgramInput with executable, args, and breakpoints

Returns:
    str: Program state after stopping (backtrace, variables)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'lldb_run' tool, including decorator. It sets up LLDB commands to load the target, set breakpoints and environment, run the program, capture backtrace and frame variables, and formats the output.
    @mcp.tool(
        name="lldb_run",
        annotations={
            "title": "Run Program",
            "readOnlyHint": False,
            "destructiveHint": False,
            "idempotentHint": False,
            "openWorldHint": True,
        },
    )
    async def lldb_run(params: RunProgramInput) -> str:
        """Run a program under the debugger with optional breakpoints.
    
        This tool:
        1. Loads the executable
        2. Sets any specified breakpoints
        3. Runs the program (optionally stopping at entry)
        4. Returns the state when stopped
    
        Args:
            params: RunProgramInput with executable, args, and breakpoints
    
        Returns:
            str: Program state after stopping (backtrace, variables)
        """
        commands = [f"target create {params.executable}"]
    
        # Set environment variables
        if params.environment:
            for key, value in params.environment.items():
                commands.append(f"settings set target.env-vars {key}={value}")
    
        # Set breakpoints
        if params.breakpoints:
            for bp in params.breakpoints:
                if ":" in bp and not bp.startswith("0x"):
                    parts = bp.rsplit(":", 1)
                    commands.append(f"breakpoint set --file {parts[0]} --line {parts[1]}")
                else:
                    commands.append(f"breakpoint set --name {bp}")
        elif params.stop_at_entry:
            commands.append("breakpoint set --name main")
    
        # Prepare run command
        run_cmd = "run"
        if params.args:
            run_cmd += " " + " ".join(params.args)
    
        commands.extend([run_cmd, "thread backtrace", "frame variable", "quit"])
    
        result = _run_lldb_script(commands, working_dir=params.working_dir)
    
        return (
            f"## Program Run: `{Path(params.executable).name}`\n\n```\n{result['output'].strip()}\n```"
        )
  • Pydantic BaseModel defining the input parameters for the lldb_run tool, including executable path, arguments, breakpoints, environment, stop_at_entry flag, and working directory.
    class RunProgramInput(BaseModel):
        """Input for running a program with debugging."""
    
        model_config = ConfigDict(str_strip_whitespace=True)
    
        executable: str = Field(..., description="Path to the executable to run", min_length=1)
        args: list[str] | None = Field(
            default=None, description="Command-line arguments to pass to the program"
        )
        breakpoints: list[str] | None = Field(
            default=None, description="List of breakpoint locations to set before running"
        )
        environment: dict[str, str] | None = Field(
            default=None, description="Environment variables to set"
        )
        stop_at_entry: bool = Field(default=True, description="Stop at the entry point (main function)")
        working_dir: str | None = Field(default=None, description="Working directory for the program")
  • MCP tool registration decorator specifying the name 'lldb_run' and annotations for the tool.
    @mcp.tool(
        name="lldb_run",
        annotations={
            "title": "Run Program",
            "readOnlyHint": False,
            "destructiveHint": False,
            "idempotentHint": False,
            "openWorldHint": True,
        },
    )
  • Helper function used by lldb_run to execute a sequence of LLDB commands in batch mode via subprocess.
    def _run_lldb_script(
        commands: list[str],
        target: str | None = None,
        working_dir: str | None = None,
        timeout: int = 60,
    ) -> dict[str, Any]:
        """
        Execute multiple LLDB commands in sequence.
        """
        cmd = [LLDB_EXECUTABLE]
    
        if target:
            cmd.extend(["--file", target])
    
        cmd.append("--batch")
    
        for command in commands:
            cmd.extend(["-o", command])
    
        try:
            result = subprocess.run(
                cmd, capture_output=True, text=True, timeout=timeout, cwd=working_dir or os.getcwd()
            )
            return {
                "success": result.returncode == 0,
                "output": result.stdout,
                "error": result.stderr if result.returncode != 0 else None,
                "return_code": result.returncode,
            }
        except subprocess.TimeoutExpired:
            return {
                "success": False,
                "output": "",
                "error": f"Commands timed out after {timeout} seconds",
                "return_code": -1,
            }
        except Exception as e:
            return {"success": False, "output": "", "error": str(e), "return_code": -1}
Behavior4/5

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

Annotations provide readOnlyHint=false, openWorldHint=true, idempotentHint=false, and destructiveHint=false. The description adds valuable behavioral context beyond annotations: it details the multi-step process (loads executable, sets breakpoints, runs program, returns state), specifies what happens when stopped, and describes the return content. No contradiction with annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with a clear opening sentence, numbered steps, and separate Args/Returns sections. It's appropriately sized but could be slightly more concise by integrating the steps into the main flow. Every sentence adds value, though the formatting is slightly verbose.

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 the tool's complexity (debugging execution), rich annotations, and presence of an output schema (which handles return values), the description is mostly complete. It covers the purpose, process, and key parameters, though it could benefit from more usage guidelines and parameter details to fully compensate for the 0% schema coverage.

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

Parameters3/5

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

Schema description coverage is 0%, but the description adds minimal parameter semantics: it mentions 'optional breakpoints' and 'optionally stopping at entry', and references 'RunProgramInput with executable, args, and breakpoints'. However, it doesn't fully compensate for the low coverage by explaining all parameters like environment or working_dir. Baseline 3 is appropriate as it adds some meaning but not comprehensive details.

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 specific action ('Run a program under the debugger') and resource ('executable'), distinguishing it from siblings like lldb_set_breakpoint (which only sets breakpoints) and lldb_run_command (which runs debugger commands). The four-step breakdown provides explicit scope.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for running programs with debugging, but lacks explicit guidance on when to use this vs alternatives like lldb_run_command or prerequisites. It mentions 'optional breakpoints' and 'optionally stopping at entry', which gives some context but no clear exclusions or comparisons to siblings.

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

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