From 776993d4ffb76c8eb2b25c352ad4c7d86daba029 Mon Sep 17 00:00:00 2001 From: Jesse Ruderman Date: Sun, 21 Feb 2010 13:03:20 -0800 Subject: [PATCH] Bug 539516 - Switch automation.py to use the new python stack fixer. r=ted --HG-- rename : tools/rb/fix-macosx-stack.py => tools/rb/fix_macosx_stack.py --- build/Makefile.in | 2 ++ build/automation.py.in | 26 +++++++++++-------- testing/mochitest/Makefile.in | 2 +- ...ix-macosx-stack.py => fix_macosx_stack.py} | 13 +++++++--- 4 files changed, 27 insertions(+), 16 deletions(-) rename tools/rb/{fix-macosx-stack.py => fix_macosx_stack.py} (96%) diff --git a/build/Makefile.in b/build/Makefile.in index 7242cf1a7aa..b9ca29c1906 100644 --- a/build/Makefile.in +++ b/build/Makefile.in @@ -101,6 +101,8 @@ libs:: bloatcycle.html 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:: diff --git a/build/automation.py.in b/build/automation.py.in index 7796837a4cb..08648b5d838 100644 --- a/build/automation.py.in +++ b/build/automation.py.in @@ -580,26 +580,30 @@ user_pref("camino.use_system_proxy_settings", false); // Camino-only, harmless t 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): diff --git a/testing/mochitest/Makefile.in b/testing/mochitest/Makefile.in index c87bd2d8640..11b660a4e17 100644 --- a/testing/mochitest/Makefile.in +++ b/testing/mochitest/Makefile.in @@ -106,7 +106,7 @@ TEST_HARNESS_BINS += \ endif ifeq ($(OS_ARCH),Darwin) -TEST_HARNESS_BINS += fix-macosx-stack.pl +TEST_HARNESS_BINS += fix_macosx_stack.py endif ifeq ($(OS_ARCH),Linux) diff --git a/tools/rb/fix-macosx-stack.py b/tools/rb/fix_macosx_stack.py similarity index 96% rename from tools/rb/fix-macosx-stack.py rename to tools/rb/fix_macosx_stack.py index 0e63d920721..b228342c62a 100755 --- a/tools/rb/fix-macosx-stack.py +++ b/tools/rb/fix_macosx_stack.py @@ -134,7 +134,8 @@ def cxxfilt(sym): 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 @@ -157,9 +158,13 @@ for line in sys.stdin: 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))