aboutsummaryrefslogtreecommitdiff
path: root/lib/std/debug.zig
diff options
context:
space:
mode:
authorkcbanner <kcbanner@gmail.com>2023-05-22 14:45:24 -0400
committerkcbanner <kcbanner@gmail.com>2023-07-20 22:58:13 -0400
commit9145ff7da073966ace27151f7a0921b20c7860f4 (patch)
treee033aa47d0a73180f7f7bcdb220f2e91d2897db0 /lib/std/debug.zig
parentb449d98a935a20429874d8eb379d9cc0e49c5fcd (diff)
downloadzig-9145ff7da073966ace27151f7a0921b20c7860f4.tar.gz
zig-9145ff7da073966ace27151f7a0921b20c7860f4.zip
dwarf: implement more register number mappings
- add dwarf.abi.RegisterContext to handle register numbers changing based on DWARF format
Diffstat (limited to 'lib/std/debug.zig')
-rw-r--r--lib/std/debug.zig12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig
index 5e63bd9704..66dfdc1838 100644
--- a/lib/std/debug.zig
+++ b/lib/std/debug.zig
@@ -521,6 +521,8 @@ pub const StackIterator = struct {
fn next_dwarf(self: *StackIterator) !void {
const module = try self.debug_info.?.getModuleForAddress(self.dwarf_context.pc);
if (module.getDwarfInfo()) |di| {
+ self.dwarf_context.reg_ctx.eh_frame = true;
+ self.dwarf_context.reg_ctx.is_macho = di.is_macho;
try di.unwindFrame(self.debug_info.?.allocator, &self.dwarf_context, module.base_address);
} else return error.MissingDebugInfo;
}
@@ -532,6 +534,10 @@ pub const StackIterator = struct {
} else |err| {
// Fall back to fp unwinding on the first failure,
// as the register context won't be updated
+
+ // TODO: Could still attempt dwarf unwinding after this, maybe marking non-updated registers as
+ // invalid, so the unwind only fails if it requires out of date registers?
+
self.fp = self.dwarf_context.getFp() catch 0;
self.debug_info = null;
@@ -854,6 +860,7 @@ fn readCoffDebugInfo(allocator: mem.Allocator, coff_bytes: []const u8) !ModuleDe
var dwarf = DW.DwarfInfo{
.endian = native_endian,
.sections = sections,
+ .is_macho = false,
};
try DW.openDwarfDebugInfo(&dwarf, allocator, coff_bytes);
@@ -1079,6 +1086,7 @@ pub fn readElfDebugInfo(
var di = DW.DwarfInfo{
.endian = endian,
.sections = sections,
+ .is_macho = false,
};
try DW.openDwarfDebugInfo(&di, allocator, parent_mapped_mem orelse mapped_mem);
@@ -1682,6 +1690,10 @@ pub const ModuleDebugInfo = switch (native_os) {
var di = DW.DwarfInfo{
.endian = .Little,
+ .is_macho = true,
+
+ // TODO: Get this compiling
+
.debug_info = try chopSlice(mapped_mem, debug_info.offset, debug_info.size),
.debug_abbrev = try chopSlice(mapped_mem, debug_abbrev.offset, debug_abbrev.size),
.debug_str = try chopSlice(mapped_mem, debug_str.offset, debug_str.size),