Stream: cranelift

Topic: ✔ Cranelift debuginfo with set_srcloc?


view this post on Zulip Anqur (Nov 10 2025 at 03:31):

Thanks for all the replies! @fitzgen (he/him) @Adel Prokurov I finally made it by using object and gimli for writing an in-memory ELF object with DWARF, and LLDB's JIT interface now recognizes my generated code. It's lucky that these two are all bundled in the Cranelift related crates. Some notable steps to make this happen:

Then the hard part: do the manual relocations (have to be unsafe):

Because I notice that object::write and object::build only accepts a Cow to write (I'm afraid it copies) the data, but since we already have a portion of in-memory generated code, we only need to set the right address and size.

And now settting breakpoints should work, but stacktraces and unwinding might not work properly, I'm still doing my experimentation on this.

view this post on Zulip Notification Bot (Nov 10 2025 at 03:40):

Anqur has marked this topic as resolved.

view this post on Zulip bjorn3 (Nov 10 2025 at 10:38):

For backtraces/unwinding you could take inspiration from https://github.com/rust-lang/rustc_codegen_cranelift/blob/9d292ca475cf182d404f5c1f4b6eaf07ac8bfb21/src/debuginfo/unwind.rs#L265-L312

Cranelift based backend for rustc. Contribute to rust-lang/rustc_codegen_cranelift development by creating an account on GitHub.

view this post on Zulip bjorn3 (Nov 10 2025 at 10:39):

Although I think that only works for backtraces generated by your executable itself, not for debuggers. For debuggers I suspect you need to include the .eh_frame section in the debuginfo ELF file you register with the debugger.


Last updated: Dec 06 2025 at 06:05 UTC