1Compatibility fixes for musl. 2 3--- a/m4/pc_from_ucontext.m4 4+++ b/m4/pc_from_ucontext.m4 5@@ -34,6 +34,7 @@ AC_DEFUN([AC_PC_FROM_UCONTEXT], 6 pc_fields="$pc_fields uc_mcontext.arm_pc" # Linux (arm arch 5) 7 pc_fields="$pc_fields uc_mcontext.cr0_hi" # Linux (e2k) 8 pc_fields="$pc_fields uc_mcontext.gp_regs[[PT_NIP]]" # Suse SLES 11 (ppc64) 9+ pc_fields="$pc_fields uc_mcontext.gregs[[PT_NIP]]" 10 pc_fields="$pc_fields uc_mcontext.mc_eip" # FreeBSD (i386) 11 pc_fields="$pc_fields uc_mcontext.mc_srr0" # FreeBSD (powerpc, powerpc64) 12 pc_fields="$pc_fields uc_mcontext.mc_rip" # FreeBSD (x86_64 [untested]) 13@@ -77,7 +78,8 @@ AC_DEFUN([AC_PC_FROM_UCONTEXT], 14 pc_field_found=true) 15 elif test "x$ac_cv_header_ucontext_h" = xyes; then 16 AC_TRY_COMPILE([#define _GNU_SOURCE 1 17- #include <ucontext.h>], 18+ #include <ucontext.h> 19+ #include <asm/ptrace.h>], 20 [ucontext_t u; return u.$pc_field == 0;], 21 AC_DEFINE_UNQUOTED(PC_FROM_UCONTEXT, $pc_field, 22 How to access the PC from a struct ucontext) 23--- a/src/getpc.h 24+++ b/src/getpc.h 25@@ -68,6 +68,9 @@ 26 typedef ucontext ucontext_t; 27 #endif 28 29+#if defined(__powerpc__) && !defined(PT_NIP) 30+#define PT_NIP 32 31+#endif 32 33 // Take the example where function Foo() calls function Bar(). For 34 // many architectures, Bar() is responsible for setting up and tearing 35--- a/src/stacktrace_powerpc-linux-inl.h 36+++ b/src/stacktrace_powerpc-linux-inl.h 37@@ -186,7 +186,7 @@ static int GET_STACK_TRACE_OR_FRAMES { 38 ucontext_t uc; 39 // We don't care about the rest, since the IP value is at 'uc' field. 40 } *sigframe = reinterpret_cast<signal_frame_64*>(current); 41- result[n] = (void*) sigframe->uc.uc_mcontext.gp_regs[PT_NIP]; 42+ result[n] = (void*) sigframe->uc.uc_mcontext.gp_regs[32]; 43 } 44 #else 45 if (sigtramp32_vdso && (sigtramp32_vdso == current->return_addr)) { 46@@ -196,7 +196,7 @@ static int GET_STACK_TRACE_OR_FRAMES { 47 mcontext_t mctx; 48 // We don't care about the rest, since IP value is at 'mctx' field. 49 } *sigframe = reinterpret_cast<signal_frame_32*>(current); 50- result[n] = (void*) sigframe->mctx.gregs[PT_NIP]; 51+ result[n] = (void*) sigframe->mctx.gregs[32]; 52 } else if (sigtramp32_rt_vdso && (sigtramp32_rt_vdso == current->return_addr)) { 53 struct rt_signal_frame_32 { 54 char dummy[64 + 16]; 55@@ -204,7 +204,11 @@ static int GET_STACK_TRACE_OR_FRAMES { 56 ucontext_t uc; 57 // We don't care about the rest, since IP value is at 'uc' field.A 58 } *sigframe = reinterpret_cast<rt_signal_frame_32*>(current); 59+#if defined(__GLIBC__) 60 result[n] = (void*) sigframe->uc.uc_mcontext.uc_regs->gregs[PT_NIP]; 61+#else 62+ result[n] = (void*) sigframe->uc.uc_mcontext.gregs[32]; 63+#endif 64 } 65 #endif 66 67