mirror of
https://github.com/ziglang/zig.git
synced 2025-12-26 16:13:07 +00:00
Dwarf: ensure stale relocations are deleted
This commit is contained in:
parent
b17bbf9e6c
commit
db48a78963
@ -1958,11 +1958,10 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
|
||||
const loc = tree.tokenLocation(0, tree.nodes.items(.main_token)[decl_inst.data.declaration.src_node]);
|
||||
assert(loc.line == zcu.navSrcLine(nav_index));
|
||||
|
||||
const unit = try dwarf.getUnit(file.mod);
|
||||
var wip_nav: WipNav = .{
|
||||
.dwarf = dwarf,
|
||||
.pt = pt,
|
||||
.unit = unit,
|
||||
.unit = try dwarf.getUnit(file.mod),
|
||||
.entry = undefined,
|
||||
.any_children = false,
|
||||
.func = .none,
|
||||
@ -1981,7 +1980,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
|
||||
switch (ip.indexToKey(nav_val.toIntern())) {
|
||||
.func => |func| {
|
||||
if (nav_gop.found_existing) {
|
||||
const unit_ptr = dwarf.debug_info.section.getUnit(unit);
|
||||
const unit_ptr = dwarf.debug_info.section.getUnit(wip_nav.unit);
|
||||
const entry_ptr = unit_ptr.getEntry(nav_gop.value_ptr.*);
|
||||
if (entry_ptr.len >= AbbrevCode.decl_bytes) {
|
||||
var abbrev_code_buf: [AbbrevCode.decl_bytes]u8 = undefined;
|
||||
@ -2000,7 +1999,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
|
||||
}
|
||||
}
|
||||
entry_ptr.clear();
|
||||
} else nav_gop.value_ptr.* = try dwarf.addCommonEntry(unit);
|
||||
} else nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
|
||||
wip_nav.entry = nav_gop.value_ptr.*;
|
||||
|
||||
const parent_type, const accessibility: u8 = if (nav.analysis_owner.unwrap()) |cau| parent: {
|
||||
@ -2074,8 +2073,14 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
|
||||
if (type_inst_info.inst != value_inst) break :decl_struct;
|
||||
|
||||
const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());
|
||||
if (type_gop.found_existing) nav_gop.value_ptr.* = type_gop.value_ptr.* else {
|
||||
if (!nav_gop.found_existing) nav_gop.value_ptr.* = try dwarf.addCommonEntry(unit);
|
||||
if (type_gop.found_existing) {
|
||||
dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(type_gop.value_ptr.*).clear();
|
||||
nav_gop.value_ptr.* = type_gop.value_ptr.*;
|
||||
} else {
|
||||
if (nav_gop.found_existing)
|
||||
dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear()
|
||||
else
|
||||
nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
|
||||
type_gop.value_ptr.* = nav_gop.value_ptr.*;
|
||||
}
|
||||
wip_nav.entry = nav_gop.value_ptr.*;
|
||||
@ -2139,7 +2144,10 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
|
||||
break :done;
|
||||
}
|
||||
|
||||
if (!nav_gop.found_existing) nav_gop.value_ptr.* = try dwarf.addCommonEntry(unit);
|
||||
if (nav_gop.found_existing)
|
||||
dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear()
|
||||
else
|
||||
nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
|
||||
wip_nav.entry = nav_gop.value_ptr.*;
|
||||
const diw = wip_nav.debug_info.writer(dwarf.gpa);
|
||||
try uleb128(diw, @intFromEnum(AbbrevCode.decl_alias));
|
||||
@ -2190,8 +2198,14 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
|
||||
if (type_inst_info.inst != value_inst) break :decl_enum;
|
||||
|
||||
const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());
|
||||
if (type_gop.found_existing) nav_gop.value_ptr.* = type_gop.value_ptr.* else {
|
||||
if (!nav_gop.found_existing) nav_gop.value_ptr.* = try dwarf.addCommonEntry(unit);
|
||||
if (type_gop.found_existing) {
|
||||
dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(type_gop.value_ptr.*).clear();
|
||||
nav_gop.value_ptr.* = type_gop.value_ptr.*;
|
||||
} else {
|
||||
if (nav_gop.found_existing)
|
||||
dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear()
|
||||
else
|
||||
nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
|
||||
type_gop.value_ptr.* = nav_gop.value_ptr.*;
|
||||
}
|
||||
wip_nav.entry = nav_gop.value_ptr.*;
|
||||
@ -2215,7 +2229,10 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
|
||||
break :done;
|
||||
}
|
||||
|
||||
if (!nav_gop.found_existing) nav_gop.value_ptr.* = try dwarf.addCommonEntry(unit);
|
||||
if (nav_gop.found_existing)
|
||||
dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear()
|
||||
else
|
||||
nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
|
||||
wip_nav.entry = nav_gop.value_ptr.*;
|
||||
const diw = wip_nav.debug_info.writer(dwarf.gpa);
|
||||
try uleb128(diw, @intFromEnum(AbbrevCode.decl_alias));
|
||||
@ -2264,8 +2281,14 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
|
||||
if (type_inst_info.inst != value_inst) break :decl_union;
|
||||
|
||||
const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());
|
||||
if (type_gop.found_existing) nav_gop.value_ptr.* = type_gop.value_ptr.* else {
|
||||
if (!nav_gop.found_existing) nav_gop.value_ptr.* = try dwarf.addCommonEntry(unit);
|
||||
if (type_gop.found_existing) {
|
||||
dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(type_gop.value_ptr.*).clear();
|
||||
nav_gop.value_ptr.* = type_gop.value_ptr.*;
|
||||
} else {
|
||||
if (nav_gop.found_existing)
|
||||
dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear()
|
||||
else
|
||||
nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
|
||||
type_gop.value_ptr.* = nav_gop.value_ptr.*;
|
||||
}
|
||||
wip_nav.entry = nav_gop.value_ptr.*;
|
||||
@ -2328,7 +2351,10 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
|
||||
break :done;
|
||||
}
|
||||
|
||||
if (!nav_gop.found_existing) nav_gop.value_ptr.* = try dwarf.addCommonEntry(unit);
|
||||
if (nav_gop.found_existing)
|
||||
dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear()
|
||||
else
|
||||
nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
|
||||
wip_nav.entry = nav_gop.value_ptr.*;
|
||||
const diw = wip_nav.debug_info.writer(dwarf.gpa);
|
||||
try uleb128(diw, @intFromEnum(AbbrevCode.decl_alias));
|
||||
@ -2377,8 +2403,14 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
|
||||
if (type_inst_info.inst != value_inst) break :decl_opaque;
|
||||
|
||||
const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());
|
||||
if (type_gop.found_existing) nav_gop.value_ptr.* = type_gop.value_ptr.* else {
|
||||
if (!nav_gop.found_existing) nav_gop.value_ptr.* = try dwarf.addCommonEntry(unit);
|
||||
if (type_gop.found_existing) {
|
||||
dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(type_gop.value_ptr.*).clear();
|
||||
nav_gop.value_ptr.* = type_gop.value_ptr.*;
|
||||
} else {
|
||||
if (nav_gop.found_existing)
|
||||
dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear()
|
||||
else
|
||||
nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
|
||||
type_gop.value_ptr.* = nav_gop.value_ptr.*;
|
||||
}
|
||||
wip_nav.entry = nav_gop.value_ptr.*;
|
||||
@ -2394,7 +2426,10 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
|
||||
break :done;
|
||||
}
|
||||
|
||||
if (!nav_gop.found_existing) nav_gop.value_ptr.* = try dwarf.addCommonEntry(unit);
|
||||
if (nav_gop.found_existing)
|
||||
dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear()
|
||||
else
|
||||
nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
|
||||
wip_nav.entry = nav_gop.value_ptr.*;
|
||||
const diw = wip_nav.debug_info.writer(dwarf.gpa);
|
||||
try uleb128(diw, @intFromEnum(AbbrevCode.decl_alias));
|
||||
@ -2412,7 +2447,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
|
||||
},
|
||||
}
|
||||
try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.items);
|
||||
try dwarf.debug_loclists.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_loclists.items);
|
||||
try wip_nav.flush();
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user