This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update Time-Piece to CPAN version 1.31
[perl5.git] / Porting / valgrindpp.pl
old mode 100644 (file)
new mode 100755 (executable)
index 1e7c1f8..79285cb
@@ -58,7 +58,7 @@ if (exists $opt{'output-file'}) {
 # %error = (
 #   error_name => {
 #                   stack_frame => {
-#                                    test_script => occurences
+#                                    test_script => occurrences
 #                                  }
 #                 }
 # );
@@ -66,7 +66,7 @@ if (exists $opt{'output-file'}) {
 # %leak = (
 #   leak_type => {
 #                  stack_frames => {
-#                                    test_script => occurences
+#                                    test_script => occurrences
 #                                  }
 #                } # stack frames are separated by '<'s
 # );
@@ -196,8 +196,16 @@ sub filter {
   debug(1, "processing $test ($_)\n");
 
   # Get all the valgrind output lines
-  my @l = map { chomp; s/^==\d+==\s?//; $_ }
-          do { my $fh = new IO::File $_ or die "$0: cannot open $_ ($!)\n"; <$fh> };
+  my @l = do {
+    my $fh = new IO::File $_ or die "$0: cannot open $_ ($!)\n";
+    # Process outputs can interrupt each other, so sort by pid first
+    my %pid; local $_;
+    while (<$fh>) {
+      chomp;
+      s/^==(\d+)==\s?// and push @{$pid{$1}}, $_;
+    }
+    map @$_, values %pid;
+  };
 
   # Setup some useful regexes
   my $hexaddr  = '0x[[:xdigit:]]+';