tools/summarise_kerneltrace.pl
changeset 33 900525f287f9
child 95 aad950cacc2b
equal deleted inserted replaced
32:5d6e2a54a44a 33:900525f287f9
       
     1 # Copyright (c) 2010 Symbian Foundation Ltd.
       
     2 # All rights reserved.
       
     3 # This component and the accompanying materials are made available
       
     4 # under the terms of the License "Eclipse Public License v1.0"
       
     5 # which accompanies this distribution, and is available
       
     6 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 #
       
     8 # Initial Contributors:
       
     9 # Symbian Foundation - initial contribution.
       
    10 #
       
    11 # Contributors:
       
    12 #
       
    13 # Description: 
       
    14 # This script filters kernel trace output to the bare essentials
       
    15 
       
    16 use strict;
       
    17 
       
    18 my %processes;
       
    19 my %threadcount;
       
    20 my %instancecount;
       
    21 my %originalname;
       
    22 my @deathlist;
       
    23 
       
    24 my $line;
       
    25 while ($line = <>)
       
    26 	{
       
    27 	# AddThread ekern.exe::NVMem-ecc10dce to ekern.exe
       
    28 	# Process FLogSvr.exe Die: 0 0 Kill
       
    29 	# DLibrary domainSrv.exe::domainpolicy2.dll Close m=-1
       
    30 	# Thread MTMInit::Via Infrared Via Infrared   Panic MTMInit 5
       
    31 	# DProcess::Rename MSexe.exe to !MsvServer
       
    32 	if ( $line =~ /^(AddThread |Process \S+ Die: |DLibrary |Thread |DProcess::Rename )/o)
       
    33 		{
       
    34 		
       
    35 		if ($line =~ /^DProcess::Rename (\S+) to (\S+)/o)
       
    36 			{
       
    37 			my $oldname = $1;
       
    38 			my $process = $2;
       
    39 		printf "Renaming %s (%d,%d) to %s\n", $oldname, $processes{$oldname}, $threadcount{$oldname}, $process;
       
    40 			$processes{$process} = $processes{$oldname};
       
    41 			$threadcount{$process} = $threadcount{$oldname};
       
    42 			$instancecount{$process} = $instancecount{$oldname};
       
    43 
       
    44 			$originalname{$process} = $oldname;
       
    45 			delete $processes{$oldname};
       
    46 			delete $threadcount{$oldname};
       
    47 			}
       
    48 		if ($line =~ /^AddThread (\S+)::(\S+) to (\S+)$/o)
       
    49 			{
       
    50 			my $process = $1;
       
    51 			my $thread = $2;
       
    52 			
       
    53 			if ($thread eq "Main" || $thread eq "Null")
       
    54 				{
       
    55 				# New process created
       
    56 				$processes{$process} = $.;
       
    57 				$threadcount{$process} = 0;
       
    58 				}
       
    59 			$threadcount{$process} += 1;
       
    60 			if (!defined $instancecount{$process})
       
    61 				{
       
    62 				$instancecount{$process} = 0;
       
    63 				}
       
    64 			$instancecount{$process} += 1;
       
    65 			}
       
    66 		print "$.: $line";
       
    67 
       
    68 		if ($line =~ /^Process (\S+) Die: (.*)$/o)
       
    69 			{
       
    70 			my $process = $1;
       
    71 			my $details = $2;
       
    72 			my $summary = sprintf "#%d, %d threads, lifetime %d-%d",
       
    73 				$instancecount{$process},$threadcount{$process},$processes{$process},$.;
       
    74 			
       
    75 			print "\t$process: $summary\n";
       
    76 			delete $processes{$process};
       
    77 			delete $threadcount{$process};
       
    78 
       
    79 			chomp $line;	
       
    80 			push @deathlist, sprintf "%7d\t%-20s %s, died %s", $., $process, $summary, $details;
       
    81 			}
       
    82 		next;
       
    83 		}
       
    84 
       
    85 	# Initiating transition to state 0000.ffff.
       
    86 	# R:\sf\os\devicesrv\sysstatemgmt\systemstatemgr\cmd\src\ssmcommandbase.cpp 135: Completing command with errorcode 0
       
    87 	# ***** Execute cmd no. 11 without a delay
       
    88 	# Starting : Z:\sys\bin\splashscreen.exe with arguments :  and Execution behaviour : 1
       
    89 	if ( $line =~ /^(Initiating transition |\*\*\*\*\* |Starting : )/o)
       
    90 		{
       
    91 		print "SSM: $line";
       
    92 		next;
       
    93 		}
       
    94 
       
    95 	if ($line =~ /^(MODE_USR:)/o)
       
    96 		{
       
    97 		# it's crashed
       
    98 		print $line, <>;
       
    99 		last;
       
   100 		}
       
   101 	}
       
   102 
       
   103 printf "\n\nActive processes (%d):\n", scalar keys %processes;
       
   104 foreach my $process (sort keys %processes)
       
   105 	{
       
   106 	printf "%-25s\t%d threads, created at line %d\n", $process, $threadcount{$process}, $processes{$process};
       
   107 	}
       
   108 
       
   109 printf "\n\nDead processes (%d)\n", scalar @deathlist;
       
   110 print join("\n", sort @deathlist, "");