[compiler-rt] r318438 - [sanitizer] Revert rL318410
Kostya Kortchinsky via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 16 10:53:18 PST 2017
Author: cryptoad
Date: Thu Nov 16 10:53:18 2017
New Revision: 318438
URL: http://llvm.org/viewvc/llvm-project?rev=318438&view=rev
Log:
[sanitizer] Revert rL318410
Summary:
The patch seems to have turned some Android tests flaky. The reason is unclear.
This reverts D40100 in case we can't figure out what is happening.
Reviewers: eugenis
Reviewed By: eugenis
Subscribers: srhines, kubamracek
Differential Revision: https://reviews.llvm.org/D40138
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc?rev=318438&r1=318437&r2=318438&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc Thu Nov 16 10:53:18 2017
@@ -48,6 +48,10 @@
#include <android/api-level.h>
#endif
+#if SANITIZER_ANDROID && __ANDROID_API__ < 21
+#include <android/log.h>
+#endif
+
#if !SANITIZER_ANDROID
#include <elf.h>
#include <unistd.h>
@@ -532,9 +536,12 @@ uptr GetRSS() {
return rss * GetPageSizeCached();
}
+// 64-bit Android targets don't provide the deprecated __android_log_write.
+// Starting with the L release, syslog() works and is preferable to
+// __android_log_write.
#if SANITIZER_LINUX
-# if SANITIZER_ANDROID
+#if SANITIZER_ANDROID
static atomic_uint8_t android_log_initialized;
void AndroidLogInit() {
@@ -545,53 +552,35 @@ void AndroidLogInit() {
static bool ShouldLogAfterPrintf() {
return atomic_load(&android_log_initialized, memory_order_acquire);
}
-
-extern "C" SANITIZER_WEAK_ATTRIBUTE
-int async_safe_write_log(int pri, const char* tag, const char* msg);
-extern "C" SANITIZER_WEAK_ATTRIBUTE
-int __android_log_write(int prio, const char* tag, const char* msg);
-
-// ANDROID_LOG_INFO is 4, but can't be resolved at runtime.
-#define SANITIZER_ANDROID_LOG_INFO 4
-
-// async_safe_write_log is basically __android_log_write but is only available
-// in recent versions of Bionic. __android_log_write was deprecated along the
-// way, so fallback to syslog if neither exists. The non-syslog alternatives
-// do not allocate memory and are preferable. Also syslog is broken pre-L, this
-// is another reason why we prefer __android_log_write if available.
-void WriteOneLineToSyslog(const char *s) {
- if (&async_safe_write_log) {
- async_safe_write_log(SANITIZER_ANDROID_LOG_INFO, GetProcessName(), s);
- } else if (&__android_log_write) {
- __android_log_write(SANITIZER_ANDROID_LOG_INFO, nullptr, s);
- } else {
- syslog(LOG_INFO, "%s", s);
- }
-}
-
-extern "C" SANITIZER_WEAK_ATTRIBUTE
-void android_set_abort_message(const char *);
-
-void SetAbortMessage(const char *str) {
- if (&android_set_abort_message)
- android_set_abort_message(str);
-}
-# else
+#else
void AndroidLogInit() {}
static bool ShouldLogAfterPrintf() { return true; }
+#endif // SANITIZER_ANDROID
-void WriteOneLineToSyslog(const char *s) { syslog(LOG_INFO, "%s", s); }
-
-void SetAbortMessage(const char *str) {}
-# endif // SANITIZER_ANDROID
+void WriteOneLineToSyslog(const char *s) {
+#if SANITIZER_ANDROID &&__ANDROID_API__ < 21
+ __android_log_write(ANDROID_LOG_INFO, NULL, s);
+#else
+ syslog(LOG_INFO, "%s", s);
+#endif
+}
void LogMessageOnPrintf(const char *str) {
if (common_flags()->log_to_syslog && ShouldLogAfterPrintf())
WriteToSyslog(str);
}
-#endif // SANITIZER_LINUX
+#if SANITIZER_ANDROID
+extern "C" __attribute__((weak)) void android_set_abort_message(const char *);
+void SetAbortMessage(const char *str) {
+ if (&android_set_abort_message) android_set_abort_message(str);
+}
+#else
+void SetAbortMessage(const char *str) {}
+#endif
+
+#endif // SANITIZER_LINUX
} // namespace __sanitizer
More information about the llvm-commits
mailing list