| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 | 2 |
| 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 import os | 7 import os |
| 8 import re | 8 import re |
| 9 import sys | 9 import sys |
| 10 import string | 10 import string |
| 11 import subprocess | 11 import subprocess |
| 12 | 12 |
| 13 pipes = {} | 13 pipes = {} |
| 14 filetypes = {} |
| 14 vmaddrs = {} | 15 vmaddrs = {} |
| 16 DEBUG=False |
| 17 |
| 18 def fix_filename(file_name): |
| 19 for path_to_cut in sys.argv[1:]: |
| 20 file_name = re.sub(".*" + path_to_cut, "", file_name) |
| 21 file_name = re.sub(".*asan_[a-z_]*.cc:[0-9]*", "_asan_rtl_", file_name) |
| 22 file_name = re.sub(".*crtstuff.c:0", "???:0", file_name) |
| 23 return file_name |
| 15 | 24 |
| 16 # TODO(glider): need some refactoring here | 25 # TODO(glider): need some refactoring here |
| 17 def symbolize_addr2line(line): | 26 def symbolize_addr2line(line): |
| 18 #0 0x7f6e35cf2e45 (/blah/foo.so+0x11fe45) | 27 #0 0x7f6e35cf2e45 (/blah/foo.so+0x11fe45) |
| 19 match = re.match('^( *#[0-9]+ *0x[0-9a-f]+) *\((.*)\+(0x[0-9a-f]+)\)', line) | 28 match = re.match('^( *#([0-9]+) *0x[0-9a-f]+) *\((.*)\+(0x[0-9a-f]+)\)', line) |
| 20 if match: | 29 if match: |
| 21 binary = match.group(2) | 30 frameno = match.group(2) |
| 22 addr = match.group(3) | 31 binary = match.group(3) |
| 32 addr = match.group(4) |
| 23 if not pipes.has_key(binary): | 33 if not pipes.has_key(binary): |
| 24 pipes[binary] = subprocess.Popen(["addr2line", "-f", "-e", binary], | 34 pipes[binary] = subprocess.Popen(["addr2line", "-f", "-e", binary], |
| 25 stdin=subprocess.PIPE, stdout=subprocess.PIPE) | 35 stdin=subprocess.PIPE, stdout=subprocess.PIPE) |
| 26 p = pipes[binary] | 36 p = pipes[binary] |
| 27 try: | 37 try: |
| 28 print >>p.stdin, addr | 38 print >>p.stdin, addr |
| 29 function_name = p.stdout.readline().rstrip() | 39 function_name = p.stdout.readline().rstrip() |
| 30 file_name = p.stdout.readline().rstrip() | 40 file_name = p.stdout.readline().rstrip() |
| 31 except: | 41 except: |
| 32 function_name = "" | 42 function_name = "" |
| 33 file_name = "" | 43 file_name = "" |
| 34 for path_to_cut in sys.argv[1:]: | 44 file_name = fix_filename(file_name) |
| 35 file_name = re.sub(".*" + path_to_cut, "", file_name) | |
| 36 file_name = re.sub(".*asan_rtl.cc:[0-9]*", "_asan_rtl_", file_name) | |
| 37 file_name = re.sub(".*crtstuff.c:0", "???:0", file_name) | |
| 38 | 45 |
| 39 print match.group(1), "in", function_name, file_name | 46 print match.group(1), "in", function_name, file_name |
| 40 else: | 47 else: |
| 41 print line.rstrip() | 48 print line.rstrip() |
| 42 | 49 |
| 43 def fix_binary_for_chromium(binary): | 50 def fix_binary_for_chromium(binary): |
| 44 BUILDTYPE = 'Release' | 51 BUILDTYPE = 'Release' |
| 45 # Chromium Helper EH is the same binary as Chromium Helper, but there's no | 52 # Chromium Helper EH is the same binary as Chromium Helper, but there's no |
| 46 # .dSYM directory for it. | 53 # .dSYM directory for it. |
| 47 binary = binary.replace('Chromium Helper EH', 'Chromium Helper') | 54 binary = binary.replace('Chromium Helper EH', 'Chromium Helper') |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 for line in sys.stdin: | 150 for line in sys.stdin: |
| 144 if system == 'Linux': | 151 if system == 'Linux': |
| 145 symbolize_addr2line(line) | 152 symbolize_addr2line(line) |
| 146 elif system == 'Darwin': | 153 elif system == 'Darwin': |
| 147 symbolize_atos(line) | 154 symbolize_atos(line) |
| 148 else: | 155 else: |
| 149 print 'Unknown system: ', system | 156 print 'Unknown system: ', system |
| 150 | 157 |
| 151 if __name__ == '__main__': | 158 if __name__ == '__main__': |
| 152 main() | 159 main() |
| OLD | NEW |