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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

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}
Behavior3/5

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

Annotations indicate this is a non-readOnly, non-destructive operation, which the description aligns with by implying creation without contradiction. The description adds context beyond annotations by detailing breakpoint types and confirming return details, but doesn't cover behavioral aspects like error handling, permissions, or rate limits. With annotations providing basic safety info, this earns a baseline score.

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 purpose statement, bulleted examples, and separate Args/Returns sections. It's appropriately sized without wasted sentences. Minor improvements could include tighter integration of examples, but overall it's efficient and front-loaded.

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 moderate complexity (debugging operation), rich input schema, and presence of an output schema, the description is fairly complete. It explains the tool's purpose, provides usage examples, and outlines parameters and returns. With output schema handling return values, the description focuses on input guidance adequately, though it could benefit from more behavioral context.

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 compensates by explaining the 'params' input with location examples and optional condition. It clarifies that 'params' is a SetBreakpointInput with location and condition, adding meaning beyond the bare schema. However, it doesn't detail all schema properties like 'executable' or 'working_dir', leaving gaps.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Set a breakpoint in a program') with the specific resource (breakpoints). It distinguishes from siblings like lldb_backtrace or lldb_run by focusing on breakpoint creation rather than execution or analysis. However, it doesn't explicitly contrast with lldb_watchpoint, which is a related debugging tool.

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 provides implied usage through examples of breakpoint types (function name, file:line, address, regex), suggesting when to use this tool for debugging. However, it lacks explicit guidance on when to choose this over alternatives like lldb_watchpoint or when not to use it (e.g., during program execution). No prerequisites or sibling comparisons are stated.

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