Chromium Code Reviews| Index: tools/valgrind/asan/asan_symbolize.py |
| diff --git a/tools/valgrind/asan/asan_symbolize.py b/tools/valgrind/asan/asan_symbolize.py |
| index ba8d69859fdb290451c6d1d1f931520004e1f316..ed6cce51cc96bf9447b58aa84ce5ebc57b48e7a9 100755 |
| --- a/tools/valgrind/asan/asan_symbolize.py |
| +++ b/tools/valgrind/asan/asan_symbolize.py |
| @@ -44,6 +44,40 @@ def set_symbolizer_path(): |
| assert(os.path.isfile(symbolizer_path)) |
| os.environ['LLVM_SYMBOLIZER_PATH'] = os.path.abspath(symbolizer_path) |
| +# Construct a path to the .dSYM bundle for the given binary. |
| +# There are three possible cases for binary location in Chromium: |
| +# 1. The binary is a standalone executable in the product dir, the debug info |
| +# is in "binary.dSYM" in the product dir. |
| +# 2. The binary is a standalone framework or .app bundle, the debug info is in |
| +# "Framework.framework.dSYM" or "App.app.dSYM" in the product dir. |
| +# 3. The binary is a framework or an .app bundle within another .app bundle |
| +# (e.g. Outer.app/Contents/Versions/1.2.3.4/Inner.app), and the debug info |
| +# is in Inner.app.dSYM in the product dir. |
| +# The first case is handled by llvm-symbolizer, so we only need to construct |
| +# .dSYM paths for .app bundles and frameworks. |
| +def chrome_dsym_hints(binary): |
| + 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"
|
| + app_positions = [] |
| + framework_positions = [] |
| + 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.
|
| + if part.endswith('.app'): |
| + app_positions.append(index) |
| + elif part.endswith('.framework'): |
| + framework_positions.append(index) |
| + # 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.
|
| + 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.
|
| + assert(len(app_positions) <= 2) |
| + bundles = app_positions + framework_positions |
| + bundles.sort() |
| + if len(bundles) == 0: |
| + return [] |
| + outer_bundle = bundles[0] |
| + 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.
|
| + parts[outer_bundle] = parts[bundles[-1]] |
| + parts = parts[:outer_bundle + 1] |
| + result = '%s.dSYM' % os.path.sep.join(parts) |
| + return [result] |
| + |
| def main(): |
| disable_buffering() |
| @@ -51,7 +85,7 @@ def main(): |
| asan_symbolize.demangle = True |
| asan_symbolize.fix_filename_patterns = sys.argv[1:] |
| asan_symbolize.logfile = sys.stdin |
| - loop = asan_symbolize.SymbolizationLoop() |
| + loop = asan_symbolize.SymbolizationLoop(dsym_hint_producer=chrome_dsym_hints) |
| loop.process_logfile() |
| if __name__ == '__main__': |