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 """Symbolizes stack traces generated by Chromium for Android. | 7 """Symbolizes stack traces generated by Chromium for Android. |
8 | 8 |
9 Sample usage: | 9 Sample usage: |
10 adb logcat chromium:V | symbolize.py | 10 adb logcat chromium:V | symbolize.py |
11 """ | 11 """ |
12 | 12 |
13 import os | |
14 import re | 13 import re |
15 import sys | 14 import sys |
16 | 15 |
17 from pylib import constants | 16 from pylib.constants import host_paths |
18 | 17 |
19 # Uses symbol.py from third_party/android_platform, not python's. | 18 # Uses symbol.py from third_party/android_platform, not python's. |
20 sys.path.insert(0, | 19 with host_paths.SysPath( |
21 os.path.join(constants.DIR_SOURCE_ROOT, | 20 host_paths.ANDROID_PLATFORM_DEVELOPMENT_SCRIPTS_PATH, |
22 'third_party/android_platform/development/scripts')) | 21 position=0): |
23 import symbol | 22 import symbol |
24 | 23 |
25 # Sample output from base/debug/stack_trace_android.cc | 24 # Sample output from base/debug/stack_trace_android.cc |
26 #00 0x693cd34f /path/to/some/libfoo.so+0x0007434f | 25 #00 0x693cd34f /path/to/some/libfoo.so+0x0007434f |
27 TRACE_LINE = re.compile(r'(?P<frame>\#[0-9]+ 0x[0-9a-f]{8,8}) ' | 26 TRACE_LINE = re.compile(r'(?P<frame>\#[0-9]+ 0x[0-9a-f]{8,8}) ' |
28 r'(?P<lib>[^+]+)\+0x(?P<addr>[0-9a-f]{8,8})') | 27 r'(?P<lib>[^+]+)\+0x(?P<addr>[0-9a-f]{8,8})') |
29 | 28 |
30 class Symbolizer(object): | 29 class Symbolizer(object): |
31 def __init__(self, output): | 30 def __init__(self, output): |
32 self._output = output | 31 self._output = output |
33 | 32 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 79 |
81 def main(): | 80 def main(): |
82 symbolizer = Symbolizer(sys.stdout) | 81 symbolizer = Symbolizer(sys.stdout) |
83 for line in sys.stdin: | 82 for line in sys.stdin: |
84 symbolizer.write(line) | 83 symbolizer.write(line) |
85 symbolizer.flush() | 84 symbolizer.flush() |
86 | 85 |
87 | 86 |
88 if __name__ == '__main__': | 87 if __name__ == '__main__': |
89 main() | 88 main() |
OLD | NEW |