valgrind_test_cleaner.pl 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. # Yes, it's perl even when we use python. I wrote it for myself when
  16. # I needed to clean the outputs and after it proved useful to me, I
  17. # thought it might be for others too, so I just included it. It's not
  18. # that we would be switching to perl. If it should grow in future to
  19. # include more heuristics and do something more fancy, we should probably
  20. # rewrite it in python instead.
  21. my ($block, $blockOK);
  22. sub endBlock(_) {
  23. return unless $block;
  24. if ($blockOK) {
  25. print @$block;
  26. }
  27. undef $block;
  28. undef $blockOK;
  29. }
  30. sub startBlock(_) {
  31. $block = [@_];
  32. }
  33. sub addToBlock(_) {
  34. my ($line) = @_;
  35. push @$block, $line;
  36. return unless $line =~ /^==\d+==\s+(at|by) 0x[0-9A-F]+: (.*) \(.+:\d+\)$/;
  37. $_ = $2;
  38. return $blockOK = 1 if /^isc::/;
  39. return $blockOK = 1 if /^asiolink:/;
  40. return if /^main \(/;
  41. return if /^testing::/;
  42. return if /^\(anonymous namespace\)::/;
  43. $blockOK = 1;
  44. }
  45. while(<>) {
  46. if (/^==\d+==\s*$/) {
  47. print;
  48. endBlock;
  49. } elsif (/^==\d+==\s+\d+bytes.*lost in loss record/) {
  50. startBlock;
  51. } elsif ($block) {
  52. addToBlock;
  53. } else {
  54. print;
  55. }
  56. }
  57. endBlock;