X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FTest%2FValgrind%2FParser%2FXML%2FTwig.pm;h=318e2dbb7ae20799027e9337e3abc6aec7ae62c4;hb=c449f79f31a73c4389c3f9ea5cf99c62e68b47ac;hp=c1eeea9898191db9f26422fc6d6337306884586a;hpb=b9e3e9311a415d0fa583815b40ba5af0b4a3e3a8;p=perl%2Fmodules%2FTest-Valgrind.git diff --git a/lib/Test/Valgrind/Parser/XML/Twig.pm b/lib/Test/Valgrind/Parser/XML/Twig.pm index c1eeea9..318e2db 100644 --- a/lib/Test/Valgrind/Parser/XML/Twig.pm +++ b/lib/Test/Valgrind/Parser/XML/Twig.pm @@ -12,7 +12,8 @@ use base qw/Test::Valgrind::Parser::XML Test::Valgrind::Carp XML::Twig/; BEGIN { XML::Twig->add_options('Stash'); } my %handlers = ( - '/valgrindoutput/error' => \&handle_error, + '/valgrindoutput/protocolversion' => \&handle_version, + '/valgrindoutput/error' => \&handle_error, ); sub new { @@ -32,11 +33,12 @@ sub new { sub stash { shift->{Stash} } +eval "sub $_ { \@_ <= 1 ? \$_[0]->{$_} : (\$_[0]->{$_} = \$_[1]) }" + for qw/_session protocol_version/; + # We must store the session in ourselves because it's only possible to pass # arguments to XML::Twig objects by a global stash. -sub _session { @_ <= 1 ? $_[0]->{_session} : ($_[0]->{_session} = $_[1]) } - sub start { my ($self, $sess) = @_; @@ -64,6 +66,14 @@ sub finish { return; } +sub handle_version { + my ($twig, $node) = @_; + + $twig->protocol_version($node->text); + + $twig->purge; +} + sub handle_error { my ($twig, $node) = @_; @@ -72,7 +82,14 @@ sub handle_error { my $data; - $data->{what} = $node->kid('what')->text; + my ($what, $xwhat); + if ($twig->protocol_version >= 4) { + $xwhat = $node->first_child('xwhat'); + $what = $xwhat->kid('text')->text if defined $xwhat; + } + $what = $node->kid('what')->text unless defined $what; + $data->{what} = $what; + $data->{stack} = [ map $_->listify_frame, $node->kid('stack')->children('frame') ];