Bug 819833 (part 3) - Fix fix_macosx_stack.py.
authorNicholas Nethercote <nnethercote@mozilla.com>
Mon, 10 Dec 2012 21:24:55 -0800
changeset 125557 2b374ff0f529
parent 125556 e2e42afb0b86
child 125558 18e8cb967f00
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs819833
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 819833 (part 3) - Fix fix_macosx_stack.py.
tools/rb/fix_macosx_stack.py
--- a/tools/rb/fix_macosx_stack.py
+++ b/tools/rb/fix_macosx_stack.py
@@ -85,29 +85,28 @@ def addressToSymbol(file, address):
         atoses[file] = converter
     else:
         converter = atoses[file]
     return converter.convert("0x%X" % address)
 
 cxxfilt_proc = None
 def cxxfilt(sym):
     if cxxfilt_proc is None:
+        # --no-strip-underscores because atos already stripped the underscore
         globals()["cxxfilt_proc"] = subprocess.Popen(['c++filt',
                                                       '--no-strip-underscores',
                                                       '--format', 'gnu-v3'],
                                                      stdin=subprocess.PIPE,
                                                      stdout=subprocess.PIPE)
-    # strip underscores ourselves (works better than c++filt's
-    # --strip-underscores)
-    cxxfilt_proc.stdin.write(sym[1:] + "\n")
+    cxxfilt_proc.stdin.write(sym + "\n")
     return cxxfilt_proc.stdout.readline().rstrip("\n")
 
 line_re = re.compile("^(.*) ?\[([^ ]*) \+(0x[0-9A-F]{1,8})\](.*)$")
 balance_tree_re = re.compile("^([ \|0-9-]*)")
-atos_sym_re = re.compile("^(\S+) \(in ([^)]+)\) \((.+)\)$")
+atos_name_re = re.compile("^(.+) \(in ([^)]+)\) \((.+)\)$")
 
 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, file, address, after) = result.groups()
         address = int(address, 16)
@@ -115,24 +114,27 @@ def fixSymbols(line):
         if os.path.exists(file) and os.path.isfile(file):
             address += address_adjustment(file)
             info = addressToSymbol(file, address)
 
             # atos output seems to have three forms:
             #   address
             #   address (in foo.dylib)
             #   symbol (in foo.dylib) (file:line)
-            symresult = atos_sym_re.match(info)
-            if symresult is not None:
+            name_result = atos_name_re.match(info)
+            if name_result 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)
+                (name, library, fileline) = name_result.groups()
+                # atos demangles, but occasionally it fails.  cxxfilt can mop
+                # up the remaining cases(!), which will begin with '_Z'.
+                if (name.startswith("_Z")):
+                    name = cxxfilt(name)
+                info = "%s (%s, in %s)" % (name, fileline, library)
 
-             # throw away the bad symbol, but keep balance tree structure
+            # throw away the bad symbol, but keep balance tree structure
             before = balance_tree_re.match(before).groups()[0]
 
             return before + info + after + "\n"
         else:
             sys.stderr.write("Warning: File \"" + file + "\" does not exist.\n")
             return line
     else:
         return line