summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>2021-02-19 02:08:52 +0100
committerGravatar GitHub <noreply@github.com>2021-02-18 20:08:52 -0500
commit7055876380cc4c9061e654640b807767f428b0f3 (patch)
tree15de18472ae425b6e0b6002f00cb0940ea741ebf
parentb315753c0b8b4aa4e3e1479375eddb518393bab6 (diff)
Fix uc_mcontext register access on 32-bit PowerPC (#898)
Fixes #894
-rw-r--r--absl/debugging/internal/examine_stack.cc2
-rw-r--r--absl/debugging/internal/stacktrace_powerpc-inl.inc4
2 files changed, 5 insertions, 1 deletions
diff --git a/absl/debugging/internal/examine_stack.cc b/absl/debugging/internal/examine_stack.cc
index 57913025..dff5c604 100644
--- a/absl/debugging/internal/examine_stack.cc
+++ b/absl/debugging/internal/examine_stack.cc
@@ -56,7 +56,7 @@ void* GetProgramCounter(void* vuc) {
#elif defined(__powerpc64__)
return reinterpret_cast<void*>(context->uc_mcontext.gp_regs[32]);
#elif defined(__powerpc__)
- return reinterpret_cast<void*>(context->uc_mcontext.regs->nip);
+ return reinterpret_cast<void*>(context->uc_mcontext.uc_regs->gregs[32]);
#elif defined(__riscv)
return reinterpret_cast<void*>(context->uc_mcontext.__gregs[REG_PC]);
#elif defined(__s390__) && !defined(__s390x__)
diff --git a/absl/debugging/internal/stacktrace_powerpc-inl.inc b/absl/debugging/internal/stacktrace_powerpc-inl.inc
index 2e7c2f40..5b2cdc2a 100644
--- a/absl/debugging/internal/stacktrace_powerpc-inl.inc
+++ b/absl/debugging/internal/stacktrace_powerpc-inl.inc
@@ -131,7 +131,11 @@ static void **NextStackFrame(void **old_sp, const void *uc) {
const ucontext_t* signal_context =
reinterpret_cast<const ucontext_t*>(uc);
void **const sp_before_signal =
+#if defined(__PPC64__)
reinterpret_cast<void**>(signal_context->uc_mcontext.gp_regs[PT_R1]);
+#else
+ reinterpret_cast<void**>(signal_context->uc_mcontext.uc_regs->gregs[PT_R1]);
+#endif
// Check that alleged sp before signal is nonnull and is reasonably
// aligned.
if (sp_before_signal != nullptr &&