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 \
5050
5151stage3-debug/bin/zig build test docs \
5252 --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 \
5454 -Dlibc-test-path=$HOME/deps/libc-test-f2bac77 \
5555 -fqemu \
5656 --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 \
5050stage3-debug/bin/zig build test docs \
5151 --maker-opt=Debug \
5252 --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 \
5454 -fqemu \
5555 --libc-runtimes $HOME/deps/glibc-2.43-musl-1.2.5 \
5656 -fwasmtime \
ci/x86_64-linux-release.sh+1-1
......@@ -58,7 +58,7 @@ stage3-release/bin/zig build \
5858
5959stage3-release/bin/zig build test docs \
6060 --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 \
6262 -Dlibc-test-path=$HOME/deps/libc-test-f2bac77 \
6363 -fqemu \
6464 --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 {
21242124 }
21252125 }
21262126
2127 const AbbrevCodeForForm = struct {
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 {
2127 fn bigIntConstValue(wip_nav: *WipNav, ty: Type, big_int: std.math.big.int.Const) (UpdateError || Writer.Error)!void {
21392128 const zcu = wip_nav.pt.zcu;
21402129 const diw = &wip_nav.debug_info.writer;
21412130 const signedness = switch (ty.toIntern()) {
2142 .comptime_int_type, .comptime_float_type => .signed,
2131 .comptime_int_type => .signed,
21432132 else => ty.intInfo(zcu).signedness,
21442133 };
21452134 const bits = @max(1, big_int.bitCountTwosCompForSignedness(signedness));
21462135 if (bits <= 64) {
2147 try wip_nav.abbrevCode(switch (signedness) {
2148 .signed => abbrev_code.sdata,
2149 .unsigned => abbrev_code.udata,
2150 });
2136 try diw.writeUleb128(@as(u13, switch (signedness) {
2137 .signed => DW.FORM.sdata,
2138 .unsigned => DW.FORM.udata,
2139 }));
21512140 try wip_nav.debug_info.ensureUnusedCapacity(std.math.divCeil(usize, bits, 7) catch unreachable);
21522141 var bit: usize = 0;
21532142 var carry: u1 = 1;
......@@ -2168,7 +2157,7 @@ pub const WipNav = struct {
21682157 diw.writeByte(@as(u8, if (bit < bits) 0x80 else 0x00) | twos_comp_part) catch unreachable;
21692158 }
21702159 } else {
2171 try wip_nav.abbrevCode(abbrev_code.block);
2160 try diw.writeUleb128(DW.FORM.block);
21722161 const bytes = @max(ty.abiSize(zcu), std.math.divCeil(usize, bits, 8) catch unreachable);
21732162 try diw.writeUleb128(bytes);
21742163 try wip_nav.debug_info.ensureUnusedCapacity(@intCast(bytes));
......@@ -2179,16 +2168,11 @@ pub const WipNav = struct {
21792168 }
21802169 }
21812170
2182 fn enumConstValue(
2183 wip_nav: *WipNav,
2184 loaded_enum: InternPool.LoadedEnumType,
2185 abbrev_code: AbbrevCodeForForm,
2186 field_index: usize,
2187 ) (UpdateError || Writer.Error)!void {
2171 fn enumConstValue(wip_nav: *WipNav, loaded_enum: InternPool.LoadedEnumType, field_index: usize) (UpdateError || Writer.Error)!void {
21882172 const zcu = wip_nav.pt.zcu;
21892173 const ip = &zcu.intern_pool;
21902174 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)
21922176 Value.fromInterned(loaded_enum.field_values.get(ip)[field_index]).toBigInt(&big_int_space, zcu)
21932177 else
21942178 std.math.big.int.Mutable.init(&big_int_space.limbs, field_index).toConst());
......@@ -2814,7 +2798,11 @@ fn initWipNavInner(
28142798 const diw = &wip_nav.debug_info.writer;
28152799 try wip_nav.declCommon(.{
28162800 .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 },
28182806 .decl_instance = .decl_instance_var,
28192807 }, &nav, inst_info.file, &decl);
28202808 try wip_nav.strp(switch (decl.linkage) {
......@@ -3672,7 +3660,8 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
36723660 },
36733661 }
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);
36763665 try diw.writeUleb128(0);
36773666 {
36783667 try wip_nav.abbrevCode(.generated_field);
......@@ -3736,7 +3725,8 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
37363725 } })));
37373726 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);
37403730 try diw.writeUleb128(0);
37413731 {
37423732 try wip_nav.abbrevCode(.generated_field);
......@@ -3833,13 +3823,13 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
38333823 else => .{ field_type.hasRuntimeBits(zcu), field_type.comptimeOnly(zcu) },
38343824 };
38353825 try wip_nav.abbrevCode(if (has_comptime_state)
3836 .struct_field_comptime_comptime_state
3826 .field_comptime_comptime_state
38373827 else if (has_runtime_bits)
3838 .struct_field_comptime_runtime_bits
3828 .field_comptime_runtime_bits
38393829 else if (comptime_value != .none)
3840 .struct_field_comptime
3830 .field_comptime
38413831 else
3842 .struct_field);
3832 .field);
38433833 {
38443834 var field_name_buf: [std.fmt.count("{d}", .{std.math.maxInt(u32)})]u8 = undefined;
38453835 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
39193909 };
39203910 try wip_nav.abbrevCode(if (is_comptime)
39213911 if (has_comptime_state)
3922 .struct_field_comptime_comptime_state
3912 .field_comptime_comptime_state
39233913 else if (has_runtime_bits)
3924 .struct_field_comptime_runtime_bits
3914 .field_comptime_runtime_bits
39253915 else
3926 .struct_field_comptime
3916 .field_comptime
39273917 else if (field_init != .none)
39283918 if (has_comptime_state)
3929 .struct_field_default_comptime_state
3919 .field_default_comptime_state
39303920 else if (has_runtime_bits)
3931 .struct_field_default_runtime_bits
3921 .field_default_runtime_bits
39323922 else
3933 .struct_field
3923 .field
39343924 else
3935 .struct_field);
3925 .field);
39363926 try wip_nav.strp(loaded_struct.field_names.get(ip)[field_index].toSlice(ip));
39373927 try wip_nav.refType(field_type);
39383928 if (!is_comptime) {
......@@ -3969,7 +3959,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
39693959 try wip_nav.refType(.fromInterned(loaded_struct.packed_backing_int_type));
39703960 var field_bit_offset: u16 = 0;
39713961 for (0..loaded_struct.field_types.len) |field_index| {
3972 try wip_nav.abbrevCode(.packed_struct_field);
3962 try wip_nav.abbrevCode(.packed_field);
39733963 try wip_nav.strp(loaded_struct.field_names.get(ip)[field_index].toSlice(ip));
39743964 const field_type: Type = .fromInterned(loaded_struct.field_types.get(ip)[field_index]);
39753965 try wip_nav.refType(field_type);
......@@ -3983,6 +3973,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
39833973 .union_type => {
39843974 const loaded_union = ip.loadUnionType(value_index);
39853975 const file = loaded_union.zir_index.resolveFile(ip);
3976 const loaded_tag = ip.loadEnumType(loaded_union.enum_tag_type);
39863977 switch (loaded_union.layout) {
39873978 .auto, .@"extern" => {
39883979 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
40053996 const union_layout = Type.getUnionLayout(loaded_union, zcu);
40063997 try diw.writeUleb128(union_layout.abi_size);
40073998 try diw.writeUleb128(union_layout.abi_align.toByteUnits().?);
4008 const loaded_tag = ip.loadEnumType(loaded_union.enum_tag_type);
40093999 if (loaded_union.has_runtime_tag) {
40104000 try wip_nav.abbrevCode(.tagged_union);
40114001 try wip_nav.infoSectionOffset(
......@@ -4021,13 +4011,10 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
40214011 try diw.writeUleb128(union_layout.tagOffset());
40224012
40234013 for (0..loaded_union.field_types.len) |field_index| {
4024 try wip_nav.enumConstValue(loaded_tag, .{
4025 .sdata = .signed_tagged_union_field,
4026 .udata = .unsigned_tagged_union_field,
4027 .block = .big_tagged_union_field,
4028 }, field_index);
4014 try wip_nav.abbrevCode(.tagged_union_field);
4015 try wip_nav.enumConstValue(loaded_tag, field_index);
40294016 {
4030 try wip_nav.abbrevCode(.struct_field);
4017 try wip_nav.abbrevCode(.field);
40314018 try wip_nav.strp(loaded_tag.field_names.get(ip)[field_index].toSlice(ip));
40324019 const field_type: Type = .fromInterned(loaded_union.field_types.get(ip)[field_index]);
40334020 try wip_nav.refType(field_type);
......@@ -4040,27 +4027,42 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
40404027 }
40414028 try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
40424029 } else for (0..loaded_union.field_types.len) |field_index| {
4043 try wip_nav.abbrevCode(.untagged_union_field);
4030 try wip_nav.abbrevCode(.field);
40444031 try wip_nav.strp(loaded_tag.field_names.get(ip)[field_index].toSlice(ip));
40454032 const field_type: Type = .fromInterned(loaded_union.field_types.get(ip)[field_index]);
40464033 try wip_nav.refType(field_type);
4034 try diw.writeUleb128(0);
40474035 try diw.writeUleb128(loaded_union.field_aligns.getOrNone(ip, field_index).toByteUnits() orelse
40484036 if (field_type.isNoReturn(zcu)) 1 else field_type.abiAlignment(zcu).toByteUnits().?);
40494037 }
40504038 if (need_terminator) try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
40514039 },
40524040 .@"packed" => {
4053 // TODO: debug info for packed unions
4054 try wip_nav.abbrevCode(.numeric_type);
4055 try wip_nav.strp(loaded_union.name.toSlice(ip));
4056 const backing_int_ty: Type = .fromInterned(loaded_union.packed_backing_int_type);
4057 const int_info = backing_int_ty.intInfo(zcu);
4058 try diw.writeByte(switch (int_info.signedness) {
4059 inline .signed, .unsigned => |signedness| @field(DW.ATE, @tagName(signedness)),
4060 });
4061 try diw.writeUleb128(int_info.bits);
4062 try diw.writeUleb128(backing_int_ty.abiSize(zcu));
4063 try diw.writeUleb128(backing_int_ty.abiAlignment(zcu).toByteUnits().?);
4041 const need_terminator: bool = if (loaded_union.name_nav.unwrap()) |nav_index| t: {
4042 const nav = ip.getNav(nav_index);
4043 const decl_inst = nav.srcInst(ip).resolve(ip).?;
4044 const decl = zcu.fileByIndex(file).zir.?.getDeclaration(decl_inst);
4045 try wip_nav.declCommon(.{
4046 .decl = .decl_packed_union,
4047 .generic_decl = .generic_decl_const,
4048 .decl_instance = .decl_instance_packed_union,
4049 }, &nav, file, &decl);
4050 break :t true;
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));
40644066 },
40654067 }
40664068 },
......@@ -4090,11 +4092,8 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
40904092 }
40914093 try wip_nav.refType(.fromInterned(loaded_enum.int_tag_type));
40924094 for (0..loaded_enum.field_names.len) |field_index| {
4093 try wip_nav.enumConstValue(loaded_enum, .{
4094 .sdata = .signed_enum_field,
4095 .udata = .unsigned_enum_field,
4096 .block = .big_enum_field,
4097 }, field_index);
4095 try wip_nav.abbrevCode(.enum_field);
4096 try wip_nav.enumConstValue(loaded_enum, field_index);
40984097 try wip_nav.strp(loaded_enum.field_names.get(ip)[field_index].toSlice(ip));
40994098 }
41004099 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
41044103 try wip_nav.strp(loaded_enum.name.toSlice(ip));
41054104 try wip_nav.refType(.fromInterned(loaded_enum.int_tag_type));
41064105 for (0..loaded_enum.field_names.len) |field_index| {
4107 try wip_nav.enumConstValue(loaded_enum, .{
4108 .sdata = .signed_enum_field,
4109 .udata = .unsigned_enum_field,
4110 .block = .big_enum_field,
4111 }, field_index);
4106 try wip_nav.abbrevCode(.enum_field);
4107 try wip_nav.enumConstValue(loaded_enum, field_index);
41124108 try wip_nav.strp(loaded_enum.field_names.get(ip)[field_index].toSlice(ip));
41134109 }
41144110 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
42264222 } })));
42274223 for (0..error_set_type.names.len) |field_index| {
42284224 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);
42304227 try diw.writeUleb128(ip.getErrorValueIfExists(field_name).?);
42314228 try wip_nav.strp(field_name.toSlice(ip));
42324229 }
......@@ -4256,29 +4253,24 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
42564253 },
42574254 },
42584255 .int => |int| {
4259 try wip_nav.bigIntConstValue(.{
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));
4256 try wip_nav.abbrevCode(.comptime_value);
42644257 try wip_nav.refType(.fromInterned(int.ty));
4258 try wip_nav.bigIntConstValue(.fromInterned(int.ty), Value.fromInterned(value_index).toBigInt(&big_int_space, zcu));
42654259 },
42664260 .bitpack => |bitpack| {
42674261 const backing_int_val: Value = .fromInterned(bitpack.backing_int_val);
4268 try wip_nav.bigIntConstValue(.{
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));
4262 try wip_nav.abbrevCode(.comptime_value);
42734263 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));
42744265 },
42754266 .err => |err| {
4276 try wip_nav.abbrevCode(.udata_comptime_value);
4267 try wip_nav.abbrevCode(.comptime_value);
42774268 try wip_nav.refType(.fromInterned(err.ty));
4269 try diw.writeUleb128(DW.FORM.udata);
42784270 try diw.writeUleb128(try pt.getErrorValue(err.name));
42794271 },
42804272 .error_union => |error_union| {
4281 try wip_nav.abbrevCode(.aggregate_comptime_value);
4273 try wip_nav.abbrevCode(.aggregate_undefined_comptime_value);
42824274 try wip_nav.refType(.fromInterned(error_union.ty));
42834275 var err_buf: [4]u8 = undefined;
42844276 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
43204312 try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
43214313 },
43224314 .enum_literal => |enum_literal| {
4323 try wip_nav.abbrevCode(.string_comptime_value);
4324 try wip_nav.strp(enum_literal.toSlice(ip));
4315 try wip_nav.abbrevCode(.comptime_value);
43254316 try wip_nav.refType(.enum_literal);
4317 try diw.writeUleb128(DW.FORM.strp);
4318 try wip_nav.strp(enum_literal.toSlice(ip));
43264319 },
43274320 .enum_tag => |enum_tag| {
43284321 const int = ip.indexToKey(enum_tag.int).int;
4329 try wip_nav.bigIntConstValue(.{
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));
4322 try wip_nav.abbrevCode(.comptime_value);
43344323 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));
43354325 },
43364326 .float => |float| {
4327 try wip_nav.abbrevCode(.comptime_value);
4328 try wip_nav.refType(.fromInterned(float.ty));
43374329 switch (float.storage) {
43384330 .f16 => |f16_val| {
4339 try wip_nav.abbrevCode(.data2_comptime_value);
4331 try diw.writeUleb128(DW.FORM.data2);
43404332 try diw.writeInt(u16, @bitCast(f16_val), dwarf.endian);
43414333 },
43424334 .f32 => |f32_val| {
4343 try wip_nav.abbrevCode(.data4_comptime_value);
4335 try diw.writeUleb128(DW.FORM.data4);
43444336 try diw.writeInt(u32, @bitCast(f32_val), dwarf.endian);
43454337 },
43464338 .f64 => |f64_val| {
4347 try wip_nav.abbrevCode(.data8_comptime_value);
4339 try diw.writeUleb128(DW.FORM.data8);
43484340 try diw.writeInt(u64, @bitCast(f64_val), dwarf.endian);
43494341 },
43504342 .f80 => |f80_val| {
4351 try wip_nav.abbrevCode(.block_comptime_value);
4343 try diw.writeUleb128(DW.FORM.block);
43524344 try diw.writeUleb128(@divExact(80, 8));
43534345 try diw.writeInt(u80, @bitCast(f80_val), dwarf.endian);
43544346 },
43554347 .f128 => |f128_val| {
4356 try wip_nav.abbrevCode(.data16_comptime_value);
4348 try diw.writeUleb128(DW.FORM.data16);
43574349 try diw.writeInt(u128, @bitCast(f128_val), dwarf.endian);
43584350 },
43594351 }
4360 try wip_nav.refType(.fromInterned(float.ty));
43614352 },
43624353 .ptr => |ptr| {
43634354 const Access = union(enum) {
......@@ -4379,9 +4370,11 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
43794370 const uav_ty: Type = .fromInterned(ip.typeOf(uav.val));
43804371 if (uav_ty.classify(zcu) == .one_possible_value) {
43814372 try wip_nav.abbrevCode(if (zero_bit_accesses.items.len > 0)
4382 .aggregate_udata_comptime_value
4373 .aggregate_comptime_value
43834374 else
4384 .udata_comptime_value);
4375 .comptime_value);
4376 try wip_nav.refType(.fromInterned(ptr.ty));
4377 try diw.writeUleb128(DW.FORM.udata);
43854378 try diw.writeUleb128(ip.indexToKey(uav.orig_ty).ptr_type.flags.alignment.toByteUnits() orelse
43864379 uav_ty.abiAlignment(zcu).toByteUnits().?);
43874380 break :location;
......@@ -4389,9 +4382,11 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
43894382 },
43904383 .int => {
43914384 try wip_nav.abbrevCode(if (zero_bit_accesses.items.len > 0)
4392 .aggregate_udata_comptime_value
4385 .aggregate_comptime_value
43934386 else
4394 .udata_comptime_value);
4387 .comptime_value);
4388 try wip_nav.refType(.fromInterned(ptr.ty));
4389 try diw.writeUleb128(DW.FORM.udata);
43954390 try diw.writeUleb128(byte_offset);
43964391 break :location;
43974392 },
......@@ -4434,13 +4429,13 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
44344429 .aggregate_location_comptime_value
44354430 else
44364431 .location_comptime_value);
4432 try wip_nav.refType(.fromInterned(ptr.ty));
44374433 try wip_nav.infoExprLoc(.{ .implicit_pointer = .{
44384434 .unit = base_unit,
44394435 .entry = base_entry,
44404436 .offset = byte_offset,
44414437 } });
44424438 }
4443 try wip_nav.refType(.fromInterned(ptr.ty));
44444439 if (zero_bit_accesses.items.len > 0) {
44454440 for (zero_bit_accesses.items) |access| switch (access) {
44464441 .index => |index| {
......@@ -4448,15 +4443,15 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
44484443 try diw.writeUleb128(index);
44494444 },
44504445 .field => |field| {
4451 try wip_nav.abbrevCode(.field);
4446 try wip_nav.abbrevCode(.access);
44524447 try wip_nav.strp(field.toSlice(ip));
44534448 },
44544449 .synthetic_field => |field| {
4455 try wip_nav.abbrevCode(.field);
4450 try wip_nav.abbrevCode(.access);
44564451 try wip_nav.strp(field);
44574452 },
44584453 .tuple_index => |index| {
4459 try wip_nav.abbrevCode(.field);
4454 try wip_nav.abbrevCode(.access);
44604455 var field_name_buf: [std.fmt.count("{d}", .{std.math.maxInt(u32)})]u8 = undefined;
44614456 const field_name = std.fmt.bufPrint(&field_name_buf, "{d}", .{index}) catch unreachable;
44624457 try wip_nav.strp(field_name);
......@@ -4466,7 +4461,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
44664461 }
44674462 },
44684463 .slice => |slice| {
4469 try wip_nav.abbrevCode(.aggregate_comptime_value);
4464 try wip_nav.abbrevCode(.aggregate_undefined_comptime_value);
44704465 try wip_nav.refType(.fromInterned(slice.ty));
44714466 {
44724467 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
44824477 },
44834478 .opt => |opt| {
44844479 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);
44864481 try wip_nav.refType(.fromInterned(opt.ty));
44874482 {
44884483 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
45114506 try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
45124507 },
45134508 .aggregate => |aggregate| {
4514 try wip_nav.abbrevCode(.aggregate_comptime_value);
4509 try wip_nav.abbrevCode(.aggregate_undefined_comptime_value);
45154510 try wip_nav.refType(.fromInterned(aggregate.ty));
45164511 switch (ip.indexToKey(aggregate.ty)) {
45174512 .struct_type => {
......@@ -4592,9 +4587,9 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
45924587 try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
45934588 },
45944589 .un => |un| {
4595 try wip_nav.abbrevCode(.aggregate_comptime_value);
4590 try wip_nav.abbrevCode(.aggregate_undefined_comptime_value);
45964591 try wip_nav.refType(.fromInterned(un.ty));
4597 field: {
4592 {
45984593 const loaded_union_type = ip.loadUnionType(un.ty);
45994594 assert(loaded_union_type.layout == .auto);
46004595 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
46074602 else if (has_runtime_bits)
46084603 .comptime_value_field_runtime_bits
46094604 else
4610 break :field);
4605 .access);
46114606 try wip_nav.strp(field_name.toSlice(ip));
46124607 if (has_comptime_state)
46134608 try wip_nav.refValue(.fromInterned(un.val))
4614 else
4609 else if (has_runtime_bits)
46154610 try wip_nav.blockValue(.fromInterned(un.val));
46164611 }
46174612 try diw.writeUleb128(@intFromEnum(AbbrevCode.null));
......@@ -4726,7 +4721,8 @@ fn flushWriterError(dwarf: *Dwarf, pt: Zcu.PerThread) (UpdateError || Writer.Err
47264721 .bits = zcu.errorSetBits(),
47274722 } })));
47284723 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);
47304726 try diw.writeUleb128(value);
47314727 try wip_nav.strp(name.toSlice(ip));
47324728 }
......@@ -5119,6 +5115,7 @@ const AbbrevCode = enum {
51195115 decl_struct,
51205116 decl_packed_struct,
51215117 decl_union,
5118 decl_packed_union,
51225119 decl_var,
51235120 decl_const,
51245121 decl_const_runtime_bits,
......@@ -5140,6 +5137,7 @@ const AbbrevCode = enum {
51405137 decl_instance_struct,
51415138 decl_instance_packed_struct,
51425139 decl_instance_union,
5140 decl_instance_packed_union,
51435141 decl_instance_var,
51445142 decl_instance_const,
51455143 decl_instance_const_runtime_bits,
......@@ -5157,23 +5155,18 @@ const AbbrevCode = enum {
51575155 module,
51585156 empty_file,
51595157 file,
5160 field,
5161 signed_enum_field,
5162 unsigned_enum_field,
5163 big_enum_field,
5158 access,
5159 enum_field,
51645160 generated_field,
5165 struct_field,
5166 struct_field_default_runtime_bits,
5167 struct_field_default_comptime_state,
5168 struct_field_comptime,
5169 struct_field_comptime_runtime_bits,
5170 struct_field_comptime_comptime_state,
5171 packed_struct_field,
5172 untagged_union_field,
5161 field,
5162 field_default_runtime_bits,
5163 field_default_comptime_state,
5164 field_comptime,
5165 field_comptime_runtime_bits,
5166 field_comptime_comptime_state,
5167 packed_field,
51735168 tagged_union,
5174 signed_tagged_union_field,
5175 unsigned_tagged_union_field,
5176 big_tagged_union_field,
5169 tagged_union_field,
51775170 tagged_union_default_field,
51785171 void_type,
51795172 numeric_type,
......@@ -5206,6 +5199,8 @@ const AbbrevCode = enum {
52065199 packed_struct_type,
52075200 empty_union_type,
52085201 union_type,
5202 empty_packed_union_type,
5203 packed_union_type,
52095204 builtin_extern_nullary_func,
52105205 builtin_extern_func,
52115206 builtin_extern_var,
......@@ -5230,16 +5225,9 @@ const AbbrevCode = enum {
52305225 local_const_comptime_state,
52315226 local_const_runtime_bits_comptime_state,
52325227 undefined_comptime_value,
5233 data2_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,
5228 comptime_value,
52425229 location_comptime_value,
5230 aggregate_undefined_comptime_value,
52435231 aggregate_comptime_value,
52445232 aggregate_location_comptime_value,
52455233 comptime_value_field_runtime_bits,
......@@ -5334,6 +5322,13 @@ const AbbrevCode = enum {
53345322 .{ .alignment, .udata },
53355323 },
53365324 },
5325 .decl_packed_union = .{
5326 .tag = .union_type,
5327 .children = true,
5328 .attrs = decl_abbrev_common_attrs ++ .{
5329 .{ .type, .ref_addr },
5330 },
5331 },
53375332 .decl_var = .{
53385333 .tag = .variable,
53395334 .attrs = decl_abbrev_common_attrs ++ .{
......@@ -5503,6 +5498,13 @@ const AbbrevCode = enum {
55035498 .{ .alignment, .udata },
55045499 },
55055500 },
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 },
55065508 .decl_instance_var = .{
55075509 .tag = .variable,
55085510 .attrs = decl_instance_abbrev_common_attrs ++ .{
......@@ -5651,30 +5653,16 @@ const AbbrevCode = enum {
56515653 .{ .alignment, .udata },
56525654 },
56535655 },
5654 .field = .{
5656 .access = .{
56555657 .tag = .member,
56565658 .attrs = &.{
56575659 .{ .name, .strp },
56585660 },
56595661 },
5660 .signed_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 = .{
5662 .enum_field = .{
56755663 .tag = .enumerator,
56765664 .attrs = &.{
5677 .{ .const_value, .block },
5665 .{ .const_value, .indirect },
56785666 .{ .name, .strp },
56795667 },
56805668 },
......@@ -5687,7 +5675,7 @@ const AbbrevCode = enum {
56875675 .{ .artificial, .flag_present },
56885676 },
56895677 },
5690 .struct_field = .{
5678 .field = .{
56915679 .tag = .member,
56925680 .attrs = &.{
56935681 .{ .name, .strp },
......@@ -5696,7 +5684,7 @@ const AbbrevCode = enum {
56965684 .{ .alignment, .udata },
56975685 },
56985686 },
5699 .struct_field_default_runtime_bits = .{
5687 .field_default_runtime_bits = .{
57005688 .tag = .member,
57015689 .attrs = &.{
57025690 .{ .name, .strp },
......@@ -5706,7 +5694,7 @@ const AbbrevCode = enum {
57065694 .{ .default_value, .block },
57075695 },
57085696 },
5709 .struct_field_default_comptime_state = .{
5697 .field_default_comptime_state = .{
57105698 .tag = .member,
57115699 .attrs = &.{
57125700 .{ .name, .strp },
......@@ -5716,7 +5704,7 @@ const AbbrevCode = enum {
57165704 .{ .ZIG_comptime_value, .ref_addr },
57175705 },
57185706 },
5719 .struct_field_comptime = .{
5707 .field_comptime = .{
57205708 .tag = .member,
57215709 .attrs = &.{
57225710 .{ .const_expr, .flag_present },
......@@ -5724,7 +5712,7 @@ const AbbrevCode = enum {
57245712 .{ .type, .ref_addr },
57255713 },
57265714 },
5727 .struct_field_comptime_runtime_bits = .{
5715 .field_comptime_runtime_bits = .{
57285716 .tag = .member,
57295717 .attrs = &.{
57305718 .{ .const_expr, .flag_present },
......@@ -5733,7 +5721,7 @@ const AbbrevCode = enum {
57335721 .{ .const_value, .block },
57345722 },
57355723 },
5736 .struct_field_comptime_comptime_state = .{
5724 .field_comptime_comptime_state = .{
57375725 .tag = .member,
57385726 .attrs = &.{
57395727 .{ .const_expr, .flag_present },
......@@ -5742,7 +5730,7 @@ const AbbrevCode = enum {
57425730 .{ .ZIG_comptime_value, .ref_addr },
57435731 },
57445732 },
5745 .packed_struct_field = .{
5733 .packed_field = .{
57465734 .tag = .member,
57475735 .attrs = &.{
57485736 .{ .name, .strp },
......@@ -5750,14 +5738,6 @@ const AbbrevCode = enum {
57505738 .{ .data_bit_offset, .udata },
57515739 },
57525740 },
5753 .untagged_union_field = .{
5754 .tag = .member,
5755 .attrs = &.{
5756 .{ .name, .strp },
5757 .{ .type, .ref_addr },
5758 .{ .alignment, .udata },
5759 },
5760 },
57615741 .tagged_union = .{
57625742 .tag = .variant_part,
57635743 .children = true,
......@@ -5765,25 +5745,11 @@ const AbbrevCode = enum {
57655745 .{ .discr, .ref_addr },
57665746 },
57675747 },
5768 .signed_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 = .{
5748 .tagged_union_field = .{
57835749 .tag = .variant,
57845750 .children = true,
57855751 .attrs = &.{
5786 .{ .discr_value, .block },
5752 .{ .discr_value, .indirect },
57875753 },
57885754 },
57895755 .tagged_union_default_field = .{
......@@ -6038,6 +6004,23 @@ const AbbrevCode = enum {
60386004 .{ .alignment, .udata },
60396005 },
60406006 },
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 },
60416024 .builtin_extern_nullary_func = .{
60426025 .tag = .subprogram,
60436026 .attrs = &.{
......@@ -6242,90 +6225,41 @@ const AbbrevCode = enum {
62426225 .{ .type, .ref_addr },
62436226 },
62446227 },
6245 .data2_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 = .{
6228 .aggregate_undefined_comptime_value = .{
62886229 .tag = .ZIG_comptime_value,
62896230 .children = true,
62906231 .attrs = &.{
6291 .{ .const_value, .udata },
62926232 .{ .type, .ref_addr },
62936233 },
62946234 },
6295 .block_comptime_value = .{
6235 .comptime_value = .{
62966236 .tag = .ZIG_comptime_value,
62976237 .attrs = &.{
6298 .{ .const_value, .block },
62996238 .{ .type, .ref_addr },
6239 .{ .const_value, .indirect },
63006240 },
63016241 },
6302 .string_comptime_value = .{
6242 .aggregate_comptime_value = .{
63036243 .tag = .ZIG_comptime_value,
6244 .children = true,
63046245 .attrs = &.{
6305 .{ .const_value, .strp },
63066246 .{ .type, .ref_addr },
6247 .{ .const_value, .indirect },
63076248 },
63086249 },
63096250 .location_comptime_value = .{
63106251 .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,
63196252 .attrs = &.{
63206253 .{ .type, .ref_addr },
6254 .{ .location, .exprloc },
63216255 },
63226256 },
63236257 .aggregate_location_comptime_value = .{
63246258 .tag = .ZIG_comptime_value,
63256259 .children = true,
63266260 .attrs = &.{
6327 .{ .location, .exprloc },
63286261 .{ .type, .ref_addr },
6262 .{ .location, .exprloc },
63296263 },
63306264 },
63316265 .comptime_value_field_runtime_bits = .{
test/src/Debugger.zig+71-3
......@@ -215,6 +215,74 @@ pub fn addTestsForTarget(db: *Debugger, target: *const Target) void {
215215 \\1 breakpoints deleted; 0 breakpoint locations disabled.
216216 },
217217 );
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 );
218286 db.addLldbTest(
219287 "pointers",
220288 target,
......@@ -464,7 +532,7 @@ pub fn addTestsForTarget(db: *Debugger, target: *const Target) void {
464532 ,
465533 &.{
466534 \\(lldb) expression --show-types -- Enums
467 \\(type) Enums = struct {
535 \\(type) $0 = struct {
468536 \\ (type) Zero = enum {}
469537 \\ (type) One = enum {
470538 \\ (root.enums.Enums.One) first = .first
......@@ -528,7 +596,7 @@ pub fn addTestsForTarget(db: *Debugger, target: *const Target) void {
528596 ,
529597 &.{
530598 \\(lldb) expression --show-types -- Errors
531 \\(type) Errors = struct {
599 \\(type) $0 = struct {
532600 \\ (type) Zero = error {}
533601 \\ (type) One = error {
534602 \\ (error{One}) One = error.One
......@@ -661,7 +729,7 @@ pub fn addTestsForTarget(db: *Debugger, target: *const Target) void {
661729 ,
662730 &.{
663731 \\(lldb) expression --show-types -- Unions
664 \\(type) Unions = struct {
732 \\(type) $0 = struct {
665733 \\ (type) Untagged = union {}
666734 \\ (type) SafetyTagged = union(enum) {
667735 \\ (@typeInfo(unions.Unions.SafetyTagged).@"union".tag_type.?) void = .void