Skip to main content
Glama

lldb_source

Display source code from debugged executables by line number, function name, or current position to inspect program logic during debugging sessions.

Instructions

List source code for a file, function, or current location.

Can display:
- Source around a specific line
- Source for a named function
- Source at the current debug position

Args:
    params: ListSourceInput specifying what source to show

Returns:
    str: Source code listing with line numbers

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Implementation Reference

  • The handler function executes LLDB source listing commands based on the provided input parameters and formats the output as markdown.
    async def lldb_source(params: ListSourceInput) -> str:
        """List source code for a file, function, or current location.
    
        Can display:
        - Source around a specific line
        - Source for a named function
        - Source at the current debug position
    
        Args:
            params: ListSourceInput specifying what source to show
    
        Returns:
            str: Source code listing with line numbers
        """
        commands = [f"target create {params.executable}"]
    
        if params.function:
            commands.append(f"source list --name {params.function} --count {params.count}")
        elif params.file and params.line:
            commands.append(
                f"source list --file {params.file} --line {params.line} --count {params.count}"
            )
        elif params.file:
            commands.append(f"source list --file {params.file} --count {params.count}")
        else:
            commands.append(f"source list --count {params.count}")
    
        result = _run_lldb_script(commands)
    
        title = params.function or params.file or "Source"
        return f"## {title}\n\n```cpp\n{result['output'].strip()}\n```"
  • Pydantic input model defining parameters for the lldb_source tool: executable path, optional file/line/function, and line count.
    class ListSourceInput(BaseModel):
        """Input for listing source code."""
    
        model_config = ConfigDict(str_strip_whitespace=True)
    
        executable: str = Field(..., description="Path to the executable", min_length=1)
        file: str | None = Field(
            default=None, description="Source file to list (if None, lists around current location)"
        )
        line: int | None = Field(default=None, description="Line number to center on", ge=1)
        count: int = Field(default=20, description="Number of lines to show", ge=1, le=500)
        function: str | None = Field(default=None, description="Show source for a specific function")
  • MCP tool registration decorator that registers the lldb_source handler with metadata annotations.
    @mcp.tool(
        name="lldb_source",
        annotations={
            "title": "List Source 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