Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: tools/traceline/traceline/scripts/crit_sec.py

Issue 20494: Import Traceline, a Windows performance trace event logger. (Closed)
Patch Set: Feedback. Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/traceline/traceline/scripts/crit_sec.js ('k') | tools/traceline/traceline/scripts/heap.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/traceline/traceline/scripts/crit_sec.py
diff --git a/tools/traceline/traceline/scripts/crit_sec.py b/tools/traceline/traceline/scripts/crit_sec.py
new file mode 100755
index 0000000000000000000000000000000000000000..f43f50d3bdae8cee2e47e0ac8018b13954e9294e
--- /dev/null
+++ b/tools/traceline/traceline/scripts/crit_sec.py
@@ -0,0 +1,51 @@
+# Copyright (c) 2009 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import sys
+import os
+
+execfile(os.path.join(
+ os.path.dirname(os.path.join(os.path.curdir, __file__)),
+ 'syscalls.py'))
+
+def parseEvents(z):
+ crits = { }
+ calls = { }
+ for e in z:
+ if (e['eventtype'] == 'EVENT_TYPE_ENTER_CS' or
+ e['eventtype'] == 'EVENT_TYPE_TRYENTER_CS' or
+ e['eventtype'] == 'EVENT_TYPE_LEAVE_CS'):
+ cs = e['critical_section']
+ if not crits.has_key(cs):
+ crits[cs] = [ ]
+ crits[cs].append(e)
+
+# for cs, es in crits.iteritems():
+# print 'cs: 0x%08x' % cs
+# for e in es:
+# print ' 0x%08x - %s - %f' % (e['thread'], e['eventtype'], e['ms'])
+
+ for cs, es in crits.iteritems():
+ print 'cs: 0x%08x' % cs
+
+ tid_stack = [ ]
+ for e in es:
+ if e['eventtype'] == 'EVENT_TYPE_ENTER_CS':
+ tid_stack.append(e)
+ elif e['eventtype'] == 'EVENT_TYPE_TRYENTER_CS':
+ if e['retval'] != 0:
+ tid_stack.append(e)
+ elif e['eventtype'] == 'EVENT_TYPE_LEAVE_CS':
+ if not tid_stack:
+ raise repr(e)
+ tid = tid_stack.pop()
+ if tid['thread'] != e['thread']:
+ raise repr(tid) + '--' + repr(e)
+
+ # Critical section left locked?
+ if tid_stack:
+ #raise repr(tid_stack)
+ pass
+
+execfile(sys.argv[1])
« no previous file with comments | « tools/traceline/traceline/scripts/crit_sec.js ('k') | tools/traceline/traceline/scripts/heap.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698