X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FTest-Valgrind.git;a=blobdiff_plain;f=lib%2FTest%2FValgrind%2FSuppressions.pm;h=dc1878280c3619fca6cc0b2366d017fbd9a90f2f;hp=3af3a9847631fb3025c7857709b2f4a0ff77287e;hb=f81011346e3e0eb98b78830bcdb9b547a09ad3e8;hpb=02988812caad37eabb53817242d72f65d435316f diff --git a/lib/Test/Valgrind/Suppressions.pm b/lib/Test/Valgrind/Suppressions.pm index 3af3a98..dc18782 100644 --- a/lib/Test/Valgrind/Suppressions.pm +++ b/lib/Test/Valgrind/Suppressions.pm @@ -111,6 +111,54 @@ sub strip_tail { $supp; } +=head2 C + +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.