diff options
author | Kostya Serebryany <kcc@google.com> | 2017-08-28 22:52:22 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2017-08-28 22:52:22 +0000 |
commit | c07008653c109345b1446f27f2ccc72dbfe5da41 (patch) | |
tree | 81266cbf90c7fea5aab081c4a1bd6a116e8950fb /compiler-rt/lib/fuzzer/FuzzerTracePC.cpp | |
parent | 4976d6a0c6d114adb4feb19195af42d0d835870f (diff) | |
download | bcm5719-llvm-c07008653c109345b1446f27f2ccc72dbfe5da41.tar.gz bcm5719-llvm-c07008653c109345b1446f27f2ccc72dbfe5da41.zip |
[libFuzzer] allow -print_funcs=N: N is the max number of new covered function printed
llvm-svn: 311945
Diffstat (limited to 'compiler-rt/lib/fuzzer/FuzzerTracePC.cpp')
-rw-r--r-- | compiler-rt/lib/fuzzer/FuzzerTracePC.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp b/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp index 831316aa3f4..78f0d41715b 100644 --- a/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp +++ b/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp @@ -143,6 +143,7 @@ void TracePC::HandleCallerCallee(uintptr_t Caller, uintptr_t Callee) { } void TracePC::UpdateObservedPCs() { + Vector<uintptr_t> CoveredFuncs; auto ObservePC = [&](uintptr_t PC) { if (ObservedPCs.insert(PC).second && DoPrintNewPCs) PrintPC("\tNEW_PC: %p %F %L\n", "\tNEW_PC: %p\n", PC + 1); @@ -150,8 +151,8 @@ void TracePC::UpdateObservedPCs() { auto Observe = [&](const PCTableEntry &TE) { if (TE.PCFlags & 1) - if (ObservedFuncs.insert(TE.PC).second && DoPrintNewFuncs) - PrintPC("\tNEW_FUNC: %p %F %L\n", "\tNEW_PC: %p\n", TE.PC + 1); + if (ObservedFuncs.insert(TE.PC).second && NumPrintNewFuncs) + CoveredFuncs.push_back(TE.PC); ObservePC(TE.PC); }; @@ -186,6 +187,11 @@ void TracePC::UpdateObservedPCs() { if (P[Idx]) ObservePC((uintptr_t)Idx); } + + for (size_t i = 0, N = Min(CoveredFuncs.size(), NumPrintNewFuncs); i < N; i++) { + Printf("\tNEW_FUNC[%zd/%zd]: ", i, CoveredFuncs.size()); + PrintPC("%p %F %L\n", "%p\n", CoveredFuncs[i] + 1); + } } inline ALWAYS_INLINE uintptr_t GetPreviousInstructionPc(uintptr_t PC) { |