[compiler-rt] r177864 - asan/tsan: add Printf/Report hook

Dmitry Vyukov dvyukov at google.com
Tue Mar 26 05:08:13 PDT 2013


Done r178009.

On Mon, Mar 25, 2013 at 5:19 PM, Alexey Samsonov <samsonov at google.com> wrote:
>
> On Mon, Mar 25, 2013 at 4:58 PM, Dmitry Vyukov <dvyukov at google.com> wrote:
>>
>> Author: dvyukov
>> Date: Mon Mar 25 07:58:09 2013
>> New Revision: 177864
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=177864&view=rev
>> Log:
>> asan/tsan: add Printf/Report hook
>> The hook can be overriden in frontend to print to e.g. a file.
>>
>>
>> Modified:
>>     compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc
>>
>> Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc
>> URL:
>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc?rev=177864&r1=177863&r2=177864&view=diff
>>
>> ==============================================================================
>> --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc (original)
>> +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc Mon Mar 25
>> 07:58:09 2013
>> @@ -173,6 +173,21 @@ void SetPrintfAndReportCallback(void (*c
>>    PrintfAndReportCallback = callback;
>>  }
>>
>> +// Can be overriden in frontend.
>> +#ifndef SANITIZER_GO
>> +SANITIZER_INTERFACE_ATTRIBUTE void WEAK OnPrint(const char *str) {
>> +  (void)str;
>> +}
>> +#endif
>
>
> Why not SANITIZER_SUPPORTS_WEAK_HOOKS (we have it in
> sanitizer_internal_defs.h)
>
>>
>> +
>> +static void CallPrintfAndReportCallback(const char *str) {
>> +#ifndef SANITIZER_GO
>> +  OnPrint(str);
>> +#endif
>> +  if (PrintfAndReportCallback)
>> +    PrintfAndReportCallback(str);
>> +}
>> +
>>  void Printf(const char *format, ...) {
>>    const int kLen = 16 * 1024;
>>    InternalScopedBuffer<char> buffer(kLen);
>> @@ -182,8 +197,7 @@ void Printf(const char *format, ...) {
>>    va_end(args);
>>    RAW_CHECK_MSG(needed_length < kLen, "Buffer in Printf is too
>> short!\n");
>>    RawWrite(buffer.data());
>> -  if (PrintfAndReportCallback)
>> -    PrintfAndReportCallback(buffer.data());
>> +  CallPrintfAndReportCallback(buffer.data());
>>  }
>>
>>  // Writes at most "length" symbols to "buffer" (including trailing '\0').
>> @@ -238,8 +252,7 @@ void Report(const char *format, ...) {
>>        }
>>      } else {
>>        RawWrite(buffer);
>> -      if (PrintfAndReportCallback)
>> -        PrintfAndReportCallback(buffer);
>> +      CallPrintfAndReportCallback(buffer);
>>        // Don't do anything for the second time if the first iteration
>>        // succeeded.
>>        break;
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
>
>
> --
> Alexey Samsonov, MSK



More information about the llvm-commits mailing list