[libcxxabi] r226310 - Fix abort_message.cpp for the NDK.
Dan Albert
danalbert at google.com
Fri Jan 16 12:00:49 PST 2015
Author: danalbert
Date: Fri Jan 16 14:00:49 2015
New Revision: 226310
URL: http://llvm.org/viewvc/llvm-project?rev=226310&view=rev
Log:
Fix abort_message.cpp for the NDK.
The NDK doesn't have access to `android/set_abort_message.h`, so use
an extern declaration instead for API 21. For older releases, just use
`__assert2`, which will report to logcat and/or the tombstone for some
older releases.
Modified:
libcxxabi/trunk/src/abort_message.cpp
Modified: libcxxabi/trunk/src/abort_message.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/abort_message.cpp?rev=226310&r1=226309&r2=226310&view=diff
==============================================================================
--- libcxxabi/trunk/src/abort_message.cpp (original)
+++ libcxxabi/trunk/src/abort_message.cpp Fri Jan 16 14:00:49 2015
@@ -13,9 +13,14 @@
#include "abort_message.h"
#ifdef __BIONIC__
-#include <android/set_abort_message.h>
+#include <android/api-level.h>
+#if __ANDROID_API__ >= 21
#include <syslog.h>
-#endif
+extern "C" void android_set_abort_message(const char* msg);
+#else
+#include <assert.h>
+#endif // __ANDROID_API__ >= 21
+#endif // __BIONIC__
#pragma GCC visibility push(hidden)
@@ -54,6 +59,7 @@ void abort_message(const char* format, .
vasprintf(&buffer, format, list2);
va_end(list2);
+#if __ANDROID_API__ >= 21
// Show error in tombstone.
android_set_abort_message(buffer);
@@ -61,7 +67,13 @@ void abort_message(const char* format, .
openlog("libc++abi", 0, 0);
syslog(LOG_CRIT, "%s", buffer);
closelog();
-#endif
+#else
+ // The good error reporting wasn't available in Android until L. Since we're
+ // about to abort anyway, just call __assert2, which will log _somewhere_
+ // (tombstone and/or logcat) in older releases.
+ __assert2(__FILE__, __LINE__, __func__, buffer);
+#endif // __ANDROID_API__ >= 21
+#endif // __BIONIC__
abort();
}
More information about the cfe-commits
mailing list