ERR/E3.0 (slice 2): emit DWARF line-info
Attach LLVM debug metadata so a captured return-address PC resolves to file:line:col (the runtime half E3.3 needs) and sx binaries become debuggable in lldb/gdb. - llvm_api.zig: bind llvm-c/DebugInfo.h (DIBuilder C API was unbound). - emit_llvm.zig: DIBuilder + one DICompileUnit/DIFile on the main file, a DISubprogram per function (LLVMSetSubprogram), and a DILocation per instruction from Inst.span (errors.SourceLoc.compute, scoped to the subprogram). Plus the "Debug Info Version"/"Dwarf Version" module flags and LLVMDIBuilderFinalize. - Gated on opt none/less + a wired source map (setDebugContext from core.zig), mirroring lower.zig's tracesEnabled; release strips it. Verified: sx ir/sx asm --opt none show correct DILocations + .loc directives; the 290-example JIT suite (-O0 -> debug on) verifies and runs unchanged. +2 DWARF unit tests.
This commit is contained in:
@@ -146,6 +146,7 @@ pub const Compilation = struct {
|
||||
const ir_mod_ptr = try self.allocator.create(ir.Module);
|
||||
ir_mod_ptr.* = try self.lowerToIR();
|
||||
var emitter = ir.LLVMEmitter.init(self.allocator, ir_mod_ptr, "sx_module", self.target_config);
|
||||
emitter.setDebugContext(&self.import_sources, self.file_path);
|
||||
emitter.emit();
|
||||
// Keep the IR module alive past LLVM emission so post-link
|
||||
// callbacks can re-enter the interpreter via `invokeByName`.
|
||||
|
||||
Reference in New Issue
Block a user