diff options
author | Elliott Hughes <enh@google.com> | 2012-05-21 13:59:52 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2012-05-21 13:59:52 -0700 |
commit | 6b3bab39d128947bf51deefe6a28c247cafd7bae (patch) | |
tree | 45b969aa9b7828e65f2684cf76da6da3ccd9c544 /libcorkscrew | |
parent | 04607b8aa91051bb43cd652dca1cef1579ed5dad (diff) | |
download | system_core-6b3bab39d128947bf51deefe6a28c247cafd7bae.zip system_core-6b3bab39d128947bf51deefe6a28c247cafd7bae.tar.gz system_core-6b3bab39d128947bf51deefe6a28c247cafd7bae.tar.bz2 |
Fix libcorkscrew for x86 targets (bionic) as well as the host (glibc).
Longer term, we might want to offer <ucontext.h> and have that be like glibc's,
but not today. (Note that POSIX says nothing about mcontext_t and glibc,
Mac OS, and the Linux kernel headers are all mutually incompatible.)
Change-Id: Ia074b51f4567cd54e06bbe29721389c8d1278614
Diffstat (limited to 'libcorkscrew')
-rw-r--r-- | libcorkscrew/arch-x86/backtrace-x86.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/libcorkscrew/arch-x86/backtrace-x86.c b/libcorkscrew/arch-x86/backtrace-x86.c index a568c6d..01d9ed5 100644 --- a/libcorkscrew/arch-x86/backtrace-x86.c +++ b/libcorkscrew/arch-x86/backtrace-x86.c @@ -33,9 +33,21 @@ #include <sys/ptrace.h> #include <cutils/log.h> +#if defined(__BIONIC__) + +// Bionic offers the Linux kernel headers. +#include <asm/sigcontext.h> +#include <asm/ucontext.h> +typedef struct ucontext ucontext_t; + +#else + +// glibc has its own renaming of the Linux kernel's structures. #define __USE_GNU // For REG_EBP, REG_ESP, and REG_EIP. #include <ucontext.h> +#endif + /* Unwind state. */ typedef struct { uint32_t ebp; @@ -84,9 +96,15 @@ ssize_t unwind_backtrace_signal_arch(siginfo_t* siginfo, void* sigcontext, const ucontext_t* uc = (const ucontext_t*)sigcontext; unwind_state_t state; +#if defined(__BIONIC__) + state.ebp = uc->uc_mcontext.ebp; + state.esp = uc->uc_mcontext.esp; + state.eip = uc->uc_mcontext.eip; +#else state.ebp = uc->uc_mcontext.gregs[REG_EBP]; state.esp = uc->uc_mcontext.gregs[REG_ESP]; state.eip = uc->uc_mcontext.gregs[REG_EIP]; +#endif memory_t memory; init_memory(&memory, map_info_list); |