Skip to content

Commit 4870fbd

Browse files
authored
vm_dump.c: unbreak unwind on powerpc (ruby#14650)
1 parent bdeee70 commit 4870fbd

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

vm_dump.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ rb_vmdebug_thread_dump_state(FILE *errout, VALUE self)
770770
# include <sys/mman.h>
771771
# undef backtrace
772772

773-
# if defined(__arm64__)
773+
# if defined(__arm64__) || defined(__POWERPC__)
774774
static bool
775775
is_coroutine_start(unw_word_t ip)
776776
{
@@ -879,19 +879,22 @@ backtrace(void **trace, int size)
879879
}
880880
return n;
881881

882-
# elif defined(__arm64__)
882+
# elif defined(__arm64__) || defined(__POWERPC__)
883883
/* Since Darwin arm64's _sigtramp is implemented as normal function,
884884
* unwind can unwind frames without special code.
885885
* https://github.com/apple/darwin-libplatform/blob/215b09856ab5765b7462a91be7076183076600df/src/setjmp/generic/sigtramp.c
886886
*/
887887
while (unw_step(&cursor) > 0) {
888888
unw_get_reg(&cursor, UNW_REG_IP, &ip);
889+
# if defined(__arm64__)
889890
// Strip Arm64's pointer authentication.
890891
// https://developer.apple.com/documentation/security/preparing_your_app_to_work_with_pointer_authentication
891892
// I wish I could use "ptrauth_strip()" but I get an error:
892893
// "this target does not support pointer authentication"
893894
trace[n++] = (void *)(ip & 0x7fffffffffffull);
894-
895+
# else
896+
trace[n++] = (void *)ip;
897+
# endif
895898
// Apple's libunwind can't handle our coroutine switching code
896899
if (is_coroutine_start(ip)) break;
897900
}

0 commit comments

Comments
 (0)