X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FTest%2FValgrind%2FTool%2Fmemcheck.pm;h=e3932ef079fd18f4096c04ba5ed1a7dd955c9add;hb=5b7da288da2757d62ecaa3de0c40ea876ef9be2b;hp=1213b7b29c71d8c365649e762c397aed15a92ed9;hpb=d44c95e8e9820ee69e76506bde7c2c5fbe37b568;p=perl%2Fmodules%2FTest-Valgrind.git diff --git a/lib/Test/Valgrind/Tool/memcheck.pm b/lib/Test/Valgrind/Tool/memcheck.pm index 1213b7b..e3932ef 100644 --- a/lib/Test/Valgrind/Tool/memcheck.pm +++ b/lib/Test/Valgrind/Tool/memcheck.pm @@ -9,11 +9,11 @@ Test::Valgrind::Tool::memcheck - Run an analysis through the memcheck tool. =head1 VERSION -Version 1.10 +Version 1.15 =cut -our $VERSION = '1.10'; +our $VERSION = '1.15'; =head1 DESCRIPTION @@ -21,7 +21,7 @@ This class contains the information required by the session for running the C; =head1 METHODS @@ -29,13 +29,20 @@ This class inherits L. =head2 C + my $required_version = $tvt->requires_version; + This tool requires C C<3.1.0>. =cut sub requires_version { '3.1.0' } -=head2 C<< new callers => $callers, ... >> +=head2 C + + my $tvtm = Test::Valgrind::Tool::memcheck->new( + callers => $callers, + %extra_args, + ); Your usual constructor. @@ -65,6 +72,8 @@ sub new_trainer { shift->new(callers => 50) } =head2 C + my $callers = $tvtm->callers; + Read-only accessor for the C option. =cut @@ -73,9 +82,11 @@ sub callers { $_[0]->{callers} } sub suppressions_tag { 'memcheck-' . $_[1]->version } -=head2 C +=head2 C + + my $parser_class = $tvtm->parser_class($session); -This tool uses a C parser in analysis mode, and a C parser in suppressions mode. +This tool uses a L parser in analysis mode, and a L parser in suppressions mode. =cut @@ -86,23 +97,31 @@ sub parser_class { ? 'Test::Valgrind::Parser::Suppressions::Text' : 'Test::Valgrind::Parser::XML::Twig'; - local $@; - eval "require $class"; + { + local $@; + eval "require $class; 1" or die $@; + } return $class; } -=head2 C +=head2 C + + my $report_class = $tvtm->report_class($session); -This tool emits C object reports in analysis mode. +This tool emits C object reports in analysis mode, and C object reports in suppressions mode. =cut sub report_class { my ($self, $session) = @_; - $session->do_suppressions ? 'Test::Valgrind::Report::Suppressions' - : 'Test::Valgrind::Tool::memcheck::Report' + if ($session->do_suppressions) { + require Test::Valgrind::Parser::Suppressions::Text; + return 'Test::Valgrind::Report::Suppressions'; + } else { + return 'Test::Valgrind::Tool::memcheck::Report'; + } } sub args { @@ -149,7 +168,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,2015 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. @@ -159,11 +178,11 @@ This program is free software; you can redistribute it and/or modify it under th package Test::Valgrind::Tool::memcheck::Report; -use base qw/Test::Valgrind::Report/; +use base qw; -our $VERSION = '1.10'; +our $VERSION = '1.15'; -my @kinds = qw/ +my @kinds = qw< InvalidFree MismatchedFree InvalidRead @@ -179,7 +198,7 @@ my @kinds = qw/ Leak_IndirectlyLost Leak_PossiblyLost Leak_StillReachable -/; +>; push @kinds, __PACKAGE__->SUPER::kinds(); my %kinds_hashed = map { $_ => 1 } @kinds; @@ -216,9 +235,9 @@ sub dump { my ($ip, $obj, $fn, $dir, $file, $line) = map { (defined) ? $_ : '?' } @$_; my $frame; if ($fn eq '?' and $obj eq '?') { - $ip =~ s/^0x//g; - $ip = hex $ip; - $frame = sprintf "0x%0${pad}X", $ip; + $ip =~ s/^0x//gi; + my $l = length $ip; + $frame = '0x' . ($l < $pad ? ('0' x ($pad - $l)) : '') . uc($ip); } else { $frame = sprintf '%s (%s) [%s:%s]', $fn, $obj, $file, $line; }