diff options
author | Andy McFadden <fadden@android.com> | 2009-10-21 12:18:54 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2009-10-21 12:18:54 -0700 |
commit | 0703efeae25523e8f870cbf70f57b9ecc1186ac7 (patch) | |
tree | 6d663102cb2ca85462d3bf8f4911668765d1deaf /libc | |
parent | 214dec2811ef893984ce5bceceb28a47d701fa9f (diff) | |
parent | 96bbbe21778fc3f4a932822c2436238d6ce5721b (diff) | |
download | bionic-0703efeae25523e8f870cbf70f57b9ecc1186ac7.zip bionic-0703efeae25523e8f870cbf70f57b9ecc1186ac7.tar.gz bionic-0703efeae25523e8f870cbf70f57b9ecc1186ac7.tar.bz2 |
am 96bbbe21: Wrap ARM abort() to improve stack trace.
Merge commit '96bbbe21778fc3f4a932822c2436238d6ce5721b' into eclair-plus-aosp
* commit '96bbbe21778fc3f4a932822c2436238d6ce5721b':
Wrap ARM abort() to improve stack trace.
Diffstat (limited to 'libc')
-rw-r--r-- | libc/unistd/abort.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/libc/unistd/abort.c b/libc/unistd/abort.c index f323941..3e3aab0 100644 --- a/libc/unistd/abort.c +++ b/libc/unistd/abort.c @@ -39,8 +39,13 @@ #define debug_log(format, ...) \ __libc_android_log_print(ANDROID_LOG_DEBUG, "libc-abort", (format), ##__VA_ARGS__ ) +#ifdef __arm__ +void +__libc_android_abort(void) +#else void abort(void) +#endif { struct atexit *p = __atexit; static int cleanup_called = 0; @@ -97,3 +102,29 @@ abort(void) (void)kill(getpid(), SIGABRT); _exit(1); } + +#ifdef __arm__ +/* + * abort() does not return, which gcc interprets to mean that it doesn't + * need to preserve any of the callee-save registers. Unfortunately this + * includes the link register, so if LR is used there is no way to determine + * which function called abort(). + * + * We work around this by inserting a trivial stub that doesn't alter + * any of the "interesting" registers and thus doesn't need to save them. + * We can't just call __libc_android_abort from C because gcc uses "bl" + * without first saving LR, so we use an asm statement. This also has + * the side-effect of replacing abort() with __libc_android_abort() in + * the stack trace. + * + * Ideally __libc_android_abort would be static, but I haven't figured out + * how to tell gcc to call a static function from an asm statement. + */ +void +abort(void) +{ + asm ("b __libc_android_abort"); + _exit(1); /* suppress gcc noreturn warnings */ +} +#endif + |