From f5d9160f1b9fcf7b459c6746e8256d349f0c6873 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Wed, 30 Mar 2022 11:03:50 +0200 Subject: dwarf: pass DeclState around instead of storing a temp global in Dwarf Avoids many pitfalls connected with premature/early return in case there are errors with Decl, etc. This is effectively bringing back the old design however in a much nicer packaging, where every mechanism related to tracking Decl's debug info is now nicely wrapped in a single struct (aka the `DeclState`). This includes relocation table, type arena, etc. It is now the caller's responsibility to deinit the state (so that no memory is leaked) after `Decl` has been analysed (or errored out). The caller here is typically a linker such as `Elf` or `MachO`. --- src/codegen.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/codegen.zig') diff --git a/src/codegen.zig b/src/codegen.zig index fa84ad0d52..2ace45c8cb 100644 --- a/src/codegen.zig +++ b/src/codegen.zig @@ -42,7 +42,7 @@ pub const GenerateSymbolError = error{ }; pub const DebugInfoOutput = union(enum) { - dwarf: *link.File.Dwarf, + dwarf: *link.File.Dwarf.DeclState, /// the plan9 debuginfo output is a bytecode with 4 opcodes /// assume all numbers/variables are bytes /// 0 w x y z -> interpret w x y z as a big-endian i32, and add it to the line offset -- cgit v1.2.3