diff options
| author | David 'Digit' Turner <digit@google.com> | 2012-07-10 15:53:04 +0200 |
|---|---|---|
| committer | David 'Digit' Turner <digit@android.com> | 2012-07-13 11:22:13 +0200 |
| commit | b4ef91b97513434a13d6d84a810512315ecf4768 (patch) | |
| tree | 97f8b73b0e7166ffa408009d75b3fe4280b3b0c2 /libcorkscrew/arch-x86 | |
| parent | 2177c79bddc66e295599d87007d4cbec549e1cac (diff) | |
| download | system_core-b4ef91b97513434a13d6d84a810512315ecf4768.zip system_core-b4ef91b97513434a13d6d84a810512315ecf4768.tar.gz system_core-b4ef91b97513434a13d6d84a810512315ecf4768.tar.bz2 | |
libcorkscrew: avoid future name collisions.
This is a forward-compatibility patch used to avoid two problems:
1/ The C library <signal.h> is going to be updated to define 'struct sigcontext'
properly soon. Avoid redefining this structure here when it's not really needed
to prevent a type conflict.
2/ Similarly, proper ucontext_t support is going to be added, prevent conflict by
using a macro renaming trick. Mainly because there is a slight chance that the
C library definition will follow a slightly different layout/naming.
For context, see details at:
http://code.google.com/p/android/issues/detail?id=34784
https://android-review.googlesource.com/#/c/38875/1
Change-Id: Ie94eb5d77297f8e0bafd146b65a648bd8805a551
Diffstat (limited to 'libcorkscrew/arch-x86')
| -rw-r--r-- | libcorkscrew/arch-x86/backtrace-x86.c | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/libcorkscrew/arch-x86/backtrace-x86.c b/libcorkscrew/arch-x86/backtrace-x86.c index 24fadcb..837fd75 100644 --- a/libcorkscrew/arch-x86/backtrace-x86.c +++ b/libcorkscrew/arch-x86/backtrace-x86.c @@ -34,37 +34,33 @@ #include <sys/exec_elf.h> #include <cutils/log.h> +#if !defined(__BIONIC_HAVE_UCONTEXT_T) +/* Old versions of the Android <signal.h> didn't define ucontext_t. */ + +typedef struct { + uint32_t gregs[32]; + void* fpregs; + uint32_t oldmask; + uint32_t cr2; +} mcontext_t; + +enum { + REG_GS = 0, REG_FS, REG_ES, REG_DS, + REG_EDI, REG_ESI, REG_EBP, REG_ESP, + REG_EBX, REG_EDX, REG_ECX, REG_EAX, + REG_TRAPNO, REG_ERR, REG_EIP, REG_CS, + REG_EFL, REG_UESP, REG_SS +}; + /* Machine context at the time a signal was raised. */ typedef struct ucontext { uint32_t uc_flags; struct ucontext* uc_link; stack_t uc_stack; - struct sigcontext { - uint32_t gs; - uint32_t fs; - uint32_t es; - uint32_t ds; - uint32_t edi; - uint32_t esi; - uint32_t ebp; - uint32_t esp; - uint32_t ebx; - uint32_t edx; - uint32_t ecx; - uint32_t eax; - uint32_t trapno; - uint32_t err; - uint32_t eip; - uint32_t cs; - uint32_t efl; - uint32_t uesp; - uint32_t ss; - void* fpregs; - uint32_t oldmask; - uint32_t cr2; - } uc_mcontext; + mcontext_t uc_mcontext; uint32_t uc_sigmask; } ucontext_t; +#endif /* !__BIONIC_HAVE_UCONTEXT_T */ /* Unwind state. */ typedef struct { @@ -114,9 +110,9 @@ ssize_t unwind_backtrace_signal_arch(siginfo_t* siginfo, void* sigcontext, const ucontext_t* uc = (const ucontext_t*)sigcontext; unwind_state_t state; - state.ebp = uc->uc_mcontext.ebp; - state.eip = uc->uc_mcontext.eip; - state.esp = uc->uc_mcontext.esp; + state.ebp = uc->uc_mcontext.gregs[REG_EBP]; + state.eip = uc->uc_mcontext.gregs[REG_EIP]; + state.esp = uc->uc_mcontext.gregs[REG_ESP]; memory_t memory; init_memory(&memory, map_info_list); |
