Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: tools/valgrind/asan/asan_symbolize.py

Issue 797253002: Update the upstream version of asan_symbolize.py to r222535, (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor fixes Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/valgrind/asan/third_party/README.chromium » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 # Construct a path to the .dSYM bundle for the given binary.
49 # There are three possible cases for binary location in Chromium:
50 # 1. The binary is a standalone executable or dynamic library in the product
51 # dir, the debug info is in "binary.dSYM" in the product dir.
52 # 2. The binary is a standalone framework or .app bundle, the debug info is in
53 # "Framework.framework.dSYM" or "App.app.dSYM" in the product dir.
54 # 3. The binary is a framework or an .app bundle within another .app bundle
55 # (e.g. Outer.app/Contents/Versions/1.2.3.4/Inner.app), and the debug info
56 # is in Inner.app.dSYM in the product dir.
57 # The first case is handled by llvm-symbolizer, so we only need to construct
58 # .dSYM paths for .app bundles and frameworks.
59 def chrome_dsym_hints(binary):
60 path_parts = binary.split(os.path.sep)
61 app_positions = []
62 framework_positions = []
63 for index, part in enumerate(path_parts):
64 if part.endswith('.app'):
65 app_positions.append(index)
66 elif part.endswith('.framework'):
67 framework_positions.append(index)
68 assert len(framework_positions) < 2, \
69 "The path contains more than one framework: %s" % binary
70 bundles = app_positions + framework_positions
71 bundles.sort()
72 assert len(bundles) <= 2, \
73 "The path contains more than two nested bundles: %s" % binary
74 if len(bundles) == 0:
75 # Case 1: this is a standalone executable or dylib.
76 return []
77 # Cases 2 and 3. The outermost bundle (which is the only bundle in the case 2)
78 # is located in the product dir.
79 outer_bundle = bundles[0]
80 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
81 # Case 3: if there're bundles inside the outermost one, then there is a
82 # copy of the innermost bundle in the product dir.
83 # Construct the path to it by replacing the outermost bundle name with the
84 # innermost bundle name. This invalidates path_parts[outer_bundle + 1:].
85 path_parts[outer_bundle] = path_parts[bundles[-1]]
86 # Cases 2 and 3: cut everything below the bundle in the product dir.
87 path_parts = path_parts[:outer_bundle + 1]
88 # .dSYM path for the bundle.
89 result = '%s.dSYM' % os.path.sep.join(path_parts)
90 return [result]
91
92
48 def main(): 93 def main():
49 disable_buffering() 94 disable_buffering()
50 set_symbolizer_path() 95 set_symbolizer_path()
51 asan_symbolize.demangle = True 96 asan_symbolize.demangle = True
52 asan_symbolize.fix_filename_patterns = sys.argv[1:] 97 asan_symbolize.fix_filename_patterns = sys.argv[1:]
53 asan_symbolize.logfile = sys.stdin 98 asan_symbolize.logfile = sys.stdin
54 loop = asan_symbolize.SymbolizationLoop() 99 loop = asan_symbolize.SymbolizationLoop(dsym_hint_producer=chrome_dsym_hints)
55 loop.process_logfile() 100 loop.process_logfile()
56 101
57 if __name__ == '__main__': 102 if __name__ == '__main__':
58 main() 103 main()
OLDNEW
« no previous file with comments | « no previous file | tools/valgrind/asan/third_party/README.chromium » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698