From 5f6cfce4f6608f2e450266814543e70b1ed2e02c Mon Sep 17 00:00:00 2001 From: Stephen Hines Date: Tue, 1 Oct 2013 18:20:51 -0700 Subject: [PATCH] Add simple implementation _Unwind_GetIP() for clang compiles. Clang (prior to 3.4) does not actually provide a declaration (or definition) of _Unwind_GetIP() for ARM. We can work around this by writing our own basic implementation using the available primitive operations. Change-Id: If6c66846952d8545849ad32d2b55daa4599cfe2c --- libc/bionic/debug_stacktrace.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libc/bionic/debug_stacktrace.cpp b/libc/bionic/debug_stacktrace.cpp index fb933e6f9..0f93b26c4 100644 --- a/libc/bionic/debug_stacktrace.cpp +++ b/libc/bionic/debug_stacktrace.cpp @@ -80,6 +80,18 @@ struct stack_crawl_state_t { } }; +#if defined(__arm__) && !defined(_Unwind_GetIP) +// Older versions of Clang don't provide a definition of _Unwind_GetIP(), so +// we include an appropriate version of our own. Once we have updated to +// Clang 3.4, this code can be removed. +static __inline__ +uintptr_t _Unwind_GetIP(struct _Unwind_Context *__context) { + uintptr_t __ip = 0; + _Unwind_VRS_Get(__context, _UVRSC_CORE, 15, _UVRSD_UINT32, &__ip); + return __ip & ~0x1; +} +#endif + static _Unwind_Reason_Code trace_function(__unwind_context* context, void* arg) { stack_crawl_state_t* state = static_cast(arg);