summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_printf.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sanitizer_common/sanitizer_printf.cc')
-rw-r--r--lib/sanitizer_common/sanitizer_printf.cc21
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/sanitizer_common/sanitizer_printf.cc b/lib/sanitizer_common/sanitizer_printf.cc
index 4b5a8b4af..0b6c9c6b7 100644
--- a/lib/sanitizer_common/sanitizer_printf.cc
+++ b/lib/sanitizer_common/sanitizer_printf.cc
@@ -173,6 +173,21 @@ void SetPrintfAndReportCallback(void (*callback)(const char *)) {
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;