| author | |
| committer | |
| log | 8ec68c63fa1d0f7e267ff92c054e8aa335f91da4 |
| tree | e2fbdd384dbc2509c4a3b633b41e651a6e01b157 |
| parent | 90075345519f165a0164c52b62b78453068c6ce6 |
| parent | 6aa6d088d93174767d3a8387d536f4083c39e14f |
| signature |
Dwarf: implement more decls26 files changed, 1354 insertions(+), 695 deletions(-)
ci/x86_64-linux-debug.sh+1-1| ... | ... | @@ -64,7 +64,7 @@ stage3-debug/bin/zig build \ |
| 64 | 64 | |
| 65 | 65 | stage3-debug/bin/zig build test docs \ |
| 66 | 66 | --maxrss 21000000000 \ |
| 67 | -Dlldb=$HOME/deps/lldb-zig/Debug-befcd57a8/bin/lldb \ | |
| 67 | -Dlldb=$HOME/deps/lldb-zig/Debug-4a44163df/bin/lldb \ | |
| 68 | 68 | -fqemu \ |
| 69 | 69 | -fwasmtime \ |
| 70 | 70 | -Dstatic-llvm \ |
ci/x86_64-linux-release.sh+1-1| ... | ... | @@ -64,7 +64,7 @@ stage3-release/bin/zig build \ |
| 64 | 64 | |
| 65 | 65 | stage3-release/bin/zig build test docs \ |
| 66 | 66 | --maxrss 21000000000 \ |
| 67 | -Dlldb=$HOME/deps/lldb-zig/Release-befcd57a8/bin/lldb \ | |
| 67 | -Dlldb=$HOME/deps/lldb-zig/Release-4a44163df/bin/lldb \ | |
| 68 | 68 | -fqemu \ |
| 69 | 69 | -fwasmtime \ |
| 70 | 70 | -Dstatic-llvm \ |
lib/std/hash_map.zig+5-3| ... | ... | @@ -1767,9 +1767,11 @@ pub fn HashMapUnmanaged( |
| 1767 | 1767 | } |
| 1768 | 1768 | |
| 1769 | 1769 | comptime { |
| 1770 | if (!builtin.strip_debug_info) { | |
| 1771 | _ = &dbHelper; | |
| 1772 | } | |
| 1770 | if (!builtin.strip_debug_info) _ = switch (builtin.zig_backend) { | |
| 1771 | .stage2_llvm => &dbHelper, | |
| 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 | 573 | } |
| 574 | 574 | |
| 575 | 575 | comptime { |
| 576 | if (!builtin.strip_debug_info) { | |
| 576 | if (builtin.zig_backend == .stage2_llvm and !builtin.strip_debug_info) { | |
| 577 | 577 | _ = &dbHelper; |
| 578 | 578 | _ = &Slice.dbHelper; |
| 579 | 579 | } |
src/InternPool.zig+1-1| ... | ... | @@ -4723,7 +4723,7 @@ pub const Index = enum(u32) { |
| 4723 | 4723 | } |
| 4724 | 4724 | |
| 4725 | 4725 | comptime { |
| 4726 | if (!builtin.strip_debug_info) { | |
| 4726 | if (builtin.zig_backend == .stage2_llvm and !builtin.strip_debug_info) { | |
| 4727 | 4727 | _ = &dbHelper; |
| 4728 | 4728 | } |
| 4729 | 4729 | } |
src/arch/aarch64/CodeGen.zig+2-3| ... | ... | @@ -25,7 +25,6 @@ const Alignment = InternPool.Alignment; |
| 25 | 25 | |
| 26 | 26 | const CodeGenError = codegen.CodeGenError; |
| 27 | 27 | const Result = codegen.Result; |
| 28 | const DebugInfoOutput = codegen.DebugInfoOutput; | |
| 29 | 28 | |
| 30 | 29 | const bits = @import("bits.zig"); |
| 31 | 30 | const abi = @import("abi.zig"); |
| ... | ... | @@ -48,7 +47,7 @@ pt: Zcu.PerThread, |
| 48 | 47 | air: Air, |
| 49 | 48 | liveness: Liveness, |
| 50 | 49 | bin_file: *link.File, |
| 51 | debug_output: DebugInfoOutput, | |
| 50 | debug_output: link.File.DebugInfoOutput, | |
| 52 | 51 | target: *const std.Target, |
| 53 | 52 | func_index: InternPool.Index, |
| 54 | 53 | owner_nav: InternPool.Nav.Index, |
| ... | ... | @@ -327,7 +326,7 @@ pub fn generate( |
| 327 | 326 | air: Air, |
| 328 | 327 | liveness: Liveness, |
| 329 | 328 | code: *std.ArrayList(u8), |
| 330 | debug_output: DebugInfoOutput, | |
| 329 | debug_output: link.File.DebugInfoOutput, | |
| 331 | 330 | ) CodeGenError!Result { |
| 332 | 331 | const zcu = pt.zcu; |
| 333 | 332 | const gpa = zcu.gpa; |
src/arch/aarch64/Emit.zig+1-2| ... | ... | @@ -13,11 +13,10 @@ const assert = std.debug.assert; |
| 13 | 13 | const Instruction = bits.Instruction; |
| 14 | 14 | const Register = bits.Register; |
| 15 | 15 | const log = std.log.scoped(.aarch64_emit); |
| 16 | const DebugInfoOutput = @import("../../codegen.zig").DebugInfoOutput; | |
| 17 | 16 | |
| 18 | 17 | mir: Mir, |
| 19 | 18 | bin_file: *link.File, |
| 20 | debug_output: DebugInfoOutput, | |
| 19 | debug_output: link.File.DebugInfoOutput, | |
| 21 | 20 | target: *const std.Target, |
| 22 | 21 | err_msg: ?*ErrorMsg = null, |
| 23 | 22 | src_loc: Zcu.LazySrcLoc, |
src/arch/arm/CodeGen.zig+2-3| ... | ... | @@ -25,7 +25,6 @@ const Alignment = InternPool.Alignment; |
| 25 | 25 | |
| 26 | 26 | const Result = codegen.Result; |
| 27 | 27 | const CodeGenError = codegen.CodeGenError; |
| 28 | const DebugInfoOutput = codegen.DebugInfoOutput; | |
| 29 | 28 | |
| 30 | 29 | const bits = @import("bits.zig"); |
| 31 | 30 | const abi = @import("abi.zig"); |
| ... | ... | @@ -49,7 +48,7 @@ pt: Zcu.PerThread, |
| 49 | 48 | air: Air, |
| 50 | 49 | liveness: Liveness, |
| 51 | 50 | bin_file: *link.File, |
| 52 | debug_output: DebugInfoOutput, | |
| 51 | debug_output: link.File.DebugInfoOutput, | |
| 53 | 52 | target: *const std.Target, |
| 54 | 53 | func_index: InternPool.Index, |
| 55 | 54 | err_msg: ?*ErrorMsg, |
| ... | ... | @@ -335,7 +334,7 @@ pub fn generate( |
| 335 | 334 | air: Air, |
| 336 | 335 | liveness: Liveness, |
| 337 | 336 | code: *std.ArrayList(u8), |
| 338 | debug_output: DebugInfoOutput, | |
| 337 | debug_output: link.File.DebugInfoOutput, | |
| 339 | 338 | ) CodeGenError!Result { |
| 340 | 339 | const zcu = pt.zcu; |
| 341 | 340 | const gpa = zcu.gpa; |
src/arch/arm/Emit.zig+1-2| ... | ... | @@ -16,12 +16,11 @@ const assert = std.debug.assert; |
| 16 | 16 | const Instruction = bits.Instruction; |
| 17 | 17 | const Register = bits.Register; |
| 18 | 18 | const log = std.log.scoped(.aarch32_emit); |
| 19 | const DebugInfoOutput = @import("../../codegen.zig").DebugInfoOutput; | |
| 20 | 19 | const CodeGen = @import("CodeGen.zig"); |
| 21 | 20 | |
| 22 | 21 | mir: Mir, |
| 23 | 22 | bin_file: *link.File, |
| 24 | debug_output: DebugInfoOutput, | |
| 23 | debug_output: link.File.DebugInfoOutput, | |
| 25 | 24 | target: *const std.Target, |
| 26 | 25 | err_msg: ?*ErrorMsg = null, |
| 27 | 26 | src_loc: Zcu.LazySrcLoc, |
src/arch/riscv64/CodeGen.zig+3-4| ... | ... | @@ -32,7 +32,6 @@ const Alignment = InternPool.Alignment; |
| 32 | 32 | |
| 33 | 33 | const CodeGenError = codegen.CodeGenError; |
| 34 | 34 | const Result = codegen.Result; |
| 35 | const DebugInfoOutput = codegen.DebugInfoOutput; | |
| 36 | 35 | |
| 37 | 36 | const bits = @import("bits.zig"); |
| 38 | 37 | const abi = @import("abi.zig"); |
| ... | ... | @@ -61,7 +60,7 @@ gpa: Allocator, |
| 61 | 60 | |
| 62 | 61 | mod: *Package.Module, |
| 63 | 62 | target: *const std.Target, |
| 64 | debug_output: DebugInfoOutput, | |
| 63 | debug_output: link.File.DebugInfoOutput, | |
| 65 | 64 | err_msg: ?*ErrorMsg, |
| 66 | 65 | args: []MCValue, |
| 67 | 66 | ret_mcv: InstTracking, |
| ... | ... | @@ -760,7 +759,7 @@ pub fn generate( |
| 760 | 759 | air: Air, |
| 761 | 760 | liveness: Liveness, |
| 762 | 761 | code: *std.ArrayList(u8), |
| 763 | debug_output: DebugInfoOutput, | |
| 762 | debug_output: link.File.DebugInfoOutput, | |
| 764 | 763 | ) CodeGenError!Result { |
| 765 | 764 | const zcu = pt.zcu; |
| 766 | 765 | const comp = zcu.comp; |
| ... | ... | @@ -928,7 +927,7 @@ pub fn generateLazy( |
| 928 | 927 | src_loc: Zcu.LazySrcLoc, |
| 929 | 928 | lazy_sym: link.File.LazySymbol, |
| 930 | 929 | code: *std.ArrayList(u8), |
| 931 | debug_output: DebugInfoOutput, | |
| 930 | debug_output: link.File.DebugInfoOutput, | |
| 932 | 931 | ) CodeGenError!Result { |
| 933 | 932 | const comp = bin_file.comp; |
| 934 | 933 | const gpa = comp.gpa; |
src/arch/riscv64/Emit.zig+1-2| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | |
| 3 | 3 | bin_file: *link.File, |
| 4 | 4 | lower: Lower, |
| 5 | debug_output: DebugInfoOutput, | |
| 5 | debug_output: link.File.DebugInfoOutput, | |
| 6 | 6 | code: *std.ArrayList(u8), |
| 7 | 7 | |
| 8 | 8 | prev_di_line: u32, |
| ... | ... | @@ -216,7 +216,6 @@ const log = std.log.scoped(.emit); |
| 216 | 216 | const mem = std.mem; |
| 217 | 217 | const std = @import("std"); |
| 218 | 218 | |
| 219 | const DebugInfoOutput = @import("../../codegen.zig").DebugInfoOutput; | |
| 220 | 219 | const Emit = @This(); |
| 221 | 220 | const Lower = @import("Lower.zig"); |
| 222 | 221 | const Mir = @import("Mir.zig"); |
src/arch/sparc64/CodeGen.zig+2-3| ... | ... | @@ -22,7 +22,6 @@ const Liveness = @import("../../Liveness.zig"); |
| 22 | 22 | const Type = @import("../../Type.zig"); |
| 23 | 23 | const CodeGenError = codegen.CodeGenError; |
| 24 | 24 | const Result = @import("../../codegen.zig").Result; |
| 25 | const DebugInfoOutput = @import("../../codegen.zig").DebugInfoOutput; | |
| 26 | 25 | const Endian = std.builtin.Endian; |
| 27 | 26 | const Alignment = InternPool.Alignment; |
| 28 | 27 | |
| ... | ... | @@ -57,7 +56,7 @@ bin_file: *link.File, |
| 57 | 56 | target: *const std.Target, |
| 58 | 57 | func_index: InternPool.Index, |
| 59 | 58 | code: *std.ArrayList(u8), |
| 60 | debug_output: DebugInfoOutput, | |
| 59 | debug_output: link.File.DebugInfoOutput, | |
| 61 | 60 | err_msg: ?*ErrorMsg, |
| 62 | 61 | args: []MCValue, |
| 63 | 62 | ret_mcv: MCValue, |
| ... | ... | @@ -268,7 +267,7 @@ pub fn generate( |
| 268 | 267 | air: Air, |
| 269 | 268 | liveness: Liveness, |
| 270 | 269 | code: *std.ArrayList(u8), |
| 271 | debug_output: DebugInfoOutput, | |
| 270 | debug_output: link.File.DebugInfoOutput, | |
| 272 | 271 | ) CodeGenError!Result { |
| 273 | 272 | const zcu = pt.zcu; |
| 274 | 273 | const gpa = zcu.gpa; |
src/arch/sparc64/Emit.zig+1-2| ... | ... | @@ -9,7 +9,6 @@ const Zcu = @import("../../Zcu.zig"); |
| 9 | 9 | const ErrorMsg = Zcu.ErrorMsg; |
| 10 | 10 | const Liveness = @import("../../Liveness.zig"); |
| 11 | 11 | const log = std.log.scoped(.sparcv9_emit); |
| 12 | const DebugInfoOutput = @import("../../codegen.zig").DebugInfoOutput; | |
| 13 | 12 | |
| 14 | 13 | const Emit = @This(); |
| 15 | 14 | const Mir = @import("Mir.zig"); |
| ... | ... | @@ -19,7 +18,7 @@ const Register = bits.Register; |
| 19 | 18 | |
| 20 | 19 | mir: Mir, |
| 21 | 20 | bin_file: *link.File, |
| 22 | debug_output: DebugInfoOutput, | |
| 21 | debug_output: link.File.DebugInfoOutput, | |
| 23 | 22 | target: *const std.Target, |
| 24 | 23 | err_msg: ?*ErrorMsg = null, |
| 25 | 24 | src_loc: Zcu.LazySrcLoc, |
src/arch/wasm/CodeGen.zig+2-2| ... | ... | @@ -648,7 +648,7 @@ block_depth: u32 = 0, |
| 648 | 648 | air: Air, |
| 649 | 649 | liveness: Liveness, |
| 650 | 650 | gpa: mem.Allocator, |
| 651 | debug_output: codegen.DebugInfoOutput, | |
| 651 | debug_output: link.File.DebugInfoOutput, | |
| 652 | 652 | func_index: InternPool.Index, |
| 653 | 653 | /// Contains a list of current branches. |
| 654 | 654 | /// When we return from a branch, the branch will be popped from this list, |
| ... | ... | @@ -1211,7 +1211,7 @@ pub fn generate( |
| 1211 | 1211 | air: Air, |
| 1212 | 1212 | liveness: Liveness, |
| 1213 | 1213 | code: *std.ArrayList(u8), |
| 1214 | debug_output: codegen.DebugInfoOutput, | |
| 1214 | debug_output: link.File.DebugInfoOutput, | |
| 1215 | 1215 | ) codegen.CodeGenError!codegen.Result { |
| 1216 | 1216 | const zcu = pt.zcu; |
| 1217 | 1217 | const gpa = zcu.gpa; |
src/arch/wasm/Emit.zig+1-1| ... | ... | @@ -26,7 +26,7 @@ owner_nav: InternPool.Nav.Index, |
| 26 | 26 | |
| 27 | 27 | // Debug information |
| 28 | 28 | /// Holds the debug information for this emission |
| 29 | dbg_output: codegen.DebugInfoOutput, | |
| 29 | dbg_output: link.File.DebugInfoOutput, | |
| 30 | 30 | /// Previous debug info line |
| 31 | 31 | prev_di_line: u32, |
| 32 | 32 | /// Previous debug info column |
src/arch/x86_64/CodeGen.zig+3-4| ... | ... | @@ -17,7 +17,6 @@ const Air = @import("../../Air.zig"); |
| 17 | 17 | const Allocator = mem.Allocator; |
| 18 | 18 | const CodeGenError = codegen.CodeGenError; |
| 19 | 19 | const Compilation = @import("../../Compilation.zig"); |
| 20 | const DebugInfoOutput = codegen.DebugInfoOutput; | |
| 21 | 20 | const ErrorMsg = Zcu.ErrorMsg; |
| 22 | 21 | const Result = codegen.Result; |
| 23 | 22 | const Emit = @import("Emit.zig"); |
| ... | ... | @@ -53,7 +52,7 @@ pt: Zcu.PerThread, |
| 53 | 52 | air: Air, |
| 54 | 53 | liveness: Liveness, |
| 55 | 54 | bin_file: *link.File, |
| 56 | debug_output: DebugInfoOutput, | |
| 55 | debug_output: link.File.DebugInfoOutput, | |
| 57 | 56 | target: *const std.Target, |
| 58 | 57 | owner: Owner, |
| 59 | 58 | inline_func: InternPool.Index, |
| ... | ... | @@ -819,7 +818,7 @@ pub fn generate( |
| 819 | 818 | air: Air, |
| 820 | 819 | liveness: Liveness, |
| 821 | 820 | code: *std.ArrayList(u8), |
| 822 | debug_output: DebugInfoOutput, | |
| 821 | debug_output: link.File.DebugInfoOutput, | |
| 823 | 822 | ) CodeGenError!Result { |
| 824 | 823 | const zcu = pt.zcu; |
| 825 | 824 | const comp = zcu.comp; |
| ... | ... | @@ -1000,7 +999,7 @@ pub fn generateLazy( |
| 1000 | 999 | src_loc: Zcu.LazySrcLoc, |
| 1001 | 1000 | lazy_sym: link.File.LazySymbol, |
| 1002 | 1001 | code: *std.ArrayList(u8), |
| 1003 | debug_output: DebugInfoOutput, | |
| 1002 | debug_output: link.File.DebugInfoOutput, | |
| 1004 | 1003 | ) CodeGenError!Result { |
| 1005 | 1004 | const comp = bin_file.comp; |
| 1006 | 1005 | const gpa = comp.gpa; |
src/arch/x86_64/Emit.zig+1-2| ... | ... | @@ -3,7 +3,7 @@ |
| 3 | 3 | air: Air, |
| 4 | 4 | lower: Lower, |
| 5 | 5 | atom_index: u32, |
| 6 | debug_output: DebugInfoOutput, | |
| 6 | debug_output: link.File.DebugInfoOutput, | |
| 7 | 7 | code: *std.ArrayList(u8), |
| 8 | 8 | |
| 9 | 9 | prev_di_line: u32, |
| ... | ... | @@ -546,7 +546,6 @@ const log = std.log.scoped(.emit); |
| 546 | 546 | const std = @import("std"); |
| 547 | 547 | |
| 548 | 548 | const Air = @import("../../Air.zig"); |
| 549 | const DebugInfoOutput = @import("../../codegen.zig").DebugInfoOutput; | |
| 550 | 549 | const Emit = @This(); |
| 551 | 550 | const Lower = @import("Lower.zig"); |
| 552 | 551 | const Mir = @import("Mir.zig"); |
src/codegen.zig+34-60| ... | ... | @@ -38,12 +38,6 @@ pub const CodeGenError = error{ |
| 38 | 38 | CodegenFail, |
| 39 | 39 | } || link.File.UpdateDebugInfoError; |
| 40 | 40 | |
| 41 | pub const DebugInfoOutput = union(enum) { | |
| 42 | dwarf: *link.File.Dwarf.WipNav, | |
| 43 | plan9: *link.File.Plan9.DebugInfoOutput, | |
| 44 | none, | |
| 45 | }; | |
| 46 | ||
| 47 | 41 | fn devFeatureForBackend(comptime backend: std.builtin.CompilerBackend) dev.Feature { |
| 48 | 42 | comptime assert(mem.startsWith(u8, @tagName(backend), "stage2_")); |
| 49 | 43 | return @field(dev.Feature, @tagName(backend)["stage2_".len..] ++ "_backend"); |
| ... | ... | @@ -69,7 +63,7 @@ pub fn generateFunction( |
| 69 | 63 | air: Air, |
| 70 | 64 | liveness: Liveness, |
| 71 | 65 | code: *std.ArrayList(u8), |
| 72 | debug_output: DebugInfoOutput, | |
| 66 | debug_output: link.File.DebugInfoOutput, | |
| 73 | 67 | ) CodeGenError!Result { |
| 74 | 68 | const zcu = pt.zcu; |
| 75 | 69 | const func = zcu.funcInfo(func_index); |
| ... | ... | @@ -95,7 +89,7 @@ pub fn generateLazyFunction( |
| 95 | 89 | src_loc: Zcu.LazySrcLoc, |
| 96 | 90 | lazy_sym: link.File.LazySymbol, |
| 97 | 91 | code: *std.ArrayList(u8), |
| 98 | debug_output: DebugInfoOutput, | |
| 92 | debug_output: link.File.DebugInfoOutput, | |
| 99 | 93 | ) CodeGenError!Result { |
| 100 | 94 | const zcu = pt.zcu; |
| 101 | 95 | const file = Type.fromInterned(lazy_sym.ty).typeDeclInstAllowGeneratedTag(zcu).?.resolveFile(&zcu.intern_pool); |
| ... | ... | @@ -127,10 +121,10 @@ pub fn generateLazySymbol( |
| 127 | 121 | // TODO don't use an "out" parameter like this; put it in the result instead |
| 128 | 122 | alignment: *Alignment, |
| 129 | 123 | code: *std.ArrayList(u8), |
| 130 | debug_output: DebugInfoOutput, | |
| 131 | reloc_info: RelocInfo, | |
| 124 | debug_output: link.File.DebugInfoOutput, | |
| 125 | reloc_parent: link.File.RelocInfo.Parent, | |
| 132 | 126 | ) CodeGenError!Result { |
| 133 | _ = reloc_info; | |
| 127 | _ = reloc_parent; | |
| 134 | 128 | |
| 135 | 129 | const tracy = trace(@src()); |
| 136 | 130 | defer tracy.end(); |
| ... | ... | @@ -192,8 +186,7 @@ pub fn generateSymbol( |
| 192 | 186 | src_loc: Zcu.LazySrcLoc, |
| 193 | 187 | val: Value, |
| 194 | 188 | code: *std.ArrayList(u8), |
| 195 | debug_output: DebugInfoOutput, | |
| 196 | reloc_info: RelocInfo, | |
| 189 | reloc_parent: link.File.RelocInfo.Parent, | |
| 197 | 190 | ) CodeGenError!Result { |
| 198 | 191 | const tracy = trace(@src()); |
| 199 | 192 | defer tracy.end(); |
| ... | ... | @@ -290,7 +283,7 @@ pub fn generateSymbol( |
| 290 | 283 | switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(switch (error_union.val) { |
| 291 | 284 | .err_name => try pt.intern(.{ .undef = payload_ty.toIntern() }), |
| 292 | 285 | .payload => |payload| payload, |
| 293 | }), code, debug_output, reloc_info)) { | |
| 286 | }), code, reloc_parent)) { | |
| 294 | 287 | .ok => {}, |
| 295 | 288 | .fail => |em| return .{ .fail = em }, |
| 296 | 289 | } |
| ... | ... | @@ -318,7 +311,7 @@ pub fn generateSymbol( |
| 318 | 311 | }, |
| 319 | 312 | .enum_tag => |enum_tag| { |
| 320 | 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 | 315 | .ok => {}, |
| 323 | 316 | .fail => |em| return .{ .fail = em }, |
| 324 | 317 | } |
| ... | ... | @@ -334,16 +327,16 @@ pub fn generateSymbol( |
| 334 | 327 | }, |
| 335 | 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 | 331 | .ok => {}, |
| 339 | 332 | .fail => |em| return .{ .fail = em }, |
| 340 | 333 | }, |
| 341 | 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 | 336 | .ok => {}, |
| 344 | 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 | 340 | .ok => {}, |
| 348 | 341 | .fail => |em| return .{ .fail = em }, |
| 349 | 342 | } |
| ... | ... | @@ -355,7 +348,7 @@ pub fn generateSymbol( |
| 355 | 348 | |
| 356 | 349 | if (ty.optionalReprIsPayload(zcu)) { |
| 357 | 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 | 352 | .ok => {}, |
| 360 | 353 | .fail => |em| return Result{ .fail = em }, |
| 361 | 354 | } |
| ... | ... | @@ -368,7 +361,7 @@ pub fn generateSymbol( |
| 368 | 361 | const value = payload_val orelse Value.fromInterned(try pt.intern(.{ |
| 369 | 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 | 365 | .ok => {}, |
| 373 | 366 | .fail => |em| return Result{ .fail = em }, |
| 374 | 367 | } |
| ... | ... | @@ -390,7 +383,7 @@ pub fn generateSymbol( |
| 390 | 383 | elem |
| 391 | 384 | else |
| 392 | 385 | array_type.sentinel, |
| 393 | }), code, debug_output, reloc_info)) { | |
| 386 | }), code, reloc_parent)) { | |
| 394 | 387 | .ok => {}, |
| 395 | 388 | .fail => |em| return .{ .fail = em }, |
| 396 | 389 | } |
| ... | ... | @@ -449,7 +442,7 @@ pub fn generateSymbol( |
| 449 | 442 | math.cast(usize, index) orelse return error.Overflow |
| 450 | 443 | ], |
| 451 | 444 | .repeated_elem => |elem| elem, |
| 452 | }), code, debug_output, reloc_info)) { | |
| 445 | }), code, reloc_parent)) { | |
| 453 | 446 | .ok => {}, |
| 454 | 447 | .fail => |em| return .{ .fail = em }, |
| 455 | 448 | } |
| ... | ... | @@ -482,7 +475,7 @@ pub fn generateSymbol( |
| 482 | 475 | .repeated_elem => |elem| elem, |
| 483 | 476 | }; |
| 484 | 477 | |
| 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 | 479 | .ok => {}, |
| 487 | 480 | .fail => |em| return Result{ .fail = em }, |
| 488 | 481 | } |
| ... | ... | @@ -524,7 +517,7 @@ pub fn generateSymbol( |
| 524 | 517 | return error.Overflow; |
| 525 | 518 | var tmp_list = try std.ArrayList(u8).initCapacity(code.allocator, field_size); |
| 526 | 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 | 521 | .ok => @memcpy(code.items[current_pos..][0..tmp_list.items.len], tmp_list.items), |
| 529 | 522 | .fail => |em| return Result{ .fail = em }, |
| 530 | 523 | } |
| ... | ... | @@ -559,7 +552,7 @@ pub fn generateSymbol( |
| 559 | 552 | ) orelse return error.Overflow; |
| 560 | 553 | if (padding > 0) try code.appendNTimes(0, padding); |
| 561 | 554 | |
| 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 | 556 | .ok => {}, |
| 564 | 557 | .fail => |em| return Result{ .fail = em }, |
| 565 | 558 | } |
| ... | ... | @@ -583,12 +576,12 @@ pub fn generateSymbol( |
| 583 | 576 | const layout = ty.unionGetLayout(zcu); |
| 584 | 577 | |
| 585 | 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 | } |
| 588 | 581 | |
| 589 | 582 | // Check if we should store the tag first. |
| 590 | 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 | 585 | .ok => {}, |
| 593 | 586 | .fail => |em| return Result{ .fail = em }, |
| 594 | 587 | } |
| ... | ... | @@ -601,7 +594,7 @@ pub fn generateSymbol( |
| 601 | 594 | if (!field_ty.hasRuntimeBits(zcu)) { |
| 602 | 595 | try code.appendNTimes(0xaa, math.cast(usize, layout.payload_size) orelse return error.Overflow); |
| 603 | 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 | 598 | .ok => {}, |
| 606 | 599 | .fail => |em| return Result{ .fail = em }, |
| 607 | 600 | } |
| ... | ... | @@ -612,14 +605,14 @@ pub fn generateSymbol( |
| 612 | 605 | } |
| 613 | 606 | } |
| 614 | 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 | 609 | .ok => {}, |
| 617 | 610 | .fail => |em| return Result{ .fail = em }, |
| 618 | 611 | } |
| 619 | 612 | } |
| 620 | 613 | |
| 621 | 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 | 616 | .ok => {}, |
| 624 | 617 | .fail => |em| return Result{ .fail = em }, |
| 625 | 618 | } |
| ... | ... | @@ -640,40 +633,29 @@ fn lowerPtr( |
| 640 | 633 | src_loc: Zcu.LazySrcLoc, |
| 641 | 634 | ptr_val: InternPool.Index, |
| 642 | 635 | code: *std.ArrayList(u8), |
| 643 | debug_output: DebugInfoOutput, | |
| 644 | reloc_info: RelocInfo, | |
| 636 | reloc_parent: link.File.RelocInfo.Parent, | |
| 645 | 637 | prev_offset: u64, |
| 646 | 638 | ) CodeGenError!Result { |
| 647 | 639 | const zcu = pt.zcu; |
| 648 | 640 | const ptr = zcu.intern_pool.indexToKey(ptr_val).ptr; |
| 649 | 641 | const offset: u64 = prev_offset + ptr.byte_offset; |
| 650 | 642 | return switch (ptr.base_addr) { |
| 651 | .nav => |nav| try lowerNavRef(bin_file, pt, src_loc, nav, code, debug_output, reloc_info, offset), | |
| 652 | .uav => |uav| try lowerUavRef(bin_file, pt, src_loc, uav, code, debug_output, reloc_info, offset), | |
| 653 | .int => try generateSymbol(bin_file, pt, src_loc, try pt.intValue(Type.usize, offset), code, debug_output, reloc_info), | |
| 643 | .nav => |nav| try lowerNavRef(bin_file, pt, src_loc, nav, code, reloc_parent, offset), | |
| 644 | .uav => |uav| try lowerUavRef(bin_file, pt, src_loc, uav, code, reloc_parent, offset), | |
| 645 | .int => try generateSymbol(bin_file, pt, src_loc, try pt.intValue(Type.usize, offset), code, reloc_parent), | |
| 654 | 646 | .eu_payload => |eu_ptr| try lowerPtr( |
| 655 | 647 | bin_file, |
| 656 | 648 | pt, |
| 657 | 649 | src_loc, |
| 658 | 650 | eu_ptr, |
| 659 | 651 | code, |
| 660 | debug_output, | |
| 661 | reloc_info, | |
| 652 | reloc_parent, | |
| 662 | 653 | offset + errUnionPayloadOffset( |
| 663 | 654 | Value.fromInterned(eu_ptr).typeOf(zcu).childType(zcu).errorUnionPayload(zcu), |
| 664 | 655 | zcu, |
| 665 | 656 | ), |
| 666 | 657 | ), |
| 667 | .opt_payload => |opt_ptr| try lowerPtr( | |
| 668 | bin_file, | |
| 669 | pt, | |
| 670 | src_loc, | |
| 671 | opt_ptr, | |
| 672 | code, | |
| 673 | debug_output, | |
| 674 | reloc_info, | |
| 675 | offset, | |
| 676 | ), | |
| 658 | .opt_payload => |opt_ptr| try lowerPtr(bin_file, pt, src_loc, opt_ptr, code, reloc_parent, offset), | |
| 677 | 659 | .field => |field| { |
| 678 | 660 | const base_ptr = Value.fromInterned(field.base); |
| 679 | 661 | const base_ty = base_ptr.typeOf(zcu).childType(zcu); |
| ... | ... | @@ -692,27 +674,21 @@ fn lowerPtr( |
| 692 | 674 | }, |
| 693 | 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 | 679 | .arr_elem, .comptime_field, .comptime_alloc => unreachable, |
| 698 | 680 | }; |
| 699 | 681 | } |
| 700 | 682 | |
| 701 | const RelocInfo = struct { | |
| 702 | parent_atom_index: u32, | |
| 703 | }; | |
| 704 | ||
| 705 | 683 | fn lowerUavRef( |
| 706 | 684 | lf: *link.File, |
| 707 | 685 | pt: Zcu.PerThread, |
| 708 | 686 | src_loc: Zcu.LazySrcLoc, |
| 709 | 687 | uav: InternPool.Key.Ptr.BaseAddr.Uav, |
| 710 | 688 | code: *std.ArrayList(u8), |
| 711 | debug_output: DebugInfoOutput, | |
| 712 | reloc_info: RelocInfo, | |
| 689 | reloc_parent: link.File.RelocInfo.Parent, | |
| 713 | 690 | offset: u64, |
| 714 | 691 | ) CodeGenError!Result { |
| 715 | _ = debug_output; | |
| 716 | 692 | const zcu = pt.zcu; |
| 717 | 693 | const ip = &zcu.intern_pool; |
| 718 | 694 | const target = lf.comp.root_mod.resolved_target.result; |
| ... | ... | @@ -735,7 +711,7 @@ fn lowerUavRef( |
| 735 | 711 | } |
| 736 | 712 | |
| 737 | 713 | const vaddr = try lf.getUavVAddr(uav_val, .{ |
| 738 | .parent_atom_index = reloc_info.parent_atom_index, | |
| 714 | .parent = reloc_parent, | |
| 739 | 715 | .offset = code.items.len, |
| 740 | 716 | .addend = @intCast(offset), |
| 741 | 717 | }); |
| ... | ... | @@ -756,12 +732,10 @@ fn lowerNavRef( |
| 756 | 732 | src_loc: Zcu.LazySrcLoc, |
| 757 | 733 | nav_index: InternPool.Nav.Index, |
| 758 | 734 | code: *std.ArrayList(u8), |
| 759 | debug_output: DebugInfoOutput, | |
| 760 | reloc_info: RelocInfo, | |
| 735 | reloc_parent: link.File.RelocInfo.Parent, | |
| 761 | 736 | offset: u64, |
| 762 | 737 | ) CodeGenError!Result { |
| 763 | 738 | _ = src_loc; |
| 764 | _ = debug_output; | |
| 765 | 739 | const zcu = pt.zcu; |
| 766 | 740 | const ip = &zcu.intern_pool; |
| 767 | 741 | const target = zcu.navFileScope(nav_index).mod.resolved_target.result; |
| ... | ... | @@ -775,7 +749,7 @@ fn lowerNavRef( |
| 775 | 749 | } |
| 776 | 750 | |
| 777 | 751 | const vaddr = try lf.getNavVAddr(pt, nav_index, .{ |
| 778 | .parent_atom_index = reloc_info.parent_atom_index, | |
| 752 | .parent = reloc_parent, | |
| 779 | 753 | .offset = code.items.len, |
| 780 | 754 | .addend = @intCast(offset), |
| 781 | 755 | }); |
src/link.zig+11-1| ... | ... | @@ -330,6 +330,11 @@ pub const File = struct { |
| 330 | 330 | } |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | pub const DebugInfoOutput = union(enum) { | |
| 334 | dwarf: *Dwarf.WipNav, | |
| 335 | plan9: *Plan9.DebugInfoOutput, | |
| 336 | none, | |
| 337 | }; | |
| 333 | 338 | pub const UpdateDebugInfoError = Dwarf.UpdateError; |
| 334 | 339 | pub const FlushDebugInfoError = Dwarf.FlushError; |
| 335 | 340 | |
| ... | ... | @@ -673,9 +678,14 @@ pub const File = struct { |
| 673 | 678 | } |
| 674 | 679 | |
| 675 | 680 | pub const RelocInfo = struct { |
| 676 | parent_atom_index: u32, | |
| 681 | parent: Parent, | |
| 677 | 682 | offset: u64, |
| 678 | 683 | addend: u32, |
| 684 | ||
| 685 | pub const Parent = union(enum) { | |
| 686 | atom_index: u32, | |
| 687 | debug_output: DebugInfoOutput, | |
| 688 | }; | |
| 679 | 689 | }; |
| 680 | 690 | |
| 681 | 691 | /// Get allocated `Nav`'s address in virtual memory. |
src/link/Coff.zig+12-7| ... | ... | @@ -1163,8 +1163,8 @@ fn lowerConst( |
| 1163 | 1163 | try self.setSymbolName(sym, name); |
| 1164 | 1164 | sym.section_number = @as(coff.SectionNumber, @enumFromInt(sect_id + 1)); |
| 1165 | 1165 | |
| 1166 | const res = try codegen.generateSymbol(&self.base, pt, src_loc, val, &code_buffer, .none, .{ | |
| 1167 | .parent_atom_index = self.getAtom(atom_index).getSymbolIndex().?, | |
| 1166 | const res = try codegen.generateSymbol(&self.base, pt, src_loc, val, &code_buffer, .{ | |
| 1167 | .atom_index = self.getAtom(atom_index).getSymbolIndex().?, | |
| 1168 | 1168 | }); |
| 1169 | 1169 | const code = switch (res) { |
| 1170 | 1170 | .ok => code_buffer.items, |
| ... | ... | @@ -1235,8 +1235,7 @@ pub fn updateNav( |
| 1235 | 1235 | zcu.navSrcLoc(nav_index), |
| 1236 | 1236 | nav_init, |
| 1237 | 1237 | &code_buffer, |
| 1238 | .none, | |
| 1239 | .{ .parent_atom_index = atom.getSymbolIndex().? }, | |
| 1238 | .{ .atom_index = atom.getSymbolIndex().? }, | |
| 1240 | 1239 | ); |
| 1241 | 1240 | const code = switch (res) { |
| 1242 | 1241 | .ok => code_buffer.items, |
| ... | ... | @@ -1284,7 +1283,7 @@ fn updateLazySymbolAtom( |
| 1284 | 1283 | &required_alignment, |
| 1285 | 1284 | &code_buffer, |
| 1286 | 1285 | .none, |
| 1287 | .{ .parent_atom_index = local_sym_index }, | |
| 1286 | .{ .atom_index = local_sym_index }, | |
| 1288 | 1287 | ); |
| 1289 | 1288 | const code = switch (res) { |
| 1290 | 1289 | .ok => code_buffer.items, |
| ... | ... | @@ -1823,7 +1822,10 @@ pub fn getNavVAddr( |
| 1823 | 1822 | .@"extern" => |@"extern"| try self.getGlobalSymbol(nav.name.toSlice(ip), @"extern".lib_name.toSlice(ip)), |
| 1824 | 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 | 1829 | const target = SymbolWithLoc{ .sym_index = sym_index, .file = null }; |
| 1828 | 1830 | try Atom.addRelocation(self, atom_index, .{ |
| 1829 | 1831 | .type = .direct, |
| ... | ... | @@ -1901,7 +1903,10 @@ pub fn getUavVAddr( |
| 1901 | 1903 | |
| 1902 | 1904 | const this_atom_index = self.uavs.get(uav).?.atom; |
| 1903 | 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 | 1910 | const target = SymbolWithLoc{ .sym_index = sym_index, .file = null }; |
| 1906 | 1911 | try Atom.addRelocation(self, atom_index, .{ |
| 1907 | 1912 | .type = .direct, |
src/link/Dwarf.zig+538-476| ... | ... | @@ -19,8 +19,8 @@ debug_rnglists: DebugRngLists, |
| 19 | 19 | debug_str: StringSection, |
| 20 | 20 | |
| 21 | 21 | pub const UpdateError = error{ |
| 22 | CodegenFail, | |
| 22 | 23 | ReinterpretDeclRef, |
| 23 | IllDefinedMemoryLayout, | |
| 24 | 24 | Unimplemented, |
| 25 | 25 | OutOfMemory, |
| 26 | 26 | EndOfStream, |
| ... | ... | @@ -847,10 +847,11 @@ const Entry = struct { |
| 847 | 847 | unit.len -| (unit.header_len + unit.trailer_len); |
| 848 | 848 | if (entry_ptr.off + len > end) { |
| 849 | 849 | if (entry_ptr.next.unwrap()) |next_entry| { |
| 850 | if (entry_ptr.prev.unwrap()) |prev_entry| | |
| 851 | unit.getEntry(prev_entry).next = entry_ptr.next | |
| 852 | else | |
| 853 | unit.first = entry_ptr.next; | |
| 850 | if (entry_ptr.prev.unwrap()) |prev_entry| { | |
| 851 | const prev_entry_ptr = unit.getEntry(prev_entry); | |
| 852 | prev_entry_ptr.next = entry_ptr.next; | |
| 853 | try prev_entry_ptr.pad(unit, sec, dwarf); | |
| 854 | } else unit.first = entry_ptr.next; | |
| 854 | 855 | const next_entry_ptr = unit.getEntry(next_entry); |
| 855 | 856 | const entry = next_entry_ptr.prev; |
| 856 | 857 | next_entry_ptr.prev = entry_ptr.prev; |
| ... | ... | @@ -860,6 +861,7 @@ const Entry = struct { |
| 860 | 861 | entry_ptr.next = .none; |
| 861 | 862 | entry_ptr.off = last_entry_ptr.off + sec.padToIdeal(last_entry_ptr.len); |
| 862 | 863 | unit.last = entry; |
| 864 | try last_entry_ptr.pad(unit, sec, dwarf); | |
| 863 | 865 | } |
| 864 | 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 | 1584 | wip_nav.func = func; |
| 1583 | 1585 | } |
| 1584 | 1586 | |
| 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 | 1599 | fn abbrevCode(wip_nav: *WipNav, abbrev_code: AbbrevCode) UpdateError!void { |
| 1586 | 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 | 1672 | } |
| 1659 | 1673 | |
| 1660 | 1674 | fn infoAddrSym(wip_nav: *WipNav, sym_index: u32) UpdateError!void { |
| 1661 | const dwarf = wip_nav.dwarf; | |
| 1662 | try dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(wip_nav.entry).external_relocs.append(dwarf.gpa, .{ | |
| 1675 | try wip_nav.infoExternalReloc(.{ | |
| 1663 | 1676 | .source_off = @intCast(wip_nav.debug_info.items.len), |
| 1664 | 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 | } |
| 1668 | 1681 | |
| 1669 | 1682 | fn frameExprloc(wip_nav: *WipNav, loc: Loc) UpdateError!void { |
| ... | ... | @@ -1690,12 +1703,11 @@ pub const WipNav = struct { |
| 1690 | 1703 | } |
| 1691 | 1704 | |
| 1692 | 1705 | fn frameAddrSym(wip_nav: *WipNav, sym_index: u32) UpdateError!void { |
| 1693 | const dwarf = wip_nav.dwarf; | |
| 1694 | try dwarf.debug_frame.section.getUnit(wip_nav.unit).getEntry(wip_nav.entry).external_relocs.append(dwarf.gpa, .{ | |
| 1706 | try wip_nav.frameExternalReloc(.{ | |
| 1695 | 1707 | .source_off = @intCast(wip_nav.debug_frame.items.len), |
| 1696 | 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 | } |
| 1700 | 1712 | |
| 1701 | 1713 | fn getTypeEntry(wip_nav: *WipNav, ty: Type) UpdateError!struct { Unit.Index, Entry.Index } { |
| ... | ... | @@ -1747,6 +1759,27 @@ pub const WipNav = struct { |
| 1747 | 1759 | reloc.target_off = @intCast(wip_nav.debug_info.items.len); |
| 1748 | 1760 | } |
| 1749 | 1761 | |
| 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 | 1783 | fn enumConstValue( |
| 1751 | 1784 | wip_nav: *WipNav, |
| 1752 | 1785 | loaded_enum: InternPool.LoadedEnumType, |
| ... | ... | @@ -1812,8 +1845,8 @@ pub const WipNav = struct { |
| 1812 | 1845 | } |
| 1813 | 1846 | } |
| 1814 | 1847 | |
| 1815 | fn flush(wip_nav: *WipNav) UpdateError!void { | |
| 1816 | while (wip_nav.pending_types.popOrNull()) |ty| try wip_nav.dwarf.updateType(wip_nav.pt, ty, &wip_nav.pending_types); | |
| 1848 | fn flush(wip_nav: *WipNav, src_loc: Zcu.LazySrcLoc) UpdateError!void { | |
| 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 | }; |
| 1819 | 1852 | |
| ... | ... | @@ -2169,15 +2202,15 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In |
| 2169 | 2202 | try diw.writeByte(accessibility); |
| 2170 | 2203 | try wip_nav.strp(nav.name.toSlice(ip)); |
| 2171 | 2204 | try wip_nav.strp(nav.fqn.toSlice(ip)); |
| 2172 | const ty = nav_val.typeOf(zcu); | |
| 2173 | const ty_reloc_index = try wip_nav.refForward(); | |
| 2205 | const nav_ty = nav_val.typeOf(zcu); | |
| 2206 | const nav_ty_reloc_index = try wip_nav.refForward(); | |
| 2174 | 2207 | try wip_nav.exprloc(.{ .addr = .{ .sym = sym_index } }); |
| 2175 | 2208 | try uleb128(diw, nav.status.resolved.alignment.toByteUnits() orelse |
| 2176 | ty.abiAlignment(zcu).toByteUnits().?); | |
| 2209 | nav_ty.abiAlignment(zcu).toByteUnits().?); | |
| 2177 | 2210 | try diw.writeByte(@intFromBool(false)); |
| 2178 | wip_nav.finishForward(ty_reloc_index); | |
| 2211 | wip_nav.finishForward(nav_ty_reloc_index); | |
| 2179 | 2212 | try wip_nav.abbrevCode(.is_const); |
| 2180 | try wip_nav.refType(ty); | |
| 2213 | try wip_nav.refType(nav_ty); | |
| 2181 | 2214 | }, |
| 2182 | 2215 | .variable => |variable| { |
| 2183 | 2216 | assert(file.zir_loaded); |
| ... | ... | @@ -2286,20 +2319,16 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In |
| 2286 | 2319 | .source_off = @intCast(wip_nav.debug_frame.items.len), |
| 2287 | 2320 | }); |
| 2288 | 2321 | try dfw.writeByteNTimes(0, dwarf.sectionOffsetBytes()); |
| 2289 | try entry.external_relocs.append(dwarf.gpa, .{ | |
| 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)); | |
| 2322 | try wip_nav.frameAddrSym(sym_index); | |
| 2294 | 2323 | try dfw.writeByteNTimes(undefined, @intFromEnum(dwarf.address_size)); |
| 2295 | 2324 | }, |
| 2296 | 2325 | .eh_frame => { |
| 2297 | 2326 | try dfw.writeInt(u32, undefined, dwarf.endian); |
| 2298 | try entry.external_relocs.append(dwarf.gpa, .{ | |
| 2327 | try wip_nav.frameExternalReloc(.{ | |
| 2299 | 2328 | .source_off = @intCast(wip_nav.debug_frame.items.len), |
| 2300 | 2329 | .target_sym = sym_index, |
| 2301 | 2330 | }); |
| 2302 | try dfw.writeByteNTimes(0, dwarf.sectionOffsetBytes()); | |
| 2331 | try dfw.writeInt(u32, 0, dwarf.endian); | |
| 2303 | 2332 | try dfw.writeInt(u32, undefined, dwarf.endian); |
| 2304 | 2333 | try uleb128(dfw, 0); |
| 2305 | 2334 | }, |
| ... | ... | @@ -2479,12 +2508,13 @@ pub fn finishWipNav( |
| 2479 | 2508 | } |
| 2480 | 2509 | try dwarf.debug_loclists.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_loclists.items); |
| 2481 | 2510 | |
| 2482 | try wip_nav.flush(); | |
| 2511 | try wip_nav.flush(zcu.navSrcLoc(nav_index)); | |
| 2483 | 2512 | } |
| 2484 | 2513 | |
| 2485 | 2514 | pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index) UpdateError!void { |
| 2486 | 2515 | const zcu = pt.zcu; |
| 2487 | 2516 | const ip = &zcu.intern_pool; |
| 2517 | const nav_src_loc = zcu.navSrcLoc(nav_index); | |
| 2488 | 2518 | const nav_val = zcu.navValue(nav_index); |
| 2489 | 2519 | |
| 2490 | 2520 | const nav = ip.getNav(nav_index); |
| ... | ... | @@ -2507,6 +2537,19 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2507 | 2537 | return; |
| 2508 | 2538 | } |
| 2509 | 2539 | |
| 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 | 2553 | const tree = try file.getTree(dwarf.gpa); |
| 2511 | 2554 | const loc = tree.tokenLocation(0, tree.nodes.items(.main_token)[decl_inst.data.declaration.src_node]); |
| 2512 | 2555 | assert(loc.line == zcu.navSrcLine(nav_index)); |
| ... | ... | @@ -2532,8 +2575,341 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2532 | 2575 | |
| 2533 | 2576 | const nav_gop = try dwarf.navs.getOrPut(dwarf.gpa, nav_index); |
| 2534 | 2577 | errdefer _ = dwarf.navs.pop(); |
| 2535 | switch (ip.indexToKey(nav_val.toIntern())) { | |
| 2536 | .func => |func| { | |
| 2578 | ||
| 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 | 2913 | if (nav_gop.found_existing) { |
| 2538 | 2914 | const unit_ptr = dwarf.debug_info.section.getUnit(wip_nav.unit); |
| 2539 | 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 | 2933 | } else nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit); |
| 2558 | 2934 | wip_nav.entry = nav_gop.value_ptr.*; |
| 2559 | 2935 | |
| 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 | 2936 | const func_type = ip.indexToKey(func.ty).func_type; |
| 2574 | 2937 | const diw = wip_nav.debug_info.writer(dwarf.gpa); |
| 2575 | 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 | 2954 | if (func_type.is_var_args) try wip_nav.abbrevCode(.is_var_args); |
| 2592 | 2955 | try uleb128(diw, @intFromEnum(AbbrevCode.null)); |
| 2593 | 2956 | } |
| 2957 | break :tag .done; | |
| 2594 | 2958 | }, |
| 2595 | .struct_type => done: { | |
| 2596 | const loaded_struct = ip.loadStructType(nav_val.toIntern()); | |
| 2597 | ||
| 2598 | const parent_type, const accessibility: u8 = if (nav.analysis_owner.unwrap()) |cau| parent: { | |
| 2599 | const parent_namespace_ptr = ip.namespacePtr(ip.getCau(cau).namespace); | |
| 2600 | break :parent .{ | |
| 2601 | parent_namespace_ptr.owner_type, | |
| 2602 | if (parent_namespace_ptr.pub_decls.containsContext(nav_index, .{ .zcu = zcu })) | |
| 2603 | DW.ACCESS.public | |
| 2604 | else if (parent_namespace_ptr.priv_decls.containsContext(nav_index, .{ .zcu = zcu })) | |
| 2605 | DW.ACCESS.private | |
| 2606 | else | |
| 2607 | unreachable, | |
| 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.*; | |
| 2959 | // memoization, not types | |
| 2960 | .memoized_call => unreachable, | |
| 2961 | }; | |
| 2962 | if (tag != .done) { | |
| 2963 | if (nav_gop.found_existing) | |
| 2964 | dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear() | |
| 2965 | else | |
| 2966 | nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit); | |
| 2967 | wip_nav.entry = nav_gop.value_ptr.*; | |
| 2968 | } | |
| 2969 | switch (tag) { | |
| 2970 | .done => {}, | |
| 2971 | .decl_alias => { | |
| 2796 | 2972 | const diw = wip_nav.debug_info.writer(dwarf.gpa); |
| 2797 | 2973 | try wip_nav.abbrevCode(.decl_alias); |
| 2798 | 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 | 2979 | try wip_nav.strp(nav.name.toSlice(ip)); |
| 2804 | 2980 | try wip_nav.refType(nav_val.toType()); |
| 2805 | 2981 | }, |
| 2806 | .union_type => done: { | |
| 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.*; | |
| 2982 | .decl_var => { | |
| 2917 | 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 | 2985 | try wip_nav.refType(Type.fromInterned(parent_type)); |
| 2920 | 2986 | assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf)); |
| 2921 | 2987 | try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian); |
| 2922 | 2988 | try uleb128(diw, loc.column + 1); |
| 2923 | 2989 | try diw.writeByte(accessibility); |
| 2924 | 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: { | |
| 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.*; | |
| 2999 | .decl_const => { | |
| 2993 | 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 | 3002 | try wip_nav.refType(Type.fromInterned(parent_type)); |
| 2996 | 3003 | assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf)); |
| 2997 | 3004 | try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian); |
| 2998 | 3005 | try uleb128(diw, loc.column + 1); |
| 2999 | 3006 | try diw.writeByte(accessibility); |
| 3000 | 3007 | try wip_nav.strp(nav.name.toSlice(ip)); |
| 3001 | try wip_nav.refType(nav_val.toType()); | |
| 3002 | }, | |
| 3003 | else => { | |
| 3004 | _ = dwarf.navs.pop(); | |
| 3005 | return; | |
| 3008 | try wip_nav.strp(nav.fqn.toSlice(ip)); | |
| 3009 | const nav_ty = nav_val.typeOf(zcu); | |
| 3010 | const nav_ty_reloc_index = try wip_nav.refForward(); | |
| 3011 | try wip_nav.blockValue(nav_src_loc, nav_val); | |
| 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 | 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 | } |
| 3011 | 3023 | |
| 3012 | 3024 | fn updateType( |
| 3013 | 3025 | dwarf: *Dwarf, |
| 3014 | 3026 | pt: Zcu.PerThread, |
| 3027 | src_loc: Zcu.LazySrcLoc, | |
| 3015 | 3028 | type_index: InternPool.Index, |
| 3016 | 3029 | pending_types: *std.ArrayListUnmanaged(InternPool.Index), |
| 3017 | 3030 | ) UpdateError!void { |
| ... | ... | @@ -3068,15 +3081,10 @@ fn updateType( |
| 3068 | 3081 | const ptr_child_type = Type.fromInterned(ptr_type.child); |
| 3069 | 3082 | try wip_nav.abbrevCode(if (ptr_type.sentinel == .none) .ptr_type else .ptr_sentinel_type); |
| 3070 | 3083 | try wip_nav.strp(name); |
| 3071 | if (ptr_type.sentinel != .none) { | |
| 3072 | const bytes = ptr_child_type.abiSize(zcu); | |
| 3073 | try uleb128(diw, bytes); | |
| 3074 | const mem = try wip_nav.debug_info.addManyAsSlice(dwarf.gpa, @intCast(bytes)); | |
| 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 | } | |
| 3084 | if (ptr_type.sentinel != .none) try wip_nav.blockValue( | |
| 3085 | src_loc, | |
| 3086 | Value.fromInterned(ptr_type.sentinel), | |
| 3087 | ); | |
| 3080 | 3088 | try uleb128(diw, ptr_type.flags.alignment.toByteUnits() orelse |
| 3081 | 3089 | ptr_child_type.abiAlignment(zcu).toByteUnits().?); |
| 3082 | 3090 | try diw.writeByte(@intFromEnum(ptr_type.flags.address_space)); |
| ... | ... | @@ -3122,15 +3130,10 @@ fn updateType( |
| 3122 | 3130 | const array_child_type = Type.fromInterned(array_type.child); |
| 3123 | 3131 | try wip_nav.abbrevCode(if (array_type.sentinel == .none) .array_type else .array_sentinel_type); |
| 3124 | 3132 | try wip_nav.strp(name); |
| 3125 | if (array_type.sentinel != .none) { | |
| 3126 | const bytes = array_child_type.abiSize(zcu); | |
| 3127 | try uleb128(diw, bytes); | |
| 3128 | const mem = try wip_nav.debug_info.addManyAsSlice(dwarf.gpa, @intCast(bytes)); | |
| 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 | } | |
| 3133 | if (array_type.sentinel != .none) try wip_nav.blockValue( | |
| 3134 | src_loc, | |
| 3135 | Value.fromInterned(array_type.sentinel), | |
| 3136 | ); | |
| 3134 | 3137 | try wip_nav.refType(array_child_type); |
| 3135 | 3138 | try wip_nav.abbrevCode(.array_index); |
| 3136 | 3139 | try wip_nav.refType(Type.usize); |
| ... | ... | @@ -3360,7 +3363,10 @@ fn updateType( |
| 3360 | 3363 | } |
| 3361 | 3364 | const field_type = Type.fromInterned(anon_struct_type.types.get(ip)[field_index]); |
| 3362 | 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 | 3370 | const field_align = field_type.abiAlignment(zcu); |
| 3365 | 3371 | field_byte_offset = field_align.forward(field_byte_offset); |
| 3366 | 3372 | try uleb128(diw, field_byte_offset); |
| ... | ... | @@ -3427,16 +3433,13 @@ fn updateType( |
| 3427 | 3433 | } |
| 3428 | 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)) { | |
| 3431 | .none => { | |
| 3432 | try wip_nav.abbrevCode(.void_type); | |
| 3433 | try wip_nav.strp(name); | |
| 3434 | }, | |
| 3435 | else => |ies| { | |
| 3436 | try wip_nav.abbrevCode(.inferred_error_set_type); | |
| 3437 | try wip_nav.strp(name); | |
| 3438 | try wip_nav.refType(Type.fromInterned(ies)); | |
| 3439 | }, | |
| 3436 | .inferred_error_set_type => |func| { | |
| 3437 | try wip_nav.abbrevCode(.inferred_error_set_type); | |
| 3438 | try wip_nav.strp(name); | |
| 3439 | try wip_nav.refType(Type.fromInterned(switch (ip.funcIesResolvedUnordered(func)) { | |
| 3440 | .none => .anyerror_type, | |
| 3441 | else => |ies| ies, | |
| 3442 | })); | |
| 3440 | 3443 | }, |
| 3441 | 3444 | |
| 3442 | 3445 | // values, not types |
| ... | ... | @@ -3468,6 +3471,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 3468 | 3471 | const zcu = pt.zcu; |
| 3469 | 3472 | const ip = &zcu.intern_pool; |
| 3470 | 3473 | const ty = Type.fromInterned(type_index); |
| 3474 | const ty_src_loc = ty.srcLoc(zcu); | |
| 3471 | 3475 | log.debug("updateContainerType({}({d}))", .{ ty.fmt(pt), @intFromEnum(type_index) }); |
| 3472 | 3476 | |
| 3473 | 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 | 3511 | try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?); |
| 3508 | 3512 | for (0..loaded_struct.field_types.len) |field_index| { |
| 3509 | 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 | 3524 | if (loaded_struct.fieldName(ip, field_index).unwrap()) |field_name| try wip_nav.strp(field_name.toSlice(ip)) else { |
| 3512 | 3525 | const field_name = try std.fmt.allocPrint(dwarf.gpa, "{d}", .{field_index}); |
| 3513 | 3526 | defer dwarf.gpa.free(field_name); |
| 3514 | 3527 | try wip_nav.strp(field_name); |
| 3515 | 3528 | } |
| 3516 | const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]); | |
| 3517 | try wip_nav.refType(field_type); | |
| 3518 | if (!is_comptime) { | |
| 3519 | try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]); | |
| 3520 | try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse | |
| 3521 | field_type.abiAlignment(zcu).toByteUnits().?); | |
| 3529 | if (is_comptime and field_init == .none) { | |
| 3530 | // workaround frontend bug | |
| 3531 | try wip_nav.refType(Type.void); | |
| 3532 | try wip_nav.blockValue(ty_src_loc, Value.void); | |
| 3533 | } else { | |
| 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 | 3544 | try uleb128(diw, @intFromEnum(AbbrevCode.null)); |
| 3525 | 3545 | } |
| 3526 | 3546 | |
| 3527 | 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 | 3549 | } else { |
| 3530 | 3550 | const decl_inst = file.zir.instructions.get(@intFromEnum(inst_info.inst)); |
| 3531 | 3551 | assert(decl_inst.tag == .extended); |
| ... | ... | @@ -3575,18 +3595,34 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 3575 | 3595 | try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?); |
| 3576 | 3596 | for (0..loaded_struct.field_types.len) |field_index| { |
| 3577 | 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 | 3608 | if (loaded_struct.fieldName(ip, field_index).unwrap()) |field_name| try wip_nav.strp(field_name.toSlice(ip)) else { |
| 3580 | 3609 | const field_name = try std.fmt.allocPrint(dwarf.gpa, "{d}", .{field_index}); |
| 3581 | 3610 | defer dwarf.gpa.free(field_name); |
| 3582 | 3611 | try wip_nav.strp(field_name); |
| 3583 | 3612 | } |
| 3584 | const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]); | |
| 3585 | try wip_nav.refType(field_type); | |
| 3586 | if (!is_comptime) { | |
| 3587 | try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]); | |
| 3588 | try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse | |
| 3589 | field_type.abiAlignment(zcu).toByteUnits().?); | |
| 3613 | if (is_comptime and field_init == .none) { | |
| 3614 | // workaround frontend bug | |
| 3615 | try wip_nav.refType(Type.void); | |
| 3616 | try wip_nav.blockValue(ty_src_loc, Value.void); | |
| 3617 | } else { | |
| 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 | 3628 | try uleb128(diw, @intFromEnum(AbbrevCode.null)); |
| ... | ... | @@ -3684,7 +3720,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 3684 | 3720 | } |
| 3685 | 3721 | try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.items); |
| 3686 | 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 | } |
| 3690 | 3726 | |
| ... | ... | @@ -3732,12 +3768,15 @@ fn refAbbrevCode(dwarf: *Dwarf, abbrev_code: AbbrevCode) UpdateError!@typeInfo(A |
| 3732 | 3768 | pub fn flushModule(dwarf: *Dwarf, pt: Zcu.PerThread) FlushError!void { |
| 3733 | 3769 | const zcu = pt.zcu; |
| 3734 | 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 | 3775 | var wip_nav: WipNav = .{ |
| 3737 | 3776 | .dwarf = dwarf, |
| 3738 | 3777 | .pt = pt, |
| 3739 | 3778 | .unit = .main, |
| 3740 | .entry = entry, | |
| 3779 | .entry = type_gop.value_ptr.*, | |
| 3741 | 3780 | .any_children = false, |
| 3742 | 3781 | .func = .none, |
| 3743 | 3782 | .func_sym_index = undefined, |
| ... | ... | @@ -4150,6 +4189,7 @@ const AbbrevCode = enum { |
| 4150 | 4189 | decl_packed_struct, |
| 4151 | 4190 | decl_union, |
| 4152 | 4191 | decl_var, |
| 4192 | decl_const, | |
| 4153 | 4193 | decl_func, |
| 4154 | 4194 | decl_empty_func, |
| 4155 | 4195 | decl_func_generic, |
| ... | ... | @@ -4164,6 +4204,7 @@ const AbbrevCode = enum { |
| 4164 | 4204 | big_enum_field, |
| 4165 | 4205 | generated_field, |
| 4166 | 4206 | struct_field, |
| 4207 | struct_field_default, | |
| 4167 | 4208 | struct_field_comptime, |
| 4168 | 4209 | packed_struct_field, |
| 4169 | 4210 | untagged_union_field, |
| ... | ... | @@ -4285,6 +4326,16 @@ const AbbrevCode = enum { |
| 4285 | 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 | 4339 | .decl_func = .{ |
| 4289 | 4340 | .tag = .subprogram, |
| 4290 | 4341 | .children = true, |
| ... | ... | @@ -4401,12 +4452,23 @@ const AbbrevCode = enum { |
| 4401 | 4452 | .{ .alignment, .udata }, |
| 4402 | 4453 | }, |
| 4403 | 4454 | }, |
| 4404 | .struct_field_comptime = .{ | |
| 4455 | .struct_field_default = .{ | |
| 4405 | 4456 | .tag = .member, |
| 4406 | 4457 | .attrs = &.{ |
| 4407 | 4458 | .{ .name, .strp }, |
| 4408 | 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 | 4468 | .{ .const_expr, .flag_present }, |
| 4469 | .{ .name, .strp }, | |
| 4470 | .{ .type, .ref_addr }, | |
| 4471 | .{ .const_value, .block }, | |
| 4410 | 4472 | }, |
| 4411 | 4473 | }, |
| 4412 | 4474 | .packed_struct_field = .{ |
src/link/Elf/ZigObject.zig+43-20| ... | ... | @@ -957,13 +957,26 @@ pub fn getNavVAddr( |
| 957 | 957 | }; |
| 958 | 958 | const this_sym = self.symbol(this_sym_index); |
| 959 | 959 | const vaddr = this_sym.address(.{}, elf_file); |
| 960 | const parent_atom = self.symbol(reloc_info.parent_atom_index).atom(elf_file).?; | |
| 961 | const r_type = relocation.encode(.abs, elf_file.getTarget().cpu.arch); | |
| 962 | try parent_atom.addReloc(elf_file.base.comp.gpa, .{ | |
| 963 | .r_offset = reloc_info.offset, | |
| 964 | .r_info = (@as(u64, @intCast(this_sym_index)) << 32) | r_type, | |
| 965 | .r_addend = reloc_info.addend, | |
| 966 | }, self); | |
| 960 | switch (reloc_info.parent) { | |
| 961 | .atom_index => |atom_index| { | |
| 962 | const parent_atom = self.symbol(atom_index).atom(elf_file).?; | |
| 963 | const r_type = relocation.encode(.abs, elf_file.getTarget().cpu.arch); | |
| 964 | try parent_atom.addReloc(elf_file.base.comp.gpa, .{ | |
| 965 | .r_offset = reloc_info.offset, | |
| 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 | 980 | return @intCast(vaddr); |
| 968 | 981 | } |
| 969 | 982 | |
| ... | ... | @@ -976,13 +989,26 @@ pub fn getUavVAddr( |
| 976 | 989 | const sym_index = self.uavs.get(uav).?.symbol_index; |
| 977 | 990 | const sym = self.symbol(sym_index); |
| 978 | 991 | const vaddr = sym.address(.{}, elf_file); |
| 979 | const parent_atom = self.symbol(reloc_info.parent_atom_index).atom(elf_file).?; | |
| 980 | const r_type = relocation.encode(.abs, elf_file.getTarget().cpu.arch); | |
| 981 | try parent_atom.addReloc(elf_file.base.comp.gpa, .{ | |
| 982 | .r_offset = reloc_info.offset, | |
| 983 | .r_info = (@as(u64, @intCast(sym_index)) << 32) | r_type, | |
| 984 | .r_addend = reloc_info.addend, | |
| 985 | }, self); | |
| 992 | switch (reloc_info.parent) { | |
| 993 | .atom_index => |atom_index| { | |
| 994 | const parent_atom = self.symbol(atom_index).atom(elf_file).?; | |
| 995 | const r_type = relocation.encode(.abs, elf_file.getTarget().cpu.arch); | |
| 996 | try parent_atom.addReloc(elf_file.base.comp.gpa, .{ | |
| 997 | .r_offset = reloc_info.offset, | |
| 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 | 1012 | return @intCast(vaddr); |
| 987 | 1013 | } |
| 988 | 1014 | |
| ... | ... | @@ -1600,15 +1626,13 @@ pub fn updateNav( |
| 1600 | 1626 | var debug_wip_nav = if (self.dwarf) |*dwarf| try dwarf.initWipNav(pt, nav_index, sym_index) else null; |
| 1601 | 1627 | defer if (debug_wip_nav) |*wip_nav| wip_nav.deinit(); |
| 1602 | 1628 | |
| 1603 | // TODO implement .debug_info for global variables | |
| 1604 | 1629 | const res = try codegen.generateSymbol( |
| 1605 | 1630 | &elf_file.base, |
| 1606 | 1631 | pt, |
| 1607 | 1632 | zcu.navSrcLoc(nav_index), |
| 1608 | 1633 | Value.fromInterned(nav_init), |
| 1609 | 1634 | &code_buffer, |
| 1610 | if (debug_wip_nav) |*wip_nav| .{ .dwarf = wip_nav } else .none, | |
| 1611 | .{ .parent_atom_index = sym_index }, | |
| 1635 | .{ .atom_index = sym_index }, | |
| 1612 | 1636 | ); |
| 1613 | 1637 | |
| 1614 | 1638 | const code = switch (res) { |
| ... | ... | @@ -1691,7 +1715,7 @@ fn updateLazySymbol( |
| 1691 | 1715 | &required_alignment, |
| 1692 | 1716 | &code_buffer, |
| 1693 | 1717 | .none, |
| 1694 | .{ .parent_atom_index = symbol_index }, | |
| 1718 | .{ .atom_index = symbol_index }, | |
| 1695 | 1719 | ); |
| 1696 | 1720 | const code = switch (res) { |
| 1697 | 1721 | .ok => code_buffer.items, |
| ... | ... | @@ -1780,8 +1804,7 @@ fn lowerConst( |
| 1780 | 1804 | src_loc, |
| 1781 | 1805 | val, |
| 1782 | 1806 | &code_buffer, |
| 1783 | .{ .none = {} }, | |
| 1784 | .{ .parent_atom_index = sym_index }, | |
| 1807 | .{ .atom_index = sym_index }, | |
| 1785 | 1808 | ); |
| 1786 | 1809 | const code = switch (res) { |
| 1787 | 1810 | .ok => code_buffer.items, |
src/link/MachO/ZigObject.zig+62-34| ... | ... | @@ -633,20 +633,33 @@ pub fn getNavVAddr( |
| 633 | 633 | }; |
| 634 | 634 | const sym = self.symbols.items[sym_index]; |
| 635 | 635 | const vaddr = sym.getAddress(.{}, macho_file); |
| 636 | const parent_atom = self.symbols.items[reloc_info.parent_atom_index].getAtom(macho_file).?; | |
| 637 | try parent_atom.addReloc(macho_file, .{ | |
| 638 | .tag = .@"extern", | |
| 639 | .offset = @intCast(reloc_info.offset), | |
| 640 | .target = sym_index, | |
| 641 | .addend = reloc_info.addend, | |
| 642 | .type = .unsigned, | |
| 643 | .meta = .{ | |
| 644 | .pcrel = false, | |
| 645 | .has_subtractor = false, | |
| 646 | .length = 3, | |
| 647 | .symbolnum = @intCast(sym.nlist_idx), | |
| 636 | switch (reloc_info.parent) { | |
| 637 | .atom_index => |atom_index| { | |
| 638 | const parent_atom = self.symbols.items[atom_index].getAtom(macho_file).?; | |
| 639 | try parent_atom.addReloc(macho_file, .{ | |
| 640 | .tag = .@"extern", | |
| 641 | .offset = @intCast(reloc_info.offset), | |
| 642 | .target = sym_index, | |
| 643 | .addend = reloc_info.addend, | |
| 644 | .type = .unsigned, | |
| 645 | .meta = .{ | |
| 646 | .pcrel = false, | |
| 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 | 663 | return vaddr; |
| 651 | 664 | } |
| 652 | 665 | |
| ... | ... | @@ -659,20 +672,33 @@ pub fn getUavVAddr( |
| 659 | 672 | const sym_index = self.uavs.get(uav).?.symbol_index; |
| 660 | 673 | const sym = self.symbols.items[sym_index]; |
| 661 | 674 | const vaddr = sym.getAddress(.{}, macho_file); |
| 662 | const parent_atom = self.symbols.items[reloc_info.parent_atom_index].getAtom(macho_file).?; | |
| 663 | try parent_atom.addReloc(macho_file, .{ | |
| 664 | .tag = .@"extern", | |
| 665 | .offset = @intCast(reloc_info.offset), | |
| 666 | .target = sym_index, | |
| 667 | .addend = reloc_info.addend, | |
| 668 | .type = .unsigned, | |
| 669 | .meta = .{ | |
| 670 | .pcrel = false, | |
| 671 | .has_subtractor = false, | |
| 672 | .length = 3, | |
| 673 | .symbolnum = @intCast(sym.nlist_idx), | |
| 675 | switch (reloc_info.parent) { | |
| 676 | .atom_index => |atom_index| { | |
| 677 | const parent_atom = self.symbols.items[atom_index].getAtom(macho_file).?; | |
| 678 | try parent_atom.addReloc(macho_file, .{ | |
| 679 | .tag = .@"extern", | |
| 680 | .offset = @intCast(reloc_info.offset), | |
| 681 | .target = sym_index, | |
| 682 | .addend = reloc_info.addend, | |
| 683 | .type = .unsigned, | |
| 684 | .meta = .{ | |
| 685 | .pcrel = false, | |
| 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 | 702 | return vaddr; |
| 677 | 703 | } |
| 678 | 704 | |
| ... | ... | @@ -903,8 +929,7 @@ pub fn updateNav( |
| 903 | 929 | zcu.navSrcLoc(nav_index), |
| 904 | 930 | Value.fromInterned(nav_init), |
| 905 | 931 | &code_buffer, |
| 906 | if (debug_wip_nav) |*wip_nav| .{ .dwarf = wip_nav } else .none, | |
| 907 | .{ .parent_atom_index = sym_index }, | |
| 932 | .{ .atom_index = sym_index }, | |
| 908 | 933 | ); |
| 909 | 934 | |
| 910 | 935 | const code = switch (res) { |
| ... | ... | @@ -1212,11 +1237,14 @@ fn lowerConst( |
| 1212 | 1237 | const name_str = try self.addString(gpa, name); |
| 1213 | 1238 | const sym_index = try self.newSymbolWithAtom(gpa, name_str, macho_file); |
| 1214 | 1239 | |
| 1215 | const res = try codegen.generateSymbol(&macho_file.base, pt, src_loc, val, &code_buffer, .{ | |
| 1216 | .none = {}, | |
| 1217 | }, .{ | |
| 1218 | .parent_atom_index = sym_index, | |
| 1219 | }); | |
| 1240 | const res = try codegen.generateSymbol( | |
| 1241 | &macho_file.base, | |
| 1242 | pt, | |
| 1243 | src_loc, | |
| 1244 | val, | |
| 1245 | &code_buffer, | |
| 1246 | .{ .atom_index = sym_index }, | |
| 1247 | ); | |
| 1220 | 1248 | const code = switch (res) { |
| 1221 | 1249 | .ok => code_buffer.items, |
| 1222 | 1250 | .fail => |em| return .{ .fail = em }, |
| ... | ... | @@ -1378,7 +1406,7 @@ fn updateLazySymbol( |
| 1378 | 1406 | &required_alignment, |
| 1379 | 1407 | &code_buffer, |
| 1380 | 1408 | .none, |
| 1381 | .{ .parent_atom_index = symbol_index }, | |
| 1409 | .{ .atom_index = symbol_index }, | |
| 1382 | 1410 | ); |
| 1383 | 1411 | const code = switch (res) { |
| 1384 | 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 | 422 | ); |
| 423 | 423 | const code = switch (res) { |
| 424 | 424 | .ok => try code_buffer.toOwnedSlice(), |
| 425 | .fail => |em| { | |
| 426 | try zcu.failed_codegen.put(gpa, func.owner_nav, em); | |
| 427 | return; | |
| 428 | }, | |
| 425 | .fail => |em| return zcu.failed_codegen.put(gpa, func.owner_nav, em), | |
| 429 | 426 | }; |
| 430 | 427 | self.getAtomPtr(atom_idx).code = .{ |
| 431 | 428 | .code_ptr = null, |
| ... | ... | @@ -463,15 +460,17 @@ pub fn updateNav(self: *Plan9, pt: Zcu.PerThread, nav_index: InternPool.Nav.Inde |
| 463 | 460 | var code_buffer = std.ArrayList(u8).init(gpa); |
| 464 | 461 | defer code_buffer.deinit(); |
| 465 | 462 | // 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, .{ | |
| 467 | .parent_atom_index = @intCast(atom_idx), | |
| 468 | }); | |
| 463 | const res = try codegen.generateSymbol( | |
| 464 | &self.base, | |
| 465 | pt, | |
| 466 | zcu.navSrcLoc(nav_index), | |
| 467 | nav_init, | |
| 468 | &code_buffer, | |
| 469 | .{ .atom_index = @intCast(atom_idx) }, | |
| 470 | ); | |
| 469 | 471 | const code = switch (res) { |
| 470 | 472 | .ok => code_buffer.items, |
| 471 | .fail => |em| { | |
| 472 | try zcu.failed_codegen.put(gpa, nav_index, em); | |
| 473 | return; | |
| 474 | }, | |
| 473 | .fail => |em| return zcu.failed_codegen.put(gpa, nav_index, em), | |
| 475 | 474 | }; |
| 476 | 475 | try self.data_nav_table.ensureUnusedCapacity(gpa, 1); |
| 477 | 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 | 1115 | &required_alignment, |
| 1117 | 1116 | &code_buffer, |
| 1118 | 1117 | .none, |
| 1119 | .{ .parent_atom_index = @as(Atom.Index, @intCast(atom_index)) }, | |
| 1118 | .{ .atom_index = @intCast(atom_index) }, | |
| 1120 | 1119 | ); |
| 1121 | 1120 | const code = switch (res) { |
| 1122 | 1121 | .ok => code_buffer.items, |
| ... | ... | @@ -1373,21 +1372,21 @@ pub fn getNavVAddr( |
| 1373 | 1372 | log.debug("getDeclVAddr for {}", .{nav.name.fmt(ip)}); |
| 1374 | 1373 | if (ip.indexToKey(nav.status.resolved.val) == .@"extern") { |
| 1375 | 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 | 1376 | .target = undefined, |
| 1378 | 1377 | .offset = reloc_info.offset, |
| 1379 | 1378 | .addend = reloc_info.addend, |
| 1380 | 1379 | .type = .special_etext, |
| 1381 | 1380 | }); |
| 1382 | 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 | 1383 | .target = undefined, |
| 1385 | 1384 | .offset = reloc_info.offset, |
| 1386 | 1385 | .addend = reloc_info.addend, |
| 1387 | 1386 | .type = .special_edata, |
| 1388 | 1387 | }); |
| 1389 | 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 | 1390 | .target = undefined, |
| 1392 | 1391 | .offset = reloc_info.offset, |
| 1393 | 1392 | .addend = reloc_info.addend, |
| ... | ... | @@ -1400,7 +1399,7 @@ pub fn getNavVAddr( |
| 1400 | 1399 | // otherwise, we just add a relocation |
| 1401 | 1400 | const atom_index = try self.seeNav(pt, nav_index); |
| 1402 | 1401 | // 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 | 1403 | .target = atom_index, |
| 1405 | 1404 | .offset = reloc_info.offset, |
| 1406 | 1405 | .addend = reloc_info.addend, |
| ... | ... | @@ -1435,7 +1434,7 @@ pub fn lowerUav( |
| 1435 | 1434 | gop.value_ptr.* = index; |
| 1436 | 1435 | // we need to free name latex |
| 1437 | 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 | 1438 | const code = switch (res) { |
| 1440 | 1439 | .ok => code_buffer.items, |
| 1441 | 1440 | .fail => |em| return .{ .fail = em }, |
| ... | ... | @@ -1459,7 +1458,7 @@ pub fn lowerUav( |
| 1459 | 1458 | |
| 1460 | 1459 | pub fn getUavVAddr(self: *Plan9, uav: InternPool.Index, reloc_info: link.File.RelocInfo) !u64 { |
| 1461 | 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 | 1462 | .target = atom_index, |
| 1464 | 1463 | .offset = reloc_info.offset, |
| 1465 | 1464 | .addend = reloc_info.addend, |
src/link/Wasm/ZigObject.zig+11-9| ... | ... | @@ -277,8 +277,7 @@ pub fn updateNav( |
| 277 | 277 | zcu.navSrcLoc(nav_index), |
| 278 | 278 | nav_init, |
| 279 | 279 | &code_writer, |
| 280 | .none, | |
| 281 | .{ .parent_atom_index = @intFromEnum(atom.sym_index) }, | |
| 280 | .{ .atom_index = @intFromEnum(atom.sym_index) }, | |
| 282 | 281 | ); |
| 283 | 282 | |
| 284 | 283 | const code = switch (res) { |
| ... | ... | @@ -520,10 +519,7 @@ fn lowerConst( |
| 520 | 519 | src_loc, |
| 521 | 520 | val, |
| 522 | 521 | &value_bytes, |
| 523 | .none, | |
| 524 | .{ | |
| 525 | .parent_atom_index = @intFromEnum(atom.sym_index), | |
| 526 | }, | |
| 522 | .{ .atom_index = @intFromEnum(atom.sym_index) }, | |
| 527 | 523 | ); |
| 528 | 524 | break :code switch (result) { |
| 529 | 525 | .ok => value_bytes.items, |
| ... | ... | @@ -762,8 +758,11 @@ pub fn getNavVAddr( |
| 762 | 758 | else => {}, |
| 763 | 759 | } |
| 764 | 760 | |
| 765 | 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) }).?; | |
| 761 | std.debug.assert(reloc_info.parent.atom_index != 0); | |
| 762 | const atom_index = wasm_file.symbol_atom.get(.{ | |
| 763 | .file = zig_object.index, | |
| 764 | .index = @enumFromInt(reloc_info.parent.atom_index), | |
| 765 | }).?; | |
| 767 | 766 | const atom = wasm_file.getAtomPtr(atom_index); |
| 768 | 767 | const is_wasm32 = target.cpu.arch == .wasm32; |
| 769 | 768 | if (ip.isFunctionType(ip.getNav(nav_index).typeOf(ip))) { |
| ... | ... | @@ -800,7 +799,10 @@ pub fn getUavVAddr( |
| 800 | 799 | const atom_index = zig_object.uavs.get(uav).?; |
| 801 | 800 | const target_symbol_index = @intFromEnum(wasm_file.getAtom(atom_index).sym_index); |
| 802 | 801 | |
| 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 | 806 | const parent_atom = wasm_file.getAtomPtr(parent_atom_index); |
| 805 | 807 | const is_wasm32 = target.cpu.arch == .wasm32; |
| 806 | 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 | 107 | }, |
| 108 | 108 | \\breakpoint set --file basic.zig --source-pattern-regexp '_ = basic;' |
| 109 | 109 | \\process launch |
| 110 | \\frame variable --show-types basic | |
| 110 | \\frame variable --show-types -- basic | |
| 111 | 111 | \\breakpoint delete --force 1 |
| 112 | 112 | , |
| 113 | 113 | &.{ |
| 114 | \\(lldb) frame variable --show-types basic | |
| 114 | \\(lldb) frame variable --show-types -- basic | |
| 115 | 115 | \\(root.basic.Basic) basic = { |
| 116 | 116 | \\ (void) void = {} |
| 117 | 117 | \\ (bool) bool_false = false |
| ... | ... | @@ -243,11 +243,11 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void { |
| 243 | 243 | }, |
| 244 | 244 | \\breakpoint set --file pointers.zig --source-pattern-regexp '_ = pointers;' |
| 245 | 245 | \\process launch |
| 246 | \\frame variable --show-types pointers | |
| 246 | \\frame variable --show-types -- pointers | |
| 247 | 247 | \\breakpoint delete --force 1 |
| 248 | 248 | , |
| 249 | 249 | &.{ |
| 250 | \\(lldb) frame variable --show-types pointers | |
| 250 | \\(lldb) frame variable --show-types -- pointers | |
| 251 | 251 | \\(root.pointers.Pointers) pointers = { |
| 252 | 252 | \\ (*u32) single = 0x0000000000001010 |
| 253 | 253 | \\ (*const u32) single_const = 0x0000000000001014 |
| ... | ... | @@ -330,13 +330,13 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void { |
| 330 | 330 | }, |
| 331 | 331 | \\breakpoint set --file strings.zig --source-pattern-regexp '_ = strings;' |
| 332 | 332 | \\process launch |
| 333 | \\frame variable --show-types strings.slice | |
| 334 | \\frame variable --show-types --format character strings.slice | |
| 335 | \\frame variable --show-types --format c-string strings | |
| 333 | \\frame variable --show-types -- strings.slice | |
| 334 | \\frame variable --show-types --format character -- strings.slice | |
| 335 | \\frame variable --show-types --format c-string -- strings | |
| 336 | 336 | \\breakpoint delete --force 1 |
| 337 | 337 | , |
| 338 | 338 | &.{ |
| 339 | \\(lldb) frame variable --show-types strings.slice | |
| 339 | \\(lldb) frame variable --show-types -- strings.slice | |
| 340 | 340 | \\([:0]const u8) strings.slice = len=9 { |
| 341 | 341 | \\ (u8) [0] = 115 |
| 342 | 342 | \\ (u8) [1] = 108 |
| ... | ... | @@ -348,7 +348,7 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void { |
| 348 | 348 | \\ (u8) [7] = 92 |
| 349 | 349 | \\ (u8) [8] = 0 |
| 350 | 350 | \\} |
| 351 | \\(lldb) frame variable --show-types --format character strings.slice | |
| 351 | \\(lldb) frame variable --show-types --format character -- strings.slice | |
| 352 | 352 | \\([:0]const u8) strings.slice = len=9 { |
| 353 | 353 | \\ (u8) [0] = 's' |
| 354 | 354 | \\ (u8) [1] = 'l' |
| ... | ... | @@ -360,7 +360,7 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void { |
| 360 | 360 | \\ (u8) [7] = '\\' |
| 361 | 361 | \\ (u8) [8] = '\x00' |
| 362 | 362 | \\} |
| 363 | \\(lldb) frame variable --show-types --format c-string strings | |
| 363 | \\(lldb) frame variable --show-types --format c-string -- strings | |
| 364 | 364 | \\(root.strings.Strings) strings = { |
| 365 | 365 | \\ ([*c]const u8) c_ptr = "c_ptr\x07\x08\t" |
| 366 | 366 | \\ ([*:0]const u8) many_ptr = "many_ptr\n\x0b\x0c" |
| ... | ... | @@ -411,11 +411,28 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void { |
| 411 | 411 | }, |
| 412 | 412 | \\breakpoint set --file enums.zig --source-pattern-regexp '_ = enums;' |
| 413 | 413 | \\process launch |
| 414 | \\frame variable --show-types enums | |
| 414 | \\expression --show-types -- Enums | |
| 415 | \\frame variable --show-types -- enums | |
| 415 | 416 | \\breakpoint delete --force 1 |
| 416 | 417 | , |
| 417 | 418 | &.{ |
| 418 | \\(lldb) frame variable --show-types enums | |
| 419 | \\(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 | 436 | \\(root.enums.Enums) enums = { |
| 420 | 437 | \\ (root.enums.Enums.Zero) zero = @enumFromInt(13) |
| 421 | 438 | \\ (root.enums.Enums.One) one = .first |
| ... | ... | @@ -434,12 +451,17 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void { |
| 434 | 451 | .path = "errors.zig", |
| 435 | 452 | .source = |
| 436 | 453 | \\const Errors = struct { |
| 437 | \\ one: error{One} = error.One, | |
| 438 | \\ two: error{One,Two} = error.Two, | |
| 439 | \\ three: error{One,Two,Three} = error.Three, | |
| 454 | \\ const Zero = error{}; | |
| 455 | \\ const One = Zero || error{One}; | |
| 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 | 462 | \\ any: anyerror = error.Any, |
| 441 | 463 | \\ any_void: anyerror!void = error.NotVoid, |
| 442 | \\ any_u32: error{One}!u32 = 42, | |
| 464 | \\ any_u32: One!u32 = 42, | |
| 443 | 465 | \\}; |
| 444 | 466 | \\fn testErrors(errors: Errors) void { |
| 445 | 467 | \\ _ = errors; |
| ... | ... | @@ -453,11 +475,28 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void { |
| 453 | 475 | }, |
| 454 | 476 | \\breakpoint set --file errors.zig --source-pattern-regexp '_ = errors;' |
| 455 | 477 | \\process launch |
| 456 | \\frame variable --show-types errors | |
| 478 | \\expression --show-types -- Errors | |
| 479 | \\frame variable --show-types -- errors | |
| 457 | 480 | \\breakpoint delete --force 1 |
| 458 | 481 | , |
| 459 | 482 | &.{ |
| 460 | \\(lldb) frame variable --show-types errors | |
| 483 | \\(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 | 500 | \\(root.errors.Errors) errors = { |
| 462 | 501 | \\ (error{One}) one = error.One |
| 463 | 502 | \\ (error{One,Two}) two = error.Two |
| ... | ... | @@ -496,23 +535,23 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void { |
| 496 | 535 | }, |
| 497 | 536 | \\breakpoint set --file optionals.zig --source-pattern-regexp 'maybe_u32 = 123;' |
| 498 | 537 | \\process launch |
| 499 | \\frame variable null_u32 maybe_u32 nonnull_u32 | |
| 538 | \\frame variable -- null_u32 maybe_u32 nonnull_u32 | |
| 500 | 539 | \\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 | 542 | \\process continue |
| 504 | \\frame variable --show-types null_u32 maybe_u32 nonnull_u32 | |
| 543 | \\frame variable --show-types -- null_u32 maybe_u32 nonnull_u32 | |
| 505 | 544 | \\breakpoint delete --force 2 |
| 506 | 545 | , |
| 507 | 546 | &.{ |
| 508 | \\(lldb) frame variable null_u32 maybe_u32 nonnull_u32 | |
| 547 | \\(lldb) frame variable -- null_u32 maybe_u32 nonnull_u32 | |
| 509 | 548 | \\(?u32) null_u32 = null |
| 510 | 549 | \\(?u32) maybe_u32 = null |
| 511 | 550 | \\(?u32) nonnull_u32 = (nonnull_u32.? = 456) |
| 512 | 551 | \\(lldb) breakpoint delete --force 1 |
| 513 | 552 | \\1 breakpoints deleted; 0 breakpoint locations disabled. |
| 514 | 553 | , |
| 515 | \\(lldb) frame variable --show-types null_u32 maybe_u32 nonnull_u32 | |
| 554 | \\(lldb) frame variable --show-types -- null_u32 maybe_u32 nonnull_u32 | |
| 516 | 555 | \\(?u32) null_u32 = null |
| 517 | 556 | \\(?u32) maybe_u32 = { |
| 518 | 557 | \\ (u32) maybe_u32.? = 123 |
| ... | ... | @@ -565,11 +604,31 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void { |
| 565 | 604 | }, |
| 566 | 605 | \\breakpoint set --file unions.zig --source-pattern-regexp '_ = unions;' |
| 567 | 606 | \\process launch |
| 568 | \\frame variable --show-types unions | |
| 607 | \\expression --show-types -- Unions | |
| 608 | \\frame variable --show-types -- unions | |
| 569 | 609 | \\breakpoint delete --force 1 |
| 570 | 610 | , |
| 571 | 611 | &.{ |
| 572 | \\(lldb) frame variable --show-types unions | |
| 612 | \\(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 | 632 | \\(root.unions.Unions) unions = { |
| 574 | 633 | \\ (root.unions.Unions.Untagged) untagged = { |
| 575 | 634 | \\ (u32) u32 = 3217031168 |
| ... | ... | @@ -635,17 +694,17 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void { |
| 635 | 694 | }, |
| 636 | 695 | \\breakpoint set --file storage.zig --source-pattern-regexp 'local_var = local_var;' |
| 637 | 696 | \\process launch |
| 638 | \\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_var | |
| 697 | \\target variable --show-types --format hex -- global_const global_var global_threadlocal1 global_threadlocal2 | |
| 698 | \\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 | 699 | \\breakpoint delete --force 1 |
| 641 | 700 | , |
| 642 | 701 | &.{ |
| 643 | \\(lldb) target variable --show-types --format hex global_const global_var global_threadlocal1 global_threadlocal2 | |
| 702 | \\(lldb) target variable --show-types --format hex -- global_const global_var global_threadlocal1 global_threadlocal2 | |
| 644 | 703 | \\(u64) global_const = 0x19e50dc8d6002077 |
| 645 | 704 | \\(u64) global_var = 0xcc423cec08622e32 |
| 646 | 705 | \\(u64) global_threadlocal1 = 0xb4d643528c042121 |
| 647 | 706 | \\(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_var | |
| 707 | \\(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 | 708 | \\(u64) param1 = 0x6a607e08125c7e00 |
| 650 | 709 | \\(u64) param2 = 0x98944cb2a45a8b51 |
| 651 | 710 | \\(u64) param3 = 0xa320cf10601ee6fb |
| ... | ... | @@ -1240,31 +1299,536 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void { |
| 1240 | 1299 | \\ x = fabsf(x); |
| 1241 | 1300 | \\ _ = &x; |
| 1242 | 1301 | \\} |
| 1302 | \\ | |
| 1243 | 1303 | , |
| 1244 | 1304 | }, |
| 1245 | 1305 | }, |
| 1246 | 1306 | \\breakpoint set --file main.zig --source-pattern-regexp 'x = fabsf\(x\);' |
| 1247 | 1307 | \\process launch |
| 1248 | \\frame variable x | |
| 1308 | \\frame variable -- x | |
| 1249 | 1309 | \\breakpoint delete --force 1 |
| 1250 | 1310 | \\ |
| 1251 | 1311 | \\breakpoint set --file main.zig --source-pattern-regexp '_ = &x;' |
| 1252 | 1312 | \\process continue |
| 1253 | \\frame variable x | |
| 1313 | \\frame variable -- x | |
| 1254 | 1314 | \\breakpoint delete --force 2 |
| 1255 | 1315 | , |
| 1256 | 1316 | &.{ |
| 1257 | \\(lldb) frame variable x | |
| 1317 | \\(lldb) frame variable -- x | |
| 1258 | 1318 | \\(f32) x = -1234.5 |
| 1259 | 1319 | \\(lldb) breakpoint delete --force 1 |
| 1260 | 1320 | \\1 breakpoints deleted; 0 breakpoint locations disabled. |
| 1261 | 1321 | , |
| 1262 | \\(lldb) frame variable x | |
| 1322 | \\(lldb) frame variable -- x | |
| 1263 | 1323 | \\(f32) x = 1234.5 |
| 1264 | 1324 | \\(lldb) breakpoint delete --force 2 |
| 1265 | 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 | } |
| 1269 | 1833 | |
| 1270 | 1834 | const File = struct { import: ?[]const u8 = null, path: []const u8, source: []const u8 }; |