[compiler-rt] r261376 - [sancov] use GetLoadedModules for list of modules rather than sanitizer's list.
Alexey Samsonov via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 19 16:07:07 PST 2016
On Fri, Feb 19, 2016 at 2:55 PM, Mike Aizatsky via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> 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()));
> + }
>
You forgot to call .clear() on these modules.
However, I plan to touch/fix the uses of GetListOfModules() soon, so you
might want to wait until that happens.
> +
> 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() {
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
--
Alexey Samsonov
vonosmas at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160219/51145efb/attachment.html>
More information about the llvm-commits
mailing list