|
1 # |
|
2 # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 # All rights reserved. |
|
4 # This component and the accompanying materials are made available |
|
5 # under the terms of "Eclipse Public License v1.0" |
|
6 # which accompanies this distribution, and is available |
|
7 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 # |
|
9 # Initial Contributors: |
|
10 # Nokia Corporation - initial contribution. |
|
11 # |
|
12 # Contributors: |
|
13 # |
|
14 # Description: |
|
15 # |
|
16 # |
|
17 # Abstract: |
|
18 # Produce an SVG diagram showing process/thread creation and destruction from utracedecoder output file. |
|
19 # |
|
20 # Parses the ulogger textual output from utracedecoder.exe and generates a "seq" file suitable for |
|
21 # input into parseseq.pl. For example: |
|
22 # |
|
23 # perl -S processthreadsummary.pl ulogger.txt > proc.seq |
|
24 # perl -S parseseq.pl proc.seq |
|
25 # <view log.html in SVG browser> |
|
26 # |
|
27 |
|
28 my $creatingProcess = 0; |
|
29 |
|
30 while (<>) { |
|
31 if (!/EThreadIdentification/) { |
|
32 next; |
|
33 } |
|
34 #1,3,7,3203155249,0,0x00000000,EThreadIdentification: Process Create: [DProcess=0x00dc0080] |
|
35 if (/EThreadIdentification:\s*Process Create:\s*\[DProcess=0x(.{8})\]/) { |
|
36 #print "Process Create: DProcess=$1\n"; |
|
37 $creatingProcess = $1; |
|
38 } |
|
39 #2,3,5,3203155347,0,0x00000000,EThreadIdentification: Process Name: [NThread=0x00dc044c] [DProcess=0x00dc0080] [Name=EKern.exe[100041af]0001] |
|
40 elsif (/EThreadIdentification:\s*Process Name:\s*\[NThread=0x(.{8})\] \[DProcess=0x(.{8})\] \[Name=(.*)\]\s*$/) { |
|
41 #print "Process Name: NThread=$1, DProcess=$2, Name=$3\n"; |
|
42 if ($creatingProcess eq $2) { |
|
43 my $name = trimName($3); |
|
44 $name = uniquifyName($name); |
|
45 $processName{$2} = $name; |
|
46 print "oc !", $name, " 0 $2\n"; |
|
47 print "t !", $name, " $name\n"; |
|
48 $creatingProcess = ""; |
|
49 } |
|
50 } |
|
51 #4646,3,2,3236912810,0,0x00000000,EThreadIdentification: Thread Create: [NThread=0x00e26b04] [DProcess=0x00e24108] [Name=Main] |
|
52 elsif (/EThreadIdentification:\s*Thread Create:\s*\[NThread=0x(.{8})\] \[DProcess=0x(.{8})\] \[Name=(.*)\]\s*$/) { |
|
53 #print "Thread Create: NThread=$1, DProcess=$2, Name=$3\n"; |
|
54 print "ac !", $processName{$2}, " $1 $3\n"; |
|
55 print "t !", $processName{$2}, " $3\n"; |
|
56 } |
|
57 #812,3,3,3229029799,0,0x00000000,EThreadIdentification: Thread Destroy: [NThread=0x00dee718] [DProcess=0x00dede4c] |
|
58 elsif (/EThreadIdentification: Thread Destroy: \[NThread=0x(.{8})\] \[DProcess=0x(.{8})\]\s*$/) { |
|
59 #print "Thread Destroy: NThread=$1, DProcess=$2\n"; |
|
60 print "ad $1\n"; |
|
61 } |
|
62 #813,3,8,3229030152,0,0x00000000,EThreadIdentification: Process Destroy: [DProcess=0x00dede4c] |
|
63 elsif (/EThreadIdentification: Process Destroy: \[DProcess=0x(.{8})\]\s*$/) { |
|
64 #print "Process Destroy: DProcess=$1\n"; |
|
65 print "od !", $processName{$1}, " $1\n"; |
|
66 print "t !", $processName{$1}," (destroyed)\n"; |
|
67 } |
|
68 } |
|
69 |
|
70 # |
|
71 # Remove '.exe" extension as well as the UID decoration in the name (e.g. "...[100039e3]0001") |
|
72 # |
|
73 |
|
74 sub trimName($) |
|
75 { |
|
76 my $name = $_[0]; |
|
77 $name =~ s/\[[0-9a-fA-F]{8}\][0-9a-fA-F]{4}\s*$//; |
|
78 $name =~ s/\.exe//; |
|
79 $name =~ s/\.EXE//; |
|
80 return $name; |
|
81 } |
|
82 |
|
83 sub uniquifyName() |
|
84 { |
|
85 my ($name) = @_; |
|
86 my $index = 0; |
|
87 my $proposedName = $name; |
|
88 while (defined $uniqueNames{$proposedName}) |
|
89 { |
|
90 $proposedName = $name . "(" . ++$index . ")"; |
|
91 } |
|
92 |
|
93 $uniqueNames{$proposedName} = 1; |
|
94 return $proposedName; |
|
95 } |