@@ -267,8 +267,10 @@ void PrintLeakedCb::operator()(void *p) const {
267
267
}
268
268
269
269
static void PrintLeaked () {
270
- Printf (" \n Reporting individual blocks:\n " );
270
+ Printf (" Reporting individual blocks:\n " );
271
+ Printf (" ============================\n " );
271
272
ForEachChunk (PrintLeakedCb ());
273
+ Printf (" \n " );
272
274
}
273
275
274
276
enum LeakCheckResult {
@@ -290,9 +292,14 @@ static void DoLeakCheckCallback(const SuspendedThreadsList &suspended_threads,
290
292
*result = kNoLeaks ;
291
293
return ;
292
294
}
295
+ Printf (" \n " );
296
+ Printf (" =================================================================\n " );
297
+ Report (" ERROR: LeakSanitizer: detected leaks.\n " );
293
298
leak_report.PrintLargest (flags ()->max_leaks );
294
299
if (flags ()->report_blocks )
295
300
PrintLeaked ();
301
+ leak_report.PrintSummary ();
302
+ Printf (" \n " );
296
303
ForEachChunk (ClearTagCb ());
297
304
*result = kLeaksFound ;
298
305
}
@@ -387,17 +394,27 @@ void LeakReport::PrintLargest(uptr max_leaks) {
387
394
InternalSort (&leaks_, leaks_.size (), IsLarger);
388
395
max_leaks = max_leaks > 0 ? Min (max_leaks, leaks_.size ()) : leaks_.size ();
389
396
for (uptr i = 0 ; i < max_leaks; i++) {
390
- Printf (" \n %s leak of %llu bytes in %llu objects allocated from:\n " ,
397
+ Printf (" %s leak of %llu bytes in %llu object%s allocated from:\n " ,
391
398
leaks_[i].is_directly_leaked ? " Direct" : " Indirect" ,
392
- leaks_[i].total_size , leaks_[i].hit_count );
399
+ leaks_[i].total_size , leaks_[i].hit_count ,
400
+ leaks_[i].hit_count == 1 ? " " : " s" );
393
401
PrintStackTraceById (leaks_[i].stack_trace_id );
402
+ Printf (" \n " );
394
403
}
395
404
if (max_leaks < leaks_.size ()) {
396
405
uptr remaining = leaks_.size () - max_leaks;
397
- Printf (" \n Omitting %llu more leak%s.\n " , remaining,
406
+ Printf (" Omitting %llu more leak%s.\n " , remaining,
398
407
remaining > 1 ? " s" : " " );
399
408
}
400
409
}
401
410
411
+ void LeakReport::PrintSummary () {
412
+ CHECK (leaks_.size () <= kMaxLeaksConsidered );
413
+ uptr bytes_leaked = 0 ;
414
+ for (uptr i = 0 ; i < leaks_.size (); i++) {
415
+ bytes_leaked += leaks_[i].total_size ;
416
+ }
417
+ Printf (" SUMMARY: LeakSanitizer: %llu bytes leaked.\n " , bytes_leaked);
418
+ }
402
419
} // namespace __lsan
403
420
#endif // CAN_SANITIZE_LEAKS
0 commit comments