lldb_run
Execute and debug programs using LLDB by loading executables, setting breakpoints, and analyzing program state upon stopping.
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
| Name | Required | Description | Default |
|---|---|---|---|
| params | Yes |
Implementation Reference
- lldb_mcp_server.py:1106-1150 (handler)The handler function that implements the core logic of the 'lldb_run' tool. It constructs LLDB commands to load the target, set breakpoints and environment variables, run the program, capture backtrace and variables, and formats the output.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```" )
- lldb_mcp_server.py:379-396 (schema)Pydantic model defining the input schema (parameters) for the lldb_run tool, including executable path, arguments, breakpoints, environment, and execution options.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")
- lldb_mcp_server.py:1096-1105 (registration)MCP tool registration decorator that registers the lldb_run handler function with the MCP server, specifying the tool name and annotations.@mcp.tool( name="lldb_run", annotations={ "title": "Run Program", "readOnlyHint": False, "destructiveHint": False, "idempotentHint": False, "openWorldHint": True, }, )