lldb_source
Display source code from debugged executables by line number, function name, or current position to aid debugging analysis.
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
| Name | Required | Description | Default |
|---|---|---|---|
| params | Yes |
Implementation Reference
- lldb_mcp_server.py:924-955 (handler)The handler function that implements the lldb_source tool logic, executing LLDB commands to list source code based on input parameters.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```"
- lldb_mcp_server.py:318-330 (schema)Pydantic input model defining the parameters for the lldb_source tool.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")
- lldb_mcp_server.py:914-923 (registration)MCP decorator registering the lldb_source tool with name and annotations.@mcp.tool( name="lldb_source", annotations={ "title": "List Source Code", "readOnlyHint": True, "destructiveHint": False, "idempotentHint": True, "openWorldHint": False, }, )