| Test-Valgrind documentation | Contained in the Test-Valgrind distribution. |
Test::Valgrind::Suppressions - Generate suppressions for given tool and command.
Version 1.12
This module is an helper for generating suppressions.
generate tool => $tool, command => $command, target => $targetGenerates suppressions for the command $command->new_trainer and the tool $tool->new_trainer, and writes them in the file specified by $target.
The action used behind the scenes is Test::Valgrind::Action::Suppressions.
Returns the status code.
strip_tail $session, $suppressionRemoves all wildcard frames at the end of the suppression.
Moreover, '...' is appended when valgrind 3.4.0 or higher is used.
Returns the mangled suppression.
maybe_z_demangle $symbolIf $symbol is Z-encoded as described in valgrind's include/pub_tool_redir.h, extract and decode its function name part.
Otherwise, $symbol is returned as is.
This routine follows valgrind's coregrind/m_demangle/demangle.c:maybe_Z_demangle.
Test::Valgrind, Test::Valgrind::Command, Test::Valgrind::Tool, Test::Valgrind::Action::Suppressions.
Vincent Pit, <perl at profvince.com>, http://www.profvince.com.
You can contact me by mail or on irc.perl.org (vincent).
Please report any bugs or feature requests to bug-test-valgrind-suppressions at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Valgrind.
I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc Test::Valgrind::Suppressions
Copyright 2008-2009 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.
| Test-Valgrind documentation | Contained in the Test-Valgrind distribution. |
package Test::Valgrind::Suppressions; use strict; use warnings;
our $VERSION = '1.12';
use base qw/Test::Valgrind::Carp/;
sub generate { my $self = shift; my %args = @_; my $cmd = delete $args{command}; unless (ref $cmd) { require Test::Valgrind::Command; $cmd = Test::Valgrind::Command->new( command => $cmd, args => [ ], ); } $cmd = $cmd->new_trainer; return unless defined $cmd; my $tool = delete $args{tool}; unless (ref $tool) { require Test::Valgrind::Tool; $tool = Test::Valgrind::Tool->new(tool => $tool); } $tool = $tool->new_trainer; return unless defined $tool; my $target = delete $args{target}; $self->_croak('Invalid target') unless $target and not ref $target; require Test::Valgrind::Action; my $action = Test::Valgrind::Action->new( action => 'Suppressions', target => $target, name => 'PerlSuppression', ); require Test::Valgrind::Session; my $sess = Test::Valgrind::Session->new( min_version => $tool->requires_version, ); eval { $sess->run( command => $cmd, tool => $tool, action => $action, ); }; $self->_croak($@) if $@; my $status = $sess->status; $status = 255 unless defined $status; return $status; }
sub strip_tail { shift; my ($sess, $supp) = @_; 1 while $supp =~ s/[^\r\n]*:\s*\*\s*$//; # With valgrind 3.4.0, we can replace unknown series of frames by '...' if ($sess->version ge '3.4.0') { 1 while $supp =~ s/[^\r\n]*\.{3}\s*$//; $supp .= "...\n"; } $supp; }
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; }
1; # End of Test::Valgrind::Suppressions