Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 1 | An all-in-one patch that fixes several issues: |
| 2 | |
| 3 | 1) UnscaledCycleClock not fully implemented for ppc*-musl (disabled on musl) |
| 4 | 2) powerpc stacktrace implementation only works on glibc (disabled on musl) |
| 5 | 3) powerpc stacktrace implementation has ppc64 assumptions (fixed) |
| 6 | 4) examine_stack.cpp makes glibc assumptions on powerpc (fixed) |
| 7 | |
| 8 | Sourced from void linux |
| 9 | |
| 10 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 11 | Signed-off-by: Xu Huan <xuhuan.fnst@fujitsu.com> |
| 12 | --- |
| 13 | absl/base/internal/unscaledcycleclock.cc | 4 ++-- |
| 14 | absl/base/internal/unscaledcycleclock.h | 3 ++- |
| 15 | absl/debugging/internal/examine_stack.cc | 8 +++++++- |
| 16 | absl/debugging/internal/stacktrace_config.h | 2 +- |
| 17 | 4 files changed, 12 insertions(+), 5 deletions(-) |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 18 | |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 19 | diff --git a/absl/base/internal/unscaledcycleclock.cc b/absl/base/internal/unscaledcycleclock.cc |
| 20 | index b1c396c..d62bfd6 100644 |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 21 | --- a/absl/base/internal/unscaledcycleclock.cc |
| 22 | +++ b/absl/base/internal/unscaledcycleclock.cc |
| 23 | @@ -20,7 +20,7 @@ |
| 24 | #include <intrin.h> |
| 25 | #endif |
| 26 | |
| 27 | -#if defined(__powerpc__) || defined(__ppc__) |
| 28 | +#if (defined(__powerpc__) || defined(__ppc__)) && defined(__GLIBC__) |
| 29 | #ifdef __GLIBC__ |
| 30 | #include <sys/platform/ppc.h> |
| 31 | #elif defined(__FreeBSD__) |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 32 | @@ -58,7 +58,7 @@ double UnscaledCycleClock::Frequency() { |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 33 | return base_internal::NominalCPUFrequency(); |
| 34 | } |
| 35 | |
| 36 | -#elif defined(__powerpc__) || defined(__ppc__) |
| 37 | +#elif (defined(__powerpc__) || defined(__ppc__)) && defined(__GLIBC__) |
| 38 | |
| 39 | int64_t UnscaledCycleClock::Now() { |
| 40 | #ifdef __GLIBC__ |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 41 | diff --git a/absl/base/internal/unscaledcycleclock.h b/absl/base/internal/unscaledcycleclock.h |
| 42 | index 2cbeae3..683a5ef 100644 |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 43 | --- a/absl/base/internal/unscaledcycleclock.h |
| 44 | +++ b/absl/base/internal/unscaledcycleclock.h |
| 45 | @@ -46,7 +46,8 @@ |
| 46 | |
| 47 | // The following platforms have an implementation of a hardware counter. |
| 48 | #if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) || \ |
| 49 | - defined(__powerpc__) || defined(__ppc__) || defined(__riscv) || \ |
| 50 | + ((defined(__powerpc__) || defined(__ppc__)) && defined(__GLIBC__)) || \ |
| 51 | + defined(__riscv) || \ |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 52 | defined(_M_IX86) || (defined(_M_X64) && !defined(_M_ARM64EC)) |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 53 | #define ABSL_HAVE_UNSCALED_CYCLECLOCK_IMPLEMENTATION 1 |
| 54 | #else |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 55 | diff --git a/absl/debugging/internal/examine_stack.cc b/absl/debugging/internal/examine_stack.cc |
| 56 | index 5bdd341..a784e0d 100644 |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 57 | --- a/absl/debugging/internal/examine_stack.cc |
| 58 | +++ b/absl/debugging/internal/examine_stack.cc |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 59 | @@ -33,6 +33,10 @@ |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 60 | #include <csignal> |
| 61 | #include <cstdio> |
| 62 | |
| 63 | +#if defined(__powerpc__) |
| 64 | +#include <asm/ptrace.h> |
| 65 | +#endif |
| 66 | + |
| 67 | #include "absl/base/attributes.h" |
| 68 | #include "absl/base/internal/raw_logging.h" |
| 69 | #include "absl/base/macros.h" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 70 | @@ -174,8 +178,10 @@ void* GetProgramCounter(void* const vuc) { |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 71 | return reinterpret_cast<void*>(context->uc_mcontext.pc); |
| 72 | #elif defined(__powerpc64__) |
| 73 | return reinterpret_cast<void*>(context->uc_mcontext.gp_regs[32]); |
| 74 | -#elif defined(__powerpc__) |
| 75 | +#elif defined(__powerpc__) && defined(__GLIBC__) |
| 76 | return reinterpret_cast<void*>(context->uc_mcontext.uc_regs->gregs[32]); |
| 77 | +#elif defined(__powerpc__) |
| 78 | + return reinterpret_cast<void*>(((struct pt_regs *)context->uc_regs)->gregs[32]); |
| 79 | #elif defined(__riscv) |
| 80 | return reinterpret_cast<void*>(context->uc_mcontext.__gregs[REG_PC]); |
| 81 | #elif defined(__s390__) && !defined(__s390x__) |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 82 | diff --git a/absl/debugging/internal/stacktrace_config.h b/absl/debugging/internal/stacktrace_config.h |
| 83 | index 3929b1b..23d5e50 100644 |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 84 | --- a/absl/debugging/internal/stacktrace_config.h |
| 85 | +++ b/absl/debugging/internal/stacktrace_config.h |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 86 | @@ -60,7 +60,7 @@ |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 87 | #elif defined(__i386__) || defined(__x86_64__) |
| 88 | #define ABSL_STACKTRACE_INL_HEADER \ |
| 89 | "absl/debugging/internal/stacktrace_x86-inl.inc" |
| 90 | -#elif defined(__ppc__) || defined(__PPC__) |
| 91 | +#elif (defined(__ppc__) || defined(__PPC__)) && defined(__GLIBC__) |
| 92 | #define ABSL_STACKTRACE_INL_HEADER \ |
| 93 | "absl/debugging/internal/stacktrace_powerpc-inl.inc" |
| 94 | #elif defined(__aarch64__) |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 95 | -- |
| 96 | 2.25.1 |
| 97 | |