Skip to content

Commit 7055876

Browse files
authored
Fix uc_mcontext register access on 32-bit PowerPC (#898)
Fixes #894
1 parent b315753 commit 7055876

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

absl/debugging/internal/examine_stack.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void* GetProgramCounter(void* vuc) {
5656
#elif defined(__powerpc64__)
5757
return reinterpret_cast<void*>(context->uc_mcontext.gp_regs[32]);
5858
#elif defined(__powerpc__)
59-
return reinterpret_cast<void*>(context->uc_mcontext.regs->nip);
59+
return reinterpret_cast<void*>(context->uc_mcontext.uc_regs->gregs[32]);
6060
#elif defined(__riscv)
6161
return reinterpret_cast<void*>(context->uc_mcontext.__gregs[REG_PC]);
6262
#elif defined(__s390__) && !defined(__s390x__)

absl/debugging/internal/stacktrace_powerpc-inl.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,11 @@ static void **NextStackFrame(void **old_sp, const void *uc) {
131131
const ucontext_t* signal_context =
132132
reinterpret_cast<const ucontext_t*>(uc);
133133
void **const sp_before_signal =
134+
#if defined(__PPC64__)
134135
reinterpret_cast<void**>(signal_context->uc_mcontext.gp_regs[PT_R1]);
136+
#else
137+
reinterpret_cast<void**>(signal_context->uc_mcontext.uc_regs->gregs[PT_R1]);
138+
#endif
135139
// Check that alleged sp before signal is nonnull and is reasonably
136140
// aligned.
137141
if (sp_before_signal != nullptr &&

0 commit comments

Comments
 (0)