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..d9aa24edb512d5ed13a6092a7465d6cac62ef40f 100755 |
| --- a/tools/valgrind/asan/asan_symbolize.py |
| +++ b/tools/valgrind/asan/asan_symbolize.py |
| @@ -45,13 +45,58 @@ def set_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 or dynamic library 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): |
| + path_parts = binary.split(os.path.sep) |
| + app_positions = [] |
| + framework_positions = [] |
| + for index, part in enumerate(path_parts): |
| + if part.endswith('.app'): |
| + app_positions.append(index) |
| + elif part.endswith('.framework'): |
| + framework_positions.append(index) |
| + assert len(framework_positions) < 2, \ |
| + "The path contains more than one framework: %s" % binary |
| + bundles = app_positions + framework_positions |
| + bundles.sort() |
| + assert len(bundles) <= 2, \ |
| + "The path contains more than two nested bundles: %s" % binary |
| + if len(bundles) == 0: |
| + # Case 1: this is a standalone executable or dylib. |
| + return [] |
| + # Cases 2 and 3. The outermost bundle (which is the only bundle in the case 2) |
| + # is located in the product dir. |
| + outer_bundle = bundles[0] |
| + if len(bundles) > 1: |
|
earthdok
2014/12/16 15:32:47
Ok, how about something like this:
outermost_bund
Alexander Potapenko
2014/12/16 17:18:46
Nice idea, thanks!
Done
|
| + # Case 3: if there're bundles inside the outermost one, then there is a |
| + # copy of the innermost bundle in the product dir. |
| + # Construct the path to it by replacing the outermost bundle name with the |
| + # innermost bundle name. This invalidates path_parts[outer_bundle + 1:]. |
| + path_parts[outer_bundle] = path_parts[bundles[-1]] |
| + # Cases 2 and 3: cut everything below the bundle in the product dir. |
| + path_parts = path_parts[:outer_bundle + 1] |
| + # .dSYM path for the bundle. |
| + result = '%s.dSYM' % os.path.sep.join(path_parts) |
| + return [result] |
| + |
| + |
| def main(): |
| disable_buffering() |
| set_symbolizer_path() |
| 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__': |