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 26 matching lines...) Expand all Loading... | |
37 if not os.environ.get('LLVM_SYMBOLIZER_PATH'): | 37 if not os.environ.get('LLVM_SYMBOLIZER_PATH'): |
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 # Construct a path to the .dSYM bundle for the given binary. | |
48 # There are three possible cases for binary location in Chromium: | |
49 # 1. The binary is a standalone executable in the product dir, the debug info | |
50 # is in "binary.dSYM" in the product dir. | |
51 # 2. The binary is a standalone framework or .app bundle, the debug info is in | |
52 # "Framework.framework.dSYM" or "App.app.dSYM" in the product dir. | |
53 # 3. The binary is a framework or an .app bundle within another .app bundle | |
54 # (e.g. Outer.app/Contents/Versions/1.2.3.4/Inner.app), and the debug info | |
55 # is in Inner.app.dSYM in the product dir. | |
56 # The first case is handled by llvm-symbolizer, so we only need to construct | |
57 # .dSYM paths for .app bundles and frameworks. | |
58 def chrome_dsym_hints(binary): | |
59 parts = binary.split(os.path.sep) | |
earthdok
2014/12/16 14:19:57
I'd prefer a more descriptive name.
Alexander Potapenko
2014/12/16 14:49:13
Changed to "path_parts"
| |
60 app_positions = [] | |
61 framework_positions = [] | |
62 for part, index in zip(parts, range(len(parts))): | |
earthdok
2014/12/16 14:19:57
for index, part in enumerate(parts):
Alexander Potapenko
2014/12/16 14:49:13
Done.
| |
63 if part.endswith('.app'): | |
64 app_positions.append(index) | |
65 elif part.endswith('.framework'): | |
66 framework_positions.append(index) | |
67 # TODO(glider): more assertions | |
earthdok
2014/12/16 14:19:57
Why not add more assertions now?
Alexander Potapenko
2014/12/16 14:49:13
Changed the second one, should be enough for now.
| |
68 assert(len(framework_positions) < 2) | |
earthdok
2014/12/16 14:19:57
Please raise an exception, or at the very least as
Alexander Potapenko
2014/12/16 14:49:13
Done.
| |
69 assert(len(app_positions) <= 2) | |
70 bundles = app_positions + framework_positions | |
71 bundles.sort() | |
72 if len(bundles) == 0: | |
73 return [] | |
74 outer_bundle = bundles[0] | |
75 if len(bundles) > 1: | |
earthdok
2014/12/16 14:19:57
I don't understand what this part does.
Alexander Potapenko
2014/12/16 14:49:13
Added a comment.
| |
76 parts[outer_bundle] = parts[bundles[-1]] | |
77 parts = parts[:outer_bundle + 1] | |
78 result = '%s.dSYM' % os.path.sep.join(parts) | |
79 return [result] | |
80 | |
47 | 81 |
48 def main(): | 82 def main(): |
49 disable_buffering() | 83 disable_buffering() |
50 set_symbolizer_path() | 84 set_symbolizer_path() |
51 asan_symbolize.demangle = True | 85 asan_symbolize.demangle = True |
52 asan_symbolize.fix_filename_patterns = sys.argv[1:] | 86 asan_symbolize.fix_filename_patterns = sys.argv[1:] |
53 asan_symbolize.logfile = sys.stdin | 87 asan_symbolize.logfile = sys.stdin |
54 loop = asan_symbolize.SymbolizationLoop() | 88 loop = asan_symbolize.SymbolizationLoop(dsym_hint_producer=chrome_dsym_hints) |
55 loop.process_logfile() | 89 loop.process_logfile() |
56 | 90 |
57 if __name__ == '__main__': | 91 if __name__ == '__main__': |
58 main() | 92 main() |
OLD | NEW |