-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
LLDB for Zig
@jacobly0 maintains a fork of LLDB with Zig support: https://github.com/jacobly0/llvm-project/tree/lldb-zig
This fork works best with Zig's self-hosted backends, i.e. zig build-exe -fno-llvm -fno-lld ...
.
To build the LLDB fork, make sure you have prerequisites installed, and then do something like:
$ cmake -G Ninja -B build -DLLVM_ENABLE_PROJECTS="clang;lldb" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLLVM_ENABLE_ASSERTIONS=ON
$ cmake --build build --target lldb --target lldb-server
(You may need to manually configure dependencies if CMake can't find them.)
Once built, you can run ./build/bin/lldb
and so on.
If you will be debugging the Zig compiler itself, or if you will be debugging any project compiled with Zig's LLVM backend (not recommended with the LLDB fork, prefer vanilla LLDB with a version that matches the version of LLVM that Zig is using), you can get a better debugging experience by using lldb_pretty_printers.py
.
Put this line in ~/.lldbinit
:
command script import /path/to/zig/tools/lldb_pretty_printers.py
If you will be using Zig's LLVM backend (again, not recommended with the LLDB fork), you will also want these lines:
type category enable zig.lang
type category enable zig.std
If you will be debugging a Zig compiler built using Zig's LLVM backend (again, not recommended with the LLDB fork), you will also want this line:
type category enable zig.stage2