Skip to content

Commit

Permalink
Dwarf: remove redundant debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobly0 committed Dec 19, 2024
1 parent 0ff0bdb commit 0620647
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 68 deletions.
1 change: 0 additions & 1 deletion lib/std/dwarf/AT.zig
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ pub const ZIG_padding = 0x2cce;
pub const ZIG_relative_decl = 0x2cd0;
pub const ZIG_decl_line_relative = 0x2cd1;
pub const ZIG_comptime_value = 0x2cd2;
pub const ZIG_comptime_default_value = 0x2cd3;
pub const ZIG_sentinel = 0x2ce2;

// UPC extension.
Expand Down
93 changes: 27 additions & 66 deletions src/link/Dwarf.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2687,23 +2687,19 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
},
};
try wip_nav.abbrevCode(if (is_comptime)
if (has_runtime_bits and has_comptime_state)
.struct_field_comptime_runtime_bits_comptime_state
else if (has_comptime_state)
if (has_comptime_state)
.struct_field_comptime_comptime_state
else if (has_runtime_bits)
.struct_field_comptime_runtime_bits
else
.struct_field_comptime
else if (field_init != .none)
if (has_runtime_bits and has_comptime_state)
.struct_field_default_runtime_bits_comptime_state
else if (has_comptime_state)
if (has_comptime_state)
.struct_field_default_comptime_state
else if (has_runtime_bits)
.struct_field_default_runtime_bits
else
.struct_field_default
.struct_field
else
.struct_field);
if (loaded_struct.fieldName(ip, field_index).unwrap()) |field_name| try wip_nav.strp(field_name.toSlice(ip)) else {
Expand All @@ -2717,8 +2713,10 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse
field_type.abiAlignment(zcu).toByteUnits().?);
}
if (has_runtime_bits) try wip_nav.blockValue(nav_src_loc, .fromInterned(field_init));
if (has_comptime_state) try wip_nav.refValue(.fromInterned(field_init));
if (has_comptime_state)
try wip_nav.refValue(.fromInterned(field_init))
else if (has_runtime_bits)
try wip_nav.blockValue(nav_src_loc, .fromInterned(field_init));
}
try uleb128(diw, @intFromEnum(AbbrevCode.null));
}
Expand Down Expand Up @@ -3363,9 +3361,7 @@ fn updateLazyType(
field_type.comptimeOnly(zcu) and try field_type.onePossibleValue(pt) == null,
},
};
try wip_nav.abbrevCode(if (has_runtime_bits and has_comptime_state)
.struct_field_comptime_runtime_bits_comptime_state
else if (has_comptime_state)
try wip_nav.abbrevCode(if (has_comptime_state)
.struct_field_comptime_comptime_state
else if (has_runtime_bits)
.struct_field_comptime_runtime_bits
Expand All @@ -3386,8 +3382,10 @@ fn updateLazyType(
try uleb128(diw, field_type.abiAlignment(zcu).toByteUnits().?);
field_byte_offset += field_type.abiSize(zcu);
}
if (has_runtime_bits) try wip_nav.blockValue(src_loc, .fromInterned(comptime_value));
if (has_comptime_state) try wip_nav.refValue(.fromInterned(comptime_value));
if (has_comptime_state)
try wip_nav.refValue(.fromInterned(comptime_value))
else if (has_runtime_bits)
try wip_nav.blockValue(src_loc, .fromInterned(comptime_value));
}
try uleb128(diw, @intFromEnum(AbbrevCode.null));
},
Expand Down Expand Up @@ -3956,23 +3954,19 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
},
};
try wip_nav.abbrevCode(if (is_comptime)
if (has_runtime_bits and has_comptime_state)
.struct_field_comptime_runtime_bits_comptime_state
else if (has_comptime_state)
if (has_comptime_state)
.struct_field_comptime_comptime_state
else if (has_runtime_bits)
.struct_field_comptime_runtime_bits
else
.struct_field_comptime
else if (field_init != .none)
if (has_runtime_bits and has_comptime_state)
.struct_field_default_runtime_bits_comptime_state
else if (has_comptime_state)
if (has_comptime_state)
.struct_field_default_comptime_state
else if (has_runtime_bits)
.struct_field_default_runtime_bits
else
.struct_field_default
.struct_field
else
.struct_field);
if (loaded_struct.fieldName(ip, field_index).unwrap()) |field_name| try wip_nav.strp(field_name.toSlice(ip)) else {
Expand All @@ -3986,8 +3980,10 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse
field_type.abiAlignment(zcu).toByteUnits().?);
}
if (has_runtime_bits) try wip_nav.blockValue(ty_src_loc, .fromInterned(field_init));
if (has_comptime_state) try wip_nav.refValue(.fromInterned(field_init));
if (has_comptime_state)
try wip_nav.refValue(.fromInterned(field_init))
else if (has_runtime_bits)
try wip_nav.blockValue(ty_src_loc, .fromInterned(field_init));
}
try uleb128(diw, @intFromEnum(AbbrevCode.null));
}
Expand Down Expand Up @@ -4064,23 +4060,19 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
},
};
try wip_nav.abbrevCode(if (is_comptime)
if (has_runtime_bits and has_comptime_state)
.struct_field_comptime_runtime_bits_comptime_state
else if (has_comptime_state)
if (has_comptime_state)
.struct_field_comptime_comptime_state
else if (has_runtime_bits)
.struct_field_comptime_runtime_bits
else
.struct_field_comptime
else if (field_init != .none)
if (has_runtime_bits and has_comptime_state)
.struct_field_default_runtime_bits_comptime_state
else if (has_comptime_state)
if (has_comptime_state)
.struct_field_default_comptime_state
else if (has_runtime_bits)
.struct_field_default_runtime_bits
else
.struct_field_default
.struct_field
else
.struct_field);
if (loaded_struct.fieldName(ip, field_index).unwrap()) |field_name| try wip_nav.strp(field_name.toSlice(ip)) else {
Expand All @@ -4094,8 +4086,10 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse
field_type.abiAlignment(zcu).toByteUnits().?);
}
if (has_runtime_bits) try wip_nav.blockValue(ty_src_loc, .fromInterned(field_init));
if (has_comptime_state) try wip_nav.refValue(.fromInterned(field_init));
if (has_comptime_state)
try wip_nav.refValue(.fromInterned(field_init))
else if (has_runtime_bits)
try wip_nav.blockValue(ty_src_loc, .fromInterned(field_init));
}
try uleb128(diw, @intFromEnum(AbbrevCode.null));
}
Expand Down Expand Up @@ -4680,14 +4674,11 @@ const AbbrevCode = enum {
big_enum_field,
generated_field,
struct_field,
struct_field_default,
struct_field_default_runtime_bits,
struct_field_default_comptime_state,
struct_field_default_runtime_bits_comptime_state,
struct_field_comptime,
struct_field_comptime_runtime_bits,
struct_field_comptime_comptime_state,
struct_field_comptime_runtime_bits_comptime_state,
packed_struct_field,
untagged_union_field,
tagged_union,
Expand Down Expand Up @@ -4980,15 +4971,6 @@ const AbbrevCode = enum {
.{ .alignment, .udata },
},
},
.struct_field_default = .{
.tag = .member,
.attrs = &.{
.{ .name, .strp },
.{ .type, .ref_addr },
.{ .data_member_location, .udata },
.{ .alignment, .udata },
},
},
.struct_field_default_runtime_bits = .{
.tag = .member,
.attrs = &.{
Expand All @@ -5006,18 +4988,7 @@ const AbbrevCode = enum {
.{ .type, .ref_addr },
.{ .data_member_location, .udata },
.{ .alignment, .udata },
.{ .ZIG_comptime_default_value, .ref_addr },
},
},
.struct_field_default_runtime_bits_comptime_state = .{
.tag = .member,
.attrs = &.{
.{ .name, .strp },
.{ .type, .ref_addr },
.{ .data_member_location, .udata },
.{ .alignment, .udata },
.{ .default_value, .block },
.{ .ZIG_comptime_default_value, .ref_addr },
.{ .ZIG_comptime_value, .ref_addr },
},
},
.struct_field_comptime = .{
Expand Down Expand Up @@ -5046,16 +5017,6 @@ const AbbrevCode = enum {
.{ .ZIG_comptime_value, .ref_addr },
},
},
.struct_field_comptime_runtime_bits_comptime_state = .{
.tag = .member,
.attrs = &.{
.{ .const_expr, .flag_present },
.{ .name, .strp },
.{ .type, .ref_addr },
.{ .const_value, .block },
.{ .ZIG_comptime_value, .ref_addr },
},
},
.packed_struct_field = .{
.tag = .member,
.attrs = &.{
Expand Down
2 changes: 1 addition & 1 deletion tools/lldb_pretty_printers.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ class root_InternPool_Local_List_SynthProvider:
def __init__(self, value, _=None): self.value = value
def update(self):
capacity = self.value.EvaluateExpression('@as(*@This().Header, @alignCast(@ptrCast(@this().bytes - @This().bytes_offset))).capacity')
self.view = create_struct('view', self.value.EvaluateExpression('@This().View').GetValueAsType(), bytes=self.value.GetChildMemberWithName('bytes'), len=capacity, capacity=capacity).GetNonSyntheticValue()
self.view = create_struct('view', self.value.type.FindDirectNestedType('View'), bytes=self.value.GetChildMemberWithName('bytes'), len=capacity, capacity=capacity).GetNonSyntheticValue()
def has_children(self): return True
def num_children(self): return 1
def get_child_index(self, name):
Expand Down

0 comments on commit 0620647

Please sign in to comment.