X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FTest%2FValgrind%2FSuppressions.pm;h=8e90ab7b87ddab5227e2be0ff98a950120535ac9;hb=3f7326fc2135eb0c6c637e5676456b4ebf82d197;hp=ab5294f5b0277a943a2e6726f8de989cc6af341a;hpb=d93ddba6bc7708cbd0df564b47eb63edf70d601c;p=perl%2Fmodules%2FTest-Valgrind.git diff --git a/lib/Test/Valgrind/Suppressions.pm b/lib/Test/Valgrind/Suppressions.pm index ab5294f..8e90ab7 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.14 +Version 1.18 =cut -our $VERSION = '1.14'; +our $VERSION = '1.18'; =head1 DESCRIPTION @@ -94,29 +94,49 @@ sub generate { return $status; } -=head2 C +=head2 C - my $mangled_suppression = Test::Valgrind::Suppressions->strip_tail( + my $mangled_suppression = Test::Valgrind::Suppressions->maybe_generalize( $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. +It also replaces sequences of wildcard frames by C<'...'> when C C<3.4.0> or higher is used. Returns the mangled suppression. =cut -sub strip_tail { +sub maybe_generalize { 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"; + my $can_ellipsis = $sess->version >= '3.4.0'; + + my $did_length_check; + + ELLIPSIS: { + if ($can_ellipsis) { + $supp .= "...\n"; + $supp =~ s/(?:^\s*(?:\.{3}|\*:\S*|obj:\*)\s*(?:\n|\z))+/...\n/mg; + } + + last if $did_length_check++; + + my $frames_count =()= $supp =~ m/^(?:(?:obj|fun|\*):|\.{3}\s*$)/mg; + if ($frames_count > 24) { + # Keep only 24 frames, and even sacrifice one more if we can do ellipsis. + my $last = $can_ellipsis ? 23 : 24; + my $len = length $supp; + $supp =~ m/^(?:(?:obj|fun|\*):\S*|\.{3})\s*\n/mg for 1 .. $last; + my $p = pos $supp; + substr $supp, $p, $len - $p, ''; + redo ELLIPSIS if $can_ellipsis; + } } $supp;