Bug 743306 - Part 1: On Android, log MOZ_Assert messages to logcat because stderr is directed to /dev/null. r=glandium
authorChris Peterson <cpeterson@mozilla.com>
Mon, 09 Apr 2012 12:45:17 -0700
changeset 94576 8a7965116a330f482644390ad5477d85d9fc85e4
parent 94575 d4e09a9ed76ce187ba8bc16c1d03bd2bbbd99555
child 94577 42870fe1a4a34183768b7f1a186872b4592ec2b3
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs743306
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 743306 - Part 1: On Android, log MOZ_Assert messages to logcat because stderr is directed to /dev/null. r=glandium
mfbt/Assertions.cpp
--- a/mfbt/Assertions.cpp
+++ b/mfbt/Assertions.cpp
@@ -42,16 +42,20 @@
 #include "mozilla/Types.h"
 
 #include <cstdio>
 #include <cstdlib>
 #ifndef WIN32
 #include <signal.h>
 #endif
 
+#ifdef ANDROID
+#include <android/log.h>
+#endif
+
 /* Implementations of runtime and static assertion macros for C and C++. */
 
 extern "C" {
 
 MOZ_EXPORT_API(void)
 MOZ_Crash()
 {
   /*
@@ -78,14 +82,19 @@ MOZ_Crash()
 #else
   raise(SIGABRT);  /* To continue from here in GDB: "signal 0". */
 #endif
 }
 
 MOZ_EXPORT_API(void)
 MOZ_Assert(const char* s, const char* file, int ln)
 {
+#ifdef ANDROID
+  __android_log_print(ANDROID_LOG_FATAL, "MOZ_Assert",
+                      "Assertion failure: %s, at %s:%d\n", s, file, ln);
+#else
   fprintf(stderr, "Assertion failure: %s, at %s:%d\n", s, file, ln);
   fflush(stderr);
+#endif
   MOZ_Crash();
 }
 
 }