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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 # contain other bundles. | 61 # contain other bundles. |
62 def chrome_dsym_hints(binary): | 62 def chrome_dsym_hints(binary): |
63 path_parts = binary.split(os.path.sep) | 63 path_parts = binary.split(os.path.sep) |
64 app_positions = [] | 64 app_positions = [] |
65 framework_positions = [] | 65 framework_positions = [] |
66 for index, part in enumerate(path_parts): | 66 for index, part in enumerate(path_parts): |
67 if part.endswith('.app'): | 67 if part.endswith('.app'): |
68 app_positions.append(index) | 68 app_positions.append(index) |
69 elif part.endswith('.framework'): | 69 elif part.endswith('.framework'): |
70 framework_positions.append(index) | 70 framework_positions.append(index) |
71 assert len(framework_positions) <= 1, \ | |
72 "The path contains more than one framework: %s" % binary | |
73 bundle_positions = app_positions + framework_positions | 71 bundle_positions = app_positions + framework_positions |
74 bundle_positions.sort() | 72 bundle_positions.sort() |
75 assert len(bundle_positions) <= 2, \ | 73 assert len(bundle_positions) <= 2, \ |
76 "The path contains more than two nested bundles: %s" % binary | 74 "The path contains more than two nested bundles: %s" % binary |
77 if len(bundle_positions) == 0: | 75 if len(bundle_positions) == 0: |
78 # Case 1: this is a standalone executable or dylib. | 76 # Case 1: this is a standalone executable or dylib. |
79 return [] | 77 return [] |
80 assert (len(bundle_positions) == 1 or | 78 assert (not (len(app_positions) == 1 and |
81 len(app_positions) == 2 or | 79 len(framework_positions) == 1 and |
82 app_positions[0] < framework_positions[0]), \ | 80 app_positions[0] > framework_positions[0])), \ |
83 "The path contains an app bundle inside a framework: %s" % binary | 81 "The path contains an app bundle inside a framework: %s" % binary |
84 # Cases 2 and 3. The outermost bundle (which is the only bundle in the case 2) | 82 # Cases 2 and 3. The outermost bundle (which is the only bundle in the case 2) |
85 # is located in the product dir. | 83 # is located in the product dir. |
86 outermost_bundle = bundle_positions[0] | 84 outermost_bundle = bundle_positions[0] |
87 product_dir = path_parts[:outermost_bundle] | 85 product_dir = path_parts[:outermost_bundle] |
88 # In case 2 this is the same as |outermost_bundle|. | 86 # In case 2 this is the same as |outermost_bundle|. |
89 innermost_bundle = bundle_positions[-1] | 87 innermost_bundle = bundle_positions[-1] |
90 dsym_path = product_dir + [path_parts[innermost_bundle]] | 88 dsym_path = product_dir + [path_parts[innermost_bundle]] |
91 result = '%s.dSYM' % os.path.sep.join(dsym_path) | 89 result = '%s.dSYM' % os.path.sep.join(dsym_path) |
92 return [result] | 90 return [result] |
93 | 91 |
94 | 92 |
95 def main(): | 93 def main(): |
96 disable_buffering() | 94 disable_buffering() |
97 set_symbolizer_path() | 95 set_symbolizer_path() |
98 asan_symbolize.demangle = True | 96 asan_symbolize.demangle = True |
99 asan_symbolize.fix_filename_patterns = sys.argv[1:] | 97 asan_symbolize.fix_filename_patterns = sys.argv[1:] |
100 asan_symbolize.logfile = sys.stdin | 98 asan_symbolize.logfile = sys.stdin |
101 loop = asan_symbolize.SymbolizationLoop(dsym_hint_producer=chrome_dsym_hints) | 99 loop = asan_symbolize.SymbolizationLoop(dsym_hint_producer=chrome_dsym_hints) |
102 loop.process_logfile() | 100 loop.process_logfile() |
103 | 101 |
104 if __name__ == '__main__': | 102 if __name__ == '__main__': |
105 main() | 103 main() |
OLD | NEW |