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 from third_party import asan_symbolize | 7 from third_party import asan_symbolize |
8 | 8 |
9 import os | 9 import os |
10 import sys | 10 import sys |
(...skipping 27 matching lines...) Expand all Loading... |
38 script_dir = os.path.dirname(os.path.abspath(__file__)) | 38 script_dir = os.path.dirname(os.path.abspath(__file__)) |
39 # Assume this script resides three levels below src/ (i.e. | 39 # Assume this script resides three levels below src/ (i.e. |
40 # src/tools/valgrind/asan/). | 40 # src/tools/valgrind/asan/). |
41 src_root = os.path.join(script_dir, "..", "..", "..") | 41 src_root = os.path.join(script_dir, "..", "..", "..") |
42 symbolizer_path = os.path.join(src_root, 'third_party', | 42 symbolizer_path = os.path.join(src_root, 'third_party', |
43 'llvm-build', 'Release+Asserts', 'bin', 'llvm-symbolizer') | 43 'llvm-build', 'Release+Asserts', 'bin', 'llvm-symbolizer') |
44 assert(os.path.isfile(symbolizer_path)) | 44 assert(os.path.isfile(symbolizer_path)) |
45 os.environ['LLVM_SYMBOLIZER_PATH'] = os.path.abspath(symbolizer_path) | 45 os.environ['LLVM_SYMBOLIZER_PATH'] = os.path.abspath(symbolizer_path) |
46 | 46 |
47 | 47 |
| 48 def split_path(path): |
| 49 parts = [] |
| 50 while True: |
| 51 path, tail = os.path.split(path) |
| 52 if tail: |
| 53 parts.insert(0, tail) |
| 54 else: |
| 55 parts.insert(0, path) |
| 56 break |
| 57 return parts |
| 58 |
| 59 def chrome_dsym_hints(binary): |
| 60 parts = split_path(binary) |
| 61 app_pos = -1 |
| 62 framework_pos = -1 |
| 63 for index in range(len(parts)): |
| 64 part = parts[index] |
| 65 if app_pos == -1 and part.endswith('.app'): |
| 66 app_pos = index |
| 67 if framework_pos == -1 and part.endswith('.framework'): |
| 68 framework_pos = index |
| 69 if framework_pos < 0: |
| 70 if app_pos < 0: |
| 71 return [] |
| 72 else: |
| 73 parts = parts[:app_pos + 1] |
| 74 else: |
| 75 if app_pos > 0: |
| 76 assert(app_pos < framework_pos) |
| 77 parts[app_pos] = parts[framework_pos] |
| 78 parts = parts[:app_pos + 1] |
| 79 else: |
| 80 parts = parts[:framework_pos + 1] |
| 81 result = '%s.dSYM' % reduce(os.path.join, parts) |
| 82 return [result] |
| 83 |
| 84 |
48 def main(): | 85 def main(): |
49 disable_buffering() | 86 disable_buffering() |
50 set_symbolizer_path() | 87 set_symbolizer_path() |
51 asan_symbolize.demangle = True | 88 asan_symbolize.demangle = True |
52 asan_symbolize.fix_filename_patterns = sys.argv[1:] | 89 asan_symbolize.fix_filename_patterns = sys.argv[1:] |
53 asan_symbolize.logfile = sys.stdin | 90 asan_symbolize.logfile = sys.stdin |
54 loop = asan_symbolize.SymbolizationLoop() | 91 loop = asan_symbolize.SymbolizationLoop(dsym_hint_producer=chrome_dsym_hints) |
55 loop.process_logfile() | 92 loop.process_logfile() |
56 | 93 |
57 if __name__ == '__main__': | 94 if __name__ == '__main__': |
58 main() | 95 main() |
OLD | NEW |