[PATCH] D78018: [scudo][standalone] Split logs on Android

Kostya Kortchinsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 13 17:57:35 PDT 2020


cryptoad updated this revision to Diff 257174.
cryptoad added a comment.

Without the spurious s in the comment.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78018/new/

https://reviews.llvm.org/D78018

Files:
  compiler-rt/lib/scudo/standalone/linux.cpp


Index: compiler-rt/lib/scudo/standalone/linux.cpp
===================================================================
--- compiler-rt/lib/scudo/standalone/linux.cpp
+++ compiler-rt/lib/scudo/standalone/linux.cpp
@@ -171,6 +171,23 @@
 void outputRaw(const char *Buffer) {
   if (&async_safe_write_log) {
     constexpr s32 AndroidLogInfo = 4;
+    constexpr uptr MaxLength = 1024U;
+    char LocalBuffer[MaxLength];
+    while (strlen(Buffer) > MaxLength) {
+      uptr P;
+      for (P = MaxLength - 1; P > 0; P--) {
+        if (Buffer[P] == '\n') {
+          memcpy(LocalBuffer, Buffer, P);
+          LocalBuffer[P] = '\0';
+          async_safe_write_log(AndroidLogInfo, "scudo", LocalBuffer);
+          Buffer = &Buffer[P + 1];
+          break;
+        }
+      }
+      // If no newline was found, just log the buffer.
+      if (P == 0)
+        break;
+    }
     async_safe_write_log(AndroidLogInfo, "scudo", Buffer);
   } else {
     write(2, Buffer, strlen(Buffer));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78018.257174.patch
Type: text/x-patch
Size: 982 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200414/e0269562/attachment.bin>


More information about the llvm-commits mailing list