From 3d61d8758577f5bf9ce4884544cbbc09af71ca28 Mon Sep 17 00:00:00 2001 From: Bill Schmidt Date: Wed, 29 Jul 2015 03:33:10 +0000 Subject: [PATCH] re PR sanitizer/63927 (AddressSanitizer painfully slow on ppc64) 2015-07-28 Bill Schmidt PR sanitizer/63927 * sanitizer_common/sanitizer_stacktrace.cc (BufferedStackTrace::FastUnwindStack): Fix code for PowerPC to find the link register at an offset of 16 from the base of the caller's stack frame. From-SVN: r226335 --- libsanitizer/ChangeLog | 8 ++++++++ libsanitizer/sanitizer_common/sanitizer_stacktrace.cc | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/libsanitizer/ChangeLog b/libsanitizer/ChangeLog index 84147bfb2e58..94a9531497b4 100644 --- a/libsanitizer/ChangeLog +++ b/libsanitizer/ChangeLog @@ -1,3 +1,11 @@ +2015-07-28 Bill Schmidt + + PR sanitizer/63927 + * sanitizer_common/sanitizer_stacktrace.cc + (BufferedStackTrace::FastUnwindStack): Fix code for PowerPC to + find the link register at an offset of 16 from the base of the + caller's stack frame. + 2015-05-13 Michael Haubenwallner * Makefile.in: Regenerated with automake-1.11.6. diff --git a/libsanitizer/sanitizer_common/sanitizer_stacktrace.cc b/libsanitizer/sanitizer_common/sanitizer_stacktrace.cc index 9b99b5bb201e..a751da2f7404 100644 --- a/libsanitizer/sanitizer_common/sanitizer_stacktrace.cc +++ b/libsanitizer/sanitizer_common/sanitizer_stacktrace.cc @@ -86,7 +86,18 @@ void BufferedStackTrace::FastUnwindStack(uptr pc, uptr bp, uptr stack_top, while (IsValidFrame((uptr)frame, stack_top, bottom) && IsAligned((uptr)frame, sizeof(*frame)) && size < max_depth) { +#ifdef __powerpc__ + // PowerPC ABIs specify that the return address is saved at offset + // 16 of the *caller's* stack frame. Thus we must dereference the + // back chain to find the caller frame before extracting it. + uhwptr *caller_frame = (uhwptr*)frame[0]; + if (!IsValidFrame((uptr)caller_frame, stack_top, bottom) || + !IsAligned((uptr)caller_frame, sizeof(uhwptr))) + break; + uhwptr pc1 = caller_frame[2]; +#else uhwptr pc1 = frame[1]; +#endif if (pc1 != pc) { trace_buffer[size++] = (uptr) pc1; } -- 2.39.2