X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FTest%2FValgrind%2FParser%2FSuppressions%2FText.pm;h=429110ff1b159603838d3e015d2ed6c5afffdfa5;hb=77d53e292f2fdac4991d1d6c140f1edd79ff3afa;hp=4a1db955a5b71bb5c897858cb773de73dbd0962f;hpb=91e50cd9ec30efd628f6221947d7a523eebb2248;p=perl%2Fmodules%2FTest-Valgrind.git diff --git a/lib/Test/Valgrind/Parser/Suppressions/Text.pm b/lib/Test/Valgrind/Parser/Suppressions/Text.pm index 4a1db95..429110f 100644 --- a/lib/Test/Valgrind/Parser/Suppressions/Text.pm +++ b/lib/Test/Valgrind/Parser/Suppressions/Text.pm @@ -9,34 +9,23 @@ Test::Valgrind::Parser::Suppressions::Text - Parse valgrind suppressions output =head1 VERSION -Version 1.02 +Version 1.13 =cut -our $VERSION = '1.02'; +our $VERSION = '1.13'; =head1 DESCRIPTION -This class provides a default C method, so that real tools for which suppressions are meaningful can exploit it by inheriting. - -It's not meant to be used directly as a tool. +This is a L object that can extract suppressions from C's text output. =cut -use base qw/Test::Valgrind::Carp/; - -=head1 METHODS - -=head2 C +use Test::Valgrind::Suppressions; -Just a croaking stub to remind you not to use this class as a real tool. +use base qw; -If your tool both inherit from this class and from C, and that you want to dispatch the call to your C to its ancestors', be careful with C which may end up calling this dieing version of C. -The solution is to either put C first in the C<@ISA> list or to explicitely call C instead of C. - -=cut - -sub new { shift->_croak('This mock tool isn\'t meant to be used directly') } +=head1 METHODS =head2 C @@ -47,12 +36,6 @@ Their C member contains the raw text of the suppression. sub report_class { 'Test::Valgrind::Report::Suppressions' } -=head2 C - -Parses the filehandle C<$fh> fed with the output of F and sends a report to the session C<$session> for each suppression. - -=cut - sub parse { my ($self, $sess, $fh) = @_; @@ -63,7 +46,6 @@ sub parse { s/^\s*#\s//; # Strip comments next if /^==/; # Valgrind info line - next if /valgrind/; # and /\Q$file\E/; s/^\s*//; # Strip leading spaces s/<[^>]+>//; # Strip tags @@ -73,18 +55,19 @@ sub parse { if ($_ eq '{') { # A suppression block begins $in = 1; } 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; - } - + $s = Test::Valgrind::Suppressions->strip_tail($sess, $s); # Strip the tail push @supps, $s; # Add the suppression that just ended to the list $s = ''; # Reset the state $in = 0; } elsif ($in) { # We're inside a suppresion block - $s .= "$_\n"; # Append the current line to the state + if (/^fun\s*:\s*(.*)/) { + # Sometimes valgrind seems to forget to Z-demangle the symbol names. + # Make sure it's done and append the result to the state. + my $sym = $1; + $s .= 'fun:' . Test::Valgrind::Suppressions->maybe_z_demangle($sym) . "\n"; + } else { + $s .= "$_\n"; + } } } @@ -96,11 +79,11 @@ sub parse { 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/; + $call{$_} = 1 for qw; } elsif ($t eq 're') { # realloc can also call malloc or free - $call{$_} = 0 for qw/malloc free/; + $call{$_} = 0 for qw; } elsif ($t eq 'c') { # calloc can also call malloc - $call{$_} = 0 for qw/malloc/; + $call{$_} = 0 for qw; } my $c = $_; @@ -124,7 +107,7 @@ sub parse { =head1 SEE ALSO -L, L. +L, L. =head1 AUTHOR @@ -145,7 +128,7 @@ You can find documentation for this module with the perldoc command. =head1 COPYRIGHT & LICENSE -Copyright 2009 Vincent Pit, all rights reserved. +Copyright 2009,2010,2011,2013 Vincent Pit, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. @@ -155,7 +138,7 @@ This program is free software; you can redistribute it and/or modify it under th package Test::Valgrind::Report::Suppressions; -use base qw/Test::Valgrind::Report/; +use base qw; sub kinds { shift->SUPER::kinds(), 'Suppression' }