[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

llvm-svn: 352789
This commit is contained in:
Jonathan Metzman 2019-01-31 20:32:20 +00:00
parent 4f9543b4d6
commit fc7faecb40
3 changed files with 12 additions and 8 deletions

View File

@ -334,7 +334,7 @@ bool IsInterestingCoverageFile(const std::string &FileName) {
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

View File

@ -403,9 +403,13 @@ uintptr_t TracePC::GetMaxStackOffset() const {
}
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(uint32_t *Guard) {
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

View File

@ -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