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

Side by Side Diff: build/android/stacktrace/java_deobfuscate.py

Issue 2952283002: java_deobfuscate.py: Update regexp to match thread dump stacks (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « no previous file | no next file » | 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 # Copyright 2016 The Chromium Authors. All rights reserved. 2 # Copyright 2016 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """A tool to deobfuscate Java stack traces. 6 """A tool to deobfuscate Java stack traces.
7 7
8 Utility wrapper around ReTrace to deobfuscate stack traces that have been 8 Utility wrapper around ReTrace to deobfuscate stack traces that have been
9 mangled by ProGuard. Takes stack traces from stdin (eg. adb logcat | 9 mangled by ProGuard. Takes stack traces from stdin (eg. adb logcat |
10 java_deobfuscate.py proguard.mapping) and files. 10 java_deobfuscate.py proguard.mapping) and files.
11 """ 11 """
12 12
13 # Can just run:
14 # java -jar third_party/proguard/lib/retrace.jar -regex \
15 # "(?:.*?\bat\s+%c\.%m\s*\(%s(?::%l)?\)\s*)|(?:(?:.*?[:\"]\s+)?%c(?::.*)?)" \
16 # ~/mapping
17 # in terminal to achieve same effect as this tool.
18
19 import argparse 13 import argparse
20 import os 14 import os
21 import subprocess
22 import sys
23 15
24 _THIRD_PARTY_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), 16 _SRC_DIR = os.path.normpath(
25 os.pardir, os.pardir, os.pardir, 17 os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir))
26 'third_party'))
27 sys.path.append(os.path.join(_THIRD_PARTY_DIR, 'catapult', 'devil'))
28 from devil.utils import cmd_helper
29 18
30 19 # This regex is based on the one from:
31 # This regex is taken from
32 # http://proguard.sourceforge.net/manual/retrace/usage.html. 20 # http://proguard.sourceforge.net/manual/retrace/usage.html.
21 # But with the "at" part changed to "(?::|\bat)", to account for lines like:
mikecase (-- gone --) 2017/06/22 20:34:16 Do you have an example of the type of lines this n
agrieve 2017/06/23 01:48:22 Done.
22 # 06-22 13:58:02.895 4674 4674 E THREAD_STATE: bLA.a(PG:173)
33 _LINE_PARSE_REGEX = ( 23 _LINE_PARSE_REGEX = (
34 r'(?:.*?\bat\s+%c\.%m\s*\(%s(?::%l)?\)\s*)|(?:(?:.*?[:"]\s+)?%c(?::.*)?)') 24 r'(?:.*?(?::|\bat)\s+%c\.%m\s*\(%s(?::%l)?\)\s*)|'
25 r'(?:(?:.*?[:"]\s+)?%c(?::.*)?)')
35 26
36 27
37 def main(): 28 def main():
38 parser = argparse.ArgumentParser(description=(__doc__)) 29 parser = argparse.ArgumentParser(description=(__doc__))
39 parser.add_argument( 30 parser.add_argument(
40 'mapping_file', 31 'mapping_file',
41 help='ProGuard mapping file from build which the stacktrace is from.') 32 help='ProGuard mapping file from build which the stacktrace is from.')
42 parser.add_argument( 33 parser.add_argument(
43 '--stacktrace', 34 '--stacktrace',
44 help='Stacktrace file to be deobfuscated.') 35 help='Stacktrace file to be deobfuscated.')
45 args = parser.parse_args() 36 args = parser.parse_args()
46 37
47 retrace_path = os.path.join(_THIRD_PARTY_DIR, 'proguard', 38 retrace_path = os.path.join(
48 'lib', 'retrace.jar') 39 _SRC_DIR, 'third_party', 'proguard', 'lib', 'retrace.jar')
49 40
50 base_args = ['java', '-jar', retrace_path, '-regex', _LINE_PARSE_REGEX, 41 cmd = ['java', '-jar', retrace_path, '-regex', _LINE_PARSE_REGEX,
51 args.mapping_file] 42 args.mapping_file]
52 if args.stacktrace: 43 if args.stacktrace:
53 subprocess.call(base_args + [args.stacktrace]) 44 cmd.append(args.stacktrace)
54 else: 45 os.execvp('java', cmd)
55 for line in cmd_helper.IterCmdOutputLines(base_args):
56 print line
57 46
58 47
59 if __name__ == '__main__': 48 if __name__ == '__main__':
60 main() 49 main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698