Skip to main content
Glama

lldb_set_breakpoint

Set breakpoints in C/C++ programs to pause execution at specific functions, lines, or addresses for debugging purposes.

Instructions

Set a breakpoint in a program.

Breakpoints can be set by: - Function name: 'main', 'MyClass::method' - File and line: 'main.cpp:42' - Address: '0x400500' - Regex: Use 'breakpoint set -r pattern' Args: params: SetBreakpointInput with location and optional condition Returns: str: Confirmation of breakpoint creation with details

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Implementation Reference

  • The handler function implementing the lldb_set_breakpoint tool. It constructs LLDB commands to create a breakpoint based on the provided location (function, file:line, or address), optionally adds a condition, executes the commands using _run_lldb_script, and returns formatted success or error output.
    async def lldb_set_breakpoint(params: SetBreakpointInput) -> str: """Set a breakpoint in a program. Breakpoints can be set by: - Function name: 'main', 'MyClass::method' - File and line: 'main.cpp:42' - Address: '0x400500' - Regex: Use 'breakpoint set -r pattern' Args: params: SetBreakpointInput with location and optional condition Returns: str: Confirmation of breakpoint creation with details """ commands = [f"target create {params.executable}"] # Determine breakpoint type from location format if ":" in params.location and not params.location.startswith("0x"): # File:line format parts = params.location.rsplit(":", 1) bp_cmd = f"breakpoint set --file {parts[0]} --line {parts[1]}" elif params.location.startswith("0x"): # Address bp_cmd = f"breakpoint set --address {params.location}" else: # Function name bp_cmd = f"breakpoint set --name {params.location}" if params.condition: bp_cmd += f" --condition '{params.condition}'" commands.append(bp_cmd) commands.append("breakpoint list") result = _run_lldb_script(commands, working_dir=params.working_dir) if result["success"]: return f"**Breakpoint set successfully**\n\n```\n{result['output']}\n```" else: return ( f"**Error setting breakpoint:** {result.get('error')}\n\n```\n{result['output']}\n```" )
  • MCP tool registration decorator that registers the lldb_set_breakpoint handler with the specified name and annotations indicating its behavior (not read-only, not idempotent, etc.).
    @mcp.tool( name="lldb_set_breakpoint", annotations={ "title": "Set Breakpoint", "readOnlyHint": False, "destructiveHint": False, "idempotentHint": False, "openWorldHint": False, }, )
  • Pydantic BaseModel defining the input schema for the lldb_set_breakpoint tool, validating executable path, breakpoint location, optional condition, and working directory.
    class SetBreakpointInput(BaseModel): """Input for setting breakpoints.""" model_config = ConfigDict(str_strip_whitespace=True) executable: str = Field(..., description="Path to the executable", min_length=1) location: str = Field( ..., description="Breakpoint location: function name (e.g., 'main'), file:line (e.g., 'main.cpp:42'), or address (e.g., '0x1234')", min_length=1, ) condition: str | None = Field( default=None, description="Conditional expression for the breakpoint (e.g., 'i > 10')" ) working_dir: str | None = Field(default=None, description="Working directory for the session")
  • Helper function used by the handler to execute the sequence of LLDB commands via subprocess, capturing output and handling errors/timeouts.
    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}

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