vm_dump.c: unbreak unwind on powerpc (#14650)

This commit is contained in:
Sergey Fedorov 2025-11-17 07:49:56 +08:00 committed by GitHub
parent bdeee7012c
commit 4870fbd04a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
Notes: git 2025-11-16 23:50:26 +00:00
Merged-By: ioquatix <samuel@codeotaku.com>

View File

@ -770,7 +770,7 @@ rb_vmdebug_thread_dump_state(FILE *errout, VALUE self)
# include <sys/mman.h>
# undef backtrace
# if defined(__arm64__)
# if defined(__arm64__) || defined(__POWERPC__)
static bool
is_coroutine_start(unw_word_t ip)
{
@ -879,19 +879,22 @@ darwin_sigtramp:
}
return n;
# elif defined(__arm64__)
# elif defined(__arm64__) || defined(__POWERPC__)
/* Since Darwin arm64's _sigtramp is implemented as normal function,
* unwind can unwind frames without special code.
* https://github.com/apple/darwin-libplatform/blob/215b09856ab5765b7462a91be7076183076600df/src/setjmp/generic/sigtramp.c
*/
while (unw_step(&cursor) > 0) {
unw_get_reg(&cursor, UNW_REG_IP, &ip);
# if defined(__arm64__)
// Strip Arm64's pointer authentication.
// https://developer.apple.com/documentation/security/preparing_your_app_to_work_with_pointer_authentication
// I wish I could use "ptrauth_strip()" but I get an error:
// "this target does not support pointer authentication"
trace[n++] = (void *)(ip & 0x7fffffffffffull);
# else
trace[n++] = (void *)ip;
# endif
// Apple's libunwind can't handle our coroutine switching code
if (is_coroutine_start(ip)) break;
}