OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 #===- lib/asan/scripts/asan_symbolize.py -----------------------------------===# | 2 #===- lib/asan/scripts/asan_symbolize.py -----------------------------------===# |
3 # | 3 # |
4 # The LLVM Compiler Infrastructure | 4 # The LLVM Compiler Infrastructure |
5 # | 5 # |
6 # This file is distributed under the University of Illinois Open Source | 6 # This file is distributed under the University of Illinois Open Source |
7 # License. See LICENSE.TXT for details. | 7 # License. See LICENSE.TXT for details. |
8 # | 8 # |
9 #===------------------------------------------------------------------------===# | 9 #===------------------------------------------------------------------------===# |
10 import argparse | 10 import argparse |
11 import bisect | 11 import bisect |
12 import getopt | 12 import getopt |
13 import os | 13 import os |
14 import re | 14 import re |
15 import subprocess | 15 import subprocess |
16 import sys | 16 import sys |
17 | 17 |
18 symbolizers = {} | 18 symbolizers = {} |
19 DEBUG = False | 19 DEBUG = False |
20 demangle = False | 20 demangle = False |
21 binutils_prefix = None | 21 binutils_prefix = None |
22 sysroot_path = None | 22 sysroot_path = None |
23 binary_name_filter = None | 23 binary_name_filter = None |
24 fix_filename_patterns = None | 24 fix_filename_patterns = None |
25 logfile = sys.stdin | 25 logfile = sys.stdin |
26 allow_system_symbolizer = True | |
27 | 26 |
28 # FIXME: merge the code that calls fix_filename(). | 27 # FIXME: merge the code that calls fix_filename(). |
29 def fix_filename(file_name): | 28 def fix_filename(file_name): |
30 if fix_filename_patterns: | 29 if fix_filename_patterns: |
31 for path_to_cut in fix_filename_patterns: | 30 for path_to_cut in fix_filename_patterns: |
32 file_name = re.sub('.*' + path_to_cut, '', file_name) | 31 file_name = re.sub('.*' + path_to_cut, '', file_name) |
33 file_name = re.sub('.*asan_[a-z_]*.cc:[0-9]*', '_asan_rtl_', file_name) | 32 file_name = re.sub('.*asan_[a-z_]*.cc:[0-9]*', '_asan_rtl_', file_name) |
34 file_name = re.sub('.*crtstuff.c:0', '???:0', file_name) | 33 file_name = re.sub('.*crtstuff.c:0', '???:0', file_name) |
35 return file_name | 34 return file_name |
36 | 35 |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 self.system, guess_arch(addr), self.dsym_hints) | 385 self.system, guess_arch(addr), self.dsym_hints) |
387 self.llvm_symbolizers[binary] = self.last_llvm_symbolizer | 386 self.llvm_symbolizers[binary] = self.last_llvm_symbolizer |
388 # Use the chain of symbolizers: | 387 # Use the chain of symbolizers: |
389 # Breakpad symbolizer -> LLVM symbolizer -> addr2line/atos | 388 # Breakpad symbolizer -> LLVM symbolizer -> addr2line/atos |
390 # (fall back to next symbolizer if the previous one fails). | 389 # (fall back to next symbolizer if the previous one fails). |
391 if not binary in symbolizers: | 390 if not binary in symbolizers: |
392 symbolizers[binary] = ChainSymbolizer( | 391 symbolizers[binary] = ChainSymbolizer( |
393 [BreakpadSymbolizerFactory(binary), self.llvm_symbolizers[binary]]) | 392 [BreakpadSymbolizerFactory(binary), self.llvm_symbolizers[binary]]) |
394 result = symbolizers[binary].symbolize(addr, binary, offset) | 393 result = symbolizers[binary].symbolize(addr, binary, offset) |
395 if result is None: | 394 if result is None: |
396 if not allow_system_symbolizer: | |
397 raise Exception('Failed to launch or use llvm-symbolizer.') | |
398 # Initialize system symbolizer only if other symbolizers failed. | 395 # Initialize system symbolizer only if other symbolizers failed. |
399 symbolizers[binary].append_symbolizer( | 396 symbolizers[binary].append_symbolizer( |
400 SystemSymbolizerFactory(self.system, addr, binary)) | 397 SystemSymbolizerFactory(self.system, addr, binary)) |
401 result = symbolizers[binary].symbolize(addr, binary, offset) | 398 result = symbolizers[binary].symbolize(addr, binary, offset) |
402 # The system symbolizer must produce some result. | 399 # The system symbolizer must produce some result. |
403 assert result | 400 assert result |
404 return result | 401 return result |
405 | 402 |
406 def get_symbolized_lines(self, symbolized_lines): | 403 def get_symbolized_lines(self, symbolized_lines): |
407 if not symbolized_lines: | 404 if not symbolized_lines: |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 binary_name_filter = sysroot_path_filter | 470 binary_name_filter = sysroot_path_filter |
474 sysroot_path = args.s | 471 sysroot_path = args.s |
475 if args.c: | 472 if args.c: |
476 binutils_prefix = args.c | 473 binutils_prefix = args.c |
477 if args.logfile: | 474 if args.logfile: |
478 logfile = args.logfile | 475 logfile = args.logfile |
479 else: | 476 else: |
480 logfile = sys.stdin | 477 logfile = sys.stdin |
481 loop = SymbolizationLoop(binary_name_filter) | 478 loop = SymbolizationLoop(binary_name_filter) |
482 loop.process_logfile() | 479 loop.process_logfile() |
OLD | NEW |