Open jyn514 opened 4 years ago
Currently cranelift only provides minimal debuginfo support:
But for both of these, it is up to the user to then generate the debuginfo. For examples of doing that, rustc_codegen_cranelift can generate .debug_line information from the srcloc as you have seen (as well as incomplete .debug_info support), and https://github.com/bytecodealliance/cranelift/pull/902 can generate .eh_frame information from the frame layout. Both of these use https://github.com/gimli-rs/gimli to do the writing.
Eventually there will probably be something that makes this all easier for users, but for now it's a bit experimental.
@philipc thanks for the tips! For now, this is fairly low on the todo-list, so I'm fine with waiting a little to see if a better API pops up. If not, I may get to it in a month or so.
Currently, the debug info is mostly so I can debug my own bad codegen, since no one is using my compiler for their own projects yet.
Related to https://github.com/jyn514/rcc/issues/16, but at the object file level instead of assembly level: We should emit debug info for the binary we emit.
I think https://docs.rs/cranelift-frontend/0.51.0/cranelift_frontend/struct.FunctionBuilder.html?search=#method.set_srcloc is the API we want?