1From 328805fd16930deefda400a77e9c2c5d17d04d29 Mon Sep 17 00:00:00 2001 2From: Khem Raj <raj.khem@gmail.com> 3Date: Sat, 13 Mar 2021 00:42:25 -0800 4Subject: [PATCH] Compatibility fixes for musl. 5 6--- 7Upstream-Status: Pending 8 9 src/getpc.h | 4 ++++ 10 src/stacktrace_powerpc-linux-inl.h | 8 ++++++-- 11 2 files changed, 10 insertions(+), 2 deletions(-) 12 13diff --git a/src/getpc.h b/src/getpc.h 14index 87d18b6..c569731 100644 15--- a/src/getpc.h 16+++ b/src/getpc.h 17@@ -68,6 +68,10 @@ 18 typedef ucontext ucontext_t; 19 #endif 20 21+#if defined(__powerpc__) && !defined(PT_NIP) 22+#define PT_NIP 32 23+#endif 24+ 25 namespace tcmalloc { 26 namespace getpc { 27 28diff --git a/src/stacktrace_powerpc-linux-inl.h b/src/stacktrace_powerpc-linux-inl.h 29index 883e7d2..212bd25 100644 30--- a/src/stacktrace_powerpc-linux-inl.h 31+++ b/src/stacktrace_powerpc-linux-inl.h 32@@ -186,7 +186,7 @@ static int GET_STACK_TRACE_OR_FRAMES { 33 ucontext_t uc; 34 // We don't care about the rest, since the IP value is at 'uc' field. 35 } *sigframe = reinterpret_cast<signal_frame_64*>(current); 36- result[n] = (void*) sigframe->uc.uc_mcontext.gp_regs[PT_NIP]; 37+ result[n] = (void*) sigframe->uc.uc_mcontext.gp_regs[32]; 38 } 39 #else 40 if (sigtramp32_vdso && (sigtramp32_vdso == current->return_addr)) { 41@@ -196,7 +196,7 @@ static int GET_STACK_TRACE_OR_FRAMES { 42 mcontext_t mctx; 43 // We don't care about the rest, since IP value is at 'mctx' field. 44 } *sigframe = reinterpret_cast<signal_frame_32*>(current); 45- result[n] = (void*) sigframe->mctx.gregs[PT_NIP]; 46+ result[n] = (void*) sigframe->mctx.gregs[32]; 47 } else if (sigtramp32_rt_vdso && (sigtramp32_rt_vdso == current->return_addr)) { 48 struct rt_signal_frame_32 { 49 char dummy[64 + 16]; 50@@ -204,7 +204,11 @@ static int GET_STACK_TRACE_OR_FRAMES { 51 ucontext_t uc; 52 // We don't care about the rest, since IP value is at 'uc' field.A 53 } *sigframe = reinterpret_cast<rt_signal_frame_32*>(current); 54+#if defined(__GLIBC__) 55 result[n] = (void*) sigframe->uc.uc_mcontext.uc_regs->gregs[PT_NIP]; 56+#else 57+ result[n] = (void*) sigframe->uc.uc_mcontext.gregs[32]; 58+#endif 59 } 60 #endif 61 62