[CalendarServer-changes] [5910] CalendarServer/trunk/contrib/tools/dtraceanalyze.py

source_changes at macosforge.org source_changes at macosforge.org
Fri Jul 16 13:04:20 PDT 2010


Revision: 5910
          http://trac.macosforge.org/projects/calendarserver/changeset/5910
Author:   cdaboo at apple.com
Date:     2010-07-16 13:04:19 -0700 (Fri, 16 Jul 2010)
Log Message:
-----------
Better recovery from skipped function exits in stack display.

Modified Paths:
--------------
    CalendarServer/trunk/contrib/tools/dtraceanalyze.py

Modified: CalendarServer/trunk/contrib/tools/dtraceanalyze.py
===================================================================
--- CalendarServer/trunk/contrib/tools/dtraceanalyze.py	2010-07-16 18:41:00 UTC (rev 5909)
+++ CalendarServer/trunk/contrib/tools/dtraceanalyze.py	2010-07-16 20:04:19 UTC (rev 5910)
@@ -49,6 +49,7 @@
             self.file_location = ""
             self.parent = None
             self.children = []
+            self.lineno = lineno
             
             re_matched = re.match("(..) ([^ ]+) \(([^\)]+)\)", line)
             if re_matched is None:
@@ -78,7 +79,9 @@
                             self.file_location = value
                         break
                     
-        
+        def __repr__(self):
+            return "%s (%s)" % self.getKey()
+
         def getKey(self):
             return (self.file_location, self.function_name,)
 
@@ -97,7 +100,7 @@
             return False
 
         def filePath(self):
-            return self.file_location[0][:self.file_location[0].rfind(":")]
+            return self.file_location[0:self.file_location.rfind(':')]
 
         def prettyPrint(self, indent, indents, sout):
             
@@ -111,6 +114,9 @@
                     indenter += "  "
             sout.write("%s%s (%s)\n" % (indenter, self.function_name, self.file_location,))
 
+        def stackName(self):
+            return self.function_name, self.filePath()
+
     class DtraceStack(object):
         
         def __init__(self, lines, no_collapse):
@@ -138,7 +144,9 @@
             min_indent = 0
             current_line = None
             blocks = [[]]
+            backstack = []
             for line in new_lines:
+                stackName = line.stackName()
                 if line.entering:
                     if line.function_name == "mainLoop":
                         if min_indent < 0:
@@ -149,15 +157,23 @@
                         min_indent = 0
                         indent = 0
                         blocks.append([])
+                        backstack = []
                     else:
                         indent += 1
+                        backstack.append(stackName)
                     blocks[-1].append((indent, line,))
                     if current_line:
                         current_line.addChild(line)
                     current_line = line
                 else:
-                    if len(blocks) == 1 or line.function_name != "mainLoop":
+                    if len(blocks) == 1 or line.function_name != "mainLoop" and indent:
                         indent -= 1
+                        while backstack and indent and stackName != backstack[-1]:
+                            indent -= 1
+                            backstack.pop()
+                        if backstack: backstack.pop()
+                        if indent < 0:
+                            print "help"
                     current_line = current_line.parent if current_line else None
                 min_indent = min(min_indent, indent)
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100716/68f7794c/attachment-0001.html>


More information about the calendarserver-changes mailing list