Skip to main content
Glama

lldb_watchpoint

Set watchpoints to pause program execution when specific variables are accessed, enabling precise debugging of memory interactions in C/C++ code.

Instructions

Set a watchpoint to break when a variable is accessed.

Watch types:
- 'write': Break when value is written (modified)
- 'read': Break when value is read
- 'read_write': Break on any access

Args:
    params: WatchpointInput with variable and access type

Returns:
    str: Confirmation of watchpoint creation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Implementation Reference

  • The handler function for the 'lldb_watchpoint' tool. It constructs LLDB commands to create a target, set a watchpoint on the specified variable with the given watch type and optional condition, lists the watchpoints, executes them using _run_lldb_script, and formats the output.
    async def lldb_watchpoint(params: WatchpointInput) -> str:
        """Set a watchpoint to break when a variable is accessed.
    
        Watch types:
        - 'write': Break when value is written (modified)
        - 'read': Break when value is read
        - 'read_write': Break on any access
    
        Args:
            params: WatchpointInput with variable and access type
    
        Returns:
            str: Confirmation of watchpoint creation
        """
        commands = [f"target create {params.executable}"]
    
        wp_cmd = f"watchpoint set variable {params.variable}"
    
        if params.watch_type == "read":
            wp_cmd += " --watch read"
        elif params.watch_type == "read_write":
            wp_cmd += " --watch read_write"
        # Default is write
    
        commands.append(wp_cmd)
    
        if params.condition:
            commands.append(f"watchpoint modify --condition '{params.condition}'")
    
        commands.append("watchpoint list")
    
        result = _run_lldb_script(commands)
    
        return f"## Watchpoint on `{params.variable}`\n\n```\n{result['output'].strip()}\n```"
  • Pydantic BaseModel defining the input parameters for the lldb_watchpoint tool, including executable path, variable to watch, watch type, and optional condition.
    class WatchpointInput(BaseModel):
        """Input for setting watchpoints."""
    
        model_config = ConfigDict(str_strip_whitespace=True)
    
        executable: str = Field(..., description="Path to the executable", min_length=1)
        variable: str = Field(..., description="Variable name or memory address to watch", min_length=1)
        watch_type: str = Field(
            default="write", description="Type of access to watch: 'write', 'read', 'read_write'"
        )
        condition: str | None = Field(
            default=None, description="Conditional expression for the watchpoint"
        )
  • MCP tool registration decorator that registers the lldb_watchpoint handler function with the FastMCP server, including name and annotations for the tool.
    @mcp.tool(
        name="lldb_watchpoint",
        annotations={
            "title": "Set Watchpoint",
            "readOnlyHint": False,
            "destructiveHint": False,
            "idempotentHint": False,
            "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