[compiler-rt] r177864 - asan/tsan: add Printf/Report hook
Dmitry Vyukov
dvyukov at google.com
Mon Mar 25 05:58:10 PDT 2013
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
+
+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;
More information about the llvm-commits
mailing list