From 4421b14878eb722da8a57069b2152f7b43ba7ffc Mon Sep 17 00:00:00 2001 From: kcbanner Date: Tue, 18 Jul 2023 14:02:09 -0400 Subject: [PATCH] dwarf: fixup rules for setting ip --- lib/std/dwarf.zig | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/std/dwarf.zig b/lib/std/dwarf.zig index 08bc34759be3ab6e84b33173546e222f39175b35..7aee8e0aa38d998ccbbe3ec9376e7f2917151058 100644 --- a/lib/std/dwarf.zig +++ b/lib/std/dwarf.zig @@ -1796,6 +1796,7 @@ pub const DwarfInfo = struct { }; var update_tail: ?*RegisterUpdate = null; + var has_next_ip = true; for (context.vm.rowColumns(row)) |column| { if (column.register) |register| { if (register == cie.return_address_register) { @@ -1828,11 +1829,15 @@ pub const DwarfInfo = struct { update_tail = tail.prev; } - context.pc = abi.stripInstructionPtrAuthCode(mem.readIntSliceNative(usize, try abi.regBytes( - context.thread_context, - cie.return_address_register, - context.reg_context, - ))); + if (has_next_ip) { + context.pc = abi.stripInstructionPtrAuthCode(mem.readIntSliceNative(usize, try abi.regBytes( + context.thread_context, + cie.return_address_register, + context.reg_context, + ))); + } else { + context.pc = 0; + } (try abi.regValueNative(usize, context.thread_context, abi.ipRegNum(), context.reg_context)).* = context.pc; std.debug.print(" new context.pc: 0x{x}\n", .{context.pc}); -- 2.54.0