[compiler-rt] r202250 - [asan] Fix printing of long reports to logcat on Android.

Evgeniy Stepanov eugeni.stepanov at gmail.com
Wed Feb 26 01:39:56 PST 2014


Author: eugenis
Date: Wed Feb 26 03:39:55 2014
New Revision: 202250

URL: http://llvm.org/viewvc/llvm-project?rev=202250&view=rev
Log:
[asan] Fix printing of long reports to logcat on Android.

__android_log_write has an implicit message length limit.
Print one line at a time.


Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc?rev=202250&r1=202249&r2=202250&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc Wed Feb 26 03:39:55 2014
@@ -732,7 +732,18 @@ uptr internal_clone(int (*fn)(void *), v
 // their location and message format might change in the future, so we'd really
 // like to avoid that.
 void AndroidLogWrite(const char *buffer) {
-  __android_log_write(ANDROID_LOG_INFO, NULL, buffer);
+  char *copy = internal_strdup(buffer);
+  char *p = copy;
+  char *q;
+  // __android_log_write has an implicit message length limit.
+  // Print one line at a time.
+  do {
+    q = internal_strchr(p, '\n');
+    if (q) *q = '\0';
+    __android_log_write(ANDROID_LOG_INFO, NULL, p);
+    if (q) p = q + 1;
+  } while (q);
+  InternalFree(copy);
 }
 
 void GetExtraActivationFlags(char *buf, uptr size) {





More information about the llvm-commits mailing list