authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2026-05-29 16:39:23-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-06-02 19:48:53+02:00
log3a0d766fc3e86dc9dd9d28ffcc34d8b0ab911173
tree93ae4f4df25a1a103540e0750ca9ed273670ae65
parent872629b78e434392f65ff2cb566a1538885e520f

lldb: simplify some abbrevs, test simple type names


5 files changed, 248 insertions(+), 246 deletions(-)

ci/x86_64-linux-debug-llvm.sh+1-1
...@@ -50,7 +50,7 @@ stage3-debug/bin/zig build \...@@ -50,7 +50,7 @@ stage3-debug/bin/zig build \
5050
51stage3-debug/bin/zig build test docs \51stage3-debug/bin/zig build test docs \
52 --maxrss ${ZSF_MAX_RSS:-0} \52 --maxrss ${ZSF_MAX_RSS:-0} \
53 -Dlldb=$HOME/deps/lldb-zig/Debug-ccb7ae89a9/bin/lldb \53 -Dlldb=$HOME/deps/lldb-zig/Debug-7c1090fd46/bin/lldb \
54 -Dlibc-test-path=$HOME/deps/libc-test-f2bac77 \54 -Dlibc-test-path=$HOME/deps/libc-test-f2bac77 \
55 -fqemu \55 -fqemu \
56 --libc-runtimes $HOME/deps/glibc-2.43-musl-1.2.5 \56 --libc-runtimes $HOME/deps/glibc-2.43-musl-1.2.5 \
ci/x86_64-linux-debug.sh+1-1
...@@ -50,7 +50,7 @@ stage3-debug/bin/zig build \...@@ -50,7 +50,7 @@ stage3-debug/bin/zig build \
50stage3-debug/bin/zig build test docs \50stage3-debug/bin/zig build test docs \
51 --maker-opt=Debug \51 --maker-opt=Debug \
52 --maxrss ${ZSF_MAX_RSS:-0} \52 --maxrss ${ZSF_MAX_RSS:-0} \
53 -Dlldb=$HOME/deps/lldb-zig/Debug-ccb7ae89a9/bin/lldb \53 -Dlldb=$HOME/deps/lldb-zig/Debug-7c1090fd46/bin/lldb \
54 -fqemu \54 -fqemu \
55 --libc-runtimes $HOME/deps/glibc-2.43-musl-1.2.5 \55 --libc-runtimes $HOME/deps/glibc-2.43-musl-1.2.5 \
56 -fwasmtime \56 -fwasmtime \
ci/x86_64-linux-release.sh+1-1
...@@ -58,7 +58,7 @@ stage3-release/bin/zig build \...@@ -58,7 +58,7 @@ stage3-release/bin/zig build \
5858
59stage3-release/bin/zig build test docs \59stage3-release/bin/zig build test docs \
60 --maxrss ${ZSF_MAX_RSS:-0} \60 --maxrss ${ZSF_MAX_RSS:-0} \
61 -Dlldb=$HOME/deps/lldb-zig/Release-ccb7ae89a9/bin/lldb \61 -Dlldb=$HOME/deps/lldb-zig/Release-7c1090fd46/bin/lldb \
62 -Dlibc-test-path=$HOME/deps/libc-test-f2bac77 \62 -Dlibc-test-path=$HOME/deps/libc-test-f2bac77 \
63 -fqemu \63 -fqemu \
64 --libc-runtimes $HOME/deps/glibc-2.43-musl-1.2.5 \64 --libc-runtimes $HOME/deps/glibc-2.43-musl-1.2.5 \
src/link/Dwarf.zig+174-240
...@@ -2124,30 +2124,19 @@ pub const WipNav = struct {...@@ -2124,30 +2124,19 @@ pub const WipNav = struct {
2124 }2124 }
2125 }2125 }
21262126
2127 const AbbrevCodeForForm = struct {2127 fn bigIntConstValue(wip_nav: *WipNav, ty: Type, big_int: std.math.big.int.Const) (UpdateError || Writer.Error)!void {
2128 sdata: AbbrevCode,
2129 udata: AbbrevCode,
2130 block: AbbrevCode,
2131 };
2132
2133 fn bigIntConstValue(
2134 wip_nav: *WipNav,
2135 abbrev_code: AbbrevCodeForForm,
2136 ty: Type,
2137 big_int: std.math.big.int.Const,
2138 ) (UpdateError || Writer.Error)!void {
2139 const zcu = wip_nav.pt.zcu;2128 const zcu = wip_nav.pt.zcu;
2140 const diw = &wip_nav.debug_info.writer;2129 const diw = &wip_nav.debug_info.writer;
2141 const signedness = switch (ty.toIntern()) {2130 const signedness = switch (ty.toIntern()) {
2142 .comptime_int_type, .comptime_float_type => .signed,2131 .comptime_int_type => .signed,
2143 else => ty.intInfo(zcu).signedness,2132 else => ty.intInfo(zcu).signedness,
2144 };2133 };
2145 const bits = @max(1, big_int.bitCountTwosCompForSignedness(signedness));2134 const bits = @max(1, big_int.bitCountTwosCompForSignedness(signedness));
2146 if (bits <= 64) {2135 if (bits <= 64) {
2147 try wip_nav.abbrevCode(switch (signedness) {2136 try diw.writeUleb128(@as(u13, switch (signedness) {
2148 .signed => abbrev_code.sdata,2137 .signed => DW.FORM.sdata,
2149 .unsigned => abbrev_code.udata,2138 .unsigned => DW.FORM.udata,
2150 });2139 }));
2151 try wip_nav.debug_info.ensureUnusedCapacity(std.math.divCeil(usize, bits, 7) catch unreachable);2140 try wip_nav.debug_info.ensureUnusedCapacity(std.math.divCeil(usize, bits, 7) catch unreachable);
2152 var bit: usize = 0;2141 var bit: usize = 0;
2153 var carry: u1 = 1;2142 var carry: u1 = 1;
...@@ -2168,7 +2157,7 @@ pub const WipNav = struct {...@@ -2168,7 +2157,7 @@ pub const WipNav = struct {
2168 diw.writeByte(@as(u8, if (bit < bits) 0x80 else 0x00) | twos_comp_part) catch unreachable;2157 diw.writeByte(@as(u8, if (bit < bits) 0x80 else 0x00) | twos_comp_part) catch unreachable;
2169 }2158 }
2170 } else {2159 } else {
2171 try wip_nav.abbrevCode(abbrev_code.block);2160 try diw.writeUleb128(DW.FORM.block);
2172 const bytes = @max(ty.abiSize(zcu), std.math.divCeil(usize, bits, 8) catch unreachable);2161 const bytes = @max(ty.abiSize(zcu), std.math.divCeil(usize, bits, 8) catch unreachable);
2173 try diw.writeUleb128(bytes);2162 try diw.writeUleb128(bytes);
2174 try wip_nav.debug_info.ensureUnusedCapacity(@intCast(bytes));2163 try wip_nav.debug_info.ensureUnusedCapacity(@intCast(bytes));
...@@ -2179,16 +2168,11 @@ pub const WipNav = struct {...@@ -2179,16 +2168,11 @@ pub const WipNav = struct {
2179 }2168 }
2180 }2169 }
21812170
2182 fn enumConstValue(2171 fn enumConstValue(wip_nav: *WipNav, loaded_enum: InternPool.LoadedEnumType, field_index: usize) (UpdateError || Writer.Error)!void {
2183 wip_nav: *WipNav,
2184 loaded_enum: InternPool.LoadedEnumType,
2185 abbrev_code: AbbrevCodeForForm,
2186 field_index: usize,
2187 ) (UpdateError || Writer.Error)!void {
2188 const zcu = wip_nav.pt.zcu;2172 const zcu = wip_nav.pt.zcu;
2189 const ip = &zcu.intern_pool;2173 const ip = &zcu.intern_pool;
2190 var big_int_space: Value.BigIntSpace = undefined;2174 var big_int_space: Value.BigIntSpace = undefined;
2191 try wip_nav.bigIntConstValue(abbrev_code, .fromInterned(loaded_enum.int_tag_type), if (loaded_enum.field_values.len > 0)2175 try wip_nav.bigIntConstValue(.fromInterned(loaded_enum.int_tag_type), if (loaded_enum.field_values.len > 0)
2192 Value.fromInterned(loaded_enum.field_values.get(ip)[field_index]).toBigInt(&big_int_space, zcu)2176 Value.fromInterned(loaded_enum.field_values.get(ip)[field_index]).toBigInt(&big_int_space, zcu)
2193 else2177 else
2194 std.math.big.int.Mutable.init(&big_int_space.limbs, field_index).toConst());2178 std.math.big.int.Mutable.init(&big_int_space.limbs, field_index).toConst());
...@@ -2814,7 +2798,11 @@ fn initWipNavInner(...@@ -2814,7 +2798,11 @@ fn initWipNavInner(
2814 const diw = &wip_nav.debug_info.writer;2798 const diw = &wip_nav.debug_info.writer;
2815 try wip_nav.declCommon(.{2799 try wip_nav.declCommon(.{
2816 .decl = .decl_var,2800 .decl = .decl_var,
2817 .generic_decl = .generic_decl_var,2801 .generic_decl = switch (decl.kind) {
2802 .unnamed_test, .@"test", .decltest, .@"comptime" => unreachable,
2803 .@"const" => .generic_decl_const,
2804 .@"var" => .generic_decl_var,
2805 },
2818 .decl_instance = .decl_instance_var,2806 .decl_instance = .decl_instance_var,
2819 }, &nav, inst_info.file, &decl);2807 }, &nav, inst_info.file, &decl);
2820 try wip_nav.strp(switch (decl.linkage) {2808 try wip_nav.strp(switch (decl.linkage) {
...@@ -3672,7 +3660,8 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co...@@ -3672,7 +3660,8 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
3672 },3660 },
3673 }3661 }
36743662
3675 try wip_nav.abbrevCode(.unsigned_tagged_union_field);3663 try wip_nav.abbrevCode(.tagged_union_field);
3664 try diw.writeUleb128(DW.FORM.udata);
3676 try diw.writeUleb128(0);3665 try diw.writeUleb128(0);
3677 {3666 {
3678 try wip_nav.abbrevCode(.generated_field);3667 try wip_nav.abbrevCode(.generated_field);
...@@ -3736,7 +3725,8 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co...@@ -3736,7 +3725,8 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
3736 } })));3725 } })));
3737 try diw.writeUleb128(error_union_error_set_offset);3726 try diw.writeUleb128(error_union_error_set_offset);
37383727
3739 try wip_nav.abbrevCode(.unsigned_tagged_union_field);3728 try wip_nav.abbrevCode(.tagged_union_field);
3729 try diw.writeUleb128(DW.FORM.udata);
3740 try diw.writeUleb128(0);3730 try diw.writeUleb128(0);
3741 {3731 {
3742 try wip_nav.abbrevCode(.generated_field);3732 try wip_nav.abbrevCode(.generated_field);
...@@ -3833,13 +3823,13 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co...@@ -3833,13 +3823,13 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
3833 else => .{ field_type.hasRuntimeBits(zcu), field_type.comptimeOnly(zcu) },3823 else => .{ field_type.hasRuntimeBits(zcu), field_type.comptimeOnly(zcu) },
3834 };3824 };
3835 try wip_nav.abbrevCode(if (has_comptime_state)3825 try wip_nav.abbrevCode(if (has_comptime_state)
3836 .struct_field_comptime_comptime_state3826 .field_comptime_comptime_state
3837 else if (has_runtime_bits)3827 else if (has_runtime_bits)
3838 .struct_field_comptime_runtime_bits3828 .field_comptime_runtime_bits
3839 else if (comptime_value != .none)3829 else if (comptime_value != .none)
3840 .struct_field_comptime3830 .field_comptime
3841 else3831 else
3842 .struct_field);3832 .field);
3843 {3833 {
3844 var field_name_buf: [std.fmt.count("{d}", .{std.math.maxInt(u32)})]u8 = undefined;3834 var field_name_buf: [std.fmt.count("{d}", .{std.math.maxInt(u32)})]u8 = undefined;
3845 const field_name = std.fmt.bufPrint(&field_name_buf, "{d}", .{field_index}) catch unreachable;3835 const field_name = std.fmt.bufPrint(&field_name_buf, "{d}", .{field_index}) catch unreachable;
...@@ -3919,20 +3909,20 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co...@@ -3919,20 +3909,20 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
3919 };3909 };
3920 try wip_nav.abbrevCode(if (is_comptime)3910 try wip_nav.abbrevCode(if (is_comptime)
3921 if (has_comptime_state)3911 if (has_comptime_state)
3922 .struct_field_comptime_comptime_state3912 .field_comptime_comptime_state
3923 else if (has_runtime_bits)3913 else if (has_runtime_bits)
3924 .struct_field_comptime_runtime_bits3914 .field_comptime_runtime_bits
3925 else3915 else
3926 .struct_field_comptime3916 .field_comptime
3927 else if (field_init != .none)3917 else if (field_init != .none)
3928 if (has_comptime_state)3918 if (has_comptime_state)
3929 .struct_field_default_comptime_state3919 .field_default_comptime_state
3930 else if (has_runtime_bits)3920 else if (has_runtime_bits)
3931 .struct_field_default_runtime_bits3921 .field_default_runtime_bits
3932 else3922 else
3933 .struct_field3923 .field
3934 else3924 else
3935 .struct_field);3925 .field);
3936 try wip_nav.strp(loaded_struct.field_names.get(ip)[field_index].toSlice(ip));3926 try wip_nav.strp(loaded_struct.field_names.get(ip)[field_index].toSlice(ip));
3937 try wip_nav.refType(field_type);3927 try wip_nav.refType(field_type);
3938 if (!is_comptime) {3928 if (!is_comptime) {
...@@ -3969,7 +3959,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co...@@ -3969,7 +3959,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
3969 try wip_nav.refType(.fromInterned(loaded_struct.packed_backing_int_type));3959 try wip_nav.refType(.fromInterned(loaded_struct.packed_backing_int_type));
3970 var field_bit_offset: u16 = 0;3960 var field_bit_offset: u16 = 0;
3971 for (0..loaded_struct.field_types.len) |field_index| {3961 for (0..loaded_struct.field_types.len) |field_index| {
3972 try wip_nav.abbrevCode(.packed_struct_field);3962 try wip_nav.abbrevCode(.packed_field);
3973 try wip_nav.strp(loaded_struct.field_names.get(ip)[field_index].toSlice(ip));3963 try wip_nav.strp(loaded_struct.field_names.get(ip)[field_index].toSlice(ip));
3974 const field_type: Type = .fromInterned(loaded_struct.field_types.get(ip)[field_index]);3964 const field_type: Type = .fromInterned(loaded_struct.field_types.get(ip)[field_index]);
3975 try wip_nav.refType(field_type);3965 try wip_nav.refType(field_type);
...@@ -3983,6 +3973,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co...@@ -3983,6 +3973,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
3983 .union_type => {3973 .union_type => {
3984 const loaded_union = ip.loadUnionType(value_index);3974 const loaded_union = ip.loadUnionType(value_index);
3985 const file = loaded_union.zir_index.resolveFile(ip);3975 const file = loaded_union.zir_index.resolveFile(ip);
3976 const loaded_tag = ip.loadEnumType(loaded_union.enum_tag_type);
3986 switch (loaded_union.layout) {3977 switch (loaded_union.layout) {
3987 .auto, .@"extern" => {3978 .auto, .@"extern" => {
3988 const need_terminator: bool = if (loaded_union.name_nav.unwrap()) |nav_index| t: {3979 const need_terminator: bool = if (loaded_union.name_nav.unwrap()) |nav_index| t: {
...@@ -4005,7 +3996,6 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co...@@ -4005,7 +3996,6 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
4005 const union_layout = Type.getUnionLayout(loaded_union, zcu);3996 const union_layout = Type.getUnionLayout(loaded_union, zcu);
4006 try diw.writeUleb128(union_layout.abi_size);3997 try diw.writeUleb128(union_layout.abi_size);
4007 try diw.writeUleb128(union_layout.abi_align.toByteUnits().?);3998 try diw.writeUleb128(union_layout.abi_align.toByteUnits().?);
4008 const loaded_tag = ip.loadEnumType(loaded_union.enum_tag_type);
4009 if (loaded_union.has_runtime_tag) {3999 if (loaded_union.has_runtime_tag) {
4010 try wip_nav.abbrevCode(.tagged_union);4000 try wip_nav.abbrevCode(.tagged_union);
4011 try wip_nav.infoSectionOffset(4001 try wip_nav.infoSectionOffset(
...@@ -4021,13 +4011,10 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co...@@ -4021,13 +4011,10 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
4021 try diw.writeUleb128(union_layout.tagOffset());4011 try diw.writeUleb128(union_layout.tagOffset());
40224012
4023 for (0..loaded_union.field_types.len) |field_index| {4013 for (0..loaded_union.field_types.len) |field_index| {
4024 try wip_nav.enumConstValue(loaded_tag, .{4014 try wip_nav.abbrevCode(.tagged_union_field);
4025 .sdata = .signed_tagged_union_field,4015 try wip_nav.enumConstValue(loaded_tag, field_index);
4026 .udata = .unsigned_tagged_union_field,
4027 .block = .big_tagged_union_field,
4028 }, field_index);
4029 {4016 {
4030 try wip_nav.abbrevCode(.struct_field);4017 try wip_nav.abbrevCode(.field);
4031 try wip_nav.strp(loaded_tag.field_names.get(ip)[field_index].toSlice(ip));4018 try wip_nav.strp(loaded_tag.field_names.get(ip)[field_index].toSlice(ip));
4032 const field_type: Type = .fromInterned(loaded_union.field_types.get(ip)[field_index]);4019 const field_type: Type = .fromInterned(loaded_union.field_types.get(ip)[field_index]);
4033 try wip_nav.refType(field_type);4020 try wip_nav.refType(field_type);
...@@ -4040,27 +4027,42 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co...@@ -4040,27 +4027,42 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
4040 }4027 }
4041 try diw.writeUleb128(@intFromEnum(AbbrevCode.null));4028 try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
4042 } else for (0..loaded_union.field_types.len) |field_index| {4029 } else for (0..loaded_union.field_types.len) |field_index| {
4043 try wip_nav.abbrevCode(.untagged_union_field);4030 try wip_nav.abbrevCode(.field);
4044 try wip_nav.strp(loaded_tag.field_names.get(ip)[field_index].toSlice(ip));4031 try wip_nav.strp(loaded_tag.field_names.get(ip)[field_index].toSlice(ip));
4045 const field_type: Type = .fromInterned(loaded_union.field_types.get(ip)[field_index]);4032 const field_type: Type = .fromInterned(loaded_union.field_types.get(ip)[field_index]);
4046 try wip_nav.refType(field_type);4033 try wip_nav.refType(field_type);
4034 try diw.writeUleb128(0);
4047 try diw.writeUleb128(loaded_union.field_aligns.getOrNone(ip, field_index).toByteUnits() orelse4035 try diw.writeUleb128(loaded_union.field_aligns.getOrNone(ip, field_index).toByteUnits() orelse
4048 if (field_type.isNoReturn(zcu)) 1 else field_type.abiAlignment(zcu).toByteUnits().?);4036 if (field_type.isNoReturn(zcu)) 1 else field_type.abiAlignment(zcu).toByteUnits().?);
4049 }4037 }
4050 if (need_terminator) try diw.writeUleb128(@intFromEnum(AbbrevCode.null));4038 if (need_terminator) try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
4051 },4039 },
4052 .@"packed" => {4040 .@"packed" => {
4053 // TODO: debug info for packed unions4041 const need_terminator: bool = if (loaded_union.name_nav.unwrap()) |nav_index| t: {
4054 try wip_nav.abbrevCode(.numeric_type);4042 const nav = ip.getNav(nav_index);
4055 try wip_nav.strp(loaded_union.name.toSlice(ip));4043 const decl_inst = nav.srcInst(ip).resolve(ip).?;
4056 const backing_int_ty: Type = .fromInterned(loaded_union.packed_backing_int_type);4044 const decl = zcu.fileByIndex(file).zir.?.getDeclaration(decl_inst);
4057 const int_info = backing_int_ty.intInfo(zcu);4045 try wip_nav.declCommon(.{
4058 try diw.writeByte(switch (int_info.signedness) {4046 .decl = .decl_packed_union,
4059 inline .signed, .unsigned => |signedness| @field(DW.ATE, @tagName(signedness)),4047 .generic_decl = .generic_decl_const,
4060 });4048 .decl_instance = .decl_instance_packed_union,
4061 try diw.writeUleb128(int_info.bits);4049 }, &nav, file, &decl);
4062 try diw.writeUleb128(backing_int_ty.abiSize(zcu));4050 break :t true;
4063 try diw.writeUleb128(backing_int_ty.abiAlignment(zcu).toByteUnits().?);4051 } else t: {
4052 const file_gop = try dwarf.getModInfo(unit).files.getOrPut(dwarf.gpa, file);
4053 try wip_nav.abbrevCode(if (loaded_union.field_types.len > 0) .packed_union_type else .empty_packed_union_type);
4054 try diw.writeUleb128(file_gop.index);
4055 try wip_nav.strp(loaded_union.name.toSlice(ip));
4056 break :t loaded_union.field_types.len > 0;
4057 };
4058 try wip_nav.refType(.fromInterned(loaded_union.packed_backing_int_type));
4059 for (0..loaded_union.field_types.len) |field_index| {
4060 try wip_nav.abbrevCode(.packed_field);
4061 try wip_nav.strp(loaded_tag.field_names.get(ip)[field_index].toSlice(ip));
4062 try wip_nav.refType(.fromInterned(loaded_union.field_types.get(ip)[field_index]));
4063 try diw.writeUleb128(0);
4064 }
4065 if (need_terminator) try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
4064 },4066 },
4065 }4067 }
4066 },4068 },
...@@ -4090,11 +4092,8 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co...@@ -4090,11 +4092,8 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
4090 }4092 }
4091 try wip_nav.refType(.fromInterned(loaded_enum.int_tag_type));4093 try wip_nav.refType(.fromInterned(loaded_enum.int_tag_type));
4092 for (0..loaded_enum.field_names.len) |field_index| {4094 for (0..loaded_enum.field_names.len) |field_index| {
4093 try wip_nav.enumConstValue(loaded_enum, .{4095 try wip_nav.abbrevCode(.enum_field);
4094 .sdata = .signed_enum_field,4096 try wip_nav.enumConstValue(loaded_enum, field_index);
4095 .udata = .unsigned_enum_field,
4096 .block = .big_enum_field,
4097 }, field_index);
4098 try wip_nav.strp(loaded_enum.field_names.get(ip)[field_index].toSlice(ip));4097 try wip_nav.strp(loaded_enum.field_names.get(ip)[field_index].toSlice(ip));
4099 }4098 }
4100 if (loaded_enum.field_names.len > 0) try diw.writeUleb128(@intFromEnum(AbbrevCode.null));4099 if (loaded_enum.field_names.len > 0) try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
...@@ -4104,11 +4103,8 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co...@@ -4104,11 +4103,8 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
4104 try wip_nav.strp(loaded_enum.name.toSlice(ip));4103 try wip_nav.strp(loaded_enum.name.toSlice(ip));
4105 try wip_nav.refType(.fromInterned(loaded_enum.int_tag_type));4104 try wip_nav.refType(.fromInterned(loaded_enum.int_tag_type));
4106 for (0..loaded_enum.field_names.len) |field_index| {4105 for (0..loaded_enum.field_names.len) |field_index| {
4107 try wip_nav.enumConstValue(loaded_enum, .{4106 try wip_nav.abbrevCode(.enum_field);
4108 .sdata = .signed_enum_field,4107 try wip_nav.enumConstValue(loaded_enum, field_index);
4109 .udata = .unsigned_enum_field,
4110 .block = .big_enum_field,
4111 }, field_index);
4112 try wip_nav.strp(loaded_enum.field_names.get(ip)[field_index].toSlice(ip));4108 try wip_nav.strp(loaded_enum.field_names.get(ip)[field_index].toSlice(ip));
4113 }4109 }
4114 if (loaded_enum.field_names.len > 0) try diw.writeUleb128(@intFromEnum(AbbrevCode.null));4110 if (loaded_enum.field_names.len > 0) try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
...@@ -4226,7 +4222,8 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co...@@ -4226,7 +4222,8 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
4226 } })));4222 } })));
4227 for (0..error_set_type.names.len) |field_index| {4223 for (0..error_set_type.names.len) |field_index| {
4228 const field_name = error_set_type.names.get(ip)[field_index];4224 const field_name = error_set_type.names.get(ip)[field_index];
4229 try wip_nav.abbrevCode(.unsigned_enum_field);4225 try wip_nav.abbrevCode(.enum_field);
4226 try diw.writeUleb128(DW.FORM.udata);
4230 try diw.writeUleb128(ip.getErrorValueIfExists(field_name).?);4227 try diw.writeUleb128(ip.getErrorValueIfExists(field_name).?);
4231 try wip_nav.strp(field_name.toSlice(ip));4228 try wip_nav.strp(field_name.toSlice(ip));
4232 }4229 }
...@@ -4256,29 +4253,24 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co...@@ -4256,29 +4253,24 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
4256 },4253 },
4257 },4254 },
4258 .int => |int| {4255 .int => |int| {
4259 try wip_nav.bigIntConstValue(.{4256 try wip_nav.abbrevCode(.comptime_value);
4260 .sdata = .sdata_comptime_value,
4261 .udata = .udata_comptime_value,
4262 .block = .block_comptime_value,
4263 }, .fromInterned(int.ty), Value.fromInterned(value_index).toBigInt(&big_int_space, zcu));
4264 try wip_nav.refType(.fromInterned(int.ty));4257 try wip_nav.refType(.fromInterned(int.ty));
4258 try wip_nav.bigIntConstValue(.fromInterned(int.ty), Value.fromInterned(value_index).toBigInt(&big_int_space, zcu));
4265 },4259 },
4266 .bitpack => |bitpack| {4260 .bitpack => |bitpack| {
4267 const backing_int_val: Value = .fromInterned(bitpack.backing_int_val);4261 const backing_int_val: Value = .fromInterned(bitpack.backing_int_val);
4268 try wip_nav.bigIntConstValue(.{4262 try wip_nav.abbrevCode(.comptime_value);
4269 .sdata = .sdata_comptime_value,
4270 .udata = .udata_comptime_value,
4271 .block = .block_comptime_value,
4272 }, backing_int_val.typeOf(zcu), backing_int_val.toBigInt(&big_int_space, zcu));
4273 try wip_nav.refType(.fromInterned(bitpack.ty));4263 try wip_nav.refType(.fromInterned(bitpack.ty));
4264 try wip_nav.bigIntConstValue(backing_int_val.typeOf(zcu), backing_int_val.toBigInt(&big_int_space, zcu));
4274 },4265 },
4275 .err => |err| {4266 .err => |err| {
4276 try wip_nav.abbrevCode(.udata_comptime_value);4267 try wip_nav.abbrevCode(.comptime_value);
4277 try wip_nav.refType(.fromInterned(err.ty));4268 try wip_nav.refType(.fromInterned(err.ty));
4269 try diw.writeUleb128(DW.FORM.udata);
4278 try diw.writeUleb128(try pt.getErrorValue(err.name));4270 try diw.writeUleb128(try pt.getErrorValue(err.name));
4279 },4271 },
4280 .error_union => |error_union| {4272 .error_union => |error_union| {
4281 try wip_nav.abbrevCode(.aggregate_comptime_value);4273 try wip_nav.abbrevCode(.aggregate_undefined_comptime_value);
4282 try wip_nav.refType(.fromInterned(error_union.ty));4274 try wip_nav.refType(.fromInterned(error_union.ty));
4283 var err_buf: [4]u8 = undefined;4275 var err_buf: [4]u8 = undefined;
4284 const err_bytes = err_buf[0 .. std.math.divCeil(u17, zcu.errorSetBits(), 8) catch unreachable];4276 const err_bytes = err_buf[0 .. std.math.divCeil(u17, zcu.errorSetBits(), 8) catch unreachable];
...@@ -4320,44 +4312,43 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co...@@ -4320,44 +4312,43 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
4320 try diw.writeUleb128(@intFromEnum(AbbrevCode.null));4312 try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
4321 },4313 },
4322 .enum_literal => |enum_literal| {4314 .enum_literal => |enum_literal| {
4323 try wip_nav.abbrevCode(.string_comptime_value);4315 try wip_nav.abbrevCode(.comptime_value);
4324 try wip_nav.strp(enum_literal.toSlice(ip));
4325 try wip_nav.refType(.enum_literal);4316 try wip_nav.refType(.enum_literal);
4317 try diw.writeUleb128(DW.FORM.strp);
4318 try wip_nav.strp(enum_literal.toSlice(ip));
4326 },4319 },
4327 .enum_tag => |enum_tag| {4320 .enum_tag => |enum_tag| {
4328 const int = ip.indexToKey(enum_tag.int).int;4321 const int = ip.indexToKey(enum_tag.int).int;
4329 try wip_nav.bigIntConstValue(.{4322 try wip_nav.abbrevCode(.comptime_value);
4330 .sdata = .sdata_comptime_value,
4331 .udata = .udata_comptime_value,
4332 .block = .block_comptime_value,
4333 }, .fromInterned(int.ty), Value.fromInterned(value_index).toBigInt(&big_int_space, zcu));
4334 try wip_nav.refType(.fromInterned(enum_tag.ty));4323 try wip_nav.refType(.fromInterned(enum_tag.ty));
4324 try wip_nav.bigIntConstValue(.fromInterned(int.ty), Value.fromInterned(value_index).toBigInt(&big_int_space, zcu));
4335 },4325 },
4336 .float => |float| {4326 .float => |float| {
4327 try wip_nav.abbrevCode(.comptime_value);
4328 try wip_nav.refType(.fromInterned(float.ty));
4337 switch (float.storage) {4329 switch (float.storage) {
4338 .f16 => |f16_val| {4330 .f16 => |f16_val| {
4339 try wip_nav.abbrevCode(.data2_comptime_value);4331 try diw.writeUleb128(DW.FORM.data2);
4340 try diw.writeInt(u16, @bitCast(f16_val), dwarf.endian);4332 try diw.writeInt(u16, @bitCast(f16_val), dwarf.endian);
4341 },4333 },
4342 .f32 => |f32_val| {4334 .f32 => |f32_val| {
4343 try wip_nav.abbrevCode(.data4_comptime_value);4335 try diw.writeUleb128(DW.FORM.data4);
4344 try diw.writeInt(u32, @bitCast(f32_val), dwarf.endian);4336 try diw.writeInt(u32, @bitCast(f32_val), dwarf.endian);
4345 },4337 },
4346 .f64 => |f64_val| {4338 .f64 => |f64_val| {
4347 try wip_nav.abbrevCode(.data8_comptime_value);4339 try diw.writeUleb128(DW.FORM.data8);
4348 try diw.writeInt(u64, @bitCast(f64_val), dwarf.endian);4340 try diw.writeInt(u64, @bitCast(f64_val), dwarf.endian);
4349 },4341 },
4350 .f80 => |f80_val| {4342 .f80 => |f80_val| {
4351 try wip_nav.abbrevCode(.block_comptime_value);4343 try diw.writeUleb128(DW.FORM.block);
4352 try diw.writeUleb128(@divExact(80, 8));4344 try diw.writeUleb128(@divExact(80, 8));
4353 try diw.writeInt(u80, @bitCast(f80_val), dwarf.endian);4345 try diw.writeInt(u80, @bitCast(f80_val), dwarf.endian);
4354 },4346 },
4355 .f128 => |f128_val| {4347 .f128 => |f128_val| {
4356 try wip_nav.abbrevCode(.data16_comptime_value);4348 try diw.writeUleb128(DW.FORM.data16);
4357 try diw.writeInt(u128, @bitCast(f128_val), dwarf.endian);4349 try diw.writeInt(u128, @bitCast(f128_val), dwarf.endian);
4358 },4350 },
4359 }4351 }
4360 try wip_nav.refType(.fromInterned(float.ty));
4361 },4352 },
4362 .ptr => |ptr| {4353 .ptr => |ptr| {
4363 const Access = union(enum) {4354 const Access = union(enum) {
...@@ -4379,9 +4370,11 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co...@@ -4379,9 +4370,11 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
4379 const uav_ty: Type = .fromInterned(ip.typeOf(uav.val));4370 const uav_ty: Type = .fromInterned(ip.typeOf(uav.val));
4380 if (uav_ty.classify(zcu) == .one_possible_value) {4371 if (uav_ty.classify(zcu) == .one_possible_value) {
4381 try wip_nav.abbrevCode(if (zero_bit_accesses.items.len > 0)4372 try wip_nav.abbrevCode(if (zero_bit_accesses.items.len > 0)
4382 .aggregate_udata_comptime_value4373 .aggregate_comptime_value
4383 else4374 else
4384 .udata_comptime_value);4375 .comptime_value);
4376 try wip_nav.refType(.fromInterned(ptr.ty));
4377 try diw.writeUleb128(DW.FORM.udata);
4385 try diw.writeUleb128(ip.indexToKey(uav.orig_ty).ptr_type.flags.alignment.toByteUnits() orelse4378 try diw.writeUleb128(ip.indexToKey(uav.orig_ty).ptr_type.flags.alignment.toByteUnits() orelse
4386 uav_ty.abiAlignment(zcu).toByteUnits().?);4379 uav_ty.abiAlignment(zcu).toByteUnits().?);
4387 break :location;4380 break :location;
...@@ -4389,9 +4382,11 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co...@@ -4389,9 +4382,11 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
4389 },4382 },
4390 .int => {4383 .int => {
4391 try wip_nav.abbrevCode(if (zero_bit_accesses.items.len > 0)4384 try wip_nav.abbrevCode(if (zero_bit_accesses.items.len > 0)
4392 .aggregate_udata_comptime_value4385 .aggregate_comptime_value
4393 else4386 else
4394 .udata_comptime_value);4387 .comptime_value);
4388 try wip_nav.refType(.fromInterned(ptr.ty));
4389 try diw.writeUleb128(DW.FORM.udata);
4395 try diw.writeUleb128(byte_offset);4390 try diw.writeUleb128(byte_offset);
4396 break :location;4391 break :location;
4397 },4392 },
...@@ -4434,13 +4429,13 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co...@@ -4434,13 +4429,13 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
4434 .aggregate_location_comptime_value4429 .aggregate_location_comptime_value
4435 else4430 else
4436 .location_comptime_value);4431 .location_comptime_value);
4432 try wip_nav.refType(.fromInterned(ptr.ty));
4437 try wip_nav.infoExprLoc(.{ .implicit_pointer = .{4433 try wip_nav.infoExprLoc(.{ .implicit_pointer = .{
4438 .unit = base_unit,4434 .unit = base_unit,
4439 .entry = base_entry,4435 .entry = base_entry,
4440 .offset = byte_offset,4436 .offset = byte_offset,
4441 } });4437 } });
4442 }4438 }
4443 try wip_nav.refType(.fromInterned(ptr.ty));
4444 if (zero_bit_accesses.items.len > 0) {4439 if (zero_bit_accesses.items.len > 0) {
4445 for (zero_bit_accesses.items) |access| switch (access) {4440 for (zero_bit_accesses.items) |access| switch (access) {
4446 .index => |index| {4441 .index => |index| {
...@@ -4448,15 +4443,15 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co...@@ -4448,15 +4443,15 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
4448 try diw.writeUleb128(index);4443 try diw.writeUleb128(index);
4449 },4444 },
4450 .field => |field| {4445 .field => |field| {
4451 try wip_nav.abbrevCode(.field);4446 try wip_nav.abbrevCode(.access);
4452 try wip_nav.strp(field.toSlice(ip));4447 try wip_nav.strp(field.toSlice(ip));
4453 },4448 },
4454 .synthetic_field => |field| {4449 .synthetic_field => |field| {
4455 try wip_nav.abbrevCode(.field);4450 try wip_nav.abbrevCode(.access);
4456 try wip_nav.strp(field);4451 try wip_nav.strp(field);
4457 },4452 },
4458 .tuple_index => |index| {4453 .tuple_index => |index| {
4459 try wip_nav.abbrevCode(.field);4454 try wip_nav.abbrevCode(.access);
4460 var field_name_buf: [std.fmt.count("{d}", .{std.math.maxInt(u32)})]u8 = undefined;4455 var field_name_buf: [std.fmt.count("{d}", .{std.math.maxInt(u32)})]u8 = undefined;
4461 const field_name = std.fmt.bufPrint(&field_name_buf, "{d}", .{index}) catch unreachable;4456 const field_name = std.fmt.bufPrint(&field_name_buf, "{d}", .{index}) catch unreachable;
4462 try wip_nav.strp(field_name);4457 try wip_nav.strp(field_name);
...@@ -4466,7 +4461,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co...@@ -4466,7 +4461,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
4466 }4461 }
4467 },4462 },
4468 .slice => |slice| {4463 .slice => |slice| {
4469 try wip_nav.abbrevCode(.aggregate_comptime_value);4464 try wip_nav.abbrevCode(.aggregate_undefined_comptime_value);
4470 try wip_nav.refType(.fromInterned(slice.ty));4465 try wip_nav.refType(.fromInterned(slice.ty));
4471 {4466 {
4472 try wip_nav.abbrevCode(.comptime_value_field_comptime_state);4467 try wip_nav.abbrevCode(.comptime_value_field_comptime_state);
...@@ -4482,7 +4477,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co...@@ -4482,7 +4477,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
4482 },4477 },
4483 .opt => |opt| {4478 .opt => |opt| {
4484 const opt_child_type: Type = .fromInterned(ip.indexToKey(opt.ty).opt_type);4479 const opt_child_type: Type = .fromInterned(ip.indexToKey(opt.ty).opt_type);
4485 try wip_nav.abbrevCode(.aggregate_comptime_value);4480 try wip_nav.abbrevCode(.aggregate_undefined_comptime_value);
4486 try wip_nav.refType(.fromInterned(opt.ty));4481 try wip_nav.refType(.fromInterned(opt.ty));
4487 {4482 {
4488 try wip_nav.abbrevCode(.comptime_value_field_runtime_bits);4483 try wip_nav.abbrevCode(.comptime_value_field_runtime_bits);
...@@ -4511,7 +4506,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co...@@ -4511,7 +4506,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
4511 try diw.writeUleb128(@intFromEnum(AbbrevCode.null));4506 try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
4512 },4507 },
4513 .aggregate => |aggregate| {4508 .aggregate => |aggregate| {
4514 try wip_nav.abbrevCode(.aggregate_comptime_value);4509 try wip_nav.abbrevCode(.aggregate_undefined_comptime_value);
4515 try wip_nav.refType(.fromInterned(aggregate.ty));4510 try wip_nav.refType(.fromInterned(aggregate.ty));
4516 switch (ip.indexToKey(aggregate.ty)) {4511 switch (ip.indexToKey(aggregate.ty)) {
4517 .struct_type => {4512 .struct_type => {
...@@ -4592,9 +4587,9 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co...@@ -4592,9 +4587,9 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
4592 try diw.writeUleb128(@intFromEnum(AbbrevCode.null));4587 try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
4593 },4588 },
4594 .un => |un| {4589 .un => |un| {
4595 try wip_nav.abbrevCode(.aggregate_comptime_value);4590 try wip_nav.abbrevCode(.aggregate_undefined_comptime_value);
4596 try wip_nav.refType(.fromInterned(un.ty));4591 try wip_nav.refType(.fromInterned(un.ty));
4597 field: {4592 {
4598 const loaded_union_type = ip.loadUnionType(un.ty);4593 const loaded_union_type = ip.loadUnionType(un.ty);
4599 assert(loaded_union_type.layout == .auto);4594 assert(loaded_union_type.layout == .auto);
4600 const field_index = zcu.unionTagFieldIndex(loaded_union_type, Value.fromInterned(un.tag)).?;4595 const field_index = zcu.unionTagFieldIndex(loaded_union_type, Value.fromInterned(un.tag)).?;
...@@ -4607,11 +4602,11 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co...@@ -4607,11 +4602,11 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
4607 else if (has_runtime_bits)4602 else if (has_runtime_bits)
4608 .comptime_value_field_runtime_bits4603 .comptime_value_field_runtime_bits
4609 else4604 else
4610 break :field);4605 .access);
4611 try wip_nav.strp(field_name.toSlice(ip));4606 try wip_nav.strp(field_name.toSlice(ip));
4612 if (has_comptime_state)4607 if (has_comptime_state)
4613 try wip_nav.refValue(.fromInterned(un.val))4608 try wip_nav.refValue(.fromInterned(un.val))
4614 else4609 else if (has_runtime_bits)
4615 try wip_nav.blockValue(.fromInterned(un.val));4610 try wip_nav.blockValue(.fromInterned(un.val));
4616 }4611 }
4617 try diw.writeUleb128(@intFromEnum(AbbrevCode.null));4612 try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
...@@ -4726,7 +4721,8 @@ fn flushWriterError(dwarf: *Dwarf, pt: Zcu.PerThread) (UpdateError || Writer.Err...@@ -4726,7 +4721,8 @@ fn flushWriterError(dwarf: *Dwarf, pt: Zcu.PerThread) (UpdateError || Writer.Err
4726 .bits = zcu.errorSetBits(),4721 .bits = zcu.errorSetBits(),
4727 } })));4722 } })));
4728 for (global_error_set_names, 1..) |name, value| {4723 for (global_error_set_names, 1..) |name, value| {
4729 try wip_nav.abbrevCode(.unsigned_enum_field);4724 try wip_nav.abbrevCode(.enum_field);
4725 try diw.writeUleb128(DW.FORM.udata);
4730 try diw.writeUleb128(value);4726 try diw.writeUleb128(value);
4731 try wip_nav.strp(name.toSlice(ip));4727 try wip_nav.strp(name.toSlice(ip));
4732 }4728 }
...@@ -5119,6 +5115,7 @@ const AbbrevCode = enum {...@@ -5119,6 +5115,7 @@ const AbbrevCode = enum {
5119 decl_struct,5115 decl_struct,
5120 decl_packed_struct,5116 decl_packed_struct,
5121 decl_union,5117 decl_union,
5118 decl_packed_union,
5122 decl_var,5119 decl_var,
5123 decl_const,5120 decl_const,
5124 decl_const_runtime_bits,5121 decl_const_runtime_bits,
...@@ -5140,6 +5137,7 @@ const AbbrevCode = enum {...@@ -5140,6 +5137,7 @@ const AbbrevCode = enum {
5140 decl_instance_struct,5137 decl_instance_struct,
5141 decl_instance_packed_struct,5138 decl_instance_packed_struct,
5142 decl_instance_union,5139 decl_instance_union,
5140 decl_instance_packed_union,
5143 decl_instance_var,5141 decl_instance_var,
5144 decl_instance_const,5142 decl_instance_const,
5145 decl_instance_const_runtime_bits,5143 decl_instance_const_runtime_bits,
...@@ -5157,23 +5155,18 @@ const AbbrevCode = enum {...@@ -5157,23 +5155,18 @@ const AbbrevCode = enum {
5157 module,5155 module,
5158 empty_file,5156 empty_file,
5159 file,5157 file,
5160 field,5158 access,
5161 signed_enum_field,5159 enum_field,
5162 unsigned_enum_field,
5163 big_enum_field,
5164 generated_field,5160 generated_field,
5165 struct_field,5161 field,
5166 struct_field_default_runtime_bits,5162 field_default_runtime_bits,
5167 struct_field_default_comptime_state,5163 field_default_comptime_state,
5168 struct_field_comptime,5164 field_comptime,
5169 struct_field_comptime_runtime_bits,5165 field_comptime_runtime_bits,
5170 struct_field_comptime_comptime_state,5166 field_comptime_comptime_state,
5171 packed_struct_field,5167 packed_field,
5172 untagged_union_field,
5173 tagged_union,5168 tagged_union,
5174 signed_tagged_union_field,5169 tagged_union_field,
5175 unsigned_tagged_union_field,
5176 big_tagged_union_field,
5177 tagged_union_default_field,5170 tagged_union_default_field,
5178 void_type,5171 void_type,
5179 numeric_type,5172 numeric_type,
...@@ -5206,6 +5199,8 @@ const AbbrevCode = enum {...@@ -5206,6 +5199,8 @@ const AbbrevCode = enum {
5206 packed_struct_type,5199 packed_struct_type,
5207 empty_union_type,5200 empty_union_type,
5208 union_type,5201 union_type,
5202 empty_packed_union_type,
5203 packed_union_type,
5209 builtin_extern_nullary_func,5204 builtin_extern_nullary_func,
5210 builtin_extern_func,5205 builtin_extern_func,
5211 builtin_extern_var,5206 builtin_extern_var,
...@@ -5230,16 +5225,9 @@ const AbbrevCode = enum {...@@ -5230,16 +5225,9 @@ const AbbrevCode = enum {
5230 local_const_comptime_state,5225 local_const_comptime_state,
5231 local_const_runtime_bits_comptime_state,5226 local_const_runtime_bits_comptime_state,
5232 undefined_comptime_value,5227 undefined_comptime_value,
5233 data2_comptime_value,5228 comptime_value,
5234 data4_comptime_value,
5235 data8_comptime_value,
5236 data16_comptime_value,
5237 sdata_comptime_value,
5238 udata_comptime_value,
5239 aggregate_udata_comptime_value,
5240 block_comptime_value,
5241 string_comptime_value,
5242 location_comptime_value,5229 location_comptime_value,
5230 aggregate_undefined_comptime_value,
5243 aggregate_comptime_value,5231 aggregate_comptime_value,
5244 aggregate_location_comptime_value,5232 aggregate_location_comptime_value,
5245 comptime_value_field_runtime_bits,5233 comptime_value_field_runtime_bits,
...@@ -5334,6 +5322,13 @@ const AbbrevCode = enum {...@@ -5334,6 +5322,13 @@ const AbbrevCode = enum {
5334 .{ .alignment, .udata },5322 .{ .alignment, .udata },
5335 },5323 },
5336 },5324 },
5325 .decl_packed_union = .{
5326 .tag = .union_type,
5327 .children = true,
5328 .attrs = decl_abbrev_common_attrs ++ .{
5329 .{ .type, .ref_addr },
5330 },
5331 },
5337 .decl_var = .{5332 .decl_var = .{
5338 .tag = .variable,5333 .tag = .variable,
5339 .attrs = decl_abbrev_common_attrs ++ .{5334 .attrs = decl_abbrev_common_attrs ++ .{
...@@ -5503,6 +5498,13 @@ const AbbrevCode = enum {...@@ -5503,6 +5498,13 @@ const AbbrevCode = enum {
5503 .{ .alignment, .udata },5498 .{ .alignment, .udata },
5504 },5499 },
5505 },5500 },
5501 .decl_instance_packed_union = .{
5502 .tag = .union_type,
5503 .children = true,
5504 .attrs = decl_instance_abbrev_common_attrs ++ .{
5505 .{ .type, .ref_addr },
5506 },
5507 },
5506 .decl_instance_var = .{5508 .decl_instance_var = .{
5507 .tag = .variable,5509 .tag = .variable,
5508 .attrs = decl_instance_abbrev_common_attrs ++ .{5510 .attrs = decl_instance_abbrev_common_attrs ++ .{
...@@ -5651,30 +5653,16 @@ const AbbrevCode = enum {...@@ -5651,30 +5653,16 @@ const AbbrevCode = enum {
5651 .{ .alignment, .udata },5653 .{ .alignment, .udata },
5652 },5654 },
5653 },5655 },
5654 .field = .{5656 .access = .{
5655 .tag = .member,5657 .tag = .member,
5656 .attrs = &.{5658 .attrs = &.{
5657 .{ .name, .strp },5659 .{ .name, .strp },
5658 },5660 },
5659 },5661 },
5660 .signed_enum_field = .{5662 .enum_field = .{
5661 .tag = .enumerator,
5662 .attrs = &.{
5663 .{ .const_value, .sdata },
5664 .{ .name, .strp },
5665 },
5666 },
5667 .unsigned_enum_field = .{
5668 .tag = .enumerator,
5669 .attrs = &.{
5670 .{ .const_value, .udata },
5671 .{ .name, .strp },
5672 },
5673 },
5674 .big_enum_field = .{
5675 .tag = .enumerator,5663 .tag = .enumerator,
5676 .attrs = &.{5664 .attrs = &.{
5677 .{ .const_value, .block },5665 .{ .const_value, .indirect },
5678 .{ .name, .strp },5666 .{ .name, .strp },
5679 },5667 },
5680 },5668 },
...@@ -5687,7 +5675,7 @@ const AbbrevCode = enum {...@@ -5687,7 +5675,7 @@ const AbbrevCode = enum {
5687 .{ .artificial, .flag_present },5675 .{ .artificial, .flag_present },
5688 },5676 },
5689 },5677 },
5690 .struct_field = .{5678 .field = .{
5691 .tag = .member,5679 .tag = .member,
5692 .attrs = &.{5680 .attrs = &.{
5693 .{ .name, .strp },5681 .{ .name, .strp },
...@@ -5696,7 +5684,7 @@ const AbbrevCode = enum {...@@ -5696,7 +5684,7 @@ const AbbrevCode = enum {
5696 .{ .alignment, .udata },5684 .{ .alignment, .udata },
5697 },5685 },
5698 },5686 },
5699 .struct_field_default_runtime_bits = .{5687 .field_default_runtime_bits = .{
5700 .tag = .member,5688 .tag = .member,
5701 .attrs = &.{5689 .attrs = &.{
5702 .{ .name, .strp },5690 .{ .name, .strp },
...@@ -5706,7 +5694,7 @@ const AbbrevCode = enum {...@@ -5706,7 +5694,7 @@ const AbbrevCode = enum {
5706 .{ .default_value, .block },5694 .{ .default_value, .block },
5707 },5695 },
5708 },5696 },
5709 .struct_field_default_comptime_state = .{5697 .field_default_comptime_state = .{
5710 .tag = .member,5698 .tag = .member,
5711 .attrs = &.{5699 .attrs = &.{
5712 .{ .name, .strp },5700 .{ .name, .strp },
...@@ -5716,7 +5704,7 @@ const AbbrevCode = enum {...@@ -5716,7 +5704,7 @@ const AbbrevCode = enum {
5716 .{ .ZIG_comptime_value, .ref_addr },5704 .{ .ZIG_comptime_value, .ref_addr },
5717 },5705 },
5718 },5706 },
5719 .struct_field_comptime = .{5707 .field_comptime = .{
5720 .tag = .member,5708 .tag = .member,
5721 .attrs = &.{5709 .attrs = &.{
5722 .{ .const_expr, .flag_present },5710 .{ .const_expr, .flag_present },
...@@ -5724,7 +5712,7 @@ const AbbrevCode = enum {...@@ -5724,7 +5712,7 @@ const AbbrevCode = enum {
5724 .{ .type, .ref_addr },5712 .{ .type, .ref_addr },
5725 },5713 },
5726 },5714 },
5727 .struct_field_comptime_runtime_bits = .{5715 .field_comptime_runtime_bits = .{
5728 .tag = .member,5716 .tag = .member,
5729 .attrs = &.{5717 .attrs = &.{
5730 .{ .const_expr, .flag_present },5718 .{ .const_expr, .flag_present },
...@@ -5733,7 +5721,7 @@ const AbbrevCode = enum {...@@ -5733,7 +5721,7 @@ const AbbrevCode = enum {
5733 .{ .const_value, .block },5721 .{ .const_value, .block },
5734 },5722 },
5735 },5723 },
5736 .struct_field_comptime_comptime_state = .{5724 .field_comptime_comptime_state = .{
5737 .tag = .member,5725 .tag = .member,
5738 .attrs = &.{5726 .attrs = &.{
5739 .{ .const_expr, .flag_present },5727 .{ .const_expr, .flag_present },
...@@ -5742,7 +5730,7 @@ const AbbrevCode = enum {...@@ -5742,7 +5730,7 @@ const AbbrevCode = enum {
5742 .{ .ZIG_comptime_value, .ref_addr },5730 .{ .ZIG_comptime_value, .ref_addr },
5743 },5731 },
5744 },5732 },
5745 .packed_struct_field = .{5733 .packed_field = .{
5746 .tag = .member,5734 .tag = .member,
5747 .attrs = &.{5735 .attrs = &.{
5748 .{ .name, .strp },5736 .{ .name, .strp },
...@@ -5750,14 +5738,6 @@ const AbbrevCode = enum {...@@ -5750,14 +5738,6 @@ const AbbrevCode = enum {
5750 .{ .data_bit_offset, .udata },5738 .{ .data_bit_offset, .udata },
5751 },5739 },
5752 },5740 },
5753 .untagged_union_field = .{
5754 .tag = .member,
5755 .attrs = &.{
5756 .{ .name, .strp },
5757 .{ .type, .ref_addr },
5758 .{ .alignment, .udata },
5759 },
5760 },
5761 .tagged_union = .{5741 .tagged_union = .{
5762 .tag = .variant_part,5742 .tag = .variant_part,
5763 .children = true,5743 .children = true,
...@@ -5765,25 +5745,11 @@ const AbbrevCode = enum {...@@ -5765,25 +5745,11 @@ const AbbrevCode = enum {
5765 .{ .discr, .ref_addr },5745 .{ .discr, .ref_addr },
5766 },5746 },
5767 },5747 },
5768 .signed_tagged_union_field = .{5748 .tagged_union_field = .{
5769 .tag = .variant,
5770 .children = true,
5771 .attrs = &.{
5772 .{ .discr_value, .sdata },
5773 },
5774 },
5775 .unsigned_tagged_union_field = .{
5776 .tag = .variant,
5777 .children = true,
5778 .attrs = &.{
5779 .{ .discr_value, .udata },
5780 },
5781 },
5782 .big_tagged_union_field = .{
5783 .tag = .variant,5749 .tag = .variant,
5784 .children = true,5750 .children = true,
5785 .attrs = &.{5751 .attrs = &.{
5786 .{ .discr_value, .block },5752 .{ .discr_value, .indirect },
5787 },5753 },
5788 },5754 },
5789 .tagged_union_default_field = .{5755 .tagged_union_default_field = .{
...@@ -6038,6 +6004,23 @@ const AbbrevCode = enum {...@@ -6038,6 +6004,23 @@ const AbbrevCode = enum {
6038 .{ .alignment, .udata },6004 .{ .alignment, .udata },
6039 },6005 },
6040 },6006 },
6007 .empty_packed_union_type = .{
6008 .tag = .union_type,
6009 .attrs = &.{
6010 .{ .decl_file, .udata },
6011 .{ .name, .strp },
6012 .{ .type, .ref_addr },
6013 },
6014 },
6015 .packed_union_type = .{
6016 .tag = .union_type,
6017 .children = true,
6018 .attrs = &.{
6019 .{ .decl_file, .udata },
6020 .{ .name, .strp },
6021 .{ .type, .ref_addr },
6022 },
6023 },
6041 .builtin_extern_nullary_func = .{6024 .builtin_extern_nullary_func = .{
6042 .tag = .subprogram,6025 .tag = .subprogram,
6043 .attrs = &.{6026 .attrs = &.{
...@@ -6242,90 +6225,41 @@ const AbbrevCode = enum {...@@ -6242,90 +6225,41 @@ const AbbrevCode = enum {
6242 .{ .type, .ref_addr },6225 .{ .type, .ref_addr },
6243 },6226 },
6244 },6227 },
6245 .data2_comptime_value = .{6228 .aggregate_undefined_comptime_value = .{
6246 .tag = .ZIG_comptime_value,
6247 .attrs = &.{
6248 .{ .const_value, .data2 },
6249 .{ .type, .ref_addr },
6250 },
6251 },
6252 .data4_comptime_value = .{
6253 .tag = .ZIG_comptime_value,
6254 .attrs = &.{
6255 .{ .const_value, .data4 },
6256 .{ .type, .ref_addr },
6257 },
6258 },
6259 .data8_comptime_value = .{
6260 .tag = .ZIG_comptime_value,
6261 .attrs = &.{
6262 .{ .const_value, .data8 },
6263 .{ .type, .ref_addr },
6264 },
6265 },
6266 .data16_comptime_value = .{
6267 .tag = .ZIG_comptime_value,
6268 .attrs = &.{
6269 .{ .const_value, .data16 },
6270 .{ .type, .ref_addr },
6271 },
6272 },
6273 .sdata_comptime_value = .{
6274 .tag = .ZIG_comptime_value,
6275 .attrs = &.{
6276 .{ .const_value, .sdata },
6277 .{ .type, .ref_addr },
6278 },
6279 },
6280 .udata_comptime_value = .{
6281 .tag = .ZIG_comptime_value,
6282 .attrs = &.{
6283 .{ .const_value, .udata },
6284 .{ .type, .ref_addr },
6285 },
6286 },
6287 .aggregate_udata_comptime_value = .{
6288 .tag = .ZIG_comptime_value,6229 .tag = .ZIG_comptime_value,
6289 .children = true,6230 .children = true,
6290 .attrs = &.{6231 .attrs = &.{
6291 .{ .const_value, .udata },
6292 .{ .type, .ref_addr },6232 .{ .type, .ref_addr },
6293 },6233 },
6294 },6234 },
6295 .block_comptime_value = .{6235 .comptime_value = .{
6296 .tag = .ZIG_comptime_value,6236 .tag = .ZIG_comptime_value,
6297 .attrs = &.{6237 .attrs = &.{
6298 .{ .const_value, .block },
6299 .{ .type, .ref_addr },6238 .{ .type, .ref_addr },
6239 .{ .const_value, .indirect },
6300 },6240 },
6301 },6241 },
6302 .string_comptime_value = .{6242 .aggregate_comptime_value = .{
6303 .tag = .ZIG_comptime_value,6243 .tag = .ZIG_comptime_value,
6244 .children = true,
6304 .attrs = &.{6245 .attrs = &.{
6305 .{ .const_value, .strp },
6306 .{ .type, .ref_addr },6246 .{ .type, .ref_addr },
6247 .{ .const_value, .indirect },
6307 },6248 },
6308 },6249 },
6309 .location_comptime_value = .{6250 .location_comptime_value = .{
6310 .tag = .ZIG_comptime_value,6251 .tag = .ZIG_comptime_value,
6311 .attrs = &.{
6312 .{ .location, .exprloc },
6313 .{ .type, .ref_addr },
6314 },
6315 },
6316 .aggregate_comptime_value = .{
6317 .tag = .ZIG_comptime_value,
6318 .children = true,
6319 .attrs = &.{6252 .attrs = &.{
6320 .{ .type, .ref_addr },6253 .{ .type, .ref_addr },
6254 .{ .location, .exprloc },
6321 },6255 },
6322 },6256 },
6323 .aggregate_location_comptime_value = .{6257 .aggregate_location_comptime_value = .{
6324 .tag = .ZIG_comptime_value,6258 .tag = .ZIG_comptime_value,
6325 .children = true,6259 .children = true,
6326 .attrs = &.{6260 .attrs = &.{
6327 .{ .location, .exprloc },
6328 .{ .type, .ref_addr },6261 .{ .type, .ref_addr },
6262 .{ .location, .exprloc },
6329 },6263 },
6330 },6264 },
6331 .comptime_value_field_runtime_bits = .{6265 .comptime_value_field_runtime_bits = .{
test/src/Debugger.zig+71-3
...@@ -215,6 +215,74 @@ pub fn addTestsForTarget(db: *Debugger, target: *const Target) void {...@@ -215,6 +215,74 @@ pub fn addTestsForTarget(db: *Debugger, target: *const Target) void {
215 \\1 breakpoints deleted; 0 breakpoint locations disabled.215 \\1 breakpoints deleted; 0 breakpoint locations disabled.
216 },216 },
217 );217 );
218 db.addLldbTest(
219 "types",
220 target,
221 &.{
222 .{
223 .path = "types.zig",
224 .source =
225 \\fn testTypes(
226 \\ Anyopaque: type,
227 \\ Bool: type,
228 \\ Void: type,
229 \\ Type: type,
230 \\ ComptimeInt: type,
231 \\ ComptimeFloat: type,
232 \\ Noreturn: type,
233 \\ Null: type,
234 \\ Undefined: type,
235 \\ EnumLiteral: type,
236 \\) void {
237 \\ _ = Anyopaque;
238 \\ _ = Bool;
239 \\ _ = Void;
240 \\ _ = Type;
241 \\ _ = ComptimeInt;
242 \\ _ = ComptimeFloat;
243 \\ _ = Noreturn;
244 \\ _ = Null;
245 \\ _ = Undefined;
246 \\ _ = EnumLiteral;
247 \\}
248 \\pub fn main() void {
249 \\ testTypes(
250 \\ anyopaque,
251 \\ bool,
252 \\ void,
253 \\ type,
254 \\ comptime_int,
255 \\ comptime_float,
256 \\ noreturn,
257 \\ @TypeOf(null),
258 \\ @TypeOf(undefined),
259 \\ @EnumLiteral(),
260 \\ );
261 \\}
262 ,
263 },
264 },
265 \\breakpoint set --file types.zig --source-pattern-regexp '_ = Undefined;'
266 \\process launch
267 \\frame variable --show-all-children --show-types -- Anyopaque Bool Void Type ComptimeInt ComptimeFloat Noreturn Null Undefined EnumLiteral
268 \\breakpoint delete --force 1
269 ,
270 &.{
271 \\(lldb) frame variable --show-all-children --show-types -- Anyopaque Bool Void Type ComptimeInt ComptimeFloat Noreturn Null Undefined EnumLiteral
272 \\(type) Anyopaque = anyopaque
273 \\(type) Bool = bool
274 \\(type) Void = void
275 \\(type) Type = type
276 \\(type) ComptimeInt = comptime_int
277 \\(type) ComptimeFloat = comptime_float
278 \\(type) Noreturn = noreturn
279 \\(type) Null = @TypeOf(null)
280 \\(type) Undefined = @TypeOf(undefined)
281 \\(type) EnumLiteral = @EnumLiteral()
282 \\(lldb) breakpoint delete --force 1
283 \\1 breakpoints deleted; 0 breakpoint locations disabled.
284 },
285 );
218 db.addLldbTest(286 db.addLldbTest(
219 "pointers",287 "pointers",
220 target,288 target,
...@@ -464,7 +532,7 @@ pub fn addTestsForTarget(db: *Debugger, target: *const Target) void {...@@ -464,7 +532,7 @@ pub fn addTestsForTarget(db: *Debugger, target: *const Target) void {
464 ,532 ,
465 &.{533 &.{
466 \\(lldb) expression --show-types -- Enums534 \\(lldb) expression --show-types -- Enums
467 \\(type) Enums = struct {535 \\(type) $0 = struct {
468 \\ (type) Zero = enum {}536 \\ (type) Zero = enum {}
469 \\ (type) One = enum {537 \\ (type) One = enum {
470 \\ (root.enums.Enums.One) first = .first538 \\ (root.enums.Enums.One) first = .first
...@@ -528,7 +596,7 @@ pub fn addTestsForTarget(db: *Debugger, target: *const Target) void {...@@ -528,7 +596,7 @@ pub fn addTestsForTarget(db: *Debugger, target: *const Target) void {
528 ,596 ,
529 &.{597 &.{
530 \\(lldb) expression --show-types -- Errors598 \\(lldb) expression --show-types -- Errors
531 \\(type) Errors = struct {599 \\(type) $0 = struct {
532 \\ (type) Zero = error {}600 \\ (type) Zero = error {}
533 \\ (type) One = error {601 \\ (type) One = error {
534 \\ (error{One}) One = error.One602 \\ (error{One}) One = error.One
...@@ -661,7 +729,7 @@ pub fn addTestsForTarget(db: *Debugger, target: *const Target) void {...@@ -661,7 +729,7 @@ pub fn addTestsForTarget(db: *Debugger, target: *const Target) void {
661 ,729 ,
662 &.{730 &.{
663 \\(lldb) expression --show-types -- Unions731 \\(lldb) expression --show-types -- Unions
664 \\(type) Unions = struct {732 \\(type) $0 = struct {
665 \\ (type) Untagged = union {}733 \\ (type) Untagged = union {}
666 \\ (type) SafetyTagged = union(enum) {734 \\ (type) SafetyTagged = union(enum) {
667 \\ (@typeInfo(unions.Unions.SafetyTagged).@"union".tag_type.?) void = .void735 \\ (@typeInfo(unions.Unions.SafetyTagged).@"union".tag_type.?) void = .void