Document and configure running lldb from the command line (#5324)

The docs explain that you must use `--local-lldbinit` in the command
line, and include an example of how to run a file_test under lldb from
the command line.

This PR includes `.lldbinit` file and `lldbinit.py` file which set up
our default options, copied from the VSCode launcher.

The instructions include settin the `max-string-summary-length`, and we
include this in the vscode launcher for lldb, as printing `Dump()`
output can easily get truncated otherwise when printing an InstBlockId.
This commit is contained in:
Dana Jansens
2025-04-17 21:18:25 +00:00
committed by GitHub
parent 84a0060447
commit c3e112e664
4 changed files with 58 additions and 1 deletions
+28
View File
@@ -0,0 +1,28 @@
#!/usr/bin/env python3
"""Initialization for lldb."""
__copyright__ = """
Part of the Carbon Language project, under the Apache License v2.0 with LLVM
Exceptions. See /LICENSE for license information.
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
"""
# This script is only meant to be used from LLDB.
import lldb # type: ignore
import os
project_root = os.path.dirname(os.path.realpath(__file__))
ci = lldb.debugger.GetCommandInterpreter()
result = lldb.SBCommandReturnObject()
def RunCommand(cmd: str) -> None:
"""Runs a command and prints it to the console to show that it ran."""
print("(lldb) %s" % cmd)
ci.HandleCommand(cmd, result)
RunCommand(f"settings append target.source-map . {project_root}")
RunCommand(f"settings append target.source-map /proc/self/cwd {project_root}")