-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathipc-viewer.py
59 lines (37 loc) · 1.27 KB
/
ipc-viewer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# This file analyzes the output of running with MOZ_IPC_MESSAGE_LOG=1
import sys
import re
msgPatt = re.compile('^\[time:(\d+)\]\[(\d+)(->|<-)(\d+)\]\[([^\]]+)\] (Sending|Received)((?: reply)?) ([^\(]+)\(\[TODO\]\)$')
#[time:1441041587246153][9641->9647][PPluginScriptableObjectParent] Sending reply Reply_NPN_Evaluate([TODO])
matchCount = 0
notMatchCount = 0
msgCounts = {}
for l in sys.stdin:
mm = msgPatt.match(l)
if not mm:
notMatchCount += 1
continue
timeStamp = mm.group(1)
pid1 = mm.group(2)
arrow = mm.group(3)
pid2 = mm.group(4)
actor = mm.group(5)
sendRecv = mm.group(6)
sendRecvExtra = not not mm.group(7)
msg = mm.group(8)
p = (actor, msg)
msgCounts[p] = msgCounts.setdefault(p, 0) + 1
#print timeStamp, pid1, arrow, pid2, actor, sendRecv, sendRecvExtra, msg
matchCount += 1
# Resort the data a bit.
counts = []
for p, count in msgCounts.iteritems():
counts.append((count, p))
counts.sort()
counts.reverse()
for (count, (actor, msg)) in counts:
print count, actor, msg