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
+19
View File
@@ -30,6 +30,7 @@ contributions.
- [Old LLVM versions](#old-llvm-versions)
- [Asking for help](#asking-for-help)
- [Troubleshooting debug issues](#troubleshooting-debug-issues)
- [Using LLDB from the command line](#using-lldb-from-the-command-line)
- [Debugging with GDB instead of LLDB](#debugging-with-gdb-instead-of-lldb)
- [Debugging other build modes](#debugging-other-build-modes)
- [Debugging on MacOS](#debugging-on-macos)
@@ -351,6 +352,24 @@ lldb bazel-bin/toolchain/carbon
Any installed version of LLDB at least as recent as the installed Clang used for
building should work.
### Using LLDB from the command line
We include launch commands for running lldb in VSCode in
[`.vscode/lldb_launch.json`](/.vscode/lldb_launch.json). But it's also possible
to run lldb from the command line.
When running the debugger, include the `--local-lldbinit` argument to use our
preset configuration options. This requires running from the repository root.
To debug a single `file_test`, use the following command, pointing it to an
actual carbon test file.
```
bazel build -c dbg //toolchain/testing:file_test && \
lldb --local-lldbinit bazel-bin/toolchain/testing/file_test -- \
--dump_output --file_tests /path/to/some/test.carbon
```
### Debugging with GDB instead of LLDB
If you prefer using GDB, you may want to pass some extra flags to the build: