From: Vincent Pit Date: Sun, 23 Aug 2009 23:18:29 +0000 (+0200) Subject: Cleanup Test::Valgrind::Tool::SuppressionsParser.pm X-Git-Tag: v1.10~29 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=ebbc6c9f1da1702dca38659f9b78cd2c5cfddc10;p=perl%2Fmodules%2FTest-Valgrind.git Cleanup Test::Valgrind::Tool::SuppressionsParser.pm --- diff --git a/lib/Test/Valgrind/Tool/SuppressionsParser.pm b/lib/Test/Valgrind/Tool/SuppressionsParser.pm index 6823d70..6142e42 100644 --- a/lib/Test/Valgrind/Tool/SuppressionsParser.pm +++ b/lib/Test/Valgrind/Tool/SuppressionsParser.pm @@ -60,39 +60,49 @@ sub parse_suppressions { 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;