Bug 539516 - Switch automation.py to use the new python stack fixer. r=ted
authorJesse Ruderman <jruderman@gmail.com>
Sun, 21 Feb 2010 13:03:20 -0800
changeset 38373 bf75623a6e2d331e7ea213b60cdb5c7655fb3e7d
parent 38372 71c777934f25218f682c4b2c65427a982cc5f6b3
child 38374 1b7c9f8d88d268cd487ad974e386a1cfff1dee5f
push id11718
push userjruderman@mozilla.com
push dateSun, 21 Feb 2010 21:04:25 +0000
treeherdermozilla-central@bf75623a6e2d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs539516
milestone1.9.3a2pre
Bug 539516 - Switch automation.py to use the new python stack fixer. r=ted
build/Makefile.in
build/automation.py.in
testing/mochitest/Makefile.in
tools/rb/fix-macosx-stack.py
tools/rb/fix_macosx_stack.py
--- a/build/Makefile.in
+++ b/build/Makefile.in
@@ -96,16 +96,18 @@ libs:: bloaturls.txt
 # of bloaturls.txt.  This is for browsers that can't do -f
 # autocycling of URLs.
 libs:: bloatcycle.html
 	$(INSTALL) $< $(DIST)/bin/res
 
 ifeq ($(OS_ARCH),Darwin)
 libs:: $(topsrcdir)/tools/rb/fix-macosx-stack.pl
 	$(INSTALL) $< $(DIST)/bin
+libs:: $(topsrcdir)/tools/rb/fix_macosx_stack.py
+	$(INSTALL) $< $(DIST)/bin
 
 # Basic unit tests for some stuff in the unify script
 check::
 # build ppc/i386 binaries, and unify them
 	rm -f unify-test-ppc unify-test-i386 unify-test-universal
 	$(HOST_CC) -arch ppc $(srcdir)/unify-test.c -o unify-test-ppc
 	$(HOST_CC) -arch i386 $(srcdir)/unify-test.c -o unify-test-i386
 	@if ! $(srcdir)/macosx/universal/unify ./unify-test-ppc ./unify-test-i386 \
--- a/build/automation.py.in
+++ b/build/automation.py.in
@@ -575,36 +575,40 @@ user_pref("camino.use_system_proxy_setti
           return
     #TODO: kill the process such that it triggers Breakpad on OS X (bug 525296)
     self.log.info("Can't trigger Breakpad, just killing process")
     proc.kill()
 
   def waitForFinish(self, proc, utilityPath, timeout, maxTime, startTime):
     """ Look for timeout or crashes and return the status after the process terminates """
     stackFixerProcess = None
+    stackFixerModule = None
     didTimeout = False
     if proc.stdout is None:
       self.log.info("TEST-INFO: Not logging stdout or stderr due to debugger connection")
     else:
       logsource = proc.stdout
-      if self.IS_DEBUG_BUILD:
-        stackFixerCommand = None
-        if self.IS_MAC:
-          stackFixerCommand = "fix-macosx-stack.pl"
-        elif self.IS_LINUX:
-          stackFixerCommand = "fix-linux-stack.pl"
-        if stackFixerCommand is not None:
-          stackFixerProcess = self.Process([self.PERL, os.path.join(utilityPath, stackFixerCommand)], 
-                                           stdin=logsource, 
-                                           stdout=subprocess.PIPE)
-          logsource = stackFixerProcess.stdout
+      if self.IS_DEBUG_BUILD and self.IS_LINUX:
+        # Run logsource through fix-linux-stack.pl
+        stackFixerProcess = self.Process([self.PERL, os.path.join(utilityPath, "fix-linux-stack.pl")],
+                                         stdin=logsource,
+                                         stdout=subprocess.PIPE)
+        logsource = stackFixerProcess.stdout
+
+      if self.IS_DEBUG_BUILD and self.IS_MAC:
+        # Import fix_macosx_stack.py from utilityPath
+        sys.path.insert(0, utilityPath)
+        import fix_macosx_stack as stackFixerModule
+        del sys.path[0]
 
       (line, didTimeout) = self.readWithTimeout(logsource, timeout)
       hitMaxTime = False
       while line != "" and not didTimeout:
+        if stackFixerModule:
+          line = stackFixerModule.fixSymbols(line)
         self.log.info(line.rstrip())
         (line, didTimeout) = self.readWithTimeout(logsource, timeout)
         if not hitMaxTime and maxTime and datetime.now() - startTime > timedelta(seconds = maxTime):
           # Kill the application, but continue reading from stack fixer so as not to deadlock on stackFixerProcess.wait().
           hitMaxTime = True
           self.log.info("TEST-UNEXPECTED-FAIL | automation.py | application ran for longer than allowed maximum time of %d seconds", int(maxTime))
           self.triggerBreakpad(proc, utilityPath)
       if didTimeout:
--- a/testing/mochitest/Makefile.in
+++ b/testing/mochitest/Makefile.in
@@ -101,17 +101,17 @@ TEST_HARNESS_BINS := \
 ifeq ($(OS_ARCH),WINNT)
 TEST_HARNESS_BINS += \
   crashinject$(BIN_SUFFIX) \
   crashinjectdll$(DLL_SUFFIX) \
   $(NULL)
 endif
 
 ifeq ($(OS_ARCH),Darwin)
-TEST_HARNESS_BINS += fix-macosx-stack.pl
+TEST_HARNESS_BINS += fix_macosx_stack.py
 endif
 
 ifeq ($(OS_ARCH),Linux)
 TEST_HARNESS_BINS += fix-linux-stack.pl
 endif
 
 # Components / typelibs that don't get packaged with
 # the build, but that we need for the test harness.
rename from tools/rb/fix-macosx-stack.py
rename to tools/rb/fix_macosx_stack.py
--- a/tools/rb/fix-macosx-stack.py
+++ b/tools/rb/fix_macosx_stack.py
@@ -129,17 +129,18 @@ def cxxfilt(sym):
                                                      stdout=subprocess.PIPE)
     # strip underscores ourselves (works better than c++filt's
     # --strip-underscores)
     cxxfilt_proc.stdin.write(sym[1:] + "\n")
     return cxxfilt_proc.stdout.readline().rstrip("\n")
 
 line_re = re.compile("^([ \|0-9-]*)(.*) ?\[([^ ]*) \+(0x[0-9A-F]{1,8})\](.*)$")
 atos_sym_re = re.compile("^(\S+) \(in ([^)]+)\) \((.+)\)$")
-for line in sys.stdin:
+
+def fixSymbols(line):
     result = line_re.match(line)
     if result is not None:
         # before allows preservation of balance trees
         # after allows preservation of counts
         (before, badsymbol, file, address, after) = result.groups()
         address = int(address, 16)
 
         if os.path.exists(file) and os.path.isfile(file):
@@ -152,14 +153,18 @@ for line in sys.stdin:
             #   symbol (in foo.dylib) (file:line)
             symresult = atos_sym_re.match(info)
             if symresult is not None:
                 # Print the first two forms as-is, and transform the third
                 (symbol, library, fileline) = symresult.groups()
                 symbol = cxxfilt(symbol)
                 info = "%s (%s, in %s)" % (symbol, fileline, library)
 
-            sys.stdout.write(before + info + after + "\n")
+            return before + info + after + "\n"
         else:
             sys.stderr.write("Warning: File \"" + file + "\" does not exist.\n")
-            sys.stdout.write(line)
+            return line
     else:
-        sys.stdout.write(line)
+        return line
+
+if __name__ == "__main__":
+    for line in sys.stdin:
+        sys.stdout.write(fixSymbols(line))