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

Side by Side Diff: build/android/symbolize.py

Issue 19010004: Update build/android/symbolize.py to match base/debug/stack_trace_android.cc format. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 5 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | build/android/symbolize_test.py » ('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 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 13 import os
14 import re 14 import re
15 import sys 15 import sys
16 16
17 from pylib import constants 17 from pylib import constants
18 18
19 # Uses symbol.py from third_party/android_platform, not python's. 19 # Uses symbol.py from third_party/android_platform, not python's.
20 sys.path.insert(0, 20 sys.path.insert(0,
21 os.path.join(constants.DIR_SOURCE_ROOT, 21 os.path.join(constants.DIR_SOURCE_ROOT,
22 'third_party/android_platform/development/scripts')) 22 'third_party/android_platform/development/scripts'))
23 import symbol 23 import symbol
24 24
25 # Sample output from base/debug/stack_trace_android.cc 25 # Sample output from base/debug/stack_trace_android.cc
26 #00 pc 000634c1 /data/app-lib/org.chromium.native_test-1/libbase_unittests.so 26 #00 0x693cd34f /path/to/some/libfoo.so+0x0007434f
27 TRACE_LINE = re.compile('(?P<frame>\#[0-9]+) pc (?P<addr>[0-9a-f]{8,8}) ' 27 TRACE_LINE = re.compile('(?P<frame>\#[0-9]+ 0x[0-9a-f]{8,8}) '
28 '(?P<lib>[^\r\n \t]+)') 28 '(?P<lib>[^+]+)\+0x(?P<addr>[0-9a-f]{8,8})')
29 29
30 class Symbolizer(object): 30 class Symbolizer(object):
31 def __init__(self, file_in, file_out): 31 def __init__(self, file_in, file_out):
32 self.file_in = file_in 32 self.file_in = file_in
33 self.file_out = file_out 33 self.file_out = file_out
34 34
35 def ProcessInput(self): 35 def ProcessInput(self):
36 for line in self.file_in: 36 for line in self.file_in:
37 match = re.search(TRACE_LINE, line) 37 match = re.search(TRACE_LINE, line)
38 if not match: 38 if not match:
(...skipping 19 matching lines...) Expand all
58 # (e.g., adb logcat) when doing incremental development. Consider clearing 58 # (e.g., adb logcat) when doing incremental development. Consider clearing
59 # the cache when modification timestamp of libraries change. 59 # the cache when modification timestamp of libraries change.
60 sym = symbol.SymbolInformation(lib, addr, False)[0][0] 60 sym = symbol.SymbolInformation(lib, addr, False)[0][0]
61 61
62 if not sym: 62 if not sym:
63 self.file_out.write(line) 63 self.file_out.write(line)
64 self.file_out.flush() 64 self.file_out.flush()
65 continue 65 continue
66 66
67 pre = line[0:match.start('frame')] 67 pre = line[0:match.start('frame')]
68 post = line[match.end('lib'):] 68 post = line[match.end('addr'):]
69 69
70 self.file_out.write('%s%s pc %s %s%s' % (pre, frame, addr, sym, post)) 70 self.file_out.write(pre)
71 self.file_out.write(frame)
72 self.file_out.write(' ')
73 self.file_out.write(sym)
74 self.file_out.write(post)
71 self.file_out.flush() 75 self.file_out.flush()
72 76
73 77
74 def main(): 78 def main():
75 symbolizer = Symbolizer(sys.stdin, sys.stdout) 79 symbolizer = Symbolizer(sys.stdin, sys.stdout)
76 symbolizer.ProcessInput() 80 symbolizer.ProcessInput()
77 81
78 82
79 if __name__ == '__main__': 83 if __name__ == '__main__':
80 main() 84 main()
OLDNEW
« no previous file with comments | « no previous file | build/android/symbolize_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698