authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-09-10 17:31:06-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-09-10 17:31:06-04:00
log8ec68c63fa1d0f7e267ff92c054e8aa335f91da4
treee2fbdd384dbc2509c4a3b633b41e651a6e01b157
parent90075345519f165a0164c52b62b78453068c6ce6
parent6aa6d088d93174767d3a8387d536f4083c39e14f
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #21323 from jacobly0/dwarf-decls

Dwarf: implement more decls

26 files changed, 1354 insertions(+), 695 deletions(-)

ci/x86_64-linux-debug.sh+1-1
...@@ -64,7 +64,7 @@ stage3-debug/bin/zig build \...@@ -64,7 +64,7 @@ stage3-debug/bin/zig build \
6464
65stage3-debug/bin/zig build test docs \65stage3-debug/bin/zig build test docs \
66 --maxrss 21000000000 \66 --maxrss 21000000000 \
67 -Dlldb=$HOME/deps/lldb-zig/Debug-befcd57a8/bin/lldb \67 -Dlldb=$HOME/deps/lldb-zig/Debug-4a44163df/bin/lldb \
68 -fqemu \68 -fqemu \
69 -fwasmtime \69 -fwasmtime \
70 -Dstatic-llvm \70 -Dstatic-llvm \
ci/x86_64-linux-release.sh+1-1
...@@ -64,7 +64,7 @@ stage3-release/bin/zig build \...@@ -64,7 +64,7 @@ stage3-release/bin/zig build \
6464
65stage3-release/bin/zig build test docs \65stage3-release/bin/zig build test docs \
66 --maxrss 21000000000 \66 --maxrss 21000000000 \
67 -Dlldb=$HOME/deps/lldb-zig/Release-befcd57a8/bin/lldb \67 -Dlldb=$HOME/deps/lldb-zig/Release-4a44163df/bin/lldb \
68 -fqemu \68 -fqemu \
69 -fwasmtime \69 -fwasmtime \
70 -Dstatic-llvm \70 -Dstatic-llvm \
lib/std/hash_map.zig+5-3
...@@ -1767,9 +1767,11 @@ pub fn HashMapUnmanaged(...@@ -1767,9 +1767,11 @@ pub fn HashMapUnmanaged(
1767 }1767 }
17681768
1769 comptime {1769 comptime {
1770 if (!builtin.strip_debug_info) {1770 if (!builtin.strip_debug_info) _ = switch (builtin.zig_backend) {
1771 _ = &dbHelper;1771 .stage2_llvm => &dbHelper,
1772 }1772 .stage2_x86_64 => KV,
1773 else => {},
1774 };
1773 }1775 }
1774 };1776 };
1775}1777}
lib/std/multi_array_list.zig+1-1
...@@ -573,7 +573,7 @@ pub fn MultiArrayList(comptime T: type) type {...@@ -573,7 +573,7 @@ pub fn MultiArrayList(comptime T: type) type {
573 }573 }
574574
575 comptime {575 comptime {
576 if (!builtin.strip_debug_info) {576 if (builtin.zig_backend == .stage2_llvm and !builtin.strip_debug_info) {
577 _ = &dbHelper;577 _ = &dbHelper;
578 _ = &Slice.dbHelper;578 _ = &Slice.dbHelper;
579 }579 }
src/InternPool.zig+1-1
...@@ -4723,7 +4723,7 @@ pub const Index = enum(u32) {...@@ -4723,7 +4723,7 @@ pub const Index = enum(u32) {
4723 }4723 }
47244724
4725 comptime {4725 comptime {
4726 if (!builtin.strip_debug_info) {4726 if (builtin.zig_backend == .stage2_llvm and !builtin.strip_debug_info) {
4727 _ = &dbHelper;4727 _ = &dbHelper;
4728 }4728 }
4729 }4729 }
src/arch/aarch64/CodeGen.zig+2-3
...@@ -25,7 +25,6 @@ const Alignment = InternPool.Alignment;...@@ -25,7 +25,6 @@ const Alignment = InternPool.Alignment;
2525
26const CodeGenError = codegen.CodeGenError;26const CodeGenError = codegen.CodeGenError;
27const Result = codegen.Result;27const Result = codegen.Result;
28const DebugInfoOutput = codegen.DebugInfoOutput;
2928
30const bits = @import("bits.zig");29const bits = @import("bits.zig");
31const abi = @import("abi.zig");30const abi = @import("abi.zig");
...@@ -48,7 +47,7 @@ pt: Zcu.PerThread,...@@ -48,7 +47,7 @@ pt: Zcu.PerThread,
48air: Air,47air: Air,
49liveness: Liveness,48liveness: Liveness,
50bin_file: *link.File,49bin_file: *link.File,
51debug_output: DebugInfoOutput,50debug_output: link.File.DebugInfoOutput,
52target: *const std.Target,51target: *const std.Target,
53func_index: InternPool.Index,52func_index: InternPool.Index,
54owner_nav: InternPool.Nav.Index,53owner_nav: InternPool.Nav.Index,
...@@ -327,7 +326,7 @@ pub fn generate(...@@ -327,7 +326,7 @@ pub fn generate(
327 air: Air,326 air: Air,
328 liveness: Liveness,327 liveness: Liveness,
329 code: *std.ArrayList(u8),328 code: *std.ArrayList(u8),
330 debug_output: DebugInfoOutput,329 debug_output: link.File.DebugInfoOutput,
331) CodeGenError!Result {330) CodeGenError!Result {
332 const zcu = pt.zcu;331 const zcu = pt.zcu;
333 const gpa = zcu.gpa;332 const gpa = zcu.gpa;
src/arch/aarch64/Emit.zig+1-2
...@@ -13,11 +13,10 @@ const assert = std.debug.assert;...@@ -13,11 +13,10 @@ const assert = std.debug.assert;
13const Instruction = bits.Instruction;13const Instruction = bits.Instruction;
14const Register = bits.Register;14const Register = bits.Register;
15const log = std.log.scoped(.aarch64_emit);15const log = std.log.scoped(.aarch64_emit);
16const DebugInfoOutput = @import("../../codegen.zig").DebugInfoOutput;
1716
18mir: Mir,17mir: Mir,
19bin_file: *link.File,18bin_file: *link.File,
20debug_output: DebugInfoOutput,19debug_output: link.File.DebugInfoOutput,
21target: *const std.Target,20target: *const std.Target,
22err_msg: ?*ErrorMsg = null,21err_msg: ?*ErrorMsg = null,
23src_loc: Zcu.LazySrcLoc,22src_loc: Zcu.LazySrcLoc,
src/arch/arm/CodeGen.zig+2-3
...@@ -25,7 +25,6 @@ const Alignment = InternPool.Alignment;...@@ -25,7 +25,6 @@ const Alignment = InternPool.Alignment;
2525
26const Result = codegen.Result;26const Result = codegen.Result;
27const CodeGenError = codegen.CodeGenError;27const CodeGenError = codegen.CodeGenError;
28const DebugInfoOutput = codegen.DebugInfoOutput;
2928
30const bits = @import("bits.zig");29const bits = @import("bits.zig");
31const abi = @import("abi.zig");30const abi = @import("abi.zig");
...@@ -49,7 +48,7 @@ pt: Zcu.PerThread,...@@ -49,7 +48,7 @@ pt: Zcu.PerThread,
49air: Air,48air: Air,
50liveness: Liveness,49liveness: Liveness,
51bin_file: *link.File,50bin_file: *link.File,
52debug_output: DebugInfoOutput,51debug_output: link.File.DebugInfoOutput,
53target: *const std.Target,52target: *const std.Target,
54func_index: InternPool.Index,53func_index: InternPool.Index,
55err_msg: ?*ErrorMsg,54err_msg: ?*ErrorMsg,
...@@ -335,7 +334,7 @@ pub fn generate(...@@ -335,7 +334,7 @@ pub fn generate(
335 air: Air,334 air: Air,
336 liveness: Liveness,335 liveness: Liveness,
337 code: *std.ArrayList(u8),336 code: *std.ArrayList(u8),
338 debug_output: DebugInfoOutput,337 debug_output: link.File.DebugInfoOutput,
339) CodeGenError!Result {338) CodeGenError!Result {
340 const zcu = pt.zcu;339 const zcu = pt.zcu;
341 const gpa = zcu.gpa;340 const gpa = zcu.gpa;
src/arch/arm/Emit.zig+1-2
...@@ -16,12 +16,11 @@ const assert = std.debug.assert;...@@ -16,12 +16,11 @@ const assert = std.debug.assert;
16const Instruction = bits.Instruction;16const Instruction = bits.Instruction;
17const Register = bits.Register;17const Register = bits.Register;
18const log = std.log.scoped(.aarch32_emit);18const log = std.log.scoped(.aarch32_emit);
19const DebugInfoOutput = @import("../../codegen.zig").DebugInfoOutput;
20const CodeGen = @import("CodeGen.zig");19const CodeGen = @import("CodeGen.zig");
2120
22mir: Mir,21mir: Mir,
23bin_file: *link.File,22bin_file: *link.File,
24debug_output: DebugInfoOutput,23debug_output: link.File.DebugInfoOutput,
25target: *const std.Target,24target: *const std.Target,
26err_msg: ?*ErrorMsg = null,25err_msg: ?*ErrorMsg = null,
27src_loc: Zcu.LazySrcLoc,26src_loc: Zcu.LazySrcLoc,
src/arch/riscv64/CodeGen.zig+3-4
...@@ -32,7 +32,6 @@ const Alignment = InternPool.Alignment;...@@ -32,7 +32,6 @@ const Alignment = InternPool.Alignment;
3232
33const CodeGenError = codegen.CodeGenError;33const CodeGenError = codegen.CodeGenError;
34const Result = codegen.Result;34const Result = codegen.Result;
35const DebugInfoOutput = codegen.DebugInfoOutput;
3635
37const bits = @import("bits.zig");36const bits = @import("bits.zig");
38const abi = @import("abi.zig");37const abi = @import("abi.zig");
...@@ -61,7 +60,7 @@ gpa: Allocator,...@@ -61,7 +60,7 @@ gpa: Allocator,
6160
62mod: *Package.Module,61mod: *Package.Module,
63target: *const std.Target,62target: *const std.Target,
64debug_output: DebugInfoOutput,63debug_output: link.File.DebugInfoOutput,
65err_msg: ?*ErrorMsg,64err_msg: ?*ErrorMsg,
66args: []MCValue,65args: []MCValue,
67ret_mcv: InstTracking,66ret_mcv: InstTracking,
...@@ -760,7 +759,7 @@ pub fn generate(...@@ -760,7 +759,7 @@ pub fn generate(
760 air: Air,759 air: Air,
761 liveness: Liveness,760 liveness: Liveness,
762 code: *std.ArrayList(u8),761 code: *std.ArrayList(u8),
763 debug_output: DebugInfoOutput,762 debug_output: link.File.DebugInfoOutput,
764) CodeGenError!Result {763) CodeGenError!Result {
765 const zcu = pt.zcu;764 const zcu = pt.zcu;
766 const comp = zcu.comp;765 const comp = zcu.comp;
...@@ -928,7 +927,7 @@ pub fn generateLazy(...@@ -928,7 +927,7 @@ pub fn generateLazy(
928 src_loc: Zcu.LazySrcLoc,927 src_loc: Zcu.LazySrcLoc,
929 lazy_sym: link.File.LazySymbol,928 lazy_sym: link.File.LazySymbol,
930 code: *std.ArrayList(u8),929 code: *std.ArrayList(u8),
931 debug_output: DebugInfoOutput,930 debug_output: link.File.DebugInfoOutput,
932) CodeGenError!Result {931) CodeGenError!Result {
933 const comp = bin_file.comp;932 const comp = bin_file.comp;
934 const gpa = comp.gpa;933 const gpa = comp.gpa;
src/arch/riscv64/Emit.zig+1-2
...@@ -2,7 +2,7 @@...@@ -2,7 +2,7 @@
22
3bin_file: *link.File,3bin_file: *link.File,
4lower: Lower,4lower: Lower,
5debug_output: DebugInfoOutput,5debug_output: link.File.DebugInfoOutput,
6code: *std.ArrayList(u8),6code: *std.ArrayList(u8),
77
8prev_di_line: u32,8prev_di_line: u32,
...@@ -216,7 +216,6 @@ const log = std.log.scoped(.emit);...@@ -216,7 +216,6 @@ const log = std.log.scoped(.emit);
216const mem = std.mem;216const mem = std.mem;
217const std = @import("std");217const std = @import("std");
218218
219const DebugInfoOutput = @import("../../codegen.zig").DebugInfoOutput;
220const Emit = @This();219const Emit = @This();
221const Lower = @import("Lower.zig");220const Lower = @import("Lower.zig");
222const Mir = @import("Mir.zig");221const Mir = @import("Mir.zig");
src/arch/sparc64/CodeGen.zig+2-3
...@@ -22,7 +22,6 @@ const Liveness = @import("../../Liveness.zig");...@@ -22,7 +22,6 @@ const Liveness = @import("../../Liveness.zig");
22const Type = @import("../../Type.zig");22const Type = @import("../../Type.zig");
23const CodeGenError = codegen.CodeGenError;23const CodeGenError = codegen.CodeGenError;
24const Result = @import("../../codegen.zig").Result;24const Result = @import("../../codegen.zig").Result;
25const DebugInfoOutput = @import("../../codegen.zig").DebugInfoOutput;
26const Endian = std.builtin.Endian;25const Endian = std.builtin.Endian;
27const Alignment = InternPool.Alignment;26const Alignment = InternPool.Alignment;
2827
...@@ -57,7 +56,7 @@ bin_file: *link.File,...@@ -57,7 +56,7 @@ bin_file: *link.File,
57target: *const std.Target,56target: *const std.Target,
58func_index: InternPool.Index,57func_index: InternPool.Index,
59code: *std.ArrayList(u8),58code: *std.ArrayList(u8),
60debug_output: DebugInfoOutput,59debug_output: link.File.DebugInfoOutput,
61err_msg: ?*ErrorMsg,60err_msg: ?*ErrorMsg,
62args: []MCValue,61args: []MCValue,
63ret_mcv: MCValue,62ret_mcv: MCValue,
...@@ -268,7 +267,7 @@ pub fn generate(...@@ -268,7 +267,7 @@ pub fn generate(
268 air: Air,267 air: Air,
269 liveness: Liveness,268 liveness: Liveness,
270 code: *std.ArrayList(u8),269 code: *std.ArrayList(u8),
271 debug_output: DebugInfoOutput,270 debug_output: link.File.DebugInfoOutput,
272) CodeGenError!Result {271) CodeGenError!Result {
273 const zcu = pt.zcu;272 const zcu = pt.zcu;
274 const gpa = zcu.gpa;273 const gpa = zcu.gpa;
src/arch/sparc64/Emit.zig+1-2
...@@ -9,7 +9,6 @@ const Zcu = @import("../../Zcu.zig");...@@ -9,7 +9,6 @@ const Zcu = @import("../../Zcu.zig");
9const ErrorMsg = Zcu.ErrorMsg;9const ErrorMsg = Zcu.ErrorMsg;
10const Liveness = @import("../../Liveness.zig");10const Liveness = @import("../../Liveness.zig");
11const log = std.log.scoped(.sparcv9_emit);11const log = std.log.scoped(.sparcv9_emit);
12const DebugInfoOutput = @import("../../codegen.zig").DebugInfoOutput;
1312
14const Emit = @This();13const Emit = @This();
15const Mir = @import("Mir.zig");14const Mir = @import("Mir.zig");
...@@ -19,7 +18,7 @@ const Register = bits.Register;...@@ -19,7 +18,7 @@ const Register = bits.Register;
1918
20mir: Mir,19mir: Mir,
21bin_file: *link.File,20bin_file: *link.File,
22debug_output: DebugInfoOutput,21debug_output: link.File.DebugInfoOutput,
23target: *const std.Target,22target: *const std.Target,
24err_msg: ?*ErrorMsg = null,23err_msg: ?*ErrorMsg = null,
25src_loc: Zcu.LazySrcLoc,24src_loc: Zcu.LazySrcLoc,
src/arch/wasm/CodeGen.zig+2-2
...@@ -648,7 +648,7 @@ block_depth: u32 = 0,...@@ -648,7 +648,7 @@ block_depth: u32 = 0,
648air: Air,648air: Air,
649liveness: Liveness,649liveness: Liveness,
650gpa: mem.Allocator,650gpa: mem.Allocator,
651debug_output: codegen.DebugInfoOutput,651debug_output: link.File.DebugInfoOutput,
652func_index: InternPool.Index,652func_index: InternPool.Index,
653/// Contains a list of current branches.653/// Contains a list of current branches.
654/// When we return from a branch, the branch will be popped from this list,654/// When we return from a branch, the branch will be popped from this list,
...@@ -1211,7 +1211,7 @@ pub fn generate(...@@ -1211,7 +1211,7 @@ pub fn generate(
1211 air: Air,1211 air: Air,
1212 liveness: Liveness,1212 liveness: Liveness,
1213 code: *std.ArrayList(u8),1213 code: *std.ArrayList(u8),
1214 debug_output: codegen.DebugInfoOutput,1214 debug_output: link.File.DebugInfoOutput,
1215) codegen.CodeGenError!codegen.Result {1215) codegen.CodeGenError!codegen.Result {
1216 const zcu = pt.zcu;1216 const zcu = pt.zcu;
1217 const gpa = zcu.gpa;1217 const gpa = zcu.gpa;
src/arch/wasm/Emit.zig+1-1
...@@ -26,7 +26,7 @@ owner_nav: InternPool.Nav.Index,...@@ -26,7 +26,7 @@ owner_nav: InternPool.Nav.Index,
2626
27// Debug information27// Debug information
28/// Holds the debug information for this emission28/// Holds the debug information for this emission
29dbg_output: codegen.DebugInfoOutput,29dbg_output: link.File.DebugInfoOutput,
30/// Previous debug info line30/// Previous debug info line
31prev_di_line: u32,31prev_di_line: u32,
32/// Previous debug info column32/// Previous debug info column
src/arch/x86_64/CodeGen.zig+3-4
...@@ -17,7 +17,6 @@ const Air = @import("../../Air.zig");...@@ -17,7 +17,6 @@ const Air = @import("../../Air.zig");
17const Allocator = mem.Allocator;17const Allocator = mem.Allocator;
18const CodeGenError = codegen.CodeGenError;18const CodeGenError = codegen.CodeGenError;
19const Compilation = @import("../../Compilation.zig");19const Compilation = @import("../../Compilation.zig");
20const DebugInfoOutput = codegen.DebugInfoOutput;
21const ErrorMsg = Zcu.ErrorMsg;20const ErrorMsg = Zcu.ErrorMsg;
22const Result = codegen.Result;21const Result = codegen.Result;
23const Emit = @import("Emit.zig");22const Emit = @import("Emit.zig");
...@@ -53,7 +52,7 @@ pt: Zcu.PerThread,...@@ -53,7 +52,7 @@ pt: Zcu.PerThread,
53air: Air,52air: Air,
54liveness: Liveness,53liveness: Liveness,
55bin_file: *link.File,54bin_file: *link.File,
56debug_output: DebugInfoOutput,55debug_output: link.File.DebugInfoOutput,
57target: *const std.Target,56target: *const std.Target,
58owner: Owner,57owner: Owner,
59inline_func: InternPool.Index,58inline_func: InternPool.Index,
...@@ -819,7 +818,7 @@ pub fn generate(...@@ -819,7 +818,7 @@ pub fn generate(
819 air: Air,818 air: Air,
820 liveness: Liveness,819 liveness: Liveness,
821 code: *std.ArrayList(u8),820 code: *std.ArrayList(u8),
822 debug_output: DebugInfoOutput,821 debug_output: link.File.DebugInfoOutput,
823) CodeGenError!Result {822) CodeGenError!Result {
824 const zcu = pt.zcu;823 const zcu = pt.zcu;
825 const comp = zcu.comp;824 const comp = zcu.comp;
...@@ -1000,7 +999,7 @@ pub fn generateLazy(...@@ -1000,7 +999,7 @@ pub fn generateLazy(
1000 src_loc: Zcu.LazySrcLoc,999 src_loc: Zcu.LazySrcLoc,
1001 lazy_sym: link.File.LazySymbol,1000 lazy_sym: link.File.LazySymbol,
1002 code: *std.ArrayList(u8),1001 code: *std.ArrayList(u8),
1003 debug_output: DebugInfoOutput,1002 debug_output: link.File.DebugInfoOutput,
1004) CodeGenError!Result {1003) CodeGenError!Result {
1005 const comp = bin_file.comp;1004 const comp = bin_file.comp;
1006 const gpa = comp.gpa;1005 const gpa = comp.gpa;
src/arch/x86_64/Emit.zig+1-2
...@@ -3,7 +3,7 @@...@@ -3,7 +3,7 @@
3air: Air,3air: Air,
4lower: Lower,4lower: Lower,
5atom_index: u32,5atom_index: u32,
6debug_output: DebugInfoOutput,6debug_output: link.File.DebugInfoOutput,
7code: *std.ArrayList(u8),7code: *std.ArrayList(u8),
88
9prev_di_line: u32,9prev_di_line: u32,
...@@ -546,7 +546,6 @@ const log = std.log.scoped(.emit);...@@ -546,7 +546,6 @@ const log = std.log.scoped(.emit);
546const std = @import("std");546const std = @import("std");
547547
548const Air = @import("../../Air.zig");548const Air = @import("../../Air.zig");
549const DebugInfoOutput = @import("../../codegen.zig").DebugInfoOutput;
550const Emit = @This();549const Emit = @This();
551const Lower = @import("Lower.zig");550const Lower = @import("Lower.zig");
552const Mir = @import("Mir.zig");551const Mir = @import("Mir.zig");
src/codegen.zig+34-60
...@@ -38,12 +38,6 @@ pub const CodeGenError = error{...@@ -38,12 +38,6 @@ pub const CodeGenError = error{
38 CodegenFail,38 CodegenFail,
39} || link.File.UpdateDebugInfoError;39} || link.File.UpdateDebugInfoError;
4040
41pub const DebugInfoOutput = union(enum) {
42 dwarf: *link.File.Dwarf.WipNav,
43 plan9: *link.File.Plan9.DebugInfoOutput,
44 none,
45};
46
47fn devFeatureForBackend(comptime backend: std.builtin.CompilerBackend) dev.Feature {41fn devFeatureForBackend(comptime backend: std.builtin.CompilerBackend) dev.Feature {
48 comptime assert(mem.startsWith(u8, @tagName(backend), "stage2_"));42 comptime assert(mem.startsWith(u8, @tagName(backend), "stage2_"));
49 return @field(dev.Feature, @tagName(backend)["stage2_".len..] ++ "_backend");43 return @field(dev.Feature, @tagName(backend)["stage2_".len..] ++ "_backend");
...@@ -69,7 +63,7 @@ pub fn generateFunction(...@@ -69,7 +63,7 @@ pub fn generateFunction(
69 air: Air,63 air: Air,
70 liveness: Liveness,64 liveness: Liveness,
71 code: *std.ArrayList(u8),65 code: *std.ArrayList(u8),
72 debug_output: DebugInfoOutput,66 debug_output: link.File.DebugInfoOutput,
73) CodeGenError!Result {67) CodeGenError!Result {
74 const zcu = pt.zcu;68 const zcu = pt.zcu;
75 const func = zcu.funcInfo(func_index);69 const func = zcu.funcInfo(func_index);
...@@ -95,7 +89,7 @@ pub fn generateLazyFunction(...@@ -95,7 +89,7 @@ pub fn generateLazyFunction(
95 src_loc: Zcu.LazySrcLoc,89 src_loc: Zcu.LazySrcLoc,
96 lazy_sym: link.File.LazySymbol,90 lazy_sym: link.File.LazySymbol,
97 code: *std.ArrayList(u8),91 code: *std.ArrayList(u8),
98 debug_output: DebugInfoOutput,92 debug_output: link.File.DebugInfoOutput,
99) CodeGenError!Result {93) CodeGenError!Result {
100 const zcu = pt.zcu;94 const zcu = pt.zcu;
101 const file = Type.fromInterned(lazy_sym.ty).typeDeclInstAllowGeneratedTag(zcu).?.resolveFile(&zcu.intern_pool);95 const file = Type.fromInterned(lazy_sym.ty).typeDeclInstAllowGeneratedTag(zcu).?.resolveFile(&zcu.intern_pool);
...@@ -127,10 +121,10 @@ pub fn generateLazySymbol(...@@ -127,10 +121,10 @@ pub fn generateLazySymbol(
127 // TODO don't use an "out" parameter like this; put it in the result instead121 // TODO don't use an "out" parameter like this; put it in the result instead
128 alignment: *Alignment,122 alignment: *Alignment,
129 code: *std.ArrayList(u8),123 code: *std.ArrayList(u8),
130 debug_output: DebugInfoOutput,124 debug_output: link.File.DebugInfoOutput,
131 reloc_info: RelocInfo,125 reloc_parent: link.File.RelocInfo.Parent,
132) CodeGenError!Result {126) CodeGenError!Result {
133 _ = reloc_info;127 _ = reloc_parent;
134128
135 const tracy = trace(@src());129 const tracy = trace(@src());
136 defer tracy.end();130 defer tracy.end();
...@@ -192,8 +186,7 @@ pub fn generateSymbol(...@@ -192,8 +186,7 @@ pub fn generateSymbol(
192 src_loc: Zcu.LazySrcLoc,186 src_loc: Zcu.LazySrcLoc,
193 val: Value,187 val: Value,
194 code: *std.ArrayList(u8),188 code: *std.ArrayList(u8),
195 debug_output: DebugInfoOutput,189 reloc_parent: link.File.RelocInfo.Parent,
196 reloc_info: RelocInfo,
197) CodeGenError!Result {190) CodeGenError!Result {
198 const tracy = trace(@src());191 const tracy = trace(@src());
199 defer tracy.end();192 defer tracy.end();
...@@ -290,7 +283,7 @@ pub fn generateSymbol(...@@ -290,7 +283,7 @@ pub fn generateSymbol(
290 switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(switch (error_union.val) {283 switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(switch (error_union.val) {
291 .err_name => try pt.intern(.{ .undef = payload_ty.toIntern() }),284 .err_name => try pt.intern(.{ .undef = payload_ty.toIntern() }),
292 .payload => |payload| payload,285 .payload => |payload| payload,
293 }), code, debug_output, reloc_info)) {286 }), code, reloc_parent)) {
294 .ok => {},287 .ok => {},
295 .fail => |em| return .{ .fail = em },288 .fail => |em| return .{ .fail = em },
296 }289 }
...@@ -318,7 +311,7 @@ pub fn generateSymbol(...@@ -318,7 +311,7 @@ pub fn generateSymbol(
318 },311 },
319 .enum_tag => |enum_tag| {312 .enum_tag => |enum_tag| {
320 const int_tag_ty = ty.intTagType(zcu);313 const int_tag_ty = ty.intTagType(zcu);
321 switch (try generateSymbol(bin_file, pt, src_loc, try pt.getCoerced(Value.fromInterned(enum_tag.int), int_tag_ty), code, debug_output, reloc_info)) {314 switch (try generateSymbol(bin_file, pt, src_loc, try pt.getCoerced(Value.fromInterned(enum_tag.int), int_tag_ty), code, reloc_parent)) {
322 .ok => {},315 .ok => {},
323 .fail => |em| return .{ .fail = em },316 .fail => |em| return .{ .fail = em },
324 }317 }
...@@ -334,16 +327,16 @@ pub fn generateSymbol(...@@ -334,16 +327,16 @@ pub fn generateSymbol(
334 },327 },
335 .f128 => |f128_val| writeFloat(f128, f128_val, target, endian, try code.addManyAsArray(16)),328 .f128 => |f128_val| writeFloat(f128, f128_val, target, endian, try code.addManyAsArray(16)),
336 },329 },
337 .ptr => switch (try lowerPtr(bin_file, pt, src_loc, val.toIntern(), code, debug_output, reloc_info, 0)) {330 .ptr => switch (try lowerPtr(bin_file, pt, src_loc, val.toIntern(), code, reloc_parent, 0)) {
338 .ok => {},331 .ok => {},
339 .fail => |em| return .{ .fail = em },332 .fail => |em| return .{ .fail = em },
340 },333 },
341 .slice => |slice| {334 .slice => |slice| {
342 switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(slice.ptr), code, debug_output, reloc_info)) {335 switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(slice.ptr), code, reloc_parent)) {
343 .ok => {},336 .ok => {},
344 .fail => |em| return .{ .fail = em },337 .fail => |em| return .{ .fail = em },
345 }338 }
346 switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(slice.len), code, debug_output, reloc_info)) {339 switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(slice.len), code, reloc_parent)) {
347 .ok => {},340 .ok => {},
348 .fail => |em| return .{ .fail = em },341 .fail => |em| return .{ .fail = em },
349 }342 }
...@@ -355,7 +348,7 @@ pub fn generateSymbol(...@@ -355,7 +348,7 @@ pub fn generateSymbol(
355348
356 if (ty.optionalReprIsPayload(zcu)) {349 if (ty.optionalReprIsPayload(zcu)) {
357 if (payload_val) |value| {350 if (payload_val) |value| {
358 switch (try generateSymbol(bin_file, pt, src_loc, value, code, debug_output, reloc_info)) {351 switch (try generateSymbol(bin_file, pt, src_loc, value, code, reloc_parent)) {
359 .ok => {},352 .ok => {},
360 .fail => |em| return Result{ .fail = em },353 .fail => |em| return Result{ .fail = em },
361 }354 }
...@@ -368,7 +361,7 @@ pub fn generateSymbol(...@@ -368,7 +361,7 @@ pub fn generateSymbol(
368 const value = payload_val orelse Value.fromInterned(try pt.intern(.{361 const value = payload_val orelse Value.fromInterned(try pt.intern(.{
369 .undef = payload_type.toIntern(),362 .undef = payload_type.toIntern(),
370 }));363 }));
371 switch (try generateSymbol(bin_file, pt, src_loc, value, code, debug_output, reloc_info)) {364 switch (try generateSymbol(bin_file, pt, src_loc, value, code, reloc_parent)) {
372 .ok => {},365 .ok => {},
373 .fail => |em| return Result{ .fail = em },366 .fail => |em| return Result{ .fail = em },
374 }367 }
...@@ -390,7 +383,7 @@ pub fn generateSymbol(...@@ -390,7 +383,7 @@ pub fn generateSymbol(
390 elem383 elem
391 else384 else
392 array_type.sentinel,385 array_type.sentinel,
393 }), code, debug_output, reloc_info)) {386 }), code, reloc_parent)) {
394 .ok => {},387 .ok => {},
395 .fail => |em| return .{ .fail = em },388 .fail => |em| return .{ .fail = em },
396 }389 }
...@@ -449,7 +442,7 @@ pub fn generateSymbol(...@@ -449,7 +442,7 @@ pub fn generateSymbol(
449 math.cast(usize, index) orelse return error.Overflow442 math.cast(usize, index) orelse return error.Overflow
450 ],443 ],
451 .repeated_elem => |elem| elem,444 .repeated_elem => |elem| elem,
452 }), code, debug_output, reloc_info)) {445 }), code, reloc_parent)) {
453 .ok => {},446 .ok => {},
454 .fail => |em| return .{ .fail = em },447 .fail => |em| return .{ .fail = em },
455 }448 }
...@@ -482,7 +475,7 @@ pub fn generateSymbol(...@@ -482,7 +475,7 @@ pub fn generateSymbol(
482 .repeated_elem => |elem| elem,475 .repeated_elem => |elem| elem,
483 };476 };
484477
485 switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(field_val), code, debug_output, reloc_info)) {478 switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(field_val), code, reloc_parent)) {
486 .ok => {},479 .ok => {},
487 .fail => |em| return Result{ .fail = em },480 .fail => |em| return Result{ .fail = em },
488 }481 }
...@@ -524,7 +517,7 @@ pub fn generateSymbol(...@@ -524,7 +517,7 @@ pub fn generateSymbol(
524 return error.Overflow;517 return error.Overflow;
525 var tmp_list = try std.ArrayList(u8).initCapacity(code.allocator, field_size);518 var tmp_list = try std.ArrayList(u8).initCapacity(code.allocator, field_size);
526 defer tmp_list.deinit();519 defer tmp_list.deinit();
527 switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(field_val), &tmp_list, debug_output, reloc_info)) {520 switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(field_val), &tmp_list, reloc_parent)) {
528 .ok => @memcpy(code.items[current_pos..][0..tmp_list.items.len], tmp_list.items),521 .ok => @memcpy(code.items[current_pos..][0..tmp_list.items.len], tmp_list.items),
529 .fail => |em| return Result{ .fail = em },522 .fail => |em| return Result{ .fail = em },
530 }523 }
...@@ -559,7 +552,7 @@ pub fn generateSymbol(...@@ -559,7 +552,7 @@ pub fn generateSymbol(
559 ) orelse return error.Overflow;552 ) orelse return error.Overflow;
560 if (padding > 0) try code.appendNTimes(0, padding);553 if (padding > 0) try code.appendNTimes(0, padding);
561554
562 switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(field_val), code, debug_output, reloc_info)) {555 switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(field_val), code, reloc_parent)) {
563 .ok => {},556 .ok => {},
564 .fail => |em| return Result{ .fail = em },557 .fail => |em| return Result{ .fail = em },
565 }558 }
...@@ -583,12 +576,12 @@ pub fn generateSymbol(...@@ -583,12 +576,12 @@ pub fn generateSymbol(
583 const layout = ty.unionGetLayout(zcu);576 const layout = ty.unionGetLayout(zcu);
584577
585 if (layout.payload_size == 0) {578 if (layout.payload_size == 0) {
586 return generateSymbol(bin_file, pt, src_loc, Value.fromInterned(un.tag), code, debug_output, reloc_info);579 return generateSymbol(bin_file, pt, src_loc, Value.fromInterned(un.tag), code, reloc_parent);
587 }580 }
588581
589 // Check if we should store the tag first.582 // Check if we should store the tag first.
590 if (layout.tag_size > 0 and layout.tag_align.compare(.gte, layout.payload_align)) {583 if (layout.tag_size > 0 and layout.tag_align.compare(.gte, layout.payload_align)) {
591 switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(un.tag), code, debug_output, reloc_info)) {584 switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(un.tag), code, reloc_parent)) {
592 .ok => {},585 .ok => {},
593 .fail => |em| return Result{ .fail = em },586 .fail => |em| return Result{ .fail = em },
594 }587 }
...@@ -601,7 +594,7 @@ pub fn generateSymbol(...@@ -601,7 +594,7 @@ pub fn generateSymbol(
601 if (!field_ty.hasRuntimeBits(zcu)) {594 if (!field_ty.hasRuntimeBits(zcu)) {
602 try code.appendNTimes(0xaa, math.cast(usize, layout.payload_size) orelse return error.Overflow);595 try code.appendNTimes(0xaa, math.cast(usize, layout.payload_size) orelse return error.Overflow);
603 } else {596 } else {
604 switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(un.val), code, debug_output, reloc_info)) {597 switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(un.val), code, reloc_parent)) {
605 .ok => {},598 .ok => {},
606 .fail => |em| return Result{ .fail = em },599 .fail => |em| return Result{ .fail = em },
607 }600 }
...@@ -612,14 +605,14 @@ pub fn generateSymbol(...@@ -612,14 +605,14 @@ pub fn generateSymbol(
612 }605 }
613 }606 }
614 } else {607 } else {
615 switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(un.val), code, debug_output, reloc_info)) {608 switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(un.val), code, reloc_parent)) {
616 .ok => {},609 .ok => {},
617 .fail => |em| return Result{ .fail = em },610 .fail => |em| return Result{ .fail = em },
618 }611 }
619 }612 }
620613
621 if (layout.tag_size > 0 and layout.tag_align.compare(.lt, layout.payload_align)) {614 if (layout.tag_size > 0 and layout.tag_align.compare(.lt, layout.payload_align)) {
622 switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(un.tag), code, debug_output, reloc_info)) {615 switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(un.tag), code, reloc_parent)) {
623 .ok => {},616 .ok => {},
624 .fail => |em| return Result{ .fail = em },617 .fail => |em| return Result{ .fail = em },
625 }618 }
...@@ -640,40 +633,29 @@ fn lowerPtr(...@@ -640,40 +633,29 @@ fn lowerPtr(
640 src_loc: Zcu.LazySrcLoc,633 src_loc: Zcu.LazySrcLoc,
641 ptr_val: InternPool.Index,634 ptr_val: InternPool.Index,
642 code: *std.ArrayList(u8),635 code: *std.ArrayList(u8),
643 debug_output: DebugInfoOutput,636 reloc_parent: link.File.RelocInfo.Parent,
644 reloc_info: RelocInfo,
645 prev_offset: u64,637 prev_offset: u64,
646) CodeGenError!Result {638) CodeGenError!Result {
647 const zcu = pt.zcu;639 const zcu = pt.zcu;
648 const ptr = zcu.intern_pool.indexToKey(ptr_val).ptr;640 const ptr = zcu.intern_pool.indexToKey(ptr_val).ptr;
649 const offset: u64 = prev_offset + ptr.byte_offset;641 const offset: u64 = prev_offset + ptr.byte_offset;
650 return switch (ptr.base_addr) {642 return switch (ptr.base_addr) {
651 .nav => |nav| try lowerNavRef(bin_file, pt, src_loc, nav, code, debug_output, reloc_info, offset),643 .nav => |nav| try lowerNavRef(bin_file, pt, src_loc, nav, code, reloc_parent, offset),
652 .uav => |uav| try lowerUavRef(bin_file, pt, src_loc, uav, code, debug_output, reloc_info, offset),644 .uav => |uav| try lowerUavRef(bin_file, pt, src_loc, uav, code, reloc_parent, offset),
653 .int => try generateSymbol(bin_file, pt, src_loc, try pt.intValue(Type.usize, offset), code, debug_output, reloc_info),645 .int => try generateSymbol(bin_file, pt, src_loc, try pt.intValue(Type.usize, offset), code, reloc_parent),
654 .eu_payload => |eu_ptr| try lowerPtr(646 .eu_payload => |eu_ptr| try lowerPtr(
655 bin_file,647 bin_file,
656 pt,648 pt,
657 src_loc,649 src_loc,
658 eu_ptr,650 eu_ptr,
659 code,651 code,
660 debug_output,652 reloc_parent,
661 reloc_info,
662 offset + errUnionPayloadOffset(653 offset + errUnionPayloadOffset(
663 Value.fromInterned(eu_ptr).typeOf(zcu).childType(zcu).errorUnionPayload(zcu),654 Value.fromInterned(eu_ptr).typeOf(zcu).childType(zcu).errorUnionPayload(zcu),
664 zcu,655 zcu,
665 ),656 ),
666 ),657 ),
667 .opt_payload => |opt_ptr| try lowerPtr(658 .opt_payload => |opt_ptr| try lowerPtr(bin_file, pt, src_loc, opt_ptr, code, reloc_parent, offset),
668 bin_file,
669 pt,
670 src_loc,
671 opt_ptr,
672 code,
673 debug_output,
674 reloc_info,
675 offset,
676 ),
677 .field => |field| {659 .field => |field| {
678 const base_ptr = Value.fromInterned(field.base);660 const base_ptr = Value.fromInterned(field.base);
679 const base_ty = base_ptr.typeOf(zcu).childType(zcu);661 const base_ty = base_ptr.typeOf(zcu).childType(zcu);
...@@ -692,27 +674,21 @@ fn lowerPtr(...@@ -692,27 +674,21 @@ fn lowerPtr(
692 },674 },
693 else => unreachable,675 else => unreachable,
694 };676 };
695 return lowerPtr(bin_file, pt, src_loc, field.base, code, debug_output, reloc_info, offset + field_off);677 return lowerPtr(bin_file, pt, src_loc, field.base, code, reloc_parent, offset + field_off);
696 },678 },
697 .arr_elem, .comptime_field, .comptime_alloc => unreachable,679 .arr_elem, .comptime_field, .comptime_alloc => unreachable,
698 };680 };
699}681}
700682
701const RelocInfo = struct {
702 parent_atom_index: u32,
703};
704
705fn lowerUavRef(683fn lowerUavRef(
706 lf: *link.File,684 lf: *link.File,
707 pt: Zcu.PerThread,685 pt: Zcu.PerThread,
708 src_loc: Zcu.LazySrcLoc,686 src_loc: Zcu.LazySrcLoc,
709 uav: InternPool.Key.Ptr.BaseAddr.Uav,687 uav: InternPool.Key.Ptr.BaseAddr.Uav,
710 code: *std.ArrayList(u8),688 code: *std.ArrayList(u8),
711 debug_output: DebugInfoOutput,689 reloc_parent: link.File.RelocInfo.Parent,
712 reloc_info: RelocInfo,
713 offset: u64,690 offset: u64,
714) CodeGenError!Result {691) CodeGenError!Result {
715 _ = debug_output;
716 const zcu = pt.zcu;692 const zcu = pt.zcu;
717 const ip = &zcu.intern_pool;693 const ip = &zcu.intern_pool;
718 const target = lf.comp.root_mod.resolved_target.result;694 const target = lf.comp.root_mod.resolved_target.result;
...@@ -735,7 +711,7 @@ fn lowerUavRef(...@@ -735,7 +711,7 @@ fn lowerUavRef(
735 }711 }
736712
737 const vaddr = try lf.getUavVAddr(uav_val, .{713 const vaddr = try lf.getUavVAddr(uav_val, .{
738 .parent_atom_index = reloc_info.parent_atom_index,714 .parent = reloc_parent,
739 .offset = code.items.len,715 .offset = code.items.len,
740 .addend = @intCast(offset),716 .addend = @intCast(offset),
741 });717 });
...@@ -756,12 +732,10 @@ fn lowerNavRef(...@@ -756,12 +732,10 @@ fn lowerNavRef(
756 src_loc: Zcu.LazySrcLoc,732 src_loc: Zcu.LazySrcLoc,
757 nav_index: InternPool.Nav.Index,733 nav_index: InternPool.Nav.Index,
758 code: *std.ArrayList(u8),734 code: *std.ArrayList(u8),
759 debug_output: DebugInfoOutput,735 reloc_parent: link.File.RelocInfo.Parent,
760 reloc_info: RelocInfo,
761 offset: u64,736 offset: u64,
762) CodeGenError!Result {737) CodeGenError!Result {
763 _ = src_loc;738 _ = src_loc;
764 _ = debug_output;
765 const zcu = pt.zcu;739 const zcu = pt.zcu;
766 const ip = &zcu.intern_pool;740 const ip = &zcu.intern_pool;
767 const target = zcu.navFileScope(nav_index).mod.resolved_target.result;741 const target = zcu.navFileScope(nav_index).mod.resolved_target.result;
...@@ -775,7 +749,7 @@ fn lowerNavRef(...@@ -775,7 +749,7 @@ fn lowerNavRef(
775 }749 }
776750
777 const vaddr = try lf.getNavVAddr(pt, nav_index, .{751 const vaddr = try lf.getNavVAddr(pt, nav_index, .{
778 .parent_atom_index = reloc_info.parent_atom_index,752 .parent = reloc_parent,
779 .offset = code.items.len,753 .offset = code.items.len,
780 .addend = @intCast(offset),754 .addend = @intCast(offset),
781 });755 });
src/link.zig+11-1
...@@ -330,6 +330,11 @@ pub const File = struct {...@@ -330,6 +330,11 @@ pub const File = struct {
330 }330 }
331 }331 }
332332
333 pub const DebugInfoOutput = union(enum) {
334 dwarf: *Dwarf.WipNav,
335 plan9: *Plan9.DebugInfoOutput,
336 none,
337 };
333 pub const UpdateDebugInfoError = Dwarf.UpdateError;338 pub const UpdateDebugInfoError = Dwarf.UpdateError;
334 pub const FlushDebugInfoError = Dwarf.FlushError;339 pub const FlushDebugInfoError = Dwarf.FlushError;
335340
...@@ -673,9 +678,14 @@ pub const File = struct {...@@ -673,9 +678,14 @@ pub const File = struct {
673 }678 }
674679
675 pub const RelocInfo = struct {680 pub const RelocInfo = struct {
676 parent_atom_index: u32,681 parent: Parent,
677 offset: u64,682 offset: u64,
678 addend: u32,683 addend: u32,
684
685 pub const Parent = union(enum) {
686 atom_index: u32,
687 debug_output: DebugInfoOutput,
688 };
679 };689 };
680690
681 /// Get allocated `Nav`'s address in virtual memory.691 /// Get allocated `Nav`'s address in virtual memory.
src/link/Coff.zig+12-7
...@@ -1163,8 +1163,8 @@ fn lowerConst(...@@ -1163,8 +1163,8 @@ fn lowerConst(
1163 try self.setSymbolName(sym, name);1163 try self.setSymbolName(sym, name);
1164 sym.section_number = @as(coff.SectionNumber, @enumFromInt(sect_id + 1));1164 sym.section_number = @as(coff.SectionNumber, @enumFromInt(sect_id + 1));
11651165
1166 const res = try codegen.generateSymbol(&self.base, pt, src_loc, val, &code_buffer, .none, .{1166 const res = try codegen.generateSymbol(&self.base, pt, src_loc, val, &code_buffer, .{
1167 .parent_atom_index = self.getAtom(atom_index).getSymbolIndex().?,1167 .atom_index = self.getAtom(atom_index).getSymbolIndex().?,
1168 });1168 });
1169 const code = switch (res) {1169 const code = switch (res) {
1170 .ok => code_buffer.items,1170 .ok => code_buffer.items,
...@@ -1235,8 +1235,7 @@ pub fn updateNav(...@@ -1235,8 +1235,7 @@ pub fn updateNav(
1235 zcu.navSrcLoc(nav_index),1235 zcu.navSrcLoc(nav_index),
1236 nav_init,1236 nav_init,
1237 &code_buffer,1237 &code_buffer,
1238 .none,1238 .{ .atom_index = atom.getSymbolIndex().? },
1239 .{ .parent_atom_index = atom.getSymbolIndex().? },
1240 );1239 );
1241 const code = switch (res) {1240 const code = switch (res) {
1242 .ok => code_buffer.items,1241 .ok => code_buffer.items,
...@@ -1284,7 +1283,7 @@ fn updateLazySymbolAtom(...@@ -1284,7 +1283,7 @@ fn updateLazySymbolAtom(
1284 &required_alignment,1283 &required_alignment,
1285 &code_buffer,1284 &code_buffer,
1286 .none,1285 .none,
1287 .{ .parent_atom_index = local_sym_index },1286 .{ .atom_index = local_sym_index },
1288 );1287 );
1289 const code = switch (res) {1288 const code = switch (res) {
1290 .ok => code_buffer.items,1289 .ok => code_buffer.items,
...@@ -1823,7 +1822,10 @@ pub fn getNavVAddr(...@@ -1823,7 +1822,10 @@ pub fn getNavVAddr(
1823 .@"extern" => |@"extern"| try self.getGlobalSymbol(nav.name.toSlice(ip), @"extern".lib_name.toSlice(ip)),1822 .@"extern" => |@"extern"| try self.getGlobalSymbol(nav.name.toSlice(ip), @"extern".lib_name.toSlice(ip)),
1824 else => self.getAtom(try self.getOrCreateAtomForNav(nav_index)).getSymbolIndex().?,1823 else => self.getAtom(try self.getOrCreateAtomForNav(nav_index)).getSymbolIndex().?,
1825 };1824 };
1826 const atom_index = self.getAtomIndexForSymbol(.{ .sym_index = reloc_info.parent_atom_index, .file = null }).?;1825 const atom_index = self.getAtomIndexForSymbol(.{
1826 .sym_index = reloc_info.parent.atom_index,
1827 .file = null,
1828 }).?;
1827 const target = SymbolWithLoc{ .sym_index = sym_index, .file = null };1829 const target = SymbolWithLoc{ .sym_index = sym_index, .file = null };
1828 try Atom.addRelocation(self, atom_index, .{1830 try Atom.addRelocation(self, atom_index, .{
1829 .type = .direct,1831 .type = .direct,
...@@ -1901,7 +1903,10 @@ pub fn getUavVAddr(...@@ -1901,7 +1903,10 @@ pub fn getUavVAddr(
19011903
1902 const this_atom_index = self.uavs.get(uav).?.atom;1904 const this_atom_index = self.uavs.get(uav).?.atom;
1903 const sym_index = self.getAtom(this_atom_index).getSymbolIndex().?;1905 const sym_index = self.getAtom(this_atom_index).getSymbolIndex().?;
1904 const atom_index = self.getAtomIndexForSymbol(.{ .sym_index = reloc_info.parent_atom_index, .file = null }).?;1906 const atom_index = self.getAtomIndexForSymbol(.{
1907 .sym_index = reloc_info.parent.atom_index,
1908 .file = null,
1909 }).?;
1905 const target = SymbolWithLoc{ .sym_index = sym_index, .file = null };1910 const target = SymbolWithLoc{ .sym_index = sym_index, .file = null };
1906 try Atom.addRelocation(self, atom_index, .{1911 try Atom.addRelocation(self, atom_index, .{
1907 .type = .direct,1912 .type = .direct,
src/link/Dwarf.zig+538-476
...@@ -19,8 +19,8 @@ debug_rnglists: DebugRngLists,...@@ -19,8 +19,8 @@ debug_rnglists: DebugRngLists,
19debug_str: StringSection,19debug_str: StringSection,
2020
21pub const UpdateError = error{21pub const UpdateError = error{
22 CodegenFail,
22 ReinterpretDeclRef,23 ReinterpretDeclRef,
23 IllDefinedMemoryLayout,
24 Unimplemented,24 Unimplemented,
25 OutOfMemory,25 OutOfMemory,
26 EndOfStream,26 EndOfStream,
...@@ -847,10 +847,11 @@ const Entry = struct {...@@ -847,10 +847,11 @@ const Entry = struct {
847 unit.len -| (unit.header_len + unit.trailer_len);847 unit.len -| (unit.header_len + unit.trailer_len);
848 if (entry_ptr.off + len > end) {848 if (entry_ptr.off + len > end) {
849 if (entry_ptr.next.unwrap()) |next_entry| {849 if (entry_ptr.next.unwrap()) |next_entry| {
850 if (entry_ptr.prev.unwrap()) |prev_entry|850 if (entry_ptr.prev.unwrap()) |prev_entry| {
851 unit.getEntry(prev_entry).next = entry_ptr.next851 const prev_entry_ptr = unit.getEntry(prev_entry);
852 else852 prev_entry_ptr.next = entry_ptr.next;
853 unit.first = entry_ptr.next;853 try prev_entry_ptr.pad(unit, sec, dwarf);
854 } else unit.first = entry_ptr.next;
854 const next_entry_ptr = unit.getEntry(next_entry);855 const next_entry_ptr = unit.getEntry(next_entry);
855 const entry = next_entry_ptr.prev;856 const entry = next_entry_ptr.prev;
856 next_entry_ptr.prev = entry_ptr.prev;857 next_entry_ptr.prev = entry_ptr.prev;
...@@ -860,6 +861,7 @@ const Entry = struct {...@@ -860,6 +861,7 @@ const Entry = struct {
860 entry_ptr.next = .none;861 entry_ptr.next = .none;
861 entry_ptr.off = last_entry_ptr.off + sec.padToIdeal(last_entry_ptr.len);862 entry_ptr.off = last_entry_ptr.off + sec.padToIdeal(last_entry_ptr.len);
862 unit.last = entry;863 unit.last = entry;
864 try last_entry_ptr.pad(unit, sec, dwarf);
863 }865 }
864 try unit.resize(sec, dwarf, 0, @intCast(unit.header_len + entry_ptr.off + sec.padToIdeal(len) + unit.trailer_len));866 try unit.resize(sec, dwarf, 0, @intCast(unit.header_len + entry_ptr.off + sec.padToIdeal(len) + unit.trailer_len));
865 }867 }
...@@ -1582,6 +1584,18 @@ pub const WipNav = struct {...@@ -1582,6 +1584,18 @@ pub const WipNav = struct {
1582 wip_nav.func = func;1584 wip_nav.func = func;
1583 }1585 }
15841586
1587 fn externalReloc(wip_nav: *WipNav, sec: *Section, reloc: ExternalReloc) std.mem.Allocator.Error!void {
1588 try sec.getUnit(wip_nav.unit).getEntry(wip_nav.entry).external_relocs.append(wip_nav.dwarf.gpa, reloc);
1589 }
1590
1591 pub fn infoExternalReloc(wip_nav: *WipNav, reloc: ExternalReloc) std.mem.Allocator.Error!void {
1592 try wip_nav.externalReloc(&wip_nav.dwarf.debug_info.section, reloc);
1593 }
1594
1595 fn frameExternalReloc(wip_nav: *WipNav, reloc: ExternalReloc) std.mem.Allocator.Error!void {
1596 try wip_nav.externalReloc(&wip_nav.dwarf.debug_frame.section, reloc);
1597 }
1598
1585 fn abbrevCode(wip_nav: *WipNav, abbrev_code: AbbrevCode) UpdateError!void {1599 fn abbrevCode(wip_nav: *WipNav, abbrev_code: AbbrevCode) UpdateError!void {
1586 try uleb128(wip_nav.debug_info.writer(wip_nav.dwarf.gpa), try wip_nav.dwarf.refAbbrevCode(abbrev_code));1600 try uleb128(wip_nav.debug_info.writer(wip_nav.dwarf.gpa), try wip_nav.dwarf.refAbbrevCode(abbrev_code));
1587 }1601 }
...@@ -1658,12 +1672,11 @@ pub const WipNav = struct {...@@ -1658,12 +1672,11 @@ pub const WipNav = struct {
1658 }1672 }
16591673
1660 fn infoAddrSym(wip_nav: *WipNav, sym_index: u32) UpdateError!void {1674 fn infoAddrSym(wip_nav: *WipNav, sym_index: u32) UpdateError!void {
1661 const dwarf = wip_nav.dwarf;1675 try wip_nav.infoExternalReloc(.{
1662 try dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(wip_nav.entry).external_relocs.append(dwarf.gpa, .{
1663 .source_off = @intCast(wip_nav.debug_info.items.len),1676 .source_off = @intCast(wip_nav.debug_info.items.len),
1664 .target_sym = sym_index,1677 .target_sym = sym_index,
1665 });1678 });
1666 try wip_nav.debug_info.appendNTimes(dwarf.gpa, 0, @intFromEnum(dwarf.address_size));1679 try wip_nav.debug_info.appendNTimes(wip_nav.dwarf.gpa, 0, @intFromEnum(wip_nav.dwarf.address_size));
1667 }1680 }
16681681
1669 fn frameExprloc(wip_nav: *WipNav, loc: Loc) UpdateError!void {1682 fn frameExprloc(wip_nav: *WipNav, loc: Loc) UpdateError!void {
...@@ -1690,12 +1703,11 @@ pub const WipNav = struct {...@@ -1690,12 +1703,11 @@ pub const WipNav = struct {
1690 }1703 }
16911704
1692 fn frameAddrSym(wip_nav: *WipNav, sym_index: u32) UpdateError!void {1705 fn frameAddrSym(wip_nav: *WipNav, sym_index: u32) UpdateError!void {
1693 const dwarf = wip_nav.dwarf;1706 try wip_nav.frameExternalReloc(.{
1694 try dwarf.debug_frame.section.getUnit(wip_nav.unit).getEntry(wip_nav.entry).external_relocs.append(dwarf.gpa, .{
1695 .source_off = @intCast(wip_nav.debug_frame.items.len),1707 .source_off = @intCast(wip_nav.debug_frame.items.len),
1696 .target_sym = sym_index,1708 .target_sym = sym_index,
1697 });1709 });
1698 try wip_nav.debug_frame.appendNTimes(dwarf.gpa, 0, @intFromEnum(dwarf.address_size));1710 try wip_nav.debug_frame.appendNTimes(wip_nav.dwarf.gpa, 0, @intFromEnum(wip_nav.dwarf.address_size));
1699 }1711 }
17001712
1701 fn getTypeEntry(wip_nav: *WipNav, ty: Type) UpdateError!struct { Unit.Index, Entry.Index } {1713 fn getTypeEntry(wip_nav: *WipNav, ty: Type) UpdateError!struct { Unit.Index, Entry.Index } {
...@@ -1747,6 +1759,27 @@ pub const WipNav = struct {...@@ -1747,6 +1759,27 @@ pub const WipNav = struct {
1747 reloc.target_off = @intCast(wip_nav.debug_info.items.len);1759 reloc.target_off = @intCast(wip_nav.debug_info.items.len);
1748 }1760 }
17491761
1762 fn blockValue(wip_nav: *WipNav, src_loc: Zcu.LazySrcLoc, val: Value) UpdateError!void {
1763 const ty = val.typeOf(wip_nav.pt.zcu);
1764 const diw = wip_nav.debug_info.writer(wip_nav.dwarf.gpa);
1765 const bytes = if (ty.hasRuntimeBits(wip_nav.pt.zcu)) ty.abiSize(wip_nav.pt.zcu) else 0;
1766 try uleb128(diw, bytes);
1767 if (bytes == 0) return;
1768 var dim = wip_nav.debug_info.toManaged(wip_nav.dwarf.gpa);
1769 defer wip_nav.debug_info = dim.moveToUnmanaged();
1770 switch (try codegen.generateSymbol(
1771 wip_nav.dwarf.bin_file,
1772 wip_nav.pt,
1773 src_loc,
1774 val,
1775 &dim,
1776 .{ .debug_output = .{ .dwarf = wip_nav } },
1777 )) {
1778 .ok => assert(dim.items.len == wip_nav.debug_info.items.len + bytes),
1779 .fail => unreachable,
1780 }
1781 }
1782
1750 fn enumConstValue(1783 fn enumConstValue(
1751 wip_nav: *WipNav,1784 wip_nav: *WipNav,
1752 loaded_enum: InternPool.LoadedEnumType,1785 loaded_enum: InternPool.LoadedEnumType,
...@@ -1812,8 +1845,8 @@ pub const WipNav = struct {...@@ -1812,8 +1845,8 @@ pub const WipNav = struct {
1812 }1845 }
1813 }1846 }
18141847
1815 fn flush(wip_nav: *WipNav) UpdateError!void {1848 fn flush(wip_nav: *WipNav, src_loc: Zcu.LazySrcLoc) UpdateError!void {
1816 while (wip_nav.pending_types.popOrNull()) |ty| try wip_nav.dwarf.updateType(wip_nav.pt, ty, &wip_nav.pending_types);1849 while (wip_nav.pending_types.popOrNull()) |ty| try wip_nav.dwarf.updateType(wip_nav.pt, src_loc, ty, &wip_nav.pending_types);
1817 }1850 }
1818};1851};
18191852
...@@ -2169,15 +2202,15 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In...@@ -2169,15 +2202,15 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In
2169 try diw.writeByte(accessibility);2202 try diw.writeByte(accessibility);
2170 try wip_nav.strp(nav.name.toSlice(ip));2203 try wip_nav.strp(nav.name.toSlice(ip));
2171 try wip_nav.strp(nav.fqn.toSlice(ip));2204 try wip_nav.strp(nav.fqn.toSlice(ip));
2172 const ty = nav_val.typeOf(zcu);2205 const nav_ty = nav_val.typeOf(zcu);
2173 const ty_reloc_index = try wip_nav.refForward();2206 const nav_ty_reloc_index = try wip_nav.refForward();
2174 try wip_nav.exprloc(.{ .addr = .{ .sym = sym_index } });2207 try wip_nav.exprloc(.{ .addr = .{ .sym = sym_index } });
2175 try uleb128(diw, nav.status.resolved.alignment.toByteUnits() orelse2208 try uleb128(diw, nav.status.resolved.alignment.toByteUnits() orelse
2176 ty.abiAlignment(zcu).toByteUnits().?);2209 nav_ty.abiAlignment(zcu).toByteUnits().?);
2177 try diw.writeByte(@intFromBool(false));2210 try diw.writeByte(@intFromBool(false));
2178 wip_nav.finishForward(ty_reloc_index);2211 wip_nav.finishForward(nav_ty_reloc_index);
2179 try wip_nav.abbrevCode(.is_const);2212 try wip_nav.abbrevCode(.is_const);
2180 try wip_nav.refType(ty);2213 try wip_nav.refType(nav_ty);
2181 },2214 },
2182 .variable => |variable| {2215 .variable => |variable| {
2183 assert(file.zir_loaded);2216 assert(file.zir_loaded);
...@@ -2286,20 +2319,16 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In...@@ -2286,20 +2319,16 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In
2286 .source_off = @intCast(wip_nav.debug_frame.items.len),2319 .source_off = @intCast(wip_nav.debug_frame.items.len),
2287 });2320 });
2288 try dfw.writeByteNTimes(0, dwarf.sectionOffsetBytes());2321 try dfw.writeByteNTimes(0, dwarf.sectionOffsetBytes());
2289 try entry.external_relocs.append(dwarf.gpa, .{2322 try wip_nav.frameAddrSym(sym_index);
2290 .source_off = @intCast(wip_nav.debug_frame.items.len),
2291 .target_sym = sym_index,
2292 });
2293 try dfw.writeByteNTimes(0, @intFromEnum(dwarf.address_size));
2294 try dfw.writeByteNTimes(undefined, @intFromEnum(dwarf.address_size));2323 try dfw.writeByteNTimes(undefined, @intFromEnum(dwarf.address_size));
2295 },2324 },
2296 .eh_frame => {2325 .eh_frame => {
2297 try dfw.writeInt(u32, undefined, dwarf.endian);2326 try dfw.writeInt(u32, undefined, dwarf.endian);
2298 try entry.external_relocs.append(dwarf.gpa, .{2327 try wip_nav.frameExternalReloc(.{
2299 .source_off = @intCast(wip_nav.debug_frame.items.len),2328 .source_off = @intCast(wip_nav.debug_frame.items.len),
2300 .target_sym = sym_index,2329 .target_sym = sym_index,
2301 });2330 });
2302 try dfw.writeByteNTimes(0, dwarf.sectionOffsetBytes());2331 try dfw.writeInt(u32, 0, dwarf.endian);
2303 try dfw.writeInt(u32, undefined, dwarf.endian);2332 try dfw.writeInt(u32, undefined, dwarf.endian);
2304 try uleb128(dfw, 0);2333 try uleb128(dfw, 0);
2305 },2334 },
...@@ -2479,12 +2508,13 @@ pub fn finishWipNav(...@@ -2479,12 +2508,13 @@ pub fn finishWipNav(
2479 }2508 }
2480 try dwarf.debug_loclists.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_loclists.items);2509 try dwarf.debug_loclists.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_loclists.items);
24812510
2482 try wip_nav.flush();2511 try wip_nav.flush(zcu.navSrcLoc(nav_index));
2483}2512}
24842513
2485pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index) UpdateError!void {2514pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index) UpdateError!void {
2486 const zcu = pt.zcu;2515 const zcu = pt.zcu;
2487 const ip = &zcu.intern_pool;2516 const ip = &zcu.intern_pool;
2517 const nav_src_loc = zcu.navSrcLoc(nav_index);
2488 const nav_val = zcu.navValue(nav_index);2518 const nav_val = zcu.navValue(nav_index);
24892519
2490 const nav = ip.getNav(nav_index);2520 const nav = ip.getNav(nav_index);
...@@ -2507,6 +2537,19 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2507,6 +2537,19 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2507 return;2537 return;
2508 }2538 }
25092539
2540 const parent_type, const accessibility: u8 = if (nav.analysis_owner.unwrap()) |cau| parent: {
2541 const parent_namespace_ptr = ip.namespacePtr(ip.getCau(cau).namespace);
2542 break :parent .{
2543 parent_namespace_ptr.owner_type,
2544 if (parent_namespace_ptr.pub_decls.containsContext(nav_index, .{ .zcu = zcu }))
2545 DW.ACCESS.public
2546 else if (parent_namespace_ptr.priv_decls.containsContext(nav_index, .{ .zcu = zcu }))
2547 DW.ACCESS.private
2548 else
2549 unreachable,
2550 };
2551 } else .{ zcu.fileRootType(inst_info.file), DW.ACCESS.private };
2552
2510 const tree = try file.getTree(dwarf.gpa);2553 const tree = try file.getTree(dwarf.gpa);
2511 const loc = tree.tokenLocation(0, tree.nodes.items(.main_token)[decl_inst.data.declaration.src_node]);2554 const loc = tree.tokenLocation(0, tree.nodes.items(.main_token)[decl_inst.data.declaration.src_node]);
2512 assert(loc.line == zcu.navSrcLine(nav_index));2555 assert(loc.line == zcu.navSrcLine(nav_index));
...@@ -2532,8 +2575,341 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2532,8 +2575,341 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
25322575
2533 const nav_gop = try dwarf.navs.getOrPut(dwarf.gpa, nav_index);2576 const nav_gop = try dwarf.navs.getOrPut(dwarf.gpa, nav_index);
2534 errdefer _ = dwarf.navs.pop();2577 errdefer _ = dwarf.navs.pop();
2535 switch (ip.indexToKey(nav_val.toIntern())) {2578
2536 .func => |func| {2579 const tag: enum { done, decl_alias, decl_var, decl_const } = switch (ip.indexToKey(nav_val.toIntern())) {
2580 .int_type,
2581 .ptr_type,
2582 .array_type,
2583 .vector_type,
2584 .opt_type,
2585 .anyframe_type,
2586 .error_union_type,
2587 .simple_type,
2588 .anon_struct_type,
2589 .func_type,
2590 .error_set_type,
2591 .inferred_error_set_type,
2592 => .decl_alias,
2593 .struct_type => tag: {
2594 const loaded_struct = ip.loadStructType(nav_val.toIntern());
2595 if (loaded_struct.zir_index == .none) break :tag .decl_alias;
2596
2597 const type_inst_info = loaded_struct.zir_index.unwrap().?.resolveFull(ip).?;
2598 if (type_inst_info.file != inst_info.file) break :tag .decl_alias;
2599
2600 const value_inst = value_inst: {
2601 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
2602 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));
2603 if (break_inst.tag != .break_inline) break :value_inst null;
2604 assert(file.zir.extraData(Zir.Inst.Break, break_inst.data.@"break".payload_index).data.block_inst == inst_info.inst);
2605 var value_inst = break_inst.data.@"break".operand.toIndex();
2606 while (value_inst) |value_inst_index| switch (file.zir.instructions.items(.tag)[@intFromEnum(value_inst_index)]) {
2607 else => break,
2608 .as_node => value_inst = file.zir.extraData(
2609 Zir.Inst.As,
2610 file.zir.instructions.items(.data)[@intFromEnum(value_inst_index)].pl_node.payload_index,
2611 ).data.operand.toIndex(),
2612 };
2613 break :value_inst value_inst;
2614 };
2615 if (type_inst_info.inst != value_inst) break :tag .decl_alias;
2616
2617 const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());
2618 if (type_gop.found_existing) {
2619 dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(type_gop.value_ptr.*).clear();
2620 nav_gop.value_ptr.* = type_gop.value_ptr.*;
2621 } else {
2622 if (nav_gop.found_existing)
2623 dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear()
2624 else
2625 nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
2626 type_gop.value_ptr.* = nav_gop.value_ptr.*;
2627 }
2628 wip_nav.entry = nav_gop.value_ptr.*;
2629
2630 const diw = wip_nav.debug_info.writer(dwarf.gpa);
2631
2632 switch (loaded_struct.layout) {
2633 .auto, .@"extern" => {
2634 try wip_nav.abbrevCode(if (loaded_struct.field_types.len == 0) .decl_namespace_struct else .decl_struct);
2635 try wip_nav.refType(Type.fromInterned(parent_type));
2636 assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));
2637 try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian);
2638 try uleb128(diw, loc.column + 1);
2639 try diw.writeByte(accessibility);
2640 try wip_nav.strp(nav.name.toSlice(ip));
2641 if (loaded_struct.field_types.len == 0) try diw.writeByte(@intFromBool(false)) else {
2642 try uleb128(diw, nav_val.toType().abiSize(zcu));
2643 try uleb128(diw, nav_val.toType().abiAlignment(zcu).toByteUnits().?);
2644 for (0..loaded_struct.field_types.len) |field_index| {
2645 const is_comptime = loaded_struct.fieldIsComptime(ip, field_index);
2646 const field_init = if (loaded_struct.haveFieldInits(ip))
2647 loaded_struct.fieldInit(ip, field_index)
2648 else
2649 .none;
2650 try wip_nav.abbrevCode(if (is_comptime)
2651 .struct_field_comptime
2652 else if (field_init != .none)
2653 .struct_field_default
2654 else
2655 .struct_field);
2656 if (loaded_struct.fieldName(ip, field_index).unwrap()) |field_name| try wip_nav.strp(field_name.toSlice(ip)) else {
2657 const field_name = try std.fmt.allocPrint(dwarf.gpa, "{d}", .{field_index});
2658 defer dwarf.gpa.free(field_name);
2659 try wip_nav.strp(field_name);
2660 }
2661 if (is_comptime and field_init == .none) {
2662 // workaround frontend bug
2663 try wip_nav.refType(Type.void);
2664 try wip_nav.blockValue(nav_src_loc, Value.void);
2665 } else {
2666 const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]);
2667 try wip_nav.refType(field_type);
2668 if (!is_comptime) {
2669 try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]);
2670 try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse
2671 field_type.abiAlignment(zcu).toByteUnits().?);
2672 }
2673 if (field_init != .none) try wip_nav.blockValue(nav_src_loc, Value.fromInterned(field_init));
2674 }
2675 }
2676 try uleb128(diw, @intFromEnum(AbbrevCode.null));
2677 }
2678 },
2679 .@"packed" => {
2680 try wip_nav.abbrevCode(.decl_packed_struct);
2681 try wip_nav.refType(Type.fromInterned(parent_type));
2682 assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));
2683 try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian);
2684 try uleb128(diw, loc.column + 1);
2685 try diw.writeByte(accessibility);
2686 try wip_nav.strp(nav.name.toSlice(ip));
2687 try wip_nav.refType(Type.fromInterned(loaded_struct.backingIntTypeUnordered(ip)));
2688 var field_bit_offset: u16 = 0;
2689 for (0..loaded_struct.field_types.len) |field_index| {
2690 try wip_nav.abbrevCode(.packed_struct_field);
2691 try wip_nav.strp(loaded_struct.fieldName(ip, field_index).unwrap().?.toSlice(ip));
2692 const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]);
2693 try wip_nav.refType(field_type);
2694 try uleb128(diw, field_bit_offset);
2695 field_bit_offset += @intCast(field_type.bitSize(zcu));
2696 }
2697 try uleb128(diw, @intFromEnum(AbbrevCode.null));
2698 },
2699 }
2700 break :tag .done;
2701 },
2702 .enum_type => tag: {
2703 const loaded_enum = ip.loadEnumType(nav_val.toIntern());
2704 if (loaded_enum.zir_index == .none) break :tag .decl_alias;
2705
2706 const type_inst_info = loaded_enum.zir_index.unwrap().?.resolveFull(ip).?;
2707 if (type_inst_info.file != inst_info.file) break :tag .decl_alias;
2708
2709 const value_inst = value_inst: {
2710 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
2711 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));
2712 if (break_inst.tag != .break_inline) break :value_inst null;
2713 assert(file.zir.extraData(Zir.Inst.Break, break_inst.data.@"break".payload_index).data.block_inst == inst_info.inst);
2714 var value_inst = break_inst.data.@"break".operand.toIndex();
2715 while (value_inst) |value_inst_index| switch (file.zir.instructions.items(.tag)[@intFromEnum(value_inst_index)]) {
2716 else => break,
2717 .as_node => value_inst = file.zir.extraData(
2718 Zir.Inst.As,
2719 file.zir.instructions.items(.data)[@intFromEnum(value_inst_index)].pl_node.payload_index,
2720 ).data.operand.toIndex(),
2721 };
2722 break :value_inst value_inst;
2723 };
2724 if (type_inst_info.inst != value_inst) break :tag .decl_alias;
2725
2726 const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());
2727 if (type_gop.found_existing) {
2728 dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(type_gop.value_ptr.*).clear();
2729 nav_gop.value_ptr.* = type_gop.value_ptr.*;
2730 } else {
2731 if (nav_gop.found_existing)
2732 dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear()
2733 else
2734 nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
2735 type_gop.value_ptr.* = nav_gop.value_ptr.*;
2736 }
2737 wip_nav.entry = nav_gop.value_ptr.*;
2738 const diw = wip_nav.debug_info.writer(dwarf.gpa);
2739 try wip_nav.abbrevCode(if (loaded_enum.names.len > 0) .decl_enum else .decl_empty_enum);
2740 try wip_nav.refType(Type.fromInterned(parent_type));
2741 assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));
2742 try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian);
2743 try uleb128(diw, loc.column + 1);
2744 try diw.writeByte(accessibility);
2745 try wip_nav.strp(nav.name.toSlice(ip));
2746 try wip_nav.refType(Type.fromInterned(loaded_enum.tag_ty));
2747 for (0..loaded_enum.names.len) |field_index| {
2748 try wip_nav.enumConstValue(loaded_enum, .{
2749 .sdata = .signed_enum_field,
2750 .udata = .unsigned_enum_field,
2751 .block = .big_enum_field,
2752 }, field_index);
2753 try wip_nav.strp(loaded_enum.names.get(ip)[field_index].toSlice(ip));
2754 }
2755 if (loaded_enum.names.len > 0) try uleb128(diw, @intFromEnum(AbbrevCode.null));
2756 break :tag .done;
2757 },
2758 .union_type => tag: {
2759 const loaded_union = ip.loadUnionType(nav_val.toIntern());
2760
2761 const type_inst_info = loaded_union.zir_index.resolveFull(ip).?;
2762 if (type_inst_info.file != inst_info.file) break :tag .decl_alias;
2763
2764 const value_inst = value_inst: {
2765 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
2766 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));
2767 if (break_inst.tag != .break_inline) break :value_inst null;
2768 assert(file.zir.extraData(Zir.Inst.Break, break_inst.data.@"break".payload_index).data.block_inst == inst_info.inst);
2769 var value_inst = break_inst.data.@"break".operand.toIndex();
2770 while (value_inst) |value_inst_index| switch (file.zir.instructions.items(.tag)[@intFromEnum(value_inst_index)]) {
2771 else => break,
2772 .as_node => value_inst = file.zir.extraData(
2773 Zir.Inst.As,
2774 file.zir.instructions.items(.data)[@intFromEnum(value_inst_index)].pl_node.payload_index,
2775 ).data.operand.toIndex(),
2776 };
2777 break :value_inst value_inst;
2778 };
2779 if (type_inst_info.inst != value_inst) break :tag .decl_alias;
2780
2781 const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());
2782 if (type_gop.found_existing) {
2783 dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(type_gop.value_ptr.*).clear();
2784 nav_gop.value_ptr.* = type_gop.value_ptr.*;
2785 } else {
2786 if (nav_gop.found_existing)
2787 dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear()
2788 else
2789 nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
2790 type_gop.value_ptr.* = nav_gop.value_ptr.*;
2791 }
2792 wip_nav.entry = nav_gop.value_ptr.*;
2793 const diw = wip_nav.debug_info.writer(dwarf.gpa);
2794 try wip_nav.abbrevCode(.decl_union);
2795 try wip_nav.refType(Type.fromInterned(parent_type));
2796 assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));
2797 try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian);
2798 try uleb128(diw, loc.column + 1);
2799 try diw.writeByte(accessibility);
2800 try wip_nav.strp(nav.name.toSlice(ip));
2801 const union_layout = Type.getUnionLayout(loaded_union, zcu);
2802 try uleb128(diw, union_layout.abi_size);
2803 try uleb128(diw, union_layout.abi_align.toByteUnits().?);
2804 const loaded_tag = loaded_union.loadTagType(ip);
2805 if (loaded_union.hasTag(ip)) {
2806 try wip_nav.abbrevCode(.tagged_union);
2807 try wip_nav.infoSectionOffset(
2808 .debug_info,
2809 wip_nav.unit,
2810 wip_nav.entry,
2811 @intCast(wip_nav.debug_info.items.len + dwarf.sectionOffsetBytes()),
2812 );
2813 {
2814 try wip_nav.abbrevCode(.generated_field);
2815 try wip_nav.strp("tag");
2816 try wip_nav.refType(Type.fromInterned(loaded_union.enum_tag_ty));
2817 try uleb128(diw, union_layout.tagOffset());
2818
2819 for (0..loaded_union.field_types.len) |field_index| {
2820 try wip_nav.enumConstValue(loaded_tag, .{
2821 .sdata = .signed_tagged_union_field,
2822 .udata = .unsigned_tagged_union_field,
2823 .block = .big_tagged_union_field,
2824 }, field_index);
2825 {
2826 try wip_nav.abbrevCode(.struct_field);
2827 try wip_nav.strp(loaded_tag.names.get(ip)[field_index].toSlice(ip));
2828 const field_type = Type.fromInterned(loaded_union.field_types.get(ip)[field_index]);
2829 try wip_nav.refType(field_type);
2830 try uleb128(diw, union_layout.payloadOffset());
2831 try uleb128(diw, loaded_union.fieldAlign(ip, field_index).toByteUnits() orelse
2832 if (field_type.isNoReturn(zcu)) 1 else field_type.abiAlignment(zcu).toByteUnits().?);
2833 }
2834 try uleb128(diw, @intFromEnum(AbbrevCode.null));
2835 }
2836 }
2837 try uleb128(diw, @intFromEnum(AbbrevCode.null));
2838 } else for (0..loaded_union.field_types.len) |field_index| {
2839 try wip_nav.abbrevCode(.untagged_union_field);
2840 try wip_nav.strp(loaded_tag.names.get(ip)[field_index].toSlice(ip));
2841 const field_type = Type.fromInterned(loaded_union.field_types.get(ip)[field_index]);
2842 try wip_nav.refType(field_type);
2843 try uleb128(diw, loaded_union.fieldAlign(ip, field_index).toByteUnits() orelse
2844 field_type.abiAlignment(zcu).toByteUnits().?);
2845 }
2846 try uleb128(diw, @intFromEnum(AbbrevCode.null));
2847 break :tag .done;
2848 },
2849 .opaque_type => tag: {
2850 const loaded_opaque = ip.loadOpaqueType(nav_val.toIntern());
2851
2852 const type_inst_info = loaded_opaque.zir_index.resolveFull(ip).?;
2853 if (type_inst_info.file != inst_info.file) break :tag .decl_alias;
2854
2855 const value_inst = value_inst: {
2856 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
2857 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));
2858 if (break_inst.tag != .break_inline) break :value_inst null;
2859 assert(file.zir.extraData(Zir.Inst.Break, break_inst.data.@"break".payload_index).data.block_inst == inst_info.inst);
2860 var value_inst = break_inst.data.@"break".operand.toIndex();
2861 while (value_inst) |value_inst_index| switch (file.zir.instructions.items(.tag)[@intFromEnum(value_inst_index)]) {
2862 else => break,
2863 .as_node => value_inst = file.zir.extraData(
2864 Zir.Inst.As,
2865 file.zir.instructions.items(.data)[@intFromEnum(value_inst_index)].pl_node.payload_index,
2866 ).data.operand.toIndex(),
2867 };
2868 break :value_inst value_inst;
2869 };
2870 if (type_inst_info.inst != value_inst) break :tag .decl_alias;
2871
2872 const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());
2873 if (type_gop.found_existing) {
2874 dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(type_gop.value_ptr.*).clear();
2875 nav_gop.value_ptr.* = type_gop.value_ptr.*;
2876 } else {
2877 if (nav_gop.found_existing)
2878 dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear()
2879 else
2880 nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
2881 type_gop.value_ptr.* = nav_gop.value_ptr.*;
2882 }
2883 wip_nav.entry = nav_gop.value_ptr.*;
2884 const diw = wip_nav.debug_info.writer(dwarf.gpa);
2885 try wip_nav.abbrevCode(.decl_namespace_struct);
2886 try wip_nav.refType(Type.fromInterned(parent_type));
2887 assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));
2888 try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian);
2889 try uleb128(diw, loc.column + 1);
2890 try diw.writeByte(accessibility);
2891 try wip_nav.strp(nav.name.toSlice(ip));
2892 try diw.writeByte(@intFromBool(false));
2893 break :tag .done;
2894 },
2895 .undef,
2896 .simple_value,
2897 .@"extern",
2898 .int,
2899 .err,
2900 .error_union,
2901 .enum_literal,
2902 .enum_tag,
2903 .empty_enum_value,
2904 .float,
2905 .ptr,
2906 .slice,
2907 .opt,
2908 .aggregate,
2909 .un,
2910 => .decl_const,
2911 .variable => .decl_var,
2912 .func => |func| tag: {
2537 if (nav_gop.found_existing) {2913 if (nav_gop.found_existing) {
2538 const unit_ptr = dwarf.debug_info.section.getUnit(wip_nav.unit);2914 const unit_ptr = dwarf.debug_info.section.getUnit(wip_nav.unit);
2539 const entry_ptr = unit_ptr.getEntry(nav_gop.value_ptr.*);2915 const entry_ptr = unit_ptr.getEntry(nav_gop.value_ptr.*);
...@@ -2557,19 +2933,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2557,19 +2933,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2557 } else nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);2933 } else nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
2558 wip_nav.entry = nav_gop.value_ptr.*;2934 wip_nav.entry = nav_gop.value_ptr.*;
25592935
2560 const parent_type, const accessibility: u8 = if (nav.analysis_owner.unwrap()) |cau| parent: {
2561 const parent_namespace_ptr = ip.namespacePtr(ip.getCau(cau).namespace);
2562 break :parent .{
2563 parent_namespace_ptr.owner_type,
2564 if (parent_namespace_ptr.pub_decls.containsContext(nav_index, .{ .zcu = zcu }))
2565 DW.ACCESS.public
2566 else if (parent_namespace_ptr.priv_decls.containsContext(nav_index, .{ .zcu = zcu }))
2567 DW.ACCESS.private
2568 else
2569 unreachable,
2570 };
2571 } else .{ zcu.fileRootType(inst_info.file), DW.ACCESS.private };
2572
2573 const func_type = ip.indexToKey(func.ty).func_type;2936 const func_type = ip.indexToKey(func.ty).func_type;
2574 const diw = wip_nav.debug_info.writer(dwarf.gpa);2937 const diw = wip_nav.debug_info.writer(dwarf.gpa);
2575 try wip_nav.abbrevCode(if (func_type.param_types.len > 0 or func_type.is_var_args)2938 try wip_nav.abbrevCode(if (func_type.param_types.len > 0 or func_type.is_var_args)
...@@ -2591,208 +2954,21 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2591,208 +2954,21 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2591 if (func_type.is_var_args) try wip_nav.abbrevCode(.is_var_args);2954 if (func_type.is_var_args) try wip_nav.abbrevCode(.is_var_args);
2592 try uleb128(diw, @intFromEnum(AbbrevCode.null));2955 try uleb128(diw, @intFromEnum(AbbrevCode.null));
2593 }2956 }
2957 break :tag .done;
2594 },2958 },
2595 .struct_type => done: {2959 // memoization, not types
2596 const loaded_struct = ip.loadStructType(nav_val.toIntern());2960 .memoized_call => unreachable,
25972961 };
2598 const parent_type, const accessibility: u8 = if (nav.analysis_owner.unwrap()) |cau| parent: {2962 if (tag != .done) {
2599 const parent_namespace_ptr = ip.namespacePtr(ip.getCau(cau).namespace);2963 if (nav_gop.found_existing)
2600 break :parent .{2964 dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear()
2601 parent_namespace_ptr.owner_type,2965 else
2602 if (parent_namespace_ptr.pub_decls.containsContext(nav_index, .{ .zcu = zcu }))2966 nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
2603 DW.ACCESS.public2967 wip_nav.entry = nav_gop.value_ptr.*;
2604 else if (parent_namespace_ptr.priv_decls.containsContext(nav_index, .{ .zcu = zcu }))2968 }
2605 DW.ACCESS.private2969 switch (tag) {
2606 else2970 .done => {},
2607 unreachable,2971 .decl_alias => {
2608 };
2609 } else .{ zcu.fileRootType(inst_info.file), DW.ACCESS.private };
2610
2611 decl_struct: {
2612 if (loaded_struct.zir_index == .none) break :decl_struct;
2613
2614 const type_inst_info = loaded_struct.zir_index.unwrap().?.resolveFull(ip).?;
2615 if (type_inst_info.file != inst_info.file) break :decl_struct;
2616
2617 const value_inst = value_inst: {
2618 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
2619 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));
2620 if (break_inst.tag != .break_inline) break :value_inst null;
2621 assert(file.zir.extraData(Zir.Inst.Break, break_inst.data.@"break".payload_index).data.block_inst == inst_info.inst);
2622 var value_inst = break_inst.data.@"break".operand.toIndex();
2623 while (value_inst) |value_inst_index| switch (file.zir.instructions.items(.tag)[@intFromEnum(value_inst_index)]) {
2624 else => break,
2625 .as_node => value_inst = file.zir.extraData(
2626 Zir.Inst.As,
2627 file.zir.instructions.items(.data)[@intFromEnum(value_inst_index)].pl_node.payload_index,
2628 ).data.operand.toIndex(),
2629 };
2630 break :value_inst value_inst;
2631 };
2632 if (type_inst_info.inst != value_inst) break :decl_struct;
2633
2634 const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());
2635 if (type_gop.found_existing) {
2636 dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(type_gop.value_ptr.*).clear();
2637 nav_gop.value_ptr.* = type_gop.value_ptr.*;
2638 } else {
2639 if (nav_gop.found_existing)
2640 dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear()
2641 else
2642 nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
2643 type_gop.value_ptr.* = nav_gop.value_ptr.*;
2644 }
2645 wip_nav.entry = nav_gop.value_ptr.*;
2646
2647 const diw = wip_nav.debug_info.writer(dwarf.gpa);
2648
2649 switch (loaded_struct.layout) {
2650 .auto, .@"extern" => {
2651 try wip_nav.abbrevCode(if (loaded_struct.field_types.len == 0) .decl_namespace_struct else .decl_struct);
2652 try wip_nav.refType(Type.fromInterned(parent_type));
2653 assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));
2654 try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian);
2655 try uleb128(diw, loc.column + 1);
2656 try diw.writeByte(accessibility);
2657 try wip_nav.strp(nav.name.toSlice(ip));
2658 if (loaded_struct.field_types.len == 0) try diw.writeByte(@intFromBool(false)) else {
2659 try uleb128(diw, nav_val.toType().abiSize(zcu));
2660 try uleb128(diw, nav_val.toType().abiAlignment(zcu).toByteUnits().?);
2661 for (0..loaded_struct.field_types.len) |field_index| {
2662 const is_comptime = loaded_struct.fieldIsComptime(ip, field_index);
2663 try wip_nav.abbrevCode(if (is_comptime) .struct_field_comptime else .struct_field);
2664 if (loaded_struct.fieldName(ip, field_index).unwrap()) |field_name| try wip_nav.strp(field_name.toSlice(ip)) else {
2665 const field_name = try std.fmt.allocPrint(dwarf.gpa, "{d}", .{field_index});
2666 defer dwarf.gpa.free(field_name);
2667 try wip_nav.strp(field_name);
2668 }
2669 const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]);
2670 try wip_nav.refType(field_type);
2671 if (!is_comptime) {
2672 try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]);
2673 try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse
2674 field_type.abiAlignment(zcu).toByteUnits().?);
2675 }
2676 }
2677 try uleb128(diw, @intFromEnum(AbbrevCode.null));
2678 }
2679 },
2680 .@"packed" => {
2681 try wip_nav.abbrevCode(.decl_packed_struct);
2682 try wip_nav.refType(Type.fromInterned(parent_type));
2683 assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));
2684 try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian);
2685 try uleb128(diw, loc.column + 1);
2686 try diw.writeByte(accessibility);
2687 try wip_nav.strp(nav.name.toSlice(ip));
2688 try wip_nav.refType(Type.fromInterned(loaded_struct.backingIntTypeUnordered(ip)));
2689 var field_bit_offset: u16 = 0;
2690 for (0..loaded_struct.field_types.len) |field_index| {
2691 try wip_nav.abbrevCode(.packed_struct_field);
2692 try wip_nav.strp(loaded_struct.fieldName(ip, field_index).unwrap().?.toSlice(ip));
2693 const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]);
2694 try wip_nav.refType(field_type);
2695 try uleb128(diw, field_bit_offset);
2696 field_bit_offset += @intCast(field_type.bitSize(zcu));
2697 }
2698 try uleb128(diw, @intFromEnum(AbbrevCode.null));
2699 },
2700 }
2701 break :done;
2702 }
2703
2704 if (nav_gop.found_existing)
2705 dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear()
2706 else
2707 nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
2708 wip_nav.entry = nav_gop.value_ptr.*;
2709 const diw = wip_nav.debug_info.writer(dwarf.gpa);
2710 try wip_nav.abbrevCode(.decl_alias);
2711 try wip_nav.refType(Type.fromInterned(parent_type));
2712 assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));
2713 try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian);
2714 try uleb128(diw, loc.column + 1);
2715 try diw.writeByte(accessibility);
2716 try wip_nav.strp(nav.name.toSlice(ip));
2717 try wip_nav.refType(nav_val.toType());
2718 },
2719 .enum_type => done: {
2720 const loaded_enum = ip.loadEnumType(nav_val.toIntern());
2721
2722 const parent_type, const accessibility: u8 = if (nav.analysis_owner.unwrap()) |cau| parent: {
2723 const parent_namespace_ptr = ip.namespacePtr(ip.getCau(cau).namespace);
2724 break :parent .{
2725 parent_namespace_ptr.owner_type,
2726 if (parent_namespace_ptr.pub_decls.containsContext(nav_index, .{ .zcu = zcu }))
2727 DW.ACCESS.public
2728 else if (parent_namespace_ptr.priv_decls.containsContext(nav_index, .{ .zcu = zcu }))
2729 DW.ACCESS.private
2730 else
2731 unreachable,
2732 };
2733 } else .{ zcu.fileRootType(inst_info.file), DW.ACCESS.private };
2734
2735 decl_enum: {
2736 if (loaded_enum.zir_index == .none) break :decl_enum;
2737
2738 const type_inst_info = loaded_enum.zir_index.unwrap().?.resolveFull(ip).?;
2739 if (type_inst_info.file != inst_info.file) break :decl_enum;
2740
2741 const value_inst = value_inst: {
2742 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
2743 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));
2744 if (break_inst.tag != .break_inline) break :value_inst null;
2745 assert(file.zir.extraData(Zir.Inst.Break, break_inst.data.@"break".payload_index).data.block_inst == inst_info.inst);
2746 var value_inst = break_inst.data.@"break".operand.toIndex();
2747 while (value_inst) |value_inst_index| switch (file.zir.instructions.items(.tag)[@intFromEnum(value_inst_index)]) {
2748 else => break,
2749 .as_node => value_inst = file.zir.extraData(
2750 Zir.Inst.As,
2751 file.zir.instructions.items(.data)[@intFromEnum(value_inst_index)].pl_node.payload_index,
2752 ).data.operand.toIndex(),
2753 };
2754 break :value_inst value_inst;
2755 };
2756 if (type_inst_info.inst != value_inst) break :decl_enum;
2757
2758 const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());
2759 if (type_gop.found_existing) {
2760 dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(type_gop.value_ptr.*).clear();
2761 nav_gop.value_ptr.* = type_gop.value_ptr.*;
2762 } else {
2763 if (nav_gop.found_existing)
2764 dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear()
2765 else
2766 nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
2767 type_gop.value_ptr.* = nav_gop.value_ptr.*;
2768 }
2769 wip_nav.entry = nav_gop.value_ptr.*;
2770 const diw = wip_nav.debug_info.writer(dwarf.gpa);
2771 try wip_nav.abbrevCode(if (loaded_enum.names.len > 0) .decl_enum else .decl_empty_enum);
2772 try wip_nav.refType(Type.fromInterned(parent_type));
2773 assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));
2774 try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian);
2775 try uleb128(diw, loc.column + 1);
2776 try diw.writeByte(accessibility);
2777 try wip_nav.strp(nav.name.toSlice(ip));
2778 try wip_nav.refType(Type.fromInterned(loaded_enum.tag_ty));
2779 for (0..loaded_enum.names.len) |field_index| {
2780 try wip_nav.enumConstValue(loaded_enum, .{
2781 .sdata = .signed_enum_field,
2782 .udata = .unsigned_enum_field,
2783 .block = .big_enum_field,
2784 }, field_index);
2785 try wip_nav.strp(loaded_enum.names.get(ip)[field_index].toSlice(ip));
2786 }
2787 if (loaded_enum.names.len > 0) try uleb128(diw, @intFromEnum(AbbrevCode.null));
2788 break :done;
2789 }
2790
2791 if (nav_gop.found_existing)
2792 dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear()
2793 else
2794 nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
2795 wip_nav.entry = nav_gop.value_ptr.*;
2796 const diw = wip_nav.debug_info.writer(dwarf.gpa);2972 const diw = wip_nav.debug_info.writer(dwarf.gpa);
2797 try wip_nav.abbrevCode(.decl_alias);2973 try wip_nav.abbrevCode(.decl_alias);
2798 try wip_nav.refType(Type.fromInterned(parent_type));2974 try wip_nav.refType(Type.fromInterned(parent_type));
...@@ -2803,215 +2979,52 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2803,215 +2979,52 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2803 try wip_nav.strp(nav.name.toSlice(ip));2979 try wip_nav.strp(nav.name.toSlice(ip));
2804 try wip_nav.refType(nav_val.toType());2980 try wip_nav.refType(nav_val.toType());
2805 },2981 },
2806 .union_type => done: {2982 .decl_var => {
2807 const loaded_union = ip.loadUnionType(nav_val.toIntern());
2808
2809 const parent_type, const accessibility: u8 = if (nav.analysis_owner.unwrap()) |cau| parent: {
2810 const parent_namespace_ptr = ip.namespacePtr(ip.getCau(cau).namespace);
2811 break :parent .{
2812 parent_namespace_ptr.owner_type,
2813 if (parent_namespace_ptr.pub_decls.containsContext(nav_index, .{ .zcu = zcu }))
2814 DW.ACCESS.public
2815 else if (parent_namespace_ptr.priv_decls.containsContext(nav_index, .{ .zcu = zcu }))
2816 DW.ACCESS.private
2817 else
2818 unreachable,
2819 };
2820 } else .{ zcu.fileRootType(inst_info.file), DW.ACCESS.private };
2821
2822 decl_union: {
2823 const type_inst_info = loaded_union.zir_index.resolveFull(ip).?;
2824 if (type_inst_info.file != inst_info.file) break :decl_union;
2825
2826 const value_inst = value_inst: {
2827 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
2828 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));
2829 if (break_inst.tag != .break_inline) break :value_inst null;
2830 assert(file.zir.extraData(Zir.Inst.Break, break_inst.data.@"break".payload_index).data.block_inst == inst_info.inst);
2831 var value_inst = break_inst.data.@"break".operand.toIndex();
2832 while (value_inst) |value_inst_index| switch (file.zir.instructions.items(.tag)[@intFromEnum(value_inst_index)]) {
2833 else => break,
2834 .as_node => value_inst = file.zir.extraData(
2835 Zir.Inst.As,
2836 file.zir.instructions.items(.data)[@intFromEnum(value_inst_index)].pl_node.payload_index,
2837 ).data.operand.toIndex(),
2838 };
2839 break :value_inst value_inst;
2840 };
2841 if (type_inst_info.inst != value_inst) break :decl_union;
2842
2843 const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());
2844 if (type_gop.found_existing) {
2845 dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(type_gop.value_ptr.*).clear();
2846 nav_gop.value_ptr.* = type_gop.value_ptr.*;
2847 } else {
2848 if (nav_gop.found_existing)
2849 dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear()
2850 else
2851 nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
2852 type_gop.value_ptr.* = nav_gop.value_ptr.*;
2853 }
2854 wip_nav.entry = nav_gop.value_ptr.*;
2855 const diw = wip_nav.debug_info.writer(dwarf.gpa);
2856 try wip_nav.abbrevCode(.decl_union);
2857 try wip_nav.refType(Type.fromInterned(parent_type));
2858 assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));
2859 try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian);
2860 try uleb128(diw, loc.column + 1);
2861 try diw.writeByte(accessibility);
2862 try wip_nav.strp(nav.name.toSlice(ip));
2863 const union_layout = Type.getUnionLayout(loaded_union, zcu);
2864 try uleb128(diw, union_layout.abi_size);
2865 try uleb128(diw, union_layout.abi_align.toByteUnits().?);
2866 const loaded_tag = loaded_union.loadTagType(ip);
2867 if (loaded_union.hasTag(ip)) {
2868 try wip_nav.abbrevCode(.tagged_union);
2869 try wip_nav.infoSectionOffset(
2870 .debug_info,
2871 wip_nav.unit,
2872 wip_nav.entry,
2873 @intCast(wip_nav.debug_info.items.len + dwarf.sectionOffsetBytes()),
2874 );
2875 {
2876 try wip_nav.abbrevCode(.generated_field);
2877 try wip_nav.strp("tag");
2878 try wip_nav.refType(Type.fromInterned(loaded_union.enum_tag_ty));
2879 try uleb128(diw, union_layout.tagOffset());
2880
2881 for (0..loaded_union.field_types.len) |field_index| {
2882 try wip_nav.enumConstValue(loaded_tag, .{
2883 .sdata = .signed_tagged_union_field,
2884 .udata = .unsigned_tagged_union_field,
2885 .block = .big_tagged_union_field,
2886 }, field_index);
2887 {
2888 try wip_nav.abbrevCode(.struct_field);
2889 try wip_nav.strp(loaded_tag.names.get(ip)[field_index].toSlice(ip));
2890 const field_type = Type.fromInterned(loaded_union.field_types.get(ip)[field_index]);
2891 try wip_nav.refType(field_type);
2892 try uleb128(diw, union_layout.payloadOffset());
2893 try uleb128(diw, loaded_union.fieldAlign(ip, field_index).toByteUnits() orelse
2894 if (field_type.isNoReturn(zcu)) 1 else field_type.abiAlignment(zcu).toByteUnits().?);
2895 }
2896 try uleb128(diw, @intFromEnum(AbbrevCode.null));
2897 }
2898 }
2899 try uleb128(diw, @intFromEnum(AbbrevCode.null));
2900 } else for (0..loaded_union.field_types.len) |field_index| {
2901 try wip_nav.abbrevCode(.untagged_union_field);
2902 try wip_nav.strp(loaded_tag.names.get(ip)[field_index].toSlice(ip));
2903 const field_type = Type.fromInterned(loaded_union.field_types.get(ip)[field_index]);
2904 try wip_nav.refType(field_type);
2905 try uleb128(diw, loaded_union.fieldAlign(ip, field_index).toByteUnits() orelse
2906 field_type.abiAlignment(zcu).toByteUnits().?);
2907 }
2908 try uleb128(diw, @intFromEnum(AbbrevCode.null));
2909 break :done;
2910 }
2911
2912 if (nav_gop.found_existing)
2913 dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear()
2914 else
2915 nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
2916 wip_nav.entry = nav_gop.value_ptr.*;
2917 const diw = wip_nav.debug_info.writer(dwarf.gpa);2983 const diw = wip_nav.debug_info.writer(dwarf.gpa);
2918 try wip_nav.abbrevCode(.decl_alias);2984 try wip_nav.abbrevCode(.decl_var);
2919 try wip_nav.refType(Type.fromInterned(parent_type));2985 try wip_nav.refType(Type.fromInterned(parent_type));
2920 assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));2986 assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));
2921 try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian);2987 try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian);
2922 try uleb128(diw, loc.column + 1);2988 try uleb128(diw, loc.column + 1);
2923 try diw.writeByte(accessibility);2989 try diw.writeByte(accessibility);
2924 try wip_nav.strp(nav.name.toSlice(ip));2990 try wip_nav.strp(nav.name.toSlice(ip));
2925 try wip_nav.refType(nav_val.toType());2991 try wip_nav.strp(nav.fqn.toSlice(ip));
2992 const nav_ty = nav_val.typeOf(zcu);
2993 try wip_nav.refType(nav_ty);
2994 try wip_nav.blockValue(nav_src_loc, nav_val);
2995 try uleb128(diw, nav.status.resolved.alignment.toByteUnits() orelse
2996 nav_ty.abiAlignment(zcu).toByteUnits().?);
2997 try diw.writeByte(@intFromBool(false));
2926 },2998 },
2927 .opaque_type => done: {2999 .decl_const => {
2928 const loaded_opaque = ip.loadOpaqueType(nav_val.toIntern());
2929
2930 const parent_type, const accessibility: u8 = if (nav.analysis_owner.unwrap()) |cau| parent: {
2931 const parent_namespace_ptr = ip.namespacePtr(ip.getCau(cau).namespace);
2932 break :parent .{
2933 parent_namespace_ptr.owner_type,
2934 if (parent_namespace_ptr.pub_decls.containsContext(nav_index, .{ .zcu = zcu }))
2935 DW.ACCESS.public
2936 else if (parent_namespace_ptr.priv_decls.containsContext(nav_index, .{ .zcu = zcu }))
2937 DW.ACCESS.private
2938 else
2939 unreachable,
2940 };
2941 } else .{ zcu.fileRootType(inst_info.file), DW.ACCESS.private };
2942
2943 decl_opaque: {
2944 const type_inst_info = loaded_opaque.zir_index.resolveFull(ip).?;
2945 if (type_inst_info.file != inst_info.file) break :decl_opaque;
2946
2947 const value_inst = value_inst: {
2948 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
2949 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));
2950 if (break_inst.tag != .break_inline) break :value_inst null;
2951 assert(file.zir.extraData(Zir.Inst.Break, break_inst.data.@"break".payload_index).data.block_inst == inst_info.inst);
2952 var value_inst = break_inst.data.@"break".operand.toIndex();
2953 while (value_inst) |value_inst_index| switch (file.zir.instructions.items(.tag)[@intFromEnum(value_inst_index)]) {
2954 else => break,
2955 .as_node => value_inst = file.zir.extraData(
2956 Zir.Inst.As,
2957 file.zir.instructions.items(.data)[@intFromEnum(value_inst_index)].pl_node.payload_index,
2958 ).data.operand.toIndex(),
2959 };
2960 break :value_inst value_inst;
2961 };
2962 if (type_inst_info.inst != value_inst) break :decl_opaque;
2963
2964 const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());
2965 if (type_gop.found_existing) {
2966 dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(type_gop.value_ptr.*).clear();
2967 nav_gop.value_ptr.* = type_gop.value_ptr.*;
2968 } else {
2969 if (nav_gop.found_existing)
2970 dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear()
2971 else
2972 nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
2973 type_gop.value_ptr.* = nav_gop.value_ptr.*;
2974 }
2975 wip_nav.entry = nav_gop.value_ptr.*;
2976 const diw = wip_nav.debug_info.writer(dwarf.gpa);
2977 try wip_nav.abbrevCode(.decl_namespace_struct);
2978 try wip_nav.refType(Type.fromInterned(parent_type));
2979 assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));
2980 try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian);
2981 try uleb128(diw, loc.column + 1);
2982 try diw.writeByte(accessibility);
2983 try wip_nav.strp(nav.name.toSlice(ip));
2984 try diw.writeByte(@intFromBool(false));
2985 break :done;
2986 }
2987
2988 if (nav_gop.found_existing)
2989 dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear()
2990 else
2991 nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
2992 wip_nav.entry = nav_gop.value_ptr.*;
2993 const diw = wip_nav.debug_info.writer(dwarf.gpa);3000 const diw = wip_nav.debug_info.writer(dwarf.gpa);
2994 try wip_nav.abbrevCode(.decl_alias);3001 try wip_nav.abbrevCode(.decl_const);
2995 try wip_nav.refType(Type.fromInterned(parent_type));3002 try wip_nav.refType(Type.fromInterned(parent_type));
2996 assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));3003 assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));
2997 try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian);3004 try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian);
2998 try uleb128(diw, loc.column + 1);3005 try uleb128(diw, loc.column + 1);
2999 try diw.writeByte(accessibility);3006 try diw.writeByte(accessibility);
3000 try wip_nav.strp(nav.name.toSlice(ip));3007 try wip_nav.strp(nav.name.toSlice(ip));
3001 try wip_nav.refType(nav_val.toType());3008 try wip_nav.strp(nav.fqn.toSlice(ip));
3002 },3009 const nav_ty = nav_val.typeOf(zcu);
3003 else => {3010 const nav_ty_reloc_index = try wip_nav.refForward();
3004 _ = dwarf.navs.pop();3011 try wip_nav.blockValue(nav_src_loc, nav_val);
3005 return;3012 try uleb128(diw, nav.status.resolved.alignment.toByteUnits() orelse
3013 nav_ty.abiAlignment(zcu).toByteUnits().?);
3014 try diw.writeByte(@intFromBool(false));
3015 wip_nav.finishForward(nav_ty_reloc_index);
3016 try wip_nav.abbrevCode(.is_const);
3017 try wip_nav.refType(nav_ty);
3006 },3018 },
3007 }3019 }
3008 try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.items);3020 try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.items);
3009 try wip_nav.flush();3021 try wip_nav.flush(nav_src_loc);
3010}3022}
30113023
3012fn updateType(3024fn updateType(
3013 dwarf: *Dwarf,3025 dwarf: *Dwarf,
3014 pt: Zcu.PerThread,3026 pt: Zcu.PerThread,
3027 src_loc: Zcu.LazySrcLoc,
3015 type_index: InternPool.Index,3028 type_index: InternPool.Index,
3016 pending_types: *std.ArrayListUnmanaged(InternPool.Index),3029 pending_types: *std.ArrayListUnmanaged(InternPool.Index),
3017) UpdateError!void {3030) UpdateError!void {
...@@ -3068,15 +3081,10 @@ fn updateType(...@@ -3068,15 +3081,10 @@ fn updateType(
3068 const ptr_child_type = Type.fromInterned(ptr_type.child);3081 const ptr_child_type = Type.fromInterned(ptr_type.child);
3069 try wip_nav.abbrevCode(if (ptr_type.sentinel == .none) .ptr_type else .ptr_sentinel_type);3082 try wip_nav.abbrevCode(if (ptr_type.sentinel == .none) .ptr_type else .ptr_sentinel_type);
3070 try wip_nav.strp(name);3083 try wip_nav.strp(name);
3071 if (ptr_type.sentinel != .none) {3084 if (ptr_type.sentinel != .none) try wip_nav.blockValue(
3072 const bytes = ptr_child_type.abiSize(zcu);3085 src_loc,
3073 try uleb128(diw, bytes);3086 Value.fromInterned(ptr_type.sentinel),
3074 const mem = try wip_nav.debug_info.addManyAsSlice(dwarf.gpa, @intCast(bytes));3087 );
3075 Value.fromInterned(ptr_type.sentinel).writeToMemory(pt, mem) catch |err| switch (err) {
3076 error.IllDefinedMemoryLayout => @memset(mem, 0),
3077 else => |e| return e,
3078 };
3079 }
3080 try uleb128(diw, ptr_type.flags.alignment.toByteUnits() orelse3088 try uleb128(diw, ptr_type.flags.alignment.toByteUnits() orelse
3081 ptr_child_type.abiAlignment(zcu).toByteUnits().?);3089 ptr_child_type.abiAlignment(zcu).toByteUnits().?);
3082 try diw.writeByte(@intFromEnum(ptr_type.flags.address_space));3090 try diw.writeByte(@intFromEnum(ptr_type.flags.address_space));
...@@ -3122,15 +3130,10 @@ fn updateType(...@@ -3122,15 +3130,10 @@ fn updateType(
3122 const array_child_type = Type.fromInterned(array_type.child);3130 const array_child_type = Type.fromInterned(array_type.child);
3123 try wip_nav.abbrevCode(if (array_type.sentinel == .none) .array_type else .array_sentinel_type);3131 try wip_nav.abbrevCode(if (array_type.sentinel == .none) .array_type else .array_sentinel_type);
3124 try wip_nav.strp(name);3132 try wip_nav.strp(name);
3125 if (array_type.sentinel != .none) {3133 if (array_type.sentinel != .none) try wip_nav.blockValue(
3126 const bytes = array_child_type.abiSize(zcu);3134 src_loc,
3127 try uleb128(diw, bytes);3135 Value.fromInterned(array_type.sentinel),
3128 const mem = try wip_nav.debug_info.addManyAsSlice(dwarf.gpa, @intCast(bytes));3136 );
3129 Value.fromInterned(array_type.sentinel).writeToMemory(pt, mem) catch |err| switch (err) {
3130 error.IllDefinedMemoryLayout => @memset(mem, 0),
3131 else => |e| return e,
3132 };
3133 }
3134 try wip_nav.refType(array_child_type);3137 try wip_nav.refType(array_child_type);
3135 try wip_nav.abbrevCode(.array_index);3138 try wip_nav.abbrevCode(.array_index);
3136 try wip_nav.refType(Type.usize);3139 try wip_nav.refType(Type.usize);
...@@ -3360,7 +3363,10 @@ fn updateType(...@@ -3360,7 +3363,10 @@ fn updateType(
3360 }3363 }
3361 const field_type = Type.fromInterned(anon_struct_type.types.get(ip)[field_index]);3364 const field_type = Type.fromInterned(anon_struct_type.types.get(ip)[field_index]);
3362 try wip_nav.refType(field_type);3365 try wip_nav.refType(field_type);
3363 if (comptime_value == .none) {3366 if (comptime_value != .none) try wip_nav.blockValue(
3367 src_loc,
3368 Value.fromInterned(comptime_value),
3369 ) else {
3364 const field_align = field_type.abiAlignment(zcu);3370 const field_align = field_type.abiAlignment(zcu);
3365 field_byte_offset = field_align.forward(field_byte_offset);3371 field_byte_offset = field_align.forward(field_byte_offset);
3366 try uleb128(diw, field_byte_offset);3372 try uleb128(diw, field_byte_offset);
...@@ -3427,16 +3433,13 @@ fn updateType(...@@ -3427,16 +3433,13 @@ fn updateType(
3427 }3433 }
3428 if (error_set_type.names.len > 0) try uleb128(diw, @intFromEnum(AbbrevCode.null));3434 if (error_set_type.names.len > 0) try uleb128(diw, @intFromEnum(AbbrevCode.null));
3429 },3435 },
3430 .inferred_error_set_type => |func| switch (ip.funcIesResolvedUnordered(func)) {3436 .inferred_error_set_type => |func| {
3431 .none => {3437 try wip_nav.abbrevCode(.inferred_error_set_type);
3432 try wip_nav.abbrevCode(.void_type);3438 try wip_nav.strp(name);
3433 try wip_nav.strp(name);3439 try wip_nav.refType(Type.fromInterned(switch (ip.funcIesResolvedUnordered(func)) {
3434 },3440 .none => .anyerror_type,
3435 else => |ies| {3441 else => |ies| ies,
3436 try wip_nav.abbrevCode(.inferred_error_set_type);3442 }));
3437 try wip_nav.strp(name);
3438 try wip_nav.refType(Type.fromInterned(ies));
3439 },
3440 },3443 },
34413444
3442 // values, not types3445 // values, not types
...@@ -3468,6 +3471,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP...@@ -3468,6 +3471,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
3468 const zcu = pt.zcu;3471 const zcu = pt.zcu;
3469 const ip = &zcu.intern_pool;3472 const ip = &zcu.intern_pool;
3470 const ty = Type.fromInterned(type_index);3473 const ty = Type.fromInterned(type_index);
3474 const ty_src_loc = ty.srcLoc(zcu);
3471 log.debug("updateContainerType({}({d}))", .{ ty.fmt(pt), @intFromEnum(type_index) });3475 log.debug("updateContainerType({}({d}))", .{ ty.fmt(pt), @intFromEnum(type_index) });
34723476
3473 const inst_info = ty.typeDeclInst(zcu).?.resolveFull(ip).?;3477 const inst_info = ty.typeDeclInst(zcu).?.resolveFull(ip).?;
...@@ -3507,25 +3511,41 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP...@@ -3507,25 +3511,41 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
3507 try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);3511 try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);
3508 for (0..loaded_struct.field_types.len) |field_index| {3512 for (0..loaded_struct.field_types.len) |field_index| {
3509 const is_comptime = loaded_struct.fieldIsComptime(ip, field_index);3513 const is_comptime = loaded_struct.fieldIsComptime(ip, field_index);
3510 try wip_nav.abbrevCode(if (is_comptime) .struct_field_comptime else .struct_field);3514 const field_init = if (loaded_struct.haveFieldInits(ip))
3515 loaded_struct.fieldInit(ip, field_index)
3516 else
3517 .none;
3518 try wip_nav.abbrevCode(if (is_comptime)
3519 .struct_field_comptime
3520 else if (field_init != .none)
3521 .struct_field_default
3522 else
3523 .struct_field);
3511 if (loaded_struct.fieldName(ip, field_index).unwrap()) |field_name| try wip_nav.strp(field_name.toSlice(ip)) else {3524 if (loaded_struct.fieldName(ip, field_index).unwrap()) |field_name| try wip_nav.strp(field_name.toSlice(ip)) else {
3512 const field_name = try std.fmt.allocPrint(dwarf.gpa, "{d}", .{field_index});3525 const field_name = try std.fmt.allocPrint(dwarf.gpa, "{d}", .{field_index});
3513 defer dwarf.gpa.free(field_name);3526 defer dwarf.gpa.free(field_name);
3514 try wip_nav.strp(field_name);3527 try wip_nav.strp(field_name);
3515 }3528 }
3516 const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]);3529 if (is_comptime and field_init == .none) {
3517 try wip_nav.refType(field_type);3530 // workaround frontend bug
3518 if (!is_comptime) {3531 try wip_nav.refType(Type.void);
3519 try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]);3532 try wip_nav.blockValue(ty_src_loc, Value.void);
3520 try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse3533 } else {
3521 field_type.abiAlignment(zcu).toByteUnits().?);3534 const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]);
3535 try wip_nav.refType(field_type);
3536 if (!is_comptime) {
3537 try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]);
3538 try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse
3539 field_type.abiAlignment(zcu).toByteUnits().?);
3540 }
3541 if (field_init != .none) try wip_nav.blockValue(ty_src_loc, Value.fromInterned(field_init));
3522 }3542 }
3523 }3543 }
3524 try uleb128(diw, @intFromEnum(AbbrevCode.null));3544 try uleb128(diw, @intFromEnum(AbbrevCode.null));
3525 }3545 }
35263546
3527 try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.items);3547 try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.items);
3528 try wip_nav.flush();3548 try wip_nav.flush(ty_src_loc);
3529 } else {3549 } else {
3530 const decl_inst = file.zir.instructions.get(@intFromEnum(inst_info.inst));3550 const decl_inst = file.zir.instructions.get(@intFromEnum(inst_info.inst));
3531 assert(decl_inst.tag == .extended);3551 assert(decl_inst.tag == .extended);
...@@ -3575,18 +3595,34 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP...@@ -3575,18 +3595,34 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
3575 try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);3595 try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);
3576 for (0..loaded_struct.field_types.len) |field_index| {3596 for (0..loaded_struct.field_types.len) |field_index| {
3577 const is_comptime = loaded_struct.fieldIsComptime(ip, field_index);3597 const is_comptime = loaded_struct.fieldIsComptime(ip, field_index);
3578 try wip_nav.abbrevCode(if (is_comptime) .struct_field_comptime else .struct_field);3598 const field_init = if (loaded_struct.haveFieldInits(ip))
3599 loaded_struct.fieldInit(ip, field_index)
3600 else
3601 .none;
3602 try wip_nav.abbrevCode(if (is_comptime)
3603 .struct_field_comptime
3604 else if (field_init != .none)
3605 .struct_field_default
3606 else
3607 .struct_field);
3579 if (loaded_struct.fieldName(ip, field_index).unwrap()) |field_name| try wip_nav.strp(field_name.toSlice(ip)) else {3608 if (loaded_struct.fieldName(ip, field_index).unwrap()) |field_name| try wip_nav.strp(field_name.toSlice(ip)) else {
3580 const field_name = try std.fmt.allocPrint(dwarf.gpa, "{d}", .{field_index});3609 const field_name = try std.fmt.allocPrint(dwarf.gpa, "{d}", .{field_index});
3581 defer dwarf.gpa.free(field_name);3610 defer dwarf.gpa.free(field_name);
3582 try wip_nav.strp(field_name);3611 try wip_nav.strp(field_name);
3583 }3612 }
3584 const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]);3613 if (is_comptime and field_init == .none) {
3585 try wip_nav.refType(field_type);3614 // workaround frontend bug
3586 if (!is_comptime) {3615 try wip_nav.refType(Type.void);
3587 try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]);3616 try wip_nav.blockValue(ty_src_loc, Value.void);
3588 try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse3617 } else {
3589 field_type.abiAlignment(zcu).toByteUnits().?);3618 const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]);
3619 try wip_nav.refType(field_type);
3620 if (!is_comptime) {
3621 try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]);
3622 try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse
3623 field_type.abiAlignment(zcu).toByteUnits().?);
3624 }
3625 if (field_init != .none) try wip_nav.blockValue(ty_src_loc, Value.fromInterned(field_init));
3590 }3626 }
3591 }3627 }
3592 try uleb128(diw, @intFromEnum(AbbrevCode.null));3628 try uleb128(diw, @intFromEnum(AbbrevCode.null));
...@@ -3684,7 +3720,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP...@@ -3684,7 +3720,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
3684 }3720 }
3685 try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.items);3721 try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.items);
3686 try dwarf.debug_loclists.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_loclists.items);3722 try dwarf.debug_loclists.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_loclists.items);
3687 try wip_nav.flush();3723 try wip_nav.flush(ty_src_loc);
3688 }3724 }
3689}3725}
36903726
...@@ -3732,12 +3768,15 @@ fn refAbbrevCode(dwarf: *Dwarf, abbrev_code: AbbrevCode) UpdateError!@typeInfo(A...@@ -3732,12 +3768,15 @@ fn refAbbrevCode(dwarf: *Dwarf, abbrev_code: AbbrevCode) UpdateError!@typeInfo(A
3732pub fn flushModule(dwarf: *Dwarf, pt: Zcu.PerThread) FlushError!void {3768pub fn flushModule(dwarf: *Dwarf, pt: Zcu.PerThread) FlushError!void {
3733 const zcu = pt.zcu;3769 const zcu = pt.zcu;
3734 const ip = &zcu.intern_pool;3770 const ip = &zcu.intern_pool;
3735 if (dwarf.types.get(.anyerror_type)) |entry| {3771
3772 {
3773 const type_gop = try dwarf.types.getOrPut(dwarf.gpa, .anyerror_type);
3774 if (!type_gop.found_existing) type_gop.value_ptr.* = try dwarf.addCommonEntry(.main);
3736 var wip_nav: WipNav = .{3775 var wip_nav: WipNav = .{
3737 .dwarf = dwarf,3776 .dwarf = dwarf,
3738 .pt = pt,3777 .pt = pt,
3739 .unit = .main,3778 .unit = .main,
3740 .entry = entry,3779 .entry = type_gop.value_ptr.*,
3741 .any_children = false,3780 .any_children = false,
3742 .func = .none,3781 .func = .none,
3743 .func_sym_index = undefined,3782 .func_sym_index = undefined,
...@@ -4150,6 +4189,7 @@ const AbbrevCode = enum {...@@ -4150,6 +4189,7 @@ const AbbrevCode = enum {
4150 decl_packed_struct,4189 decl_packed_struct,
4151 decl_union,4190 decl_union,
4152 decl_var,4191 decl_var,
4192 decl_const,
4153 decl_func,4193 decl_func,
4154 decl_empty_func,4194 decl_empty_func,
4155 decl_func_generic,4195 decl_func_generic,
...@@ -4164,6 +4204,7 @@ const AbbrevCode = enum {...@@ -4164,6 +4204,7 @@ const AbbrevCode = enum {
4164 big_enum_field,4204 big_enum_field,
4165 generated_field,4205 generated_field,
4166 struct_field,4206 struct_field,
4207 struct_field_default,
4167 struct_field_comptime,4208 struct_field_comptime,
4168 packed_struct_field,4209 packed_struct_field,
4169 untagged_union_field,4210 untagged_union_field,
...@@ -4285,6 +4326,16 @@ const AbbrevCode = enum {...@@ -4285,6 +4326,16 @@ const AbbrevCode = enum {
4285 .{ .external, .flag },4326 .{ .external, .flag },
4286 },4327 },
4287 },4328 },
4329 .decl_const = .{
4330 .tag = .constant,
4331 .attrs = decl_abbrev_common_attrs ++ .{
4332 .{ .linkage_name, .strp },
4333 .{ .type, .ref_addr },
4334 .{ .const_value, .block },
4335 .{ .alignment, .udata },
4336 .{ .external, .flag },
4337 },
4338 },
4288 .decl_func = .{4339 .decl_func = .{
4289 .tag = .subprogram,4340 .tag = .subprogram,
4290 .children = true,4341 .children = true,
...@@ -4401,12 +4452,23 @@ const AbbrevCode = enum {...@@ -4401,12 +4452,23 @@ const AbbrevCode = enum {
4401 .{ .alignment, .udata },4452 .{ .alignment, .udata },
4402 },4453 },
4403 },4454 },
4404 .struct_field_comptime = .{4455 .struct_field_default = .{
4405 .tag = .member,4456 .tag = .member,
4406 .attrs = &.{4457 .attrs = &.{
4407 .{ .name, .strp },4458 .{ .name, .strp },
4408 .{ .type, .ref_addr },4459 .{ .type, .ref_addr },
4460 .{ .data_member_location, .udata },
4461 .{ .alignment, .udata },
4462 .{ .default_value, .block },
4463 },
4464 },
4465 .struct_field_comptime = .{
4466 .tag = .member,
4467 .attrs = &.{
4409 .{ .const_expr, .flag_present },4468 .{ .const_expr, .flag_present },
4469 .{ .name, .strp },
4470 .{ .type, .ref_addr },
4471 .{ .const_value, .block },
4410 },4472 },
4411 },4473 },
4412 .packed_struct_field = .{4474 .packed_struct_field = .{
src/link/Elf/ZigObject.zig+43-20
...@@ -957,13 +957,26 @@ pub fn getNavVAddr(...@@ -957,13 +957,26 @@ pub fn getNavVAddr(
957 };957 };
958 const this_sym = self.symbol(this_sym_index);958 const this_sym = self.symbol(this_sym_index);
959 const vaddr = this_sym.address(.{}, elf_file);959 const vaddr = this_sym.address(.{}, elf_file);
960 const parent_atom = self.symbol(reloc_info.parent_atom_index).atom(elf_file).?;960 switch (reloc_info.parent) {
961 const r_type = relocation.encode(.abs, elf_file.getTarget().cpu.arch);961 .atom_index => |atom_index| {
962 try parent_atom.addReloc(elf_file.base.comp.gpa, .{962 const parent_atom = self.symbol(atom_index).atom(elf_file).?;
963 .r_offset = reloc_info.offset,963 const r_type = relocation.encode(.abs, elf_file.getTarget().cpu.arch);
964 .r_info = (@as(u64, @intCast(this_sym_index)) << 32) | r_type,964 try parent_atom.addReloc(elf_file.base.comp.gpa, .{
965 .r_addend = reloc_info.addend,965 .r_offset = reloc_info.offset,
966 }, self);966 .r_info = (@as(u64, @intCast(this_sym_index)) << 32) | r_type,
967 .r_addend = reloc_info.addend,
968 }, self);
969 },
970 .debug_output => |debug_output| switch (debug_output) {
971 .dwarf => |wip_nav| try wip_nav.infoExternalReloc(.{
972 .source_off = @intCast(reloc_info.offset),
973 .target_sym = this_sym_index,
974 .target_off = reloc_info.addend,
975 }),
976 .plan9 => unreachable,
977 .none => unreachable,
978 },
979 }
967 return @intCast(vaddr);980 return @intCast(vaddr);
968}981}
969982
...@@ -976,13 +989,26 @@ pub fn getUavVAddr(...@@ -976,13 +989,26 @@ pub fn getUavVAddr(
976 const sym_index = self.uavs.get(uav).?.symbol_index;989 const sym_index = self.uavs.get(uav).?.symbol_index;
977 const sym = self.symbol(sym_index);990 const sym = self.symbol(sym_index);
978 const vaddr = sym.address(.{}, elf_file);991 const vaddr = sym.address(.{}, elf_file);
979 const parent_atom = self.symbol(reloc_info.parent_atom_index).atom(elf_file).?;992 switch (reloc_info.parent) {
980 const r_type = relocation.encode(.abs, elf_file.getTarget().cpu.arch);993 .atom_index => |atom_index| {
981 try parent_atom.addReloc(elf_file.base.comp.gpa, .{994 const parent_atom = self.symbol(atom_index).atom(elf_file).?;
982 .r_offset = reloc_info.offset,995 const r_type = relocation.encode(.abs, elf_file.getTarget().cpu.arch);
983 .r_info = (@as(u64, @intCast(sym_index)) << 32) | r_type,996 try parent_atom.addReloc(elf_file.base.comp.gpa, .{
984 .r_addend = reloc_info.addend,997 .r_offset = reloc_info.offset,
985 }, self);998 .r_info = (@as(u64, @intCast(sym_index)) << 32) | r_type,
999 .r_addend = reloc_info.addend,
1000 }, self);
1001 },
1002 .debug_output => |debug_output| switch (debug_output) {
1003 .dwarf => |wip_nav| try wip_nav.infoExternalReloc(.{
1004 .source_off = @intCast(reloc_info.offset),
1005 .target_sym = sym_index,
1006 .target_off = reloc_info.addend,
1007 }),
1008 .plan9 => unreachable,
1009 .none => unreachable,
1010 },
1011 }
986 return @intCast(vaddr);1012 return @intCast(vaddr);
987}1013}
9881014
...@@ -1600,15 +1626,13 @@ pub fn updateNav(...@@ -1600,15 +1626,13 @@ pub fn updateNav(
1600 var debug_wip_nav = if (self.dwarf) |*dwarf| try dwarf.initWipNav(pt, nav_index, sym_index) else null;1626 var debug_wip_nav = if (self.dwarf) |*dwarf| try dwarf.initWipNav(pt, nav_index, sym_index) else null;
1601 defer if (debug_wip_nav) |*wip_nav| wip_nav.deinit();1627 defer if (debug_wip_nav) |*wip_nav| wip_nav.deinit();
16021628
1603 // TODO implement .debug_info for global variables
1604 const res = try codegen.generateSymbol(1629 const res = try codegen.generateSymbol(
1605 &elf_file.base,1630 &elf_file.base,
1606 pt,1631 pt,
1607 zcu.navSrcLoc(nav_index),1632 zcu.navSrcLoc(nav_index),
1608 Value.fromInterned(nav_init),1633 Value.fromInterned(nav_init),
1609 &code_buffer,1634 &code_buffer,
1610 if (debug_wip_nav) |*wip_nav| .{ .dwarf = wip_nav } else .none,1635 .{ .atom_index = sym_index },
1611 .{ .parent_atom_index = sym_index },
1612 );1636 );
16131637
1614 const code = switch (res) {1638 const code = switch (res) {
...@@ -1691,7 +1715,7 @@ fn updateLazySymbol(...@@ -1691,7 +1715,7 @@ fn updateLazySymbol(
1691 &required_alignment,1715 &required_alignment,
1692 &code_buffer,1716 &code_buffer,
1693 .none,1717 .none,
1694 .{ .parent_atom_index = symbol_index },1718 .{ .atom_index = symbol_index },
1695 );1719 );
1696 const code = switch (res) {1720 const code = switch (res) {
1697 .ok => code_buffer.items,1721 .ok => code_buffer.items,
...@@ -1780,8 +1804,7 @@ fn lowerConst(...@@ -1780,8 +1804,7 @@ fn lowerConst(
1780 src_loc,1804 src_loc,
1781 val,1805 val,
1782 &code_buffer,1806 &code_buffer,
1783 .{ .none = {} },1807 .{ .atom_index = sym_index },
1784 .{ .parent_atom_index = sym_index },
1785 );1808 );
1786 const code = switch (res) {1809 const code = switch (res) {
1787 .ok => code_buffer.items,1810 .ok => code_buffer.items,
src/link/MachO/ZigObject.zig+62-34
...@@ -633,20 +633,33 @@ pub fn getNavVAddr(...@@ -633,20 +633,33 @@ pub fn getNavVAddr(
633 };633 };
634 const sym = self.symbols.items[sym_index];634 const sym = self.symbols.items[sym_index];
635 const vaddr = sym.getAddress(.{}, macho_file);635 const vaddr = sym.getAddress(.{}, macho_file);
636 const parent_atom = self.symbols.items[reloc_info.parent_atom_index].getAtom(macho_file).?;636 switch (reloc_info.parent) {
637 try parent_atom.addReloc(macho_file, .{637 .atom_index => |atom_index| {
638 .tag = .@"extern",638 const parent_atom = self.symbols.items[atom_index].getAtom(macho_file).?;
639 .offset = @intCast(reloc_info.offset),639 try parent_atom.addReloc(macho_file, .{
640 .target = sym_index,640 .tag = .@"extern",
641 .addend = reloc_info.addend,641 .offset = @intCast(reloc_info.offset),
642 .type = .unsigned,642 .target = sym_index,
643 .meta = .{643 .addend = reloc_info.addend,
644 .pcrel = false,644 .type = .unsigned,
645 .has_subtractor = false,645 .meta = .{
646 .length = 3,646 .pcrel = false,
647 .symbolnum = @intCast(sym.nlist_idx),647 .has_subtractor = false,
648 .length = 3,
649 .symbolnum = @intCast(sym.nlist_idx),
650 },
651 });
648 },652 },
649 });653 .debug_output => |debug_output| switch (debug_output) {
654 .dwarf => |wip_nav| try wip_nav.infoExternalReloc(.{
655 .source_off = @intCast(reloc_info.offset),
656 .target_sym = sym_index,
657 .target_off = reloc_info.addend,
658 }),
659 .plan9 => unreachable,
660 .none => unreachable,
661 },
662 }
650 return vaddr;663 return vaddr;
651}664}
652665
...@@ -659,20 +672,33 @@ pub fn getUavVAddr(...@@ -659,20 +672,33 @@ pub fn getUavVAddr(
659 const sym_index = self.uavs.get(uav).?.symbol_index;672 const sym_index = self.uavs.get(uav).?.symbol_index;
660 const sym = self.symbols.items[sym_index];673 const sym = self.symbols.items[sym_index];
661 const vaddr = sym.getAddress(.{}, macho_file);674 const vaddr = sym.getAddress(.{}, macho_file);
662 const parent_atom = self.symbols.items[reloc_info.parent_atom_index].getAtom(macho_file).?;675 switch (reloc_info.parent) {
663 try parent_atom.addReloc(macho_file, .{676 .atom_index => |atom_index| {
664 .tag = .@"extern",677 const parent_atom = self.symbols.items[atom_index].getAtom(macho_file).?;
665 .offset = @intCast(reloc_info.offset),678 try parent_atom.addReloc(macho_file, .{
666 .target = sym_index,679 .tag = .@"extern",
667 .addend = reloc_info.addend,680 .offset = @intCast(reloc_info.offset),
668 .type = .unsigned,681 .target = sym_index,
669 .meta = .{682 .addend = reloc_info.addend,
670 .pcrel = false,683 .type = .unsigned,
671 .has_subtractor = false,684 .meta = .{
672 .length = 3,685 .pcrel = false,
673 .symbolnum = @intCast(sym.nlist_idx),686 .has_subtractor = false,
687 .length = 3,
688 .symbolnum = @intCast(sym.nlist_idx),
689 },
690 });
674 },691 },
675 });692 .debug_output => |debug_output| switch (debug_output) {
693 .dwarf => |wip_nav| try wip_nav.infoExternalReloc(.{
694 .source_off = @intCast(reloc_info.offset),
695 .target_sym = sym_index,
696 .target_off = reloc_info.addend,
697 }),
698 .plan9 => unreachable,
699 .none => unreachable,
700 },
701 }
676 return vaddr;702 return vaddr;
677}703}
678704
...@@ -903,8 +929,7 @@ pub fn updateNav(...@@ -903,8 +929,7 @@ pub fn updateNav(
903 zcu.navSrcLoc(nav_index),929 zcu.navSrcLoc(nav_index),
904 Value.fromInterned(nav_init),930 Value.fromInterned(nav_init),
905 &code_buffer,931 &code_buffer,
906 if (debug_wip_nav) |*wip_nav| .{ .dwarf = wip_nav } else .none,932 .{ .atom_index = sym_index },
907 .{ .parent_atom_index = sym_index },
908 );933 );
909934
910 const code = switch (res) {935 const code = switch (res) {
...@@ -1212,11 +1237,14 @@ fn lowerConst(...@@ -1212,11 +1237,14 @@ fn lowerConst(
1212 const name_str = try self.addString(gpa, name);1237 const name_str = try self.addString(gpa, name);
1213 const sym_index = try self.newSymbolWithAtom(gpa, name_str, macho_file);1238 const sym_index = try self.newSymbolWithAtom(gpa, name_str, macho_file);
12141239
1215 const res = try codegen.generateSymbol(&macho_file.base, pt, src_loc, val, &code_buffer, .{1240 const res = try codegen.generateSymbol(
1216 .none = {},1241 &macho_file.base,
1217 }, .{1242 pt,
1218 .parent_atom_index = sym_index,1243 src_loc,
1219 });1244 val,
1245 &code_buffer,
1246 .{ .atom_index = sym_index },
1247 );
1220 const code = switch (res) {1248 const code = switch (res) {
1221 .ok => code_buffer.items,1249 .ok => code_buffer.items,
1222 .fail => |em| return .{ .fail = em },1250 .fail => |em| return .{ .fail = em },
...@@ -1378,7 +1406,7 @@ fn updateLazySymbol(...@@ -1378,7 +1406,7 @@ fn updateLazySymbol(
1378 &required_alignment,1406 &required_alignment,
1379 &code_buffer,1407 &code_buffer,
1380 .none,1408 .none,
1381 .{ .parent_atom_index = symbol_index },1409 .{ .atom_index = symbol_index },
1382 );1410 );
1383 const code = switch (res) {1411 const code = switch (res) {
1384 .ok => code_buffer.items,1412 .ok => code_buffer.items,
src/link/Plan9.zig+17-18
...@@ -422,10 +422,7 @@ pub fn updateFunc(self: *Plan9, pt: Zcu.PerThread, func_index: InternPool.Index,...@@ -422,10 +422,7 @@ pub fn updateFunc(self: *Plan9, pt: Zcu.PerThread, func_index: InternPool.Index,
422 );422 );
423 const code = switch (res) {423 const code = switch (res) {
424 .ok => try code_buffer.toOwnedSlice(),424 .ok => try code_buffer.toOwnedSlice(),
425 .fail => |em| {425 .fail => |em| return zcu.failed_codegen.put(gpa, func.owner_nav, em),
426 try zcu.failed_codegen.put(gpa, func.owner_nav, em);
427 return;
428 },
429 };426 };
430 self.getAtomPtr(atom_idx).code = .{427 self.getAtomPtr(atom_idx).code = .{
431 .code_ptr = null,428 .code_ptr = null,
...@@ -463,15 +460,17 @@ pub fn updateNav(self: *Plan9, pt: Zcu.PerThread, nav_index: InternPool.Nav.Inde...@@ -463,15 +460,17 @@ pub fn updateNav(self: *Plan9, pt: Zcu.PerThread, nav_index: InternPool.Nav.Inde
463 var code_buffer = std.ArrayList(u8).init(gpa);460 var code_buffer = std.ArrayList(u8).init(gpa);
464 defer code_buffer.deinit();461 defer code_buffer.deinit();
465 // TODO we need the symbol index for symbol in the table of locals for the containing atom462 // TODO we need the symbol index for symbol in the table of locals for the containing atom
466 const res = try codegen.generateSymbol(&self.base, pt, zcu.navSrcLoc(nav_index), nav_init, &code_buffer, .none, .{463 const res = try codegen.generateSymbol(
467 .parent_atom_index = @intCast(atom_idx),464 &self.base,
468 });465 pt,
466 zcu.navSrcLoc(nav_index),
467 nav_init,
468 &code_buffer,
469 .{ .atom_index = @intCast(atom_idx) },
470 );
469 const code = switch (res) {471 const code = switch (res) {
470 .ok => code_buffer.items,472 .ok => code_buffer.items,
471 .fail => |em| {473 .fail => |em| return zcu.failed_codegen.put(gpa, nav_index, em),
472 try zcu.failed_codegen.put(gpa, nav_index, em);
473 return;
474 },
475 };474 };
476 try self.data_nav_table.ensureUnusedCapacity(gpa, 1);475 try self.data_nav_table.ensureUnusedCapacity(gpa, 1);
477 const duped_code = try gpa.dupe(u8, code);476 const duped_code = try gpa.dupe(u8, code);
...@@ -1116,7 +1115,7 @@ fn updateLazySymbolAtom(self: *Plan9, pt: Zcu.PerThread, sym: File.LazySymbol, a...@@ -1116,7 +1115,7 @@ fn updateLazySymbolAtom(self: *Plan9, pt: Zcu.PerThread, sym: File.LazySymbol, a
1116 &required_alignment,1115 &required_alignment,
1117 &code_buffer,1116 &code_buffer,
1118 .none,1117 .none,
1119 .{ .parent_atom_index = @as(Atom.Index, @intCast(atom_index)) },1118 .{ .atom_index = @intCast(atom_index) },
1120 );1119 );
1121 const code = switch (res) {1120 const code = switch (res) {
1122 .ok => code_buffer.items,1121 .ok => code_buffer.items,
...@@ -1373,21 +1372,21 @@ pub fn getNavVAddr(...@@ -1373,21 +1372,21 @@ pub fn getNavVAddr(
1373 log.debug("getDeclVAddr for {}", .{nav.name.fmt(ip)});1372 log.debug("getDeclVAddr for {}", .{nav.name.fmt(ip)});
1374 if (ip.indexToKey(nav.status.resolved.val) == .@"extern") {1373 if (ip.indexToKey(nav.status.resolved.val) == .@"extern") {
1375 if (nav.name.eqlSlice("etext", ip)) {1374 if (nav.name.eqlSlice("etext", ip)) {
1376 try self.addReloc(reloc_info.parent_atom_index, .{1375 try self.addReloc(reloc_info.parent.atom_index, .{
1377 .target = undefined,1376 .target = undefined,
1378 .offset = reloc_info.offset,1377 .offset = reloc_info.offset,
1379 .addend = reloc_info.addend,1378 .addend = reloc_info.addend,
1380 .type = .special_etext,1379 .type = .special_etext,
1381 });1380 });
1382 } else if (nav.name.eqlSlice("edata", ip)) {1381 } else if (nav.name.eqlSlice("edata", ip)) {
1383 try self.addReloc(reloc_info.parent_atom_index, .{1382 try self.addReloc(reloc_info.parent.atom_index, .{
1384 .target = undefined,1383 .target = undefined,
1385 .offset = reloc_info.offset,1384 .offset = reloc_info.offset,
1386 .addend = reloc_info.addend,1385 .addend = reloc_info.addend,
1387 .type = .special_edata,1386 .type = .special_edata,
1388 });1387 });
1389 } else if (nav.name.eqlSlice("end", ip)) {1388 } else if (nav.name.eqlSlice("end", ip)) {
1390 try self.addReloc(reloc_info.parent_atom_index, .{1389 try self.addReloc(reloc_info.parent.atom_index, .{
1391 .target = undefined,1390 .target = undefined,
1392 .offset = reloc_info.offset,1391 .offset = reloc_info.offset,
1393 .addend = reloc_info.addend,1392 .addend = reloc_info.addend,
...@@ -1400,7 +1399,7 @@ pub fn getNavVAddr(...@@ -1400,7 +1399,7 @@ pub fn getNavVAddr(
1400 // otherwise, we just add a relocation1399 // otherwise, we just add a relocation
1401 const atom_index = try self.seeNav(pt, nav_index);1400 const atom_index = try self.seeNav(pt, nav_index);
1402 // the parent_atom_index in this case is just the decl_index of the parent1401 // the parent_atom_index in this case is just the decl_index of the parent
1403 try self.addReloc(reloc_info.parent_atom_index, .{1402 try self.addReloc(reloc_info.parent.atom_index, .{
1404 .target = atom_index,1403 .target = atom_index,
1405 .offset = reloc_info.offset,1404 .offset = reloc_info.offset,
1406 .addend = reloc_info.addend,1405 .addend = reloc_info.addend,
...@@ -1435,7 +1434,7 @@ pub fn lowerUav(...@@ -1435,7 +1434,7 @@ pub fn lowerUav(
1435 gop.value_ptr.* = index;1434 gop.value_ptr.* = index;
1436 // we need to free name latex1435 // we need to free name latex
1437 var code_buffer = std.ArrayList(u8).init(gpa);1436 var code_buffer = std.ArrayList(u8).init(gpa);
1438 const res = try codegen.generateSymbol(&self.base, pt, src_loc, val, &code_buffer, .{ .none = {} }, .{ .parent_atom_index = index });1437 const res = try codegen.generateSymbol(&self.base, pt, src_loc, val, &code_buffer, .{ .atom_index = index });
1439 const code = switch (res) {1438 const code = switch (res) {
1440 .ok => code_buffer.items,1439 .ok => code_buffer.items,
1441 .fail => |em| return .{ .fail = em },1440 .fail => |em| return .{ .fail = em },
...@@ -1459,7 +1458,7 @@ pub fn lowerUav(...@@ -1459,7 +1458,7 @@ pub fn lowerUav(
14591458
1460pub fn getUavVAddr(self: *Plan9, uav: InternPool.Index, reloc_info: link.File.RelocInfo) !u64 {1459pub fn getUavVAddr(self: *Plan9, uav: InternPool.Index, reloc_info: link.File.RelocInfo) !u64 {
1461 const atom_index = self.uavs.get(uav).?;1460 const atom_index = self.uavs.get(uav).?;
1462 try self.addReloc(reloc_info.parent_atom_index, .{1461 try self.addReloc(reloc_info.parent.atom_index, .{
1463 .target = atom_index,1462 .target = atom_index,
1464 .offset = reloc_info.offset,1463 .offset = reloc_info.offset,
1465 .addend = reloc_info.addend,1464 .addend = reloc_info.addend,
src/link/Wasm/ZigObject.zig+11-9
...@@ -277,8 +277,7 @@ pub fn updateNav(...@@ -277,8 +277,7 @@ pub fn updateNav(
277 zcu.navSrcLoc(nav_index),277 zcu.navSrcLoc(nav_index),
278 nav_init,278 nav_init,
279 &code_writer,279 &code_writer,
280 .none,280 .{ .atom_index = @intFromEnum(atom.sym_index) },
281 .{ .parent_atom_index = @intFromEnum(atom.sym_index) },
282 );281 );
283282
284 const code = switch (res) {283 const code = switch (res) {
...@@ -520,10 +519,7 @@ fn lowerConst(...@@ -520,10 +519,7 @@ fn lowerConst(
520 src_loc,519 src_loc,
521 val,520 val,
522 &value_bytes,521 &value_bytes,
523 .none,522 .{ .atom_index = @intFromEnum(atom.sym_index) },
524 .{
525 .parent_atom_index = @intFromEnum(atom.sym_index),
526 },
527 );523 );
528 break :code switch (result) {524 break :code switch (result) {
529 .ok => value_bytes.items,525 .ok => value_bytes.items,
...@@ -762,8 +758,11 @@ pub fn getNavVAddr(...@@ -762,8 +758,11 @@ pub fn getNavVAddr(
762 else => {},758 else => {},
763 }759 }
764760
765 std.debug.assert(reloc_info.parent_atom_index != 0);761 std.debug.assert(reloc_info.parent.atom_index != 0);
766 const atom_index = wasm_file.symbol_atom.get(.{ .file = zig_object.index, .index = @enumFromInt(reloc_info.parent_atom_index) }).?;762 const atom_index = wasm_file.symbol_atom.get(.{
763 .file = zig_object.index,
764 .index = @enumFromInt(reloc_info.parent.atom_index),
765 }).?;
767 const atom = wasm_file.getAtomPtr(atom_index);766 const atom = wasm_file.getAtomPtr(atom_index);
768 const is_wasm32 = target.cpu.arch == .wasm32;767 const is_wasm32 = target.cpu.arch == .wasm32;
769 if (ip.isFunctionType(ip.getNav(nav_index).typeOf(ip))) {768 if (ip.isFunctionType(ip.getNav(nav_index).typeOf(ip))) {
...@@ -800,7 +799,10 @@ pub fn getUavVAddr(...@@ -800,7 +799,10 @@ pub fn getUavVAddr(
800 const atom_index = zig_object.uavs.get(uav).?;799 const atom_index = zig_object.uavs.get(uav).?;
801 const target_symbol_index = @intFromEnum(wasm_file.getAtom(atom_index).sym_index);800 const target_symbol_index = @intFromEnum(wasm_file.getAtom(atom_index).sym_index);
802801
803 const parent_atom_index = wasm_file.symbol_atom.get(.{ .file = zig_object.index, .index = @enumFromInt(reloc_info.parent_atom_index) }).?;802 const parent_atom_index = wasm_file.symbol_atom.get(.{
803 .file = zig_object.index,
804 .index = @enumFromInt(reloc_info.parent.atom_index),
805 }).?;
804 const parent_atom = wasm_file.getAtomPtr(parent_atom_index);806 const parent_atom = wasm_file.getAtomPtr(parent_atom_index);
805 const is_wasm32 = target.cpu.arch == .wasm32;807 const is_wasm32 = target.cpu.arch == .wasm32;
806 const zcu = wasm_file.base.comp.zcu.?;808 const zcu = wasm_file.base.comp.zcu.?;
test/src/Debugger.zig+597-33
...@@ -107,11 +107,11 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {...@@ -107,11 +107,11 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
107 },107 },
108 \\breakpoint set --file basic.zig --source-pattern-regexp '_ = basic;'108 \\breakpoint set --file basic.zig --source-pattern-regexp '_ = basic;'
109 \\process launch109 \\process launch
110 \\frame variable --show-types basic110 \\frame variable --show-types -- basic
111 \\breakpoint delete --force 1111 \\breakpoint delete --force 1
112 ,112 ,
113 &.{113 &.{
114 \\(lldb) frame variable --show-types basic114 \\(lldb) frame variable --show-types -- basic
115 \\(root.basic.Basic) basic = {115 \\(root.basic.Basic) basic = {
116 \\ (void) void = {}116 \\ (void) void = {}
117 \\ (bool) bool_false = false117 \\ (bool) bool_false = false
...@@ -243,11 +243,11 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {...@@ -243,11 +243,11 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
243 },243 },
244 \\breakpoint set --file pointers.zig --source-pattern-regexp '_ = pointers;'244 \\breakpoint set --file pointers.zig --source-pattern-regexp '_ = pointers;'
245 \\process launch245 \\process launch
246 \\frame variable --show-types pointers246 \\frame variable --show-types -- pointers
247 \\breakpoint delete --force 1247 \\breakpoint delete --force 1
248 ,248 ,
249 &.{249 &.{
250 \\(lldb) frame variable --show-types pointers250 \\(lldb) frame variable --show-types -- pointers
251 \\(root.pointers.Pointers) pointers = {251 \\(root.pointers.Pointers) pointers = {
252 \\ (*u32) single = 0x0000000000001010252 \\ (*u32) single = 0x0000000000001010
253 \\ (*const u32) single_const = 0x0000000000001014253 \\ (*const u32) single_const = 0x0000000000001014
...@@ -330,13 +330,13 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {...@@ -330,13 +330,13 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
330 },330 },
331 \\breakpoint set --file strings.zig --source-pattern-regexp '_ = strings;'331 \\breakpoint set --file strings.zig --source-pattern-regexp '_ = strings;'
332 \\process launch332 \\process launch
333 \\frame variable --show-types strings.slice333 \\frame variable --show-types -- strings.slice
334 \\frame variable --show-types --format character strings.slice334 \\frame variable --show-types --format character -- strings.slice
335 \\frame variable --show-types --format c-string strings335 \\frame variable --show-types --format c-string -- strings
336 \\breakpoint delete --force 1336 \\breakpoint delete --force 1
337 ,337 ,
338 &.{338 &.{
339 \\(lldb) frame variable --show-types strings.slice339 \\(lldb) frame variable --show-types -- strings.slice
340 \\([:0]const u8) strings.slice = len=9 {340 \\([:0]const u8) strings.slice = len=9 {
341 \\ (u8) [0] = 115341 \\ (u8) [0] = 115
342 \\ (u8) [1] = 108342 \\ (u8) [1] = 108
...@@ -348,7 +348,7 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {...@@ -348,7 +348,7 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
348 \\ (u8) [7] = 92348 \\ (u8) [7] = 92
349 \\ (u8) [8] = 0349 \\ (u8) [8] = 0
350 \\}350 \\}
351 \\(lldb) frame variable --show-types --format character strings.slice351 \\(lldb) frame variable --show-types --format character -- strings.slice
352 \\([:0]const u8) strings.slice = len=9 {352 \\([:0]const u8) strings.slice = len=9 {
353 \\ (u8) [0] = 's'353 \\ (u8) [0] = 's'
354 \\ (u8) [1] = 'l'354 \\ (u8) [1] = 'l'
...@@ -360,7 +360,7 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {...@@ -360,7 +360,7 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
360 \\ (u8) [7] = '\\'360 \\ (u8) [7] = '\\'
361 \\ (u8) [8] = '\x00'361 \\ (u8) [8] = '\x00'
362 \\}362 \\}
363 \\(lldb) frame variable --show-types --format c-string strings363 \\(lldb) frame variable --show-types --format c-string -- strings
364 \\(root.strings.Strings) strings = {364 \\(root.strings.Strings) strings = {
365 \\ ([*c]const u8) c_ptr = "c_ptr\x07\x08\t"365 \\ ([*c]const u8) c_ptr = "c_ptr\x07\x08\t"
366 \\ ([*:0]const u8) many_ptr = "many_ptr\n\x0b\x0c"366 \\ ([*:0]const u8) many_ptr = "many_ptr\n\x0b\x0c"
...@@ -411,11 +411,28 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {...@@ -411,11 +411,28 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
411 },411 },
412 \\breakpoint set --file enums.zig --source-pattern-regexp '_ = enums;'412 \\breakpoint set --file enums.zig --source-pattern-regexp '_ = enums;'
413 \\process launch413 \\process launch
414 \\frame variable --show-types enums414 \\expression --show-types -- Enums
415 \\frame variable --show-types -- enums
415 \\breakpoint delete --force 1416 \\breakpoint delete --force 1
416 ,417 ,
417 &.{418 &.{
418 \\(lldb) frame variable --show-types enums419 \\(lldb) expression --show-types -- Enums
420 \\(type) Enums = struct {
421 \\ (type) Zero = enum {}
422 \\ (type) One = enum {
423 \\ (root.enums.Enums.One) first = .first
424 \\ }
425 \\ (type) Two = enum {
426 \\ (root.enums.Enums.Two) first = .first
427 \\ (root.enums.Enums.Two) second = .second
428 \\ }
429 \\ (type) Three = enum {
430 \\ (root.enums.Enums.Three) first = .first
431 \\ (root.enums.Enums.Three) second = .second
432 \\ (root.enums.Enums.Three) third = .third
433 \\ }
434 \\}
435 \\(lldb) frame variable --show-types -- enums
419 \\(root.enums.Enums) enums = {436 \\(root.enums.Enums) enums = {
420 \\ (root.enums.Enums.Zero) zero = @enumFromInt(13)437 \\ (root.enums.Enums.Zero) zero = @enumFromInt(13)
421 \\ (root.enums.Enums.One) one = .first438 \\ (root.enums.Enums.One) one = .first
...@@ -434,12 +451,17 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {...@@ -434,12 +451,17 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
434 .path = "errors.zig",451 .path = "errors.zig",
435 .source =452 .source =
436 \\const Errors = struct {453 \\const Errors = struct {
437 \\ one: error{One} = error.One,454 \\ const Zero = error{};
438 \\ two: error{One,Two} = error.Two,455 \\ const One = Zero || error{One};
439 \\ three: error{One,Two,Three} = error.Three,456 \\ const Two = One || error{Two};
457 \\ const Three = Two || error{Three};
458 \\
459 \\ one: One = error.One,
460 \\ two: Two = error.Two,
461 \\ three: Three = error.Three,
440 \\ any: anyerror = error.Any,462 \\ any: anyerror = error.Any,
441 \\ any_void: anyerror!void = error.NotVoid,463 \\ any_void: anyerror!void = error.NotVoid,
442 \\ any_u32: error{One}!u32 = 42,464 \\ any_u32: One!u32 = 42,
443 \\};465 \\};
444 \\fn testErrors(errors: Errors) void {466 \\fn testErrors(errors: Errors) void {
445 \\ _ = errors;467 \\ _ = errors;
...@@ -453,11 +475,28 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {...@@ -453,11 +475,28 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
453 },475 },
454 \\breakpoint set --file errors.zig --source-pattern-regexp '_ = errors;'476 \\breakpoint set --file errors.zig --source-pattern-regexp '_ = errors;'
455 \\process launch477 \\process launch
456 \\frame variable --show-types errors478 \\expression --show-types -- Errors
479 \\frame variable --show-types -- errors
457 \\breakpoint delete --force 1480 \\breakpoint delete --force 1
458 ,481 ,
459 &.{482 &.{
460 \\(lldb) frame variable --show-types errors483 \\(lldb) expression --show-types -- Errors
484 \\(type) Errors = struct {
485 \\ (type) Zero = error {}
486 \\ (type) One = error {
487 \\ (error{One}) One = error.One
488 \\ }
489 \\ (type) Two = error {
490 \\ (error{One,Two}) One = error.One
491 \\ (error{One,Two}) Two = error.Two
492 \\ }
493 \\ (type) Three = error {
494 \\ (error{One,Two,Three}) One = error.One
495 \\ (error{One,Two,Three}) Two = error.Two
496 \\ (error{One,Two,Three}) Three = error.Three
497 \\ }
498 \\}
499 \\(lldb) frame variable --show-types -- errors
461 \\(root.errors.Errors) errors = {500 \\(root.errors.Errors) errors = {
462 \\ (error{One}) one = error.One501 \\ (error{One}) one = error.One
463 \\ (error{One,Two}) two = error.Two502 \\ (error{One,Two}) two = error.Two
...@@ -496,23 +535,23 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {...@@ -496,23 +535,23 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
496 },535 },
497 \\breakpoint set --file optionals.zig --source-pattern-regexp 'maybe_u32 = 123;'536 \\breakpoint set --file optionals.zig --source-pattern-regexp 'maybe_u32 = 123;'
498 \\process launch537 \\process launch
499 \\frame variable null_u32 maybe_u32 nonnull_u32538 \\frame variable -- null_u32 maybe_u32 nonnull_u32
500 \\breakpoint delete --force 1539 \\breakpoint delete --force 1
501 \\540 \\
502 \\breakpoint set --file optionals.zig --source-pattern-regexp '_ = .{ &null_u32, &nonnull_u32 };'541 \\breakpoint set --file optionals.zig --source-pattern-regexp '_ = \.{ &null_u32, &nonnull_u32 };'
503 \\process continue542 \\process continue
504 \\frame variable --show-types null_u32 maybe_u32 nonnull_u32543 \\frame variable --show-types -- null_u32 maybe_u32 nonnull_u32
505 \\breakpoint delete --force 2544 \\breakpoint delete --force 2
506 ,545 ,
507 &.{546 &.{
508 \\(lldb) frame variable null_u32 maybe_u32 nonnull_u32547 \\(lldb) frame variable -- null_u32 maybe_u32 nonnull_u32
509 \\(?u32) null_u32 = null548 \\(?u32) null_u32 = null
510 \\(?u32) maybe_u32 = null549 \\(?u32) maybe_u32 = null
511 \\(?u32) nonnull_u32 = (nonnull_u32.? = 456)550 \\(?u32) nonnull_u32 = (nonnull_u32.? = 456)
512 \\(lldb) breakpoint delete --force 1551 \\(lldb) breakpoint delete --force 1
513 \\1 breakpoints deleted; 0 breakpoint locations disabled.552 \\1 breakpoints deleted; 0 breakpoint locations disabled.
514 ,553 ,
515 \\(lldb) frame variable --show-types null_u32 maybe_u32 nonnull_u32554 \\(lldb) frame variable --show-types -- null_u32 maybe_u32 nonnull_u32
516 \\(?u32) null_u32 = null555 \\(?u32) null_u32 = null
517 \\(?u32) maybe_u32 = {556 \\(?u32) maybe_u32 = {
518 \\ (u32) maybe_u32.? = 123557 \\ (u32) maybe_u32.? = 123
...@@ -565,11 +604,31 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {...@@ -565,11 +604,31 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
565 },604 },
566 \\breakpoint set --file unions.zig --source-pattern-regexp '_ = unions;'605 \\breakpoint set --file unions.zig --source-pattern-regexp '_ = unions;'
567 \\process launch606 \\process launch
568 \\frame variable --show-types unions607 \\expression --show-types -- Unions
608 \\frame variable --show-types -- unions
569 \\breakpoint delete --force 1609 \\breakpoint delete --force 1
570 ,610 ,
571 &.{611 &.{
572 \\(lldb) frame variable --show-types unions612 \\(lldb) expression --show-types -- Unions
613 \\(type) Unions = struct {
614 \\ (type) Untagged = union {}
615 \\ (type) SafetyTagged = union(enum) {
616 \\ (@typeInfo(unions.Unions.SafetyTagged).@"union".tag_type.?) void = .void
617 \\ (@typeInfo(unions.Unions.SafetyTagged).@"union".tag_type.?) en = .en
618 \\ (@typeInfo(unions.Unions.SafetyTagged).@"union".tag_type.?) eu = .eu
619 \\ }
620 \\ (type) Enum = enum {
621 \\ (root.unions.Unions.Enum) first = .first
622 \\ (root.unions.Unions.Enum) second = .second
623 \\ (root.unions.Unions.Enum) third = .third
624 \\ }
625 \\ (type) Tagged = union(enum) {
626 \\ (@typeInfo(unions.Unions.Tagged).@"union".tag_type.?) void = .void
627 \\ (@typeInfo(unions.Unions.Tagged).@"union".tag_type.?) en = .en
628 \\ (@typeInfo(unions.Unions.Tagged).@"union".tag_type.?) eu = .eu
629 \\ }
630 \\}
631 \\(lldb) frame variable --show-types -- unions
573 \\(root.unions.Unions) unions = {632 \\(root.unions.Unions) unions = {
574 \\ (root.unions.Unions.Untagged) untagged = {633 \\ (root.unions.Unions.Untagged) untagged = {
575 \\ (u32) u32 = 3217031168634 \\ (u32) u32 = 3217031168
...@@ -635,17 +694,17 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {...@@ -635,17 +694,17 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
635 },694 },
636 \\breakpoint set --file storage.zig --source-pattern-regexp 'local_var = local_var;'695 \\breakpoint set --file storage.zig --source-pattern-regexp 'local_var = local_var;'
637 \\process launch696 \\process launch
638 \\target variable --show-types --format hex global_const global_var global_threadlocal1 global_threadlocal2697 \\target variable --show-types --format hex -- global_const global_var global_threadlocal1 global_threadlocal2
639 \\frame variable --show-types --format hex param1 param2 param3 param4 param5 param6 param7 param8 local_comptime_val local_comptime_ptr.0 local_const local_var698 \\frame variable --show-types --format hex -- param1 param2 param3 param4 param5 param6 param7 param8 local_comptime_val local_comptime_ptr.0 local_const local_var
640 \\breakpoint delete --force 1699 \\breakpoint delete --force 1
641 ,700 ,
642 &.{701 &.{
643 \\(lldb) target variable --show-types --format hex global_const global_var global_threadlocal1 global_threadlocal2702 \\(lldb) target variable --show-types --format hex -- global_const global_var global_threadlocal1 global_threadlocal2
644 \\(u64) global_const = 0x19e50dc8d6002077703 \\(u64) global_const = 0x19e50dc8d6002077
645 \\(u64) global_var = 0xcc423cec08622e32704 \\(u64) global_var = 0xcc423cec08622e32
646 \\(u64) global_threadlocal1 = 0xb4d643528c042121705 \\(u64) global_threadlocal1 = 0xb4d643528c042121
647 \\(u64) global_threadlocal2 = 0x43faea1cf5ad7a22706 \\(u64) global_threadlocal2 = 0x43faea1cf5ad7a22
648 \\(lldb) frame variable --show-types --format hex param1 param2 param3 param4 param5 param6 param7 param8 local_comptime_val local_comptime_ptr.0 local_const local_var707 \\(lldb) frame variable --show-types --format hex -- param1 param2 param3 param4 param5 param6 param7 param8 local_comptime_val local_comptime_ptr.0 local_const local_var
649 \\(u64) param1 = 0x6a607e08125c7e00708 \\(u64) param1 = 0x6a607e08125c7e00
650 \\(u64) param2 = 0x98944cb2a45a8b51709 \\(u64) param2 = 0x98944cb2a45a8b51
651 \\(u64) param3 = 0xa320cf10601ee6fb710 \\(u64) param3 = 0xa320cf10601ee6fb
...@@ -1240,31 +1299,536 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {...@@ -1240,31 +1299,536 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
1240 \\ x = fabsf(x);1299 \\ x = fabsf(x);
1241 \\ _ = &x;1300 \\ _ = &x;
1242 \\}1301 \\}
1302 \\
1243 ,1303 ,
1244 },1304 },
1245 },1305 },
1246 \\breakpoint set --file main.zig --source-pattern-regexp 'x = fabsf\(x\);'1306 \\breakpoint set --file main.zig --source-pattern-regexp 'x = fabsf\(x\);'
1247 \\process launch1307 \\process launch
1248 \\frame variable x1308 \\frame variable -- x
1249 \\breakpoint delete --force 11309 \\breakpoint delete --force 1
1250 \\1310 \\
1251 \\breakpoint set --file main.zig --source-pattern-regexp '_ = &x;'1311 \\breakpoint set --file main.zig --source-pattern-regexp '_ = &x;'
1252 \\process continue1312 \\process continue
1253 \\frame variable x1313 \\frame variable -- x
1254 \\breakpoint delete --force 21314 \\breakpoint delete --force 2
1255 ,1315 ,
1256 &.{1316 &.{
1257 \\(lldb) frame variable x1317 \\(lldb) frame variable -- x
1258 \\(f32) x = -1234.51318 \\(f32) x = -1234.5
1259 \\(lldb) breakpoint delete --force 11319 \\(lldb) breakpoint delete --force 1
1260 \\1 breakpoints deleted; 0 breakpoint locations disabled.1320 \\1 breakpoints deleted; 0 breakpoint locations disabled.
1261 ,1321 ,
1262 \\(lldb) frame variable x1322 \\(lldb) frame variable -- x
1263 \\(f32) x = 1234.51323 \\(f32) x = 1234.5
1264 \\(lldb) breakpoint delete --force 21324 \\(lldb) breakpoint delete --force 2
1265 \\1 breakpoints deleted; 0 breakpoint locations disabled.1325 \\1 breakpoints deleted; 0 breakpoint locations disabled.
1266 },1326 },
1267 );1327 );
1328 db.addLldbTest(
1329 "hash_map",
1330 target,
1331 &.{
1332 .{
1333 .path = "main.zig",
1334 .source =
1335 \\const std = @import("std");
1336 \\const Context = struct {
1337 \\ pub fn hash(_: Context, key: u32) Map.Hash {
1338 \\ return key;
1339 \\ }
1340 \\ pub fn eql(_: Context, lhs: u32, rhs: u32) bool {
1341 \\ return lhs == rhs;
1342 \\ }
1343 \\};
1344 \\const Map = std.HashMap(u32, u32, Context, 63);
1345 \\fn testHashMap(map: Map) void {
1346 \\ _ = map;
1347 \\}
1348 \\pub fn main() !void {
1349 \\ var map = Map.init(std.heap.page_allocator);
1350 \\ defer map.deinit();
1351 \\ try map.ensureTotalCapacity(10);
1352 \\ map.putAssumeCapacity(0, 1);
1353 \\ map.putAssumeCapacity(2, 3);
1354 \\ map.putAssumeCapacity(4, 5);
1355 \\ map.putAssumeCapacity(6, 7);
1356 \\ map.putAssumeCapacity(8, 9);
1357 \\
1358 \\ testHashMap(map);
1359 \\}
1360 \\
1361 ,
1362 },
1363 },
1364 \\breakpoint set --file main.zig --source-pattern-regexp '_ = map;'
1365 \\process launch
1366 \\frame variable --show-types -- map.unmanaged
1367 \\breakpoint delete --force 1
1368 ,
1369 &.{
1370 \\(lldb) frame variable --show-types -- map.unmanaged
1371 \\(std.hash_map.HashMapUnmanaged(u32,u32,main.Context,63)) map.unmanaged = len=5 capacity=16 {
1372 \\ (std.hash_map.HashMapUnmanaged(u32,u32,main.Context,63).KV) [0] = {
1373 \\ (u32) key = 0
1374 \\ (u32) value = 1
1375 \\ }
1376 \\ (std.hash_map.HashMapUnmanaged(u32,u32,main.Context,63).KV) [1] = {
1377 \\ (u32) key = 2
1378 \\ (u32) value = 3
1379 \\ }
1380 \\ (std.hash_map.HashMapUnmanaged(u32,u32,main.Context,63).KV) [2] = {
1381 \\ (u32) key = 4
1382 \\ (u32) value = 5
1383 \\ }
1384 \\ (std.hash_map.HashMapUnmanaged(u32,u32,main.Context,63).KV) [3] = {
1385 \\ (u32) key = 6
1386 \\ (u32) value = 7
1387 \\ }
1388 \\ (std.hash_map.HashMapUnmanaged(u32,u32,main.Context,63).KV) [4] = {
1389 \\ (u32) key = 8
1390 \\ (u32) value = 9
1391 \\ }
1392 \\}
1393 \\(lldb) breakpoint delete --force 1
1394 \\1 breakpoints deleted; 0 breakpoint locations disabled.
1395 },
1396 );
1397 db.addLldbTest(
1398 "multi_array_list",
1399 target,
1400 &.{
1401 .{
1402 .path = "main.zig",
1403 .source =
1404 \\const std = @import("std");
1405 \\const Elem0 = struct { u32, u8, u16 };
1406 \\const Elem1 = struct { a: u32, b: u8, c: u16 };
1407 \\fn testMultiArrayList(
1408 \\ list0: std.MultiArrayList(Elem0),
1409 \\ slice0: std.MultiArrayList(Elem0).Slice,
1410 \\ list1: std.MultiArrayList(Elem1),
1411 \\ slice1: std.MultiArrayList(Elem1).Slice,
1412 \\) void {
1413 \\ _ = .{ list0, slice0, list1, slice1 };
1414 \\}
1415 \\pub fn main() !void {
1416 \\ var list0: std.MultiArrayList(Elem0) = .{};
1417 \\ defer list0.deinit(std.heap.page_allocator);
1418 \\ try list0.setCapacity(std.heap.page_allocator, 8);
1419 \\ list0.appendAssumeCapacity(.{ 1, 2, 3 });
1420 \\ list0.appendAssumeCapacity(.{ 4, 5, 6 });
1421 \\ list0.appendAssumeCapacity(.{ 7, 8, 9 });
1422 \\ const slice0 = list0.slice();
1423 \\
1424 \\ var list1: std.MultiArrayList(Elem1) = .{};
1425 \\ defer list1.deinit(std.heap.page_allocator);
1426 \\ try list1.setCapacity(std.heap.page_allocator, 12);
1427 \\ list1.appendAssumeCapacity(.{ .a = 1, .b = 2, .c = 3 });
1428 \\ list1.appendAssumeCapacity(.{ .a = 4, .b = 5, .c = 6 });
1429 \\ list1.appendAssumeCapacity(.{ .a = 7, .b = 8, .c = 9 });
1430 \\ const slice1 = list1.slice();
1431 \\
1432 \\ testMultiArrayList(list0, slice0, list1, slice1);
1433 \\}
1434 \\
1435 ,
1436 },
1437 },
1438 \\breakpoint set --file main.zig --source-pattern-regexp '_ = \.{ list0, slice0, list1, slice1 };'
1439 \\process launch
1440 \\frame variable --show-types -- list0 list0.len list0.capacity list0[0] list0[1] list0[2] list0.0 list0.1 list0.2
1441 \\frame variable --show-types -- slice0 slice0.len slice0.capacity slice0[0] slice0[1] slice0[2] slice0.0 slice0.1 slice0.2
1442 \\frame variable --show-types -- list1 list1.len list1.capacity list1[0] list1[1] list1[2] list1.a list1.b list1.c
1443 \\frame variable --show-types -- slice1 slice1.len slice1.capacity slice1[0] slice1[1] slice1[2] slice1.a slice1.b slice1.c
1444 \\breakpoint delete --force 1
1445 ,
1446 &.{
1447 \\(lldb) frame variable --show-types -- list0 list0.len list0.capacity list0[0] list0[1] list0[2] list0.0 list0.1 list0.2
1448 \\(std.multi_array_list.MultiArrayList(main.Elem0)) list0 = len=3 capacity=8 {
1449 \\ (root.main.Elem0) [0] = {
1450 \\ (u32) 0 = 1
1451 \\ (u8) 1 = 2
1452 \\ (u16) 2 = 3
1453 \\ }
1454 \\ (root.main.Elem0) [1] = {
1455 \\ (u32) 0 = 4
1456 \\ (u8) 1 = 5
1457 \\ (u16) 2 = 6
1458 \\ }
1459 \\ (root.main.Elem0) [2] = {
1460 \\ (u32) 0 = 7
1461 \\ (u8) 1 = 8
1462 \\ (u16) 2 = 9
1463 \\ }
1464 \\}
1465 \\(usize) list0.len = 3
1466 \\(usize) list0.capacity = 8
1467 \\(root.main.Elem0) list0[0] = {
1468 \\ (u32) 0 = 1
1469 \\ (u8) 1 = 2
1470 \\ (u16) 2 = 3
1471 \\}
1472 \\(root.main.Elem0) list0[1] = {
1473 \\ (u32) 0 = 4
1474 \\ (u8) 1 = 5
1475 \\ (u16) 2 = 6
1476 \\}
1477 \\(root.main.Elem0) list0[2] = {
1478 \\ (u32) 0 = 7
1479 \\ (u8) 1 = 8
1480 \\ (u16) 2 = 9
1481 \\}
1482 \\([3]u32) list0.0 = {
1483 \\ (u32) [0] = 1
1484 \\ (u32) [1] = 4
1485 \\ (u32) [2] = 7
1486 \\}
1487 \\([3]u8) list0.1 = {
1488 \\ (u8) [0] = 2
1489 \\ (u8) [1] = 5
1490 \\ (u8) [2] = 8
1491 \\}
1492 \\([3]u16) list0.2 = {
1493 \\ (u16) [0] = 3
1494 \\ (u16) [1] = 6
1495 \\ (u16) [2] = 9
1496 \\}
1497 \\(lldb) frame variable --show-types -- slice0 slice0.len slice0.capacity slice0[0] slice0[1] slice0[2] slice0.0 slice0.1 slice0.2
1498 \\(std.multi_array_list.MultiArrayList(main.Elem0).Slice) slice0 = len=3 capacity=8 {
1499 \\ (root.main.Elem0) [0] = {
1500 \\ (u32) 0 = 1
1501 \\ (u8) 1 = 2
1502 \\ (u16) 2 = 3
1503 \\ }
1504 \\ (root.main.Elem0) [1] = {
1505 \\ (u32) 0 = 4
1506 \\ (u8) 1 = 5
1507 \\ (u16) 2 = 6
1508 \\ }
1509 \\ (root.main.Elem0) [2] = {
1510 \\ (u32) 0 = 7
1511 \\ (u8) 1 = 8
1512 \\ (u16) 2 = 9
1513 \\ }
1514 \\}
1515 \\(usize) slice0.len = 3
1516 \\(usize) slice0.capacity = 8
1517 \\(root.main.Elem0) slice0[0] = {
1518 \\ (u32) 0 = 1
1519 \\ (u8) 1 = 2
1520 \\ (u16) 2 = 3
1521 \\}
1522 \\(root.main.Elem0) slice0[1] = {
1523 \\ (u32) 0 = 4
1524 \\ (u8) 1 = 5
1525 \\ (u16) 2 = 6
1526 \\}
1527 \\(root.main.Elem0) slice0[2] = {
1528 \\ (u32) 0 = 7
1529 \\ (u8) 1 = 8
1530 \\ (u16) 2 = 9
1531 \\}
1532 \\([3]u32) slice0.0 = {
1533 \\ (u32) [0] = 1
1534 \\ (u32) [1] = 4
1535 \\ (u32) [2] = 7
1536 \\}
1537 \\([3]u8) slice0.1 = {
1538 \\ (u8) [0] = 2
1539 \\ (u8) [1] = 5
1540 \\ (u8) [2] = 8
1541 \\}
1542 \\([3]u16) slice0.2 = {
1543 \\ (u16) [0] = 3
1544 \\ (u16) [1] = 6
1545 \\ (u16) [2] = 9
1546 \\}
1547 \\(lldb) frame variable --show-types -- list1 list1.len list1.capacity list1[0] list1[1] list1[2] list1.a list1.b list1.c
1548 \\(std.multi_array_list.MultiArrayList(main.Elem1)) list1 = len=3 capacity=12 {
1549 \\ (root.main.Elem1) [0] = {
1550 \\ (u32) a = 1
1551 \\ (u8) b = 2
1552 \\ (u16) c = 3
1553 \\ }
1554 \\ (root.main.Elem1) [1] = {
1555 \\ (u32) a = 4
1556 \\ (u8) b = 5
1557 \\ (u16) c = 6
1558 \\ }
1559 \\ (root.main.Elem1) [2] = {
1560 \\ (u32) a = 7
1561 \\ (u8) b = 8
1562 \\ (u16) c = 9
1563 \\ }
1564 \\}
1565 \\(usize) list1.len = 3
1566 \\(usize) list1.capacity = 12
1567 \\(root.main.Elem1) list1[0] = {
1568 \\ (u32) a = 1
1569 \\ (u8) b = 2
1570 \\ (u16) c = 3
1571 \\}
1572 \\(root.main.Elem1) list1[1] = {
1573 \\ (u32) a = 4
1574 \\ (u8) b = 5
1575 \\ (u16) c = 6
1576 \\}
1577 \\(root.main.Elem1) list1[2] = {
1578 \\ (u32) a = 7
1579 \\ (u8) b = 8
1580 \\ (u16) c = 9
1581 \\}
1582 \\([3]u32) list1.a = {
1583 \\ (u32) [0] = 1
1584 \\ (u32) [1] = 4
1585 \\ (u32) [2] = 7
1586 \\}
1587 \\([3]u8) list1.b = {
1588 \\ (u8) [0] = 2
1589 \\ (u8) [1] = 5
1590 \\ (u8) [2] = 8
1591 \\}
1592 \\([3]u16) list1.c = {
1593 \\ (u16) [0] = 3
1594 \\ (u16) [1] = 6
1595 \\ (u16) [2] = 9
1596 \\}
1597 \\(lldb) frame variable --show-types -- slice1 slice1.len slice1.capacity slice1[0] slice1[1] slice1[2] slice1.a slice1.b slice1.c
1598 \\(std.multi_array_list.MultiArrayList(main.Elem1).Slice) slice1 = len=3 capacity=12 {
1599 \\ (root.main.Elem1) [0] = {
1600 \\ (u32) a = 1
1601 \\ (u8) b = 2
1602 \\ (u16) c = 3
1603 \\ }
1604 \\ (root.main.Elem1) [1] = {
1605 \\ (u32) a = 4
1606 \\ (u8) b = 5
1607 \\ (u16) c = 6
1608 \\ }
1609 \\ (root.main.Elem1) [2] = {
1610 \\ (u32) a = 7
1611 \\ (u8) b = 8
1612 \\ (u16) c = 9
1613 \\ }
1614 \\}
1615 \\(usize) slice1.len = 3
1616 \\(usize) slice1.capacity = 12
1617 \\(root.main.Elem1) slice1[0] = {
1618 \\ (u32) a = 1
1619 \\ (u8) b = 2
1620 \\ (u16) c = 3
1621 \\}
1622 \\(root.main.Elem1) slice1[1] = {
1623 \\ (u32) a = 4
1624 \\ (u8) b = 5
1625 \\ (u16) c = 6
1626 \\}
1627 \\(root.main.Elem1) slice1[2] = {
1628 \\ (u32) a = 7
1629 \\ (u8) b = 8
1630 \\ (u16) c = 9
1631 \\}
1632 \\([3]u32) slice1.a = {
1633 \\ (u32) [0] = 1
1634 \\ (u32) [1] = 4
1635 \\ (u32) [2] = 7
1636 \\}
1637 \\([3]u8) slice1.b = {
1638 \\ (u8) [0] = 2
1639 \\ (u8) [1] = 5
1640 \\ (u8) [2] = 8
1641 \\}
1642 \\([3]u16) slice1.c = {
1643 \\ (u16) [0] = 3
1644 \\ (u16) [1] = 6
1645 \\ (u16) [2] = 9
1646 \\}
1647 \\(lldb) breakpoint delete --force 1
1648 \\1 breakpoints deleted; 0 breakpoint locations disabled.
1649 },
1650 );
1651 db.addLldbTest(
1652 "segmented_list",
1653 target,
1654 &.{
1655 .{
1656 .path = "main.zig",
1657 .source =
1658 \\const std = @import("std");
1659 \\fn testSegmentedList() void {}
1660 \\pub fn main() !void {
1661 \\ var list0: std.SegmentedList(usize, 0) = .{};
1662 \\ defer list0.deinit(std.heap.page_allocator);
1663 \\
1664 \\ var list1: std.SegmentedList(usize, 1) = .{};
1665 \\ defer list1.deinit(std.heap.page_allocator);
1666 \\
1667 \\ var list2: std.SegmentedList(usize, 2) = .{};
1668 \\ defer list2.deinit(std.heap.page_allocator);
1669 \\
1670 \\ var list4: std.SegmentedList(usize, 4) = .{};
1671 \\ defer list4.deinit(std.heap.page_allocator);
1672 \\
1673 \\ for (0..32) |i| {
1674 \\ try list0.append(std.heap.page_allocator, i);
1675 \\ try list1.append(std.heap.page_allocator, i);
1676 \\ try list2.append(std.heap.page_allocator, i);
1677 \\ try list4.append(std.heap.page_allocator, i);
1678 \\ }
1679 \\ testSegmentedList();
1680 \\}
1681 \\
1682 ,
1683 },
1684 },
1685 \\breakpoint set --file main.zig --source-pattern-regexp 'testSegmentedList\(\);'
1686 \\process launch
1687 \\frame variable -- list0 list1 list2 list4
1688 \\breakpoint delete --force 1
1689 ,
1690 &.{
1691 \\(lldb) frame variable -- list0 list1 list2 list4
1692 \\(std.segmented_list.SegmentedList(usize,0)) list0 = len=32 {
1693 \\ [0] = 0
1694 \\ [1] = 1
1695 \\ [2] = 2
1696 \\ [3] = 3
1697 \\ [4] = 4
1698 \\ [5] = 5
1699 \\ [6] = 6
1700 \\ [7] = 7
1701 \\ [8] = 8
1702 \\ [9] = 9
1703 \\ [10] = 10
1704 \\ [11] = 11
1705 \\ [12] = 12
1706 \\ [13] = 13
1707 \\ [14] = 14
1708 \\ [15] = 15
1709 \\ [16] = 16
1710 \\ [17] = 17
1711 \\ [18] = 18
1712 \\ [19] = 19
1713 \\ [20] = 20
1714 \\ [21] = 21
1715 \\ [22] = 22
1716 \\ [23] = 23
1717 \\ [24] = 24
1718 \\ [25] = 25
1719 \\ [26] = 26
1720 \\ [27] = 27
1721 \\ [28] = 28
1722 \\ [29] = 29
1723 \\ [30] = 30
1724 \\ [31] = 31
1725 \\}
1726 \\(std.segmented_list.SegmentedList(usize,1)) list1 = len=32 {
1727 \\ [0] = 0
1728 \\ [1] = 1
1729 \\ [2] = 2
1730 \\ [3] = 3
1731 \\ [4] = 4
1732 \\ [5] = 5
1733 \\ [6] = 6
1734 \\ [7] = 7
1735 \\ [8] = 8
1736 \\ [9] = 9
1737 \\ [10] = 10
1738 \\ [11] = 11
1739 \\ [12] = 12
1740 \\ [13] = 13
1741 \\ [14] = 14
1742 \\ [15] = 15
1743 \\ [16] = 16
1744 \\ [17] = 17
1745 \\ [18] = 18
1746 \\ [19] = 19
1747 \\ [20] = 20
1748 \\ [21] = 21
1749 \\ [22] = 22
1750 \\ [23] = 23
1751 \\ [24] = 24
1752 \\ [25] = 25
1753 \\ [26] = 26
1754 \\ [27] = 27
1755 \\ [28] = 28
1756 \\ [29] = 29
1757 \\ [30] = 30
1758 \\ [31] = 31
1759 \\}
1760 \\(std.segmented_list.SegmentedList(usize,2)) list2 = len=32 {
1761 \\ [0] = 0
1762 \\ [1] = 1
1763 \\ [2] = 2
1764 \\ [3] = 3
1765 \\ [4] = 4
1766 \\ [5] = 5
1767 \\ [6] = 6
1768 \\ [7] = 7
1769 \\ [8] = 8
1770 \\ [9] = 9
1771 \\ [10] = 10
1772 \\ [11] = 11
1773 \\ [12] = 12
1774 \\ [13] = 13
1775 \\ [14] = 14
1776 \\ [15] = 15
1777 \\ [16] = 16
1778 \\ [17] = 17
1779 \\ [18] = 18
1780 \\ [19] = 19
1781 \\ [20] = 20
1782 \\ [21] = 21
1783 \\ [22] = 22
1784 \\ [23] = 23
1785 \\ [24] = 24
1786 \\ [25] = 25
1787 \\ [26] = 26
1788 \\ [27] = 27
1789 \\ [28] = 28
1790 \\ [29] = 29
1791 \\ [30] = 30
1792 \\ [31] = 31
1793 \\}
1794 \\(std.segmented_list.SegmentedList(usize,4)) list4 = len=32 {
1795 \\ [0] = 0
1796 \\ [1] = 1
1797 \\ [2] = 2
1798 \\ [3] = 3
1799 \\ [4] = 4
1800 \\ [5] = 5
1801 \\ [6] = 6
1802 \\ [7] = 7
1803 \\ [8] = 8
1804 \\ [9] = 9
1805 \\ [10] = 10
1806 \\ [11] = 11
1807 \\ [12] = 12
1808 \\ [13] = 13
1809 \\ [14] = 14
1810 \\ [15] = 15
1811 \\ [16] = 16
1812 \\ [17] = 17
1813 \\ [18] = 18
1814 \\ [19] = 19
1815 \\ [20] = 20
1816 \\ [21] = 21
1817 \\ [22] = 22
1818 \\ [23] = 23
1819 \\ [24] = 24
1820 \\ [25] = 25
1821 \\ [26] = 26
1822 \\ [27] = 27
1823 \\ [28] = 28
1824 \\ [29] = 29
1825 \\ [30] = 30
1826 \\ [31] = 31
1827 \\}
1828 \\(lldb) breakpoint delete --force 1
1829 \\1 breakpoints deleted; 0 breakpoint locations disabled.
1830 },
1831 );
1268}1832}
12691833
1270const File = struct { import: ?[]const u8 = null, path: []const u8, source: []const u8 };1834const File = struct { import: ?[]const u8 = null, path: []const u8, source: []const u8 };