my @supps;
while (<$fh>) {
- s/^\s*#\s//;
- next if /^==/;
+ s/^\s*#\s//; # Strip comments
+
+ next if /^==/; # Valgrind info line
next if /valgrind/; # and /\Q$file\E/;
- s/^\s*//;
- s/<[^>]+>//;
- s/\s*$//;
+
+ s/^\s*//; # Strip leading spaces
+ s/<[^>]+>//; # Strip tags
+ s/\s*$//; # Strip trailing spaces
next unless length;
- if ($_ eq '{') {
+
+ if ($_ eq '{') { # A suppression block begins
$in = 1;
- } elsif ($_ eq '}') {
- my $unknown_tail;
- ++$unknown_tail while $s =~ s/(\n)\s*obj:\*\s*$/$1/;
- $s .= "...\n" if $unknown_tail and $sess->version ge '3.4.0';
- push @supps, $s;
- $s = '';
+ } elsif ($_ eq '}') { # A suppression block ends
+ # With valgrind 3.4.0, we can replace unknown series of frames by '...'
+ if ($sess->version ge '3.4.0') {
+ my $unknown_tail;
+ ++$unknown_tail while $s =~ s/(\n)\s*obj:\*\s*$/$1/;
+ $s .= "...\n" if $unknown_tail;
+ }
+
+ push @supps, $s; # Add the suppression that just ended to the list
+ $s = ''; # Reset the state
$in = 0;
- } elsif ($in) {
- $s .= "$_\n";
+ } elsif ($in) { # We're inside a suppresion block
+ $s .= "$_\n"; # Append the current line to the state
}
}
my @extra;
+
for (@supps) {
if (/\bfun:(m|c|re)alloc\b/) {
my $t = $1;
- my %call;
- if ($t eq 'm') { # malloc can also be called by calloc or realloc
+
+ my %call; # Frames to append (if the value is 1) or to prepend (if it's 0)
+ if ($t eq 'm') { # malloc can also be called by calloc or realloc
$call{$_} = 1 for qw/calloc realloc/;
} elsif ($t eq 're') { # realloc can also call malloc or free
$call{$_} = 0 for qw/malloc free/;
- } elsif ($t eq 'c') { # calloc can also call malloc
+ } elsif ($t eq 'c') { # calloc can also call malloc
$call{$_} = 0 for qw/malloc/;
}
+
my $c = $_;
for (keys %call) {
my $d = $c;