| 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 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 # TODO(glider): need some refactoring here | 25 # TODO(glider): need some refactoring here |
| 26 def symbolize_addr2line(line): | 26 def symbolize_addr2line(line): |
| 27 #0 0x7f6e35cf2e45 (/blah/foo.so+0x11fe45) | 27 #0 0x7f6e35cf2e45 (/blah/foo.so+0x11fe45) |
| 28 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) |
| 29 if match: | 29 if match: |
| 30 frameno = match.group(2) | 30 frameno = match.group(2) |
| 31 binary = match.group(3) | 31 binary = match.group(3) |
| 32 addr = match.group(4) | 32 addr = match.group(4) |
| 33 if not pipes.has_key(binary): | 33 if not pipes.has_key(binary): |
| 34 pipes[binary] = subprocess.Popen(["addr2line", "-f", "-e", binary], | 34 pipes[binary] = subprocess.Popen(["addr2line", "-f", "-e", binary], |
| 35 stdin=subprocess.PIPE, stdout=subprocess.PIPE) | 35 stdin=subprocess.PIPE, stdout=subprocess.PIPE, |
| 36 stderr=open(os.devnull, 'w')) |
| 36 p = pipes[binary] | 37 p = pipes[binary] |
| 37 try: | 38 try: |
| 38 print >>p.stdin, addr | 39 print >>p.stdin, addr |
| 39 function_name = p.stdout.readline().rstrip() | 40 function_name = p.stdout.readline().rstrip() |
| 40 file_name = p.stdout.readline().rstrip() | 41 file_name = p.stdout.readline().rstrip() |
| 41 except: | 42 except: |
| 42 function_name = "" | 43 function_name = "" |
| 43 file_name = "" | 44 file_name = "" |
| 44 file_name = fix_filename(file_name) | 45 file_name = fix_filename(file_name) |
| 45 | 46 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 for line in sys.stdin: | 151 for line in sys.stdin: |
| 151 if system == 'Linux': | 152 if system == 'Linux': |
| 152 symbolize_addr2line(line) | 153 symbolize_addr2line(line) |
| 153 elif system == 'Darwin': | 154 elif system == 'Darwin': |
| 154 symbolize_atos(line) | 155 symbolize_atos(line) |
| 155 else: | 156 else: |
| 156 print 'Unknown system: ', system | 157 print 'Unknown system: ', system |
| 157 | 158 |
| 158 if __name__ == '__main__': | 159 if __name__ == '__main__': |
| 159 main() | 160 main() |
| OLD | NEW |