diff options
| author | Elliott Hughes <enh@google.com> | 2014-04-23 14:57:32 -0700 |
|---|---|---|
| committer | Elliott Hughes <enh@google.com> | 2014-04-24 13:28:24 -0700 |
| commit | da6b2e2fd79c9aac12127b2c2f512e9555fdd06d (patch) | |
| tree | e90e6904a0afcb745a1b58fdcbf2d36541176039 /liblog | |
| parent | 07fa043341ad057ea79ca973089609965ba6c4f9 (diff) | |
| download | core-da6b2e2fd79c9aac12127b2c2f512e9555fdd06d.tar.gz core-da6b2e2fd79c9aac12127b2c2f512e9555fdd06d.tar.bz2 core-da6b2e2fd79c9aac12127b2c2f512e9555fdd06d.zip | |
Improve liblog's fatal logging.
This makes LOG_ALWAYS_FATAL and LOG_ALWAYS_FATAL_IF as good as regular
assert(3).
Change-Id: I0666684d30cae7baf23c64b33d35c1e43f81acf0
Diffstat (limited to 'liblog')
| -rw-r--r-- | liblog/logd_write.c | 8 | ||||
| -rw-r--r-- | liblog/logd_write_kern.c | 8 |
2 files changed, 14 insertions, 2 deletions
diff --git a/liblog/logd_write.c b/liblog/logd_write.c index 94722d3a4..48531d571 100644 --- a/liblog/logd_write.c +++ b/liblog/logd_write.c @@ -407,9 +407,15 @@ void __android_log_assert(const char *cond, const char *tag, strcpy(buf, "Unspecified assertion failed"); } +#if __BIONIC__ + // Ensure debuggerd gets to see what went wrong by keeping the C library in the loop. + extern __noreturn void __android_fatal(const char* tag, const char* format, ...) __printflike(2, 3); + __android_fatal(tag ? tag : "", "%s", buf); +#else __android_log_write(ANDROID_LOG_FATAL, tag, buf); - __builtin_trap(); /* trap so we have a chance to debug the situation */ +#endif + /* NOTREACHED */ } int __android_log_bwrite(int32_t tag, const void *payload, size_t len) diff --git a/liblog/logd_write_kern.c b/liblog/logd_write_kern.c index c29c28f2d..8c707adfb 100644 --- a/liblog/logd_write_kern.c +++ b/liblog/logd_write_kern.c @@ -272,9 +272,15 @@ void __android_log_assert(const char *cond, const char *tag, strcpy(buf, "Unspecified assertion failed"); } +#if __BIONIC__ + // Ensure debuggerd gets to see what went wrong by keeping the C library in the loop. + extern __noreturn void __android_fatal(const char* tag, const char* format, ...) __printflike(2, 3); + __android_fatal(tag ? tag : "", "%s", buf); +#else __android_log_write(ANDROID_LOG_FATAL, tag, buf); - __builtin_trap(); /* trap so we have a chance to debug the situation */ +#endif + /* NOTREACHED */ } int __android_log_bwrite(int32_t tag, const void *payload, size_t len) |
