summaryrefslogtreecommitdiff
path: root/cesar/common
diff options
context:
space:
mode:
authorschodet2009-11-23 08:49:13 +0000
committerschodet2009-11-23 08:49:13 +0000
commitbce3d1a401ecf2ed8952b0c56ddfc441973e8e9b (patch)
treead356ae4950ac81a9f6f321620dd9db2261a64d5 /cesar/common
parent04935efb425b47f5b3f3237c08137db85e891f27 (diff)
cesar/common/tools/traceviewer: add CPU usage annotations
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@6445 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/common')
-rw-r--r--cesar/common/tools/traceviewer/annotate/cpu.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/cesar/common/tools/traceviewer/annotate/cpu.py b/cesar/common/tools/traceviewer/annotate/cpu.py
new file mode 100644
index 0000000000..3e64981fd3
--- /dev/null
+++ b/cesar/common/tools/traceviewer/annotate/cpu.py
@@ -0,0 +1,32 @@
+"""Annotate CPU usage trace."""
+import re
+
+def annotate (trace):
+ re_switch = re.compile (r'^switch .*to sp=(.*)')
+ re_enter = re.compile (r'^(isr|dsr|phy)')
+ re_exit = re.compile (r'^(?:isr|dsr|phy) exit')
+ stack = [ ]
+ for t in trace.trace:
+ # Colorize.
+ if t.text.startswith ('switch'):
+ t.view_attr = 'green'
+ elif t.text.startswith ('isr sp='):
+ t.view_attr = 'blue'
+ elif t.text.startswith ('dsr sp='):
+ t.view_attr = 'cyan'
+ elif t.text.startswith ('phy 0'):
+ t.view_attr = 'red'
+ # Handle stack.
+ m_switch = re_switch.search (t.text)
+ if m_switch:
+ stack = [ m_switch.group (1) ]
+ elif re_exit.search (t.text):
+ if stack:
+ stack.pop ()
+ else:
+ m_enter = re_enter.search (t.text)
+ if m_enter:
+ stack.append (m_enter.group (1))
+ if stack:
+ t.view_text = stack[-1]
+