diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2025-09-18 13:32:47 +0100 |
|---|---|---|
| committer | mlugg <mlugg@mlugg.co.uk> | 2025-09-30 13:44:55 +0100 |
| commit | 2ab650b4817cbb22244c17de828e82cbb0ccf15e (patch) | |
| tree | deebb1090f939f52a363de30179f2136f8819588 /lib/std/debug/SelfInfo/WindowsModule.zig | |
| parent | 9434bab3134edadae7ae7e575f6b025cafc6a59a (diff) | |
| download | zig-2ab650b4817cbb22244c17de828e82cbb0ccf15e.tar.gz zig-2ab650b4817cbb22244c17de828e82cbb0ccf15e.zip | |
std.debug: go back to storing return addresses instead of call addresses
...and just deal with signal handlers by adding 1 to create a fake
"return address". The system I tried out where the addresses returned by
`StackIterator` were pre-subtracted didn't play nicely with error
traces, which in hindsight, makes perfect sense. This definition also
removes some ugly off-by-one issues in matching `first_address`, so I do
think this is a better approach.
Diffstat (limited to 'lib/std/debug/SelfInfo/WindowsModule.zig')
| -rw-r--r-- | lib/std/debug/SelfInfo/WindowsModule.zig | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/std/debug/SelfInfo/WindowsModule.zig b/lib/std/debug/SelfInfo/WindowsModule.zig index 75abc39ff5..1fdf69b2a0 100644 --- a/lib/std/debug/SelfInfo/WindowsModule.zig +++ b/lib/std/debug/SelfInfo/WindowsModule.zig @@ -373,7 +373,7 @@ pub const UnwindContext = struct { return ctx.cur.getRegs().bp; } }; -pub fn unwindFrame(module: *const WindowsModule, gpa: Allocator, di: *DebugInfo, context: *UnwindContext) !void { +pub fn unwindFrame(module: *const WindowsModule, gpa: Allocator, di: *DebugInfo, context: *UnwindContext) !usize { _ = module; _ = gpa; _ = di; @@ -403,9 +403,12 @@ pub fn unwindFrame(module: *const WindowsModule, gpa: Allocator, di: *DebugInfo, const tib = &windows.teb().NtTib; if (next_regs.sp < @intFromPtr(tib.StackLimit) or next_regs.sp > @intFromPtr(tib.StackBase)) { context.pc = 0; - } else { - context.pc = next_regs.ip -| 1; + return 0; } + // Like `DwarfUnwindContext.unwindFrame`, adjust our next lookup pc in case the `call` was this + // function's last instruction making `next_regs.ip` one byte past its end. + context.pc = next_regs.ip -| 1; + return next_regs.ip; } const WindowsModule = @This(); |
