lldb_watchpoint
Set watchpoints to debug C/C++ programs by breaking execution when specific variables are accessed, modified, or read during runtime.
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
| Name | Required | Description | Default |
|---|---|---|---|
| params | Yes |
Implementation Reference
- lldb_mcp_server.py:1060-1093 (handler)The asynchronous handler function for the lldb_watchpoint tool. It sets up LLDB commands to create a watchpoint on the specified variable or address with the given watch type (read, write, read_write) and optional condition, executes them, lists the watchpoints, and returns formatted 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```"
- lldb_mcp_server.py:364-377 (schema)Pydantic BaseModel defining the input parameters for the lldb_watchpoint tool: executable path, variable/address 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" )
- lldb_mcp_server.py:1050-1059 (registration)The @mcp.tool decorator registration for the lldb_watchpoint tool, specifying its name and operational annotations.@mcp.tool( name="lldb_watchpoint", annotations={ "title": "Set Watchpoint", "readOnlyHint": False, "destructiveHint": False, "idempotentHint": False, "openWorldHint": False, }, )