Fix: Babelstats fail to parse output with no process name or pid
authorChristian Babeux <christian.babeux@efficios.com>
Fri, 12 Jul 2013 20:39:02 +0000 (16:39 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Fri, 12 Jul 2013 20:39:53 +0000 (16:39 -0400)
The process name and pid are optionnal components in the babeltrace
text output.

Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
tests/utils/babelstats.pl

index d8d4dd08e04cafb92276549b9b279713858b61f9..64a243fc8a69f8b1428d8bf7c5a2231cc8756afd 100755 (executable)
@@ -146,6 +146,7 @@ while (<>)
        my $elapsed     = '\((.*)\)';
        my $hostname    = '.*';
        my $pname       = '.*';
        my $elapsed     = '\((.*)\)';
        my $hostname    = '.*';
        my $pname       = '.*';
+       my $pinfo       = '.*';
        my $pid         = '\d+';
        my $tp_provider = '.*';
        my $tp_name     = '.*';
        my $pid         = '\d+';
        my $tp_provider = '.*';
        my $tp_name     = '.*';
@@ -153,18 +154,21 @@ while (<>)
        my $fields      = '{(.*)}';
 
        # Parse babeltrace text output format
        my $fields      = '{(.*)}';
 
        # Parse babeltrace text output format
-       if (/$timestamp\s$elapsed\s($hostname):($pname):($pid)\s($tp_provider):($tp_name):\s$cpu_info,\s$fields/) {
+       if (/$timestamp\s$elapsed\s($pinfo)\s($tp_provider):($tp_name):\s$cpu_info,\s$fields/) {
                my %event_hash;
                my %event_hash;
-
                $event_hash{'timestamp'}   = $1;
                $event_hash{'elapsed'}     = $2;
                $event_hash{'timestamp'}   = $1;
                $event_hash{'elapsed'}     = $2;
-               $event_hash{'hostname'}    = $3;
-               $event_hash{'pname'}       = $4;
-               $event_hash{'pid'}         = $5;
-               $event_hash{'tp_provider'} = $6;
-               $event_hash{'tp_name'}     = $7;
-               $event_hash{'cpu_id'}      = $8;
-               $event_hash{'fields'}      = parse_fields($9);
+               $event_hash{'pinfo'}       = $3;
+
+#              my @split_pinfo = split(':', $3);
+#              $event_hash{'hostname'}    = $split_pinfo[0];
+#              $event_hash{'pname'}       = defined($split_pinfo[1]) ? $split_pinfo[1] : undef;
+#              $event_hash{'pid'}         = defined($split_pinfo[2]) ? $split_pinfo[2] : undef;
+
+               $event_hash{'tp_provider'} = $4;
+               $event_hash{'tp_name'}     = $5;
+               $event_hash{'cpu_id'}      = $6;
+               $event_hash{'fields'}      = parse_fields($7);
 
                push @events, \%event_hash;
        }
 
                push @events, \%event_hash;
        }
This page took 0.02869 seconds and 5 git commands to generate.