OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2013 The Chromium Authors. All rights reserved. | 3 # Copyright 2013 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 | 7 |
8 import collections | 8 import collections |
9 import optparse | 9 import optparse |
10 import os | 10 import os |
11 import re | 11 import re |
12 import sys | 12 import sys |
13 | 13 |
14 from pylib import constants | 14 from pylib.constants import host_paths |
15 | 15 |
16 # Uses symbol.py from third_party/android_platform, not python's. | 16 # Uses symbol.py from third_party/android_platform, not python's. |
17 sys.path.insert(0, | 17 with host_paths.SysPath( |
18 os.path.join(constants.DIR_SOURCE_ROOT, | 18 host_paths.ANDROID_PLATFORM_DEVELOPMENT_SCRIPTS_PATH, |
19 'third_party/android_platform/development/scripts')) | 19 position=0): |
20 import symbol | 20 import symbol |
21 | 21 |
22 | 22 |
23 _RE_ASAN = re.compile(r'(.*?)(#\S*?) (\S*?) \((.*?)\+(.*?)\)') | 23 _RE_ASAN = re.compile(r'(.*?)(#\S*?) (\S*?) \((.*?)\+(.*?)\)') |
24 | 24 |
25 def _ParseAsanLogLine(line): | 25 def _ParseAsanLogLine(line): |
26 m = re.match(_RE_ASAN, line) | 26 m = re.match(_RE_ASAN, line) |
27 if not m: | 27 if not m: |
28 return None | 28 return None |
29 return { | 29 return { |
30 'prefix': m.group(1), | 30 'prefix': m.group(1), |
31 'library': m.group(4), | 31 'library': m.group(4), |
32 'pos': m.group(2), | 32 'pos': m.group(2), |
33 'rel_address': '%08x' % int(m.group(5), 16), | 33 'rel_address': '%08x' % int(m.group(5), 16), |
34 } | 34 } |
35 | 35 |
36 | 36 |
37 def _FindASanLibraries(): | 37 def _FindASanLibraries(): |
38 asan_lib_dir = os.path.join(constants.DIR_SOURCE_ROOT, | 38 asan_lib_dir = os.path.join(host_paths.DIR_SOURCE_ROOT, |
39 'third_party', 'llvm-build', | 39 'third_party', 'llvm-build', |
40 'Release+Asserts', 'lib') | 40 'Release+Asserts', 'lib') |
41 asan_libs = [] | 41 asan_libs = [] |
42 for src_dir, _, files in os.walk(asan_lib_dir): | 42 for src_dir, _, files in os.walk(asan_lib_dir): |
43 asan_libs += [os.path.relpath(os.path.join(src_dir, f)) | 43 asan_libs += [os.path.relpath(os.path.join(src_dir, f)) |
44 for f in files | 44 for f in files |
45 if f.endswith('.so')] | 45 if f.endswith('.so')] |
46 return asan_libs | 46 return asan_libs |
47 | 47 |
48 | 48 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 options, _ = parser.parse_args() | 96 options, _ = parser.parse_args() |
97 if options.logcat: | 97 if options.logcat: |
98 asan_input = file(options.logcat, 'r') | 98 asan_input = file(options.logcat, 'r') |
99 else: | 99 else: |
100 asan_input = sys.stdin | 100 asan_input = sys.stdin |
101 _Symbolize(asan_input.readlines()) | 101 _Symbolize(asan_input.readlines()) |
102 | 102 |
103 | 103 |
104 if __name__ == "__main__": | 104 if __name__ == "__main__": |
105 sys.exit(main()) | 105 sys.exit(main()) |
OLD | NEW |