authorgravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2023-07-18 02:04:48-04:00
committergravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2023-07-20 22:58:16-04:00
log2bc2b01dbc0757c5381dd79c32c2f607a6bcc270
treeb2b97a0f3112a7427745ca79bc8df8f8f7f54c27
parentd99b40d38b48f046b8d7faa7698315d6c93bf685

dwarf: update the pc register


1 files changed, 8 insertions(+), 10 deletions(-)

lib/std/dwarf.zig+8-10
...@@ -1796,12 +1796,12 @@ pub const DwarfInfo = struct {...@@ -1796,12 +1796,12 @@ pub const DwarfInfo = struct {
1796 };1796 };
17971797
1798 var update_tail: ?*RegisterUpdate = null;1798 var update_tail: ?*RegisterUpdate = null;
1799 var has_next_ip = false;
1800 for (context.vm.rowColumns(row)) |column| {1799 for (context.vm.rowColumns(row)) |column| {
1801 if (column.register) |register| {1800 if (column.register) |register| {
1802 if (register == cie.return_address_register) {1801 if (register == cie.return_address_register) {
1803 has_next_ip = column.rule != .undefined;1802 has_next_ip = column.rule != .undefined;
1804 }1803 }
1804 std.debug.print(" updated {}\n", .{register});
18051805
1806 const old_value = try abi.regBytes(context.thread_context, register, context.reg_context);1806 const old_value = try abi.regBytes(context.thread_context, register, context.reg_context);
1807 const new_value = try update_allocator.alloc(u8, old_value.len);1807 const new_value = try update_allocator.alloc(u8, old_value.len);
...@@ -1828,15 +1828,13 @@ pub const DwarfInfo = struct {...@@ -1828,15 +1828,13 @@ pub const DwarfInfo = struct {
1828 update_tail = tail.prev;1828 update_tail = tail.prev;
1829 }1829 }
18301830
1831 if (has_next_ip) {1831 context.pc = abi.stripInstructionPtrAuthCode(mem.readIntSliceNative(usize, try abi.regBytes(
1832 context.pc = abi.stripInstructionPtrAuthCode(mem.readIntSliceNative(usize, try abi.regBytes(1832 context.thread_context,
1833 context.thread_context,1833 cie.return_address_register,
1834 cie.return_address_register,1834 context.reg_context,
1835 context.reg_context,1835 )));
1836 )));1836 (try abi.regValueNative(usize, context.thread_context, abi.ipRegNum(), context.reg_context)).* = context.pc;
1837 } else {1837 std.debug.print(" new context.pc: 0x{x}\n", .{context.pc});
1838 context.pc = 0;
1839 }
18401838
1841 (try abi.regValueNative(usize, context.thread_context, abi.spRegNum(context.reg_context), context.reg_context)).* = context.cfa.?;1839 (try abi.regValueNative(usize, context.thread_context, abi.spRegNum(context.reg_context), context.reg_context)).* = context.cfa.?;
18421840