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

Evgeniy Stepanov eugeni.stepanov at gmail.com
Wed Feb 26 01:51:17 PST 2014


I'm not really sure how to test this behavior, other than mocking
__android_log_write.
This code writes to a system-wide log stream, and any concurrent
activity would disturb log output.


On Wed, Feb 26, 2014 at 1:39 PM, Evgeniy Stepanov
<eugeni.stepanov at gmail.com> wrote:
> 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) {
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list