News for hackers. Stuff that matters.
Re:A Complete Guide to LLVM for Programming Language Creators by broken_symlink on Saturday December 26, 2020 @04:36AM (#25542378)
Can you print variables in lldb with the debug information?

One compiler that I use which emits llvm ir added support for debug information recently and its now possible to set breakpoints in gdb but you can't print out any stack variables or anything so its not useful other than figuring out which code paths execute.

I'd like to learn more about this. Maybe contribute to the compiler and fix this issue.

Re:A Complete Guide to LLVM for Programming Language Creators by jmorse2 on Saturday December 26, 2020 @06:49AM (#25542865)
> I'd like to learn more about this. Maybe contribute to the compiler and fix this issue.

You need to create a call to the `llvm.dbg.declare` intrinsic that connects the stack variable alloca to a DILocalVariable metadata node, and place the call after the stack variable alloca. The rest of LLVM will handle tracing the stack location through the compiler to the output, including the alloca being promoted.

See: https://llvm.org/docs/SourceLevelDebugging.html#debugger-int...