Skip to main content
Glama

lldb_read_memory

Read memory contents from a specified address in C/C++ programs during debugging. Display data in hex, binary, decimal, string, or disassembly formats to analyze program state and diagnose issues.

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
NameRequiredDescriptionDefault
paramsYes

Implementation Reference

  • The async handler function that implements the lldb_read_memory tool logic. It constructs LLDB commands to create a target, optionally set a breakpoint and run, read memory at the given address with specified format and count, and formats the output.
    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```"
  • Pydantic BaseModel defining the input parameters for the lldb_read_memory tool, including validation and descriptions.
    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" )
  • The @mcp.tool decorator that registers the lldb_read_memory function as an MCP tool with the specified name and annotations.
    @mcp.tool( name="lldb_read_memory", annotations={ "title": "Read Memory", "readOnlyHint": True, "destructiveHint": False, "idempotentHint": True, "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