[PATCH] [lsan] Prettify LSan reports and add a summary
Sergey Matveev
earthdok at google.com
Fri May 24 07:35:20 PDT 2013
- Changed summary format following offline discussion with kcc
Hi kcc, glider,
http://llvm-reviews.chandlerc.com/D859
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D859?vs=2117&id=2118#toc
Files:
lib/lsan/lsan_common.cc
lib/lsan/lsan_common.h
Index: lib/lsan/lsan_common.cc
===================================================================
--- lib/lsan/lsan_common.cc
+++ lib/lsan/lsan_common.cc
@@ -267,8 +267,10 @@
}
static void PrintLeaked() {
- Printf("\nReporting individual blocks:\n");
+ Printf("Reporting individual blocks:\n");
+ Printf("============================\n");
ForEachChunk(PrintLeakedCb());
+ Printf("\n");
}
enum LeakCheckResult {
@@ -290,9 +292,14 @@
*result = kNoLeaks;
return;
}
+ Printf("\n");
+ Printf("=================================================================\n");
+ Report("ERROR: LeakSanitizer: detected leaks.\n");
leak_report.PrintLargest(flags()->max_leaks);
if (flags()->report_blocks)
PrintLeaked();
+ leak_report.PrintSummary();
+ Printf("\n");
ForEachChunk(ClearTagCb());
*result = kLeaksFound;
}
@@ -387,17 +394,27 @@
InternalSort(&leaks_, leaks_.size(), IsLarger);
max_leaks = max_leaks > 0 ? Min(max_leaks, leaks_.size()) : leaks_.size();
for (uptr i = 0; i < max_leaks; i++) {
- Printf("\n%s leak of %llu bytes in %llu objects allocated from:\n",
+ Printf("%s leak of %llu bytes in %llu object%s allocated from:\n",
leaks_[i].is_directly_leaked ? "Direct" : "Indirect",
- leaks_[i].total_size, leaks_[i].hit_count);
+ leaks_[i].total_size, leaks_[i].hit_count,
+ leaks_[i].hit_count == 1 ? "" : "s");
PrintStackTraceById(leaks_[i].stack_trace_id);
+ Printf("\n");
}
if (max_leaks < leaks_.size()) {
uptr remaining = leaks_.size() - max_leaks;
- Printf("\nOmitting %llu more leak%s.\n", remaining,
+ Printf("Omitting %llu more leak%s.\n", remaining,
remaining > 1 ? "s" : "");
}
}
+void LeakReport::PrintSummary() {
+ CHECK(leaks_.size() <= kMaxLeaksConsidered);
+ uptr bytes_leaked = 0;
+ for (uptr i = 0; i < leaks_.size(); i++) {
+ bytes_leaked += leaks_[i].total_size;
+ }
+ Printf("SUMMARY: LeakSanitizer: %llu bytes leaked.\n", bytes_leaked);
+}
} // namespace __lsan
#endif // CAN_SANITIZE_LEAKS
Index: lib/lsan/lsan_common.h
===================================================================
--- lib/lsan/lsan_common.h
+++ lib/lsan/lsan_common.h
@@ -98,6 +98,7 @@
LeakReport() : leaks_(1) {}
void Add(u32 stack_trace_id, uptr leaked_size, ChunkTag tag);
void PrintLargest(uptr max_leaks);
+ void PrintSummary();
bool IsEmpty() { return leaks_.size() == 0; }
private:
InternalVector<Leak> leaks_;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D859.3.patch
Type: text/x-patch
Size: 2495 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130524/2c408789/attachment.bin>
More information about the llvm-commits
mailing list