[compiler-rt] r261376 - [sancov] use GetLoadedModules for list of modules rather than sanitizer's list.
Mike Aizatsky via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 19 14:55:21 PST 2016
Author: aizatsky
Date: Fri Feb 19 16:55:21 2016
New Revision: 261376
URL: http://llvm.org/viewvc/llvm-project?rev=261376&view=rev
Log:
[sancov] use GetLoadedModules for list of modules rather than sanitizer's list.
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep.cc?rev=261376&r1=261375&r2=261376&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep.cc Fri Feb 19 16:55:21 2016
@@ -783,10 +783,35 @@ void CoverageData::GetRangeOffsets(const
(*offsets)[i] = UnbundlePc((*offsets)[i]);
}
-static void GenerateHtmlReport(const InternalMmapVector<char *> &sancov_argv) {
- if (!common_flags()->html_cov_report || sancov_argv[0] == nullptr) {
+static void GenerateHtmlReport(const InternalMmapVector<char *> &cov_files) {
+ if (!common_flags()->html_cov_report) {
return;
}
+ char *sancov_path = FindPathToBinary(common_flags()->sancov_path);
+ if (sancov_path == nullptr) {
+ return;
+ }
+
+ InternalMmapVector<char *> sancov_argv(cov_files.size() * 2 + 3);
+ sancov_argv.push_back(sancov_path);
+ sancov_argv.push_back(internal_strdup("-html-report"));
+ auto argv_deleter = at_scope_exit([&] {
+ for (uptr i = 0; i < sancov_argv.size(); ++i) {
+ InternalFree(sancov_argv[i]);
+ }
+ });
+
+ for (const auto &cov_file : cov_files) {
+ sancov_argv.push_back(internal_strdup(cov_file));
+ }
+
+ InternalScopedBuffer<LoadedModule> LoadedModules(kMaxNumberOfModules);
+ uptr n_modules = GetListOfModules(LoadedModules.data(), kMaxNumberOfModules,
+ /* filter */ nullptr);
+ for (uptr i = 0; i < n_modules; ++i) {
+ sancov_argv.push_back(internal_strdup(LoadedModules[i].full_name()));
+ }
+
InternalScopedString report_path(kMaxPathLength);
fd_t report_fd =
CovOpenFile(&report_path, false /* packed */, GetProcessName(), "html");
@@ -806,12 +831,10 @@ void CoverageData::DumpOffsets() {
InternalMmapVector<uptr> offsets(0);
InternalScopedString path(kMaxPathLength);
- InternalMmapVector<char *> sancov_argv(module_name_vec.size() * 2 + 3);
- sancov_argv.push_back(FindPathToBinary(common_flags()->sancov_path));
- sancov_argv.push_back(internal_strdup("-html-report"));
- auto argv_deleter = at_scope_exit([&] {
- for (uptr i = 0; i < sancov_argv.size(); ++i) {
- InternalFree(sancov_argv[i]);
+ InternalMmapVector<char *> cov_files(module_name_vec.size());
+ auto cov_files_deleter = at_scope_exit([&] {
+ for (uptr i = 0; i < cov_files.size(); ++i) {
+ InternalFree(cov_files[i]);
}
});
@@ -839,16 +862,14 @@ void CoverageData::DumpOffsets() {
if (fd == kInvalidFd) continue;
WriteToFile(fd, offsets.data(), offsets.size() * sizeof(offsets[0]));
CloseFile(fd);
- sancov_argv.push_back(internal_strdup(r.copied_module_name));
- sancov_argv.push_back(internal_strdup(path.data()));
+ cov_files.push_back(internal_strdup(path.data()));
VReport(1, " CovDump: %s: %zd PCs written\n", path.data(), num_offsets);
}
}
if (cov_fd != kInvalidFd)
CloseFile(cov_fd);
- sancov_argv.push_back(nullptr);
- GenerateHtmlReport(sancov_argv);
+ GenerateHtmlReport(cov_files);
}
void CoverageData::DumpAll() {
More information about the llvm-commits
mailing list