std.debug: Fall back to .eh_frame/.debug_frame if .eh_frame_hdr is incomplete.

When using the self-hosted backends, especially in incremental mode, the
.eh_frame_hdr section may be incomplete, so we can't treat it as authoritative.

Instead, if we started out intending to use .eh_frame_hdr but find that it's
incomplete, load .eh_frame/.debug_frame on demand and use that info going
forward.
This commit is contained in:
Alex Rønne Petersen
2025-01-23 20:55:20 +01:00
committed by mlugg
parent 41185d297f
commit 180db2bf23
3 changed files with 88 additions and 39 deletions

View File

@@ -732,11 +732,12 @@ pub const StackIterator = struct {
// via DWARF before attempting to use the compact unwind info will produce incorrect results.
if (module.unwind_info) |unwind_info| {
if (SelfInfo.unwindFrameMachO(
unwind_state.debug_info.allocator,
module.base_address,
&unwind_state.dwarf_context,
&it.ma,
unwind_info,
module.eh_frame,
module.base_address,
)) |return_address| {
return return_address;
} else |err| {
@@ -748,7 +749,14 @@ pub const StackIterator = struct {
}
if (try module.getDwarfInfoForAddress(unwind_state.debug_info.allocator, unwind_state.dwarf_context.pc)) |di| {
return SelfInfo.unwindFrameDwarf(di, &unwind_state.dwarf_context, &it.ma, null);
return SelfInfo.unwindFrameDwarf(
unwind_state.debug_info.allocator,
di,
module.base_address,
&unwind_state.dwarf_context,
&it.ma,
null,
);
} else return error.MissingDebugInfo;
}