diff options
author | Kostya Serebryany <kcc@google.com> | 2016-12-10 01:19:35 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2016-12-10 01:19:35 +0000 |
commit | 1394ce2aa2955589a1754cb1f5d5624760d8801f (patch) | |
tree | 82f303437780dfec25e5150a7aa90ddf518e9b58 /llvm/lib/Fuzzer/FuzzerTracePC.cpp | |
parent | 3e5f0474ca83577a5e30f18cc4e450750240b63f (diff) | |
download | bcm5719-llvm-1394ce2aa2955589a1754cb1f5d5624760d8801f.tar.gz bcm5719-llvm-1394ce2aa2955589a1754cb1f5d5624760d8801f.zip |
[libFuzzer] use __sanitizer_get_module_and_offset_for_pc to get the module name while printing the coverage
llvm-svn: 289310
Diffstat (limited to 'llvm/lib/Fuzzer/FuzzerTracePC.cpp')
-rw-r--r-- | llvm/lib/Fuzzer/FuzzerTracePC.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerTracePC.cpp b/llvm/lib/Fuzzer/FuzzerTracePC.cpp index d8036edf728..7e7a9143830 100644 --- a/llvm/lib/Fuzzer/FuzzerTracePC.cpp +++ b/llvm/lib/Fuzzer/FuzzerTracePC.cpp @@ -89,8 +89,10 @@ void TracePC::PrintNewPCs() { } void TracePC::PrintCoverage() { - if (!EF->__sanitizer_symbolize_pc) { - Printf("INFO: __sanitizer_symbolize_pc is not available," + if (!EF->__sanitizer_symbolize_pc || + !EF->__sanitizer_get_module_and_offset_for_pc) { + Printf("INFO: __sanitizer_symbolize_pc or " + "__sanitizer_get_module_and_offset_for_pc is not available," " not printing coverage\n"); return; } @@ -106,12 +108,15 @@ void TracePC::PrintCoverage() { std::string FixedPCStr = DescribePC("%p", PCs[i]); std::string FunctionStr = DescribePC("%F", PCs[i]); std::string LineStr = DescribePC("%l", PCs[i]); - // TODO(kcc): get the module using some other way since this - // does not work with ASAN_OPTIONS=strip_path_prefix=something. - std::string Module = DescribePC("%m", PCs[i]); - std::string OffsetStr = DescribePC("%o", PCs[i]); + char ModulePathRaw[4096] = ""; // What's PATH_MAX in portable C++? + void *OffsetRaw = nullptr; + if (!EF->__sanitizer_get_module_and_offset_for_pc( + reinterpret_cast<void *>(PCs[i]), ModulePathRaw, + sizeof(ModulePathRaw), &OffsetRaw)) + continue; + std::string Module = ModulePathRaw; uintptr_t FixedPC = std::stol(FixedPCStr, 0, 16); - uintptr_t PcOffset = std::stol(OffsetStr, 0, 16); + uintptr_t PcOffset = reinterpret_cast<uintptr_t>(OffsetRaw); ModuleOffsets[Module] = FixedPC - PcOffset; CoveredPCsPerModule[Module].push_back(PcOffset); CoveredFunctions.insert(FunctionStr); |