lldb_read_memory
Read memory contents from specified addresses in C/C++ programs using hex, binary, decimal, string, or instruction formats for debugging analysis.
Instructions
Read and display memory contents at a specified address.
Memory can be displayed in various formats:
- 'x': Hexadecimal (default)
- 'b': Binary
- 'd': Decimal
- 's': String (null-terminated)
- 'i': Instructions (disassembly)
Args:
params: ReadMemoryInput with address, count, and format
Returns:
str: Memory contents in requested format
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| params | Yes |
Implementation Reference
- lldb_mcp_server.py:778-812 (handler)The main handler function that implements the lldb_read_memory tool logic. It constructs LLDB commands to read memory at the specified address, optionally sets a breakpoint and runs to it, executes the memory read command, and formats the output as Markdown.async def lldb_read_memory(params: ReadMemoryInput) -> str: """Read and display memory contents at a specified address. Memory can be displayed in various formats: - 'x': Hexadecimal (default) - 'b': Binary - 'd': Decimal - 's': String (null-terminated) - 'i': Instructions (disassembly) Args: params: ReadMemoryInput with address, count, and format Returns: str: Memory contents in requested format """ commands = [f"target create {params.executable}"] if params.breakpoint: commands.extend( [ f"breakpoint set --name {params.breakpoint}", "run", ] ) mem_cmd = f"memory read --format {params.format} --count {params.count} {params.address}" commands.append(mem_cmd) if params.breakpoint: commands.append("quit") result = _run_lldb_script(commands) return f"## Memory at `{params.address}`\n\n```\n{result['output'].strip()}\n```"
- lldb_mcp_server.py:768-777 (registration)The @mcp.tool decorator registers the lldb_read_memory tool with the MCP server, specifying its name and annotations describing its behavior (read-only, idempotent, etc.).@mcp.tool( name="lldb_read_memory", annotations={ "title": "Read Memory", "readOnlyHint": True, "destructiveHint": False, "idempotentHint": True, "openWorldHint": False, }, )
- lldb_mcp_server.py:258-275 (schema)Pydantic model defining the input schema for the lldb_read_memory tool, including fields for executable path, memory address, byte count, output format, and optional breakpoint.class ReadMemoryInput(BaseModel): """Input for reading memory.""" model_config = ConfigDict(str_strip_whitespace=True) executable: str = Field(..., description="Path to the executable", min_length=1) address: str = Field( ..., description="Memory address to read from (hex, e.g., '0x7fff5fbff000')", min_length=1 ) count: int = Field(default=64, description="Number of bytes to read", ge=1, le=4096) format: str = Field( default="x", description="Output format: 'x' (hex), 'b' (binary), 'd' (decimal), 's' (string), 'i' (instructions)", ) breakpoint: str | None = Field( default=None, description="Breakpoint location to stop at before reading memory" )