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

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

Issue 2956153003: android: Convert java_deobfuscate.py to Java (Closed)
Patch Set: review comments + README Created 3 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
OLDNEW
(Empty)
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
5
6 """A tool to deobfuscate Java stack traces.
7
8 Utility wrapper around ReTrace to deobfuscate stack traces that have been
9 mangled by ProGuard. Takes stack traces from stdin (eg. adb logcat |
10 java_deobfuscate.py proguard.mapping) and files.
11 """
12
13 import argparse
14 import os
15
16 _SRC_DIR = os.path.normpath(
17 os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir))
18
19 # This regex is based on the one from:
20 # http://proguard.sourceforge.net/manual/retrace/usage.html.
21 # But with the "at" part changed to "(?::|\bat)", to account for lines like:
22 # 06-22 13:58:02.895 4674 4674 E THREAD_STATE: bLA.a(PG:173)
23 # Normal stack trace lines look like:
24 # java.lang.RuntimeException: Intentional Java Crash
25 # at org.chromium.chrome.browser.tab.Tab.handleJavaCrash(Tab.java:682)
26 # at org.chromium.chrome.browser.tab.Tab.loadUrl(Tab.java:644)
27 _LINE_PARSE_REGEX = (
28 r'(?:.*?(?::|\bat)\s+%c\.%m\s*\(%s(?::%l)?\)\s*)|'
29 r'(?:(?:.*?[:"]\s+)?%c(?::.*)?)')
30
31
32 def main():
33 parser = argparse.ArgumentParser(description=(__doc__))
34 parser.add_argument(
35 'mapping_file',
36 help='ProGuard mapping file from build which the stacktrace is from.')
37 parser.add_argument(
38 '--stacktrace',
39 help='Stacktrace file to be deobfuscated.')
40 args = parser.parse_args()
41
42 retrace_path = os.path.join(
43 _SRC_DIR, 'third_party', 'proguard', 'lib', 'retrace.jar')
44
45 cmd = ['java', '-jar', retrace_path, '-regex', _LINE_PARSE_REGEX,
46 args.mapping_file]
47 if args.stacktrace:
48 cmd.append(args.stacktrace)
49 os.execvp('java', cmd)
50
51
52 if __name__ == '__main__':
53 main()
OLDNEW
« no previous file with comments | « build/android/stacktrace/java/org/chromium/build/FlushingReTrace.java ('k') | build/config/android/internal_rules.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698