valgrind_test_cleaner.pl 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. # This script can be used on a valgrind output of the tests (from
  5. # tests_in_valgrind.sh) to remove some uninteresting error reports.
  6. # Since we care about the tested application not leaking/crashing, not
  7. # the tests itself, memory leaks that are caused only by the tests
  8. # (eg. unreleased test data), we don't want to have logs full of them.
  9. #
  10. # This script does some heuristics to eliminate some of such error
  11. # reports. Currently, the memory lost reports whose stack contains
  12. # no call from the real application are suppressed.
  13. #
  14. # Of course, the rest still can contain many uninteresting entries.
  15. my ($block, $blockOK);
  16. sub endBlock(_) {
  17. return unless $block;
  18. if ($blockOK) {
  19. print @$block;
  20. }
  21. undef $block;
  22. undef $blockOK;
  23. }
  24. sub startBlock(_) {
  25. $block = [@_];
  26. }
  27. sub addToBlock(_) {
  28. my ($line) = @_;
  29. push @$block, $line;
  30. return unless $line =~ /^==\d+==\s+(at|by) 0x[0-9A-F]+: (.*) \(.+:\d+\)$/;
  31. $_ = $2;
  32. return $blockOK = 1 if /^isc::/;
  33. return $blockOK = 1 if /^asiolink:/;
  34. return if /^main \(/;
  35. return if /^testing::/;
  36. return if /^\(anonymous namespace\)::/;
  37. $blockOK = 1;
  38. }
  39. while(<>) {
  40. if (/^==\d+==\s*$/) {
  41. print;
  42. endBlock;
  43. } elsif (/^==\d+==\s+\d+bytes.*lost in loss record/) {
  44. startBlock;
  45. } elsif ($block) {
  46. addToBlock;
  47. } else {
  48. print;
  49. }
  50. }
  51. endBlock;