[compiler-rt] r352789 - [fuzzer] Use RawPrint instead of Printf for instrumentation warning
Jonathan Metzman via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 31 12:32:20 PST 2019
Author: metzman
Date: Thu Jan 31 12:32:20 2019
New Revision: 352789
URL: http://llvm.org/viewvc/llvm-project?rev=352789&view=rev
Log:
[fuzzer] Use RawPrint instead of Printf for instrumentation warning
Summary:
Use RawPrint instead of Printf for instrumentation warning because
Printf doesn't work on Win when instrumentation is being
initialized (since OutputFile is not yet initialized).
Reviewers: kcc
Reviewed By: kcc
Differential Revision: https://reviews.llvm.org/D57531
Modified:
compiler-rt/trunk/lib/fuzzer/FuzzerIOWindows.cpp
compiler-rt/trunk/lib/fuzzer/FuzzerTracePC.cpp
compiler-rt/trunk/test/fuzzer/deprecated-instrumentation.test
Modified: compiler-rt/trunk/lib/fuzzer/FuzzerIOWindows.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/fuzzer/FuzzerIOWindows.cpp?rev=352789&r1=352788&r2=352789&view=diff
==============================================================================
--- compiler-rt/trunk/lib/fuzzer/FuzzerIOWindows.cpp (original)
+++ compiler-rt/trunk/lib/fuzzer/FuzzerIOWindows.cpp Thu Jan 31 12:32:20 2019
@@ -334,7 +334,7 @@ bool IsInterestingCoverageFile(const std
void RawPrint(const char *Str) {
// Not tested, may or may not work. Fix if needed.
- Printf("%s", Str);
+ write(2, Str, strlen(Str));
}
} // namespace fuzzer
Modified: compiler-rt/trunk/lib/fuzzer/FuzzerTracePC.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/fuzzer/FuzzerTracePC.cpp?rev=352789&r1=352788&r2=352789&view=diff
==============================================================================
--- compiler-rt/trunk/lib/fuzzer/FuzzerTracePC.cpp (original)
+++ compiler-rt/trunk/lib/fuzzer/FuzzerTracePC.cpp Thu Jan 31 12:32:20 2019
@@ -403,9 +403,13 @@ uintptr_t TracePC::GetMaxStackOffset() c
}
void WarnAboutDeprecatedInstrumentation(const char *flag) {
- Printf("libFuzzer does not support %s any more.\n"
- "Please either migrate to a compiler that supports -fsanitize=fuzzer\n"
- "or use an older version of libFuzzer\n", flag);
+ // Use RawPrint because Printf cannot be used on Windows before OutputFile is
+ // initialized.
+ RawPrint(flag);
+ RawPrint(
+ " is no longer supported by libFuzzer.\n"
+ "Please either migrate to a compiler that supports -fsanitize=fuzzer\n"
+ "or use an older version of libFuzzer\n");
exit(1);
}
@@ -415,7 +419,8 @@ extern "C" {
ATTRIBUTE_INTERFACE
ATTRIBUTE_NO_SANITIZE_ALL
void __sanitizer_cov_trace_pc_guard(uint32_t *Guard) {
- fuzzer::WarnAboutDeprecatedInstrumentation("-fsanitize-coverage=trace-pc");
+ fuzzer::WarnAboutDeprecatedInstrumentation(
+ "-fsanitize-coverage=trace-pc-guard");
}
// Best-effort support for -fsanitize-coverage=trace-pc, which is available
@@ -423,8 +428,7 @@ void __sanitizer_cov_trace_pc_guard(uint
ATTRIBUTE_INTERFACE
ATTRIBUTE_NO_SANITIZE_ALL
void __sanitizer_cov_trace_pc() {
- fuzzer::WarnAboutDeprecatedInstrumentation(
- "-fsanitize-coverage=trace-pc-guard");
+ fuzzer::WarnAboutDeprecatedInstrumentation("-fsanitize-coverage=trace-pc");
}
ATTRIBUTE_INTERFACE
Modified: compiler-rt/trunk/test/fuzzer/deprecated-instrumentation.test
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/fuzzer/deprecated-instrumentation.test?rev=352789&r1=352788&r2=352789&view=diff
==============================================================================
--- compiler-rt/trunk/test/fuzzer/deprecated-instrumentation.test (original)
+++ compiler-rt/trunk/test/fuzzer/deprecated-instrumentation.test Thu Jan 31 12:32:20 2019
@@ -1,4 +1,4 @@
-CHECK: libFuzzer does not support -fsanitize-coverage=trace-pc
+CHECK: -fsanitize-coverage=trace-pc is no longer supported by libFuzzer
RUN: %cpp_compiler %S/SimpleTest.cpp -c -o %t-SimpleTest.o -fsanitize-coverage=trace-pc
RUN: %cpp_compiler %t-SimpleTest.o -o %t-SimpleTest
RUN: not %run %t-SimpleTest 2>&1 | FileCheck %s
More information about the llvm-commits
mailing list