X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FTest%2FValgrind%2FSuppressions.pm;h=ef6ad1fe67a99d3f17a6639dbcc95ff8a6971aef;hb=cc42998614d386a86ed90c9c9dd3ce9df68140f5;hp=fde934c050948e0a047b554664483b029364c1e7;hpb=ad65b4599d66c8cc26dedada4d994aa8faebfcd7;p=perl%2Fmodules%2FTest-Valgrind.git diff --git a/lib/Test/Valgrind/Suppressions.pm b/lib/Test/Valgrind/Suppressions.pm index fde934c..ef6ad1f 100644 --- a/lib/Test/Valgrind/Suppressions.pm +++ b/lib/Test/Valgrind/Suppressions.pm @@ -9,11 +9,11 @@ Test::Valgrind::Suppressions - Generate suppressions for given tool and command. =head1 VERSION -Version 1.11 +Version 1.14 =cut -our $VERSION = '1.11'; +our $VERSION = '1.14'; =head1 DESCRIPTION @@ -21,11 +21,17 @@ This module is an helper for generating suppressions. =cut -use base qw/Test::Valgrind::Carp/; +use base qw; =head1 METHODS -=head2 C<< generate tool => $tool, command => $command, target => $target >> +=head2 C + + Test::Valgrind::Suppressions->generate( + tool => $tool, + command => $command, + target => $target, + ); Generates suppressions for the command C<< $command->new_trainer >> and the tool C<< $tool->new_trainer >>, and writes them in the file specified by C<$target>. The action used behind the scenes is L. @@ -88,7 +94,12 @@ sub generate { return $status; } -=head2 C +=head2 C + + my $mangled_suppression = Test::Valgrind::Suppressions->strip_tail( + $session, + $suppression, + ); Removes all wildcard frames at the end of the suppression. Moreover, C<'...'> is appended when C C<3.4.0> or higher is used. @@ -103,11 +114,66 @@ sub strip_tail { 1 while $supp =~ s/[^\r\n]*:\s*\*\s*$//; # With valgrind 3.4.0, we can replace unknown series of frames by '...' - $supp .= "...\n" if $sess->version ge '3.4.0'; + if ($sess->version ge '3.4.0') { + 1 while $supp =~ s/[^\r\n]*\.{3}\s*$//; + $supp .= "...\n"; + } $supp; } +=head2 C + + my $demangled_symbol = Test::Valgrind::Suppressions->maybe_z_demangle( + $symbol, + ); + +If C<$symbol> is Z-encoded as described in C's F, extract and decode its function name part. +Otherwise, C<$symbol> is returned as is. + +This routine follows C's F. + +=cut + +my %z_escapes = ( + a => '*', + c => ':', + d => '.', + h => '-', + p => '+', + s => ' ', + u => '_', + A => '@', + D => '$', + L => '(', + R => ')', + Z => 'Z', +); + +sub maybe_z_demangle { + my ($self, $sym) = @_; + + $sym =~ s/^_vg[rwn]Z([ZU])_// or return $sym; + + my $fn_is_encoded = $1 eq 'Z'; + + $sym =~ /^VG_Z_/ and $self->_croak('Symbol with a "VG_Z_" prefix is invalid'); + $sym =~ s/^[^_]*_// + or $self->_croak('Symbol doesn\'t contain a function name'); + + if ($fn_is_encoded) { + $sym =~ s/Z(.)/ + my $c = $z_escapes{$1}; + $self->_croak('Invalid escape sequence') unless defined $c; + $c; + /ge; + } + + $self->_croak('Empty symbol') unless length $sym; + + return $sym; +} + =head1 SEE ALSO L, L, L, L. @@ -131,7 +197,7 @@ You can find documentation for this module with the perldoc command. =head1 COPYRIGHT & LICENSE -Copyright 2008-2009 Vincent Pit, all rights reserved. +Copyright 2008,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.