mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-26 06:14:42 +00:00
[libFuzzer] print a stack trace on timeout
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250571 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b436b77ccf
commit
9b24e29d72
@ -56,6 +56,7 @@ bool ToASCII(Unit &U);
|
||||
bool IsASCII(const Unit &U);
|
||||
|
||||
int NumberOfCpuCores();
|
||||
int GetPid();
|
||||
|
||||
// Dictionary.
|
||||
|
||||
|
@ -13,6 +13,10 @@
|
||||
#include <sanitizer/coverage_interface.h>
|
||||
#include <algorithm>
|
||||
|
||||
extern "C" {
|
||||
__attribute__((weak)) void __sanitizer_print_stack_trace();
|
||||
}
|
||||
|
||||
namespace fuzzer {
|
||||
static const size_t kMaxUnitSizeToPrint = 256;
|
||||
|
||||
@ -76,6 +80,11 @@ void Fuzzer::AlarmCallback() {
|
||||
PrintUnitInASCIIOrTokens(CurrentUnit, "\n");
|
||||
}
|
||||
WriteUnitToFileWithPrefix(CurrentUnit, "timeout-");
|
||||
Printf("==%d== ERROR: libFuzzer: timeout after %d seconds\n", GetPid(),
|
||||
Seconds);
|
||||
if (__sanitizer_print_stack_trace)
|
||||
__sanitizer_print_stack_trace();
|
||||
Printf("SUMMARY: libFuzzer: timeout\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -166,4 +166,6 @@ bool ParseDictionaryFile(const std::string &Text, std::vector<Unit> *Units) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int GetPid() { return getpid(); }
|
||||
|
||||
} // namespace fuzzer
|
||||
|
@ -14,6 +14,11 @@ MaxTotalTime: Done {{.*}} runs in {{.}} second(s)
|
||||
RUN: not LLVMFuzzer-TimeoutTest -timeout=5 2>&1 | FileCheck %s --check-prefix=TimeoutTest
|
||||
TimeoutTest: ALARM: working on the last Unit for
|
||||
TimeoutTest: Test unit written to ./timeout-
|
||||
TimeoutTest: == ERROR: libFuzzer: timeout after
|
||||
TimeoutTest: #0
|
||||
TimeoutTest: #1
|
||||
TimeoutTest: #2
|
||||
TimeoutTest: SUMMARY: libFuzzer: timeout
|
||||
|
||||
RUN: not LLVMFuzzer-TimeoutTest -timeout=5 -test_single_input=%S/hi.txt 2>&1 | FileCheck %s --check-prefix=SingleInputTimeoutTest
|
||||
SingleInputTimeoutTest: ALARM: working on the last Unit for
|
||||
|
Loading…
x
Reference in New Issue
Block a user