Skip to content

Commit

Permalink
Fix frame pointer calculation for symbol frames under libunwind, #123
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-rifkin committed May 19, 2024
1 parent b2fe396 commit 4884c4e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/unwind/unwind_with_libunwind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,16 @@ namespace detail {
if(skip) {
skip--;
} else {
// pc is the instruction after the `call`, adjust back to the previous instruction
// just a cast, signal safe
buffer[i] = to_frame_ptr(pc) - 1;
// thread and signal-safe
if(unw_is_signal_frame(&cursor)) {
// pc is the instruction that caused the signal
// just a cast, thread and signal safe
buffer[i] = to_frame_ptr(pc);
} else {
// pc is the instruction after the `call`, adjust back to the previous instruction
// just a cast, thread and signal safe
buffer[i] = to_frame_ptr(pc) - 1;
}
i++;
}
// thread and signal-safe as long as the cursor is in the local address space, which it is
Expand Down

0 comments on commit 4884c4e

Please sign in to comment.