summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes2017-02-06 12:54:00 -0600
committerElliott Hughes2017-02-06 12:54:00 -0600
commit5bae1b866d309f3d59aaab8e9a007413b3c68f83 (patch)
tree48e2f331a36c8becd2dfb76ba43c1b41cb733611 /liblog/logger_write.c
parent01b25ab14912712024d5342064c7b70de85e2db8 (diff)
downloadplatform-system-core-5bae1b866d309f3d59aaab8e9a007413b3c68f83.tar.gz
platform-system-core-5bae1b866d309f3d59aaab8e9a007413b3c68f83.tar.xz
platform-system-core-5bae1b866d309f3d59aaab8e9a007413b3c68f83.zip
Make __android_log_assert behave more like libc asserts.
If we don't output to stderr too, not only is it annoying to shell users (who won't see anything), it prevents us from writing better gtests that actually make assertions about the assert message. Bug: http://b/23675822 Test: libutils tests still pass Change-Id: I62b3144c385cba4dde485f0b0f9b42aeaef51e9a
Diffstat (limited to 'liblog/logger_write.c')
-rw-r--r--liblog/logger_write.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/liblog/logger_write.c b/liblog/logger_write.c
index 1a2d50612..43241254f 100644
--- a/liblog/logger_write.c
+++ b/liblog/logger_write.c
@@ -514,6 +514,14 @@ LIBLOG_ABI_PUBLIC void __android_log_assert(const char *cond, const char *tag,
514 strcpy(buf, "Unspecified assertion failed"); 514 strcpy(buf, "Unspecified assertion failed");
515 } 515 }
516 516
517 // Log assertion failures to stderr for the benefit of "adb shell" users
518 // and gtests (http://b/23675822).
519 struct iovec iov[2] = {
520 { buf, strlen(buf) },
521 { (char*) "\n", 1 },
522 };
523 TEMP_FAILURE_RETRY(writev(2, iov, 2));
524
517 __android_log_write(ANDROID_LOG_FATAL, tag, buf); 525 __android_log_write(ANDROID_LOG_FATAL, tag, buf);
518 abort(); /* abort so we have a chance to debug the situation */ 526 abort(); /* abort so we have a chance to debug the situation */
519 /* NOTREACHED */ 527 /* NOTREACHED */