I need to debug a binary produced by the Zig self-hosted backend. I couldn’t get the jacobly0/llvm-project to compile, and it looks stale, with the last update happening 3 years ago. Is the debugging section testing-zig-code-with-lldb outdated? Is there a newer repo somewhere?
Did you look at the lldb-zig branch GitHub - jacobly0/llvm-project at lldb-zig? The latest commit there is 9 months old. This works for me, but you will still have to build llvm which can take a lot of time depending on your machine.
Beautiful, just beautiful. I’d like to note that this custom lldb debugging is pretty high quality. I see all data structures, enums, etc. Much better than the vanilla llvm/default lldb experience. Very impressive. For posterity, you need to switch to the branch and compile it per the given instructions:
# Switch to the lldb-zig branch:
git fetch origin
git branch -r
git checkout origin/lldb-zig
# Compile...
Before you compile, make sure you comment out all miniconda3 stuff from .bashrc, or else it will replace system libs. Yes, you won’t be able to train any pytorch models during compilation, so give your CUDA cores a little rest.
Finally, once everything is compiled, uncomment miniconda3 stuff and proceed to VSCode > Settings > Extensions > “Code LLDB” and set the paths to the compiled libs:
Advanced > Lldb: Library = /home/user/p/llvm-project/build/lib/liblldb.so
Advanced > Lldb: Server = /home/user/p/llvm-project/build/bin/lldb-server
Make sure that you also update
General > Lldb › Launch: Init Commands to have
command script import /home/user/p/zig/0.16.0/tools/lldb_pretty_printers.py
type category enable zig.std
type category enable zig.lang
type category enable zig.stage2