Skip to main content
Glama

lldb_disassemble

View assembly instructions by disassembling machine code from functions, address ranges, or current execution frames in C/C++ programs.

Instructions

Disassemble machine code to view assembly instructions.

Can disassemble:
- A named function: 'main', 'MyClass::method'
- An address range: '0x1000-0x1100' or '0x1000 0x1100'
- Current frame (when stopped at breakpoint)

Options:
- show_bytes: Include raw opcode bytes
- mixed: Interleave source code with assembly

Args:
    params: DisassembleInput with target and display options

Returns:
    str: Assembly listing

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Implementation Reference

  • Main handler function that constructs and executes LLDB 'disassemble' commands based on input parameters, supporting functions, addresses, ranges, with options for showing bytes and mixed source+asm.
    async def lldb_disassemble(params: DisassembleInput) -> str:
        """Disassemble machine code to view assembly instructions.
    
        Can disassemble:
        - A named function: 'main', 'MyClass::method'
        - An address range: '0x1000-0x1100' or '0x1000 0x1100'
        - Current frame (when stopped at breakpoint)
    
        Options:
        - show_bytes: Include raw opcode bytes
        - mixed: Interleave source code with assembly
    
        Args:
            params: DisassembleInput with target and display options
    
        Returns:
            str: Assembly listing
        """
        commands = [f"target create {params.executable}"]
    
        dis_cmd = "disassemble"
    
        if "-" in params.target and params.target.startswith("0x"):
            # Address range
            parts = params.target.split("-")
            dis_cmd += f" --start-address {parts[0]} --end-address {parts[1]}"
        elif params.target.startswith("0x"):
            # Single address
            dis_cmd += f" --start-address {params.target} --count 50"
        elif params.target.lower() == "current":
            dis_cmd += " --frame"
        else:
            # Function name
            dis_cmd += f" --name {params.target}"
    
        if params.show_bytes:
            dis_cmd += " --bytes"
        if params.mixed:
            dis_cmd += " --mixed"
    
        commands.append(dis_cmd)
    
        result = _run_lldb_script(commands)
    
        return f"## Disassembly: `{params.target}`\n\n```asm\n{result['output'].strip()}\n```"
  • Pydantic input model validating parameters: executable path, disassembly target (function/address/'current'), flags for bytes and mixed mode.
    class DisassembleInput(BaseModel):
        """Input for disassembling code."""
    
        model_config = ConfigDict(str_strip_whitespace=True)
    
        executable: str = Field(..., description="Path to the executable", min_length=1)
        target: str = Field(
            ...,
            description="What to disassemble: function name, address range (e.g., '0x1000-0x1100'), or 'current' for current frame",
            min_length=1,
        )
        show_bytes: bool = Field(default=False, description="Show opcode bytes alongside instructions")
        mixed: bool = Field(default=False, description="Show mixed source and assembly")
  • MCP tool registration decorator specifying the tool name and annotations for read-only, non-destructive behavior.
    @mcp.tool(
        name="lldb_disassemble",
        annotations={
            "title": "Disassemble Code",
            "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