Fix bug 550388: avoid regexp perf issues in the stack fixer. r=dbaron
authorJesse Ruderman <jruderman@gmail.com>
Sat, 20 Mar 2010 23:08:47 -0700
changeset 39679 bf87fe24520350cae1f235a782dedcc436236996
parent 39678 783240d6e4ebd892b6403114fd1039ba33de47cc
child 39680 659d517acd6145526bf583f333ee514d2afdc39b
push id12336
push userjruderman@mozilla.com
push dateSun, 21 Mar 2010 06:09:05 +0000
treeherdermozilla-central@659d517acd61 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs550388
milestone1.9.3a4pre
Fix bug 550388: avoid regexp perf issues in the stack fixer. r=dbaron
tools/rb/fix_macosx_stack.py
--- a/tools/rb/fix_macosx_stack.py
+++ b/tools/rb/fix_macosx_stack.py
@@ -127,25 +127,26 @@ def cxxfilt(sym):
                                                       '--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")
     return cxxfilt_proc.stdout.readline().rstrip("\n")
 
-line_re = re.compile("^([ \|0-9-]*)(.*) ?\[([^ ]*) \+(0x[0-9A-F]{1,8})\](.*)$")
+line_re = re.compile("^(.*) ?\[([^ ]*) \+(0x[0-9A-F]{1,8})\](.*)$")
+balance_tree_re = re.compile("^([ \|0-9-]*)")
 atos_sym_re = re.compile("^(\S+) \(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, badsymbol, file, address, after) = result.groups()
+        (before, file, address, after) = result.groups()
         address = int(address, 16)
 
         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
@@ -153,16 +154,19 @@ def fixSymbols(line):
             #   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)
 
+             # 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
 
 if __name__ == "__main__":