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

Unified Diff: build/android/stacktrace/java/org/chromium/build/FlushingReTrace.java

Issue 2956153003: android: Convert java_deobfuscate.py to Java (Closed)
Patch Set: review comments + README 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/stacktrace/README.md ('k') | build/android/stacktrace/java_deobfuscate.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/stacktrace/java/org/chromium/build/FlushingReTrace.java
diff --git a/build/android/stacktrace/java/org/chromium/build/FlushingReTrace.java b/build/android/stacktrace/java/org/chromium/build/FlushingReTrace.java
new file mode 100644
index 0000000000000000000000000000000000000000..1402511ac8f1aa3a5b386c0c8b577a51239113d8
--- /dev/null
+++ b/build/android/stacktrace/java/org/chromium/build/FlushingReTrace.java
@@ -0,0 +1,60 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.build;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.LineNumberReader;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+
+import proguard.retrace.ReTrace;
+
+/**
+ * A wrapper around ReTrace that:
+ * 1. Hardcodes a more useful line regular expression
+ * 2. Disables output buffering
+ */
+public class FlushingReTrace {
+ // This regex is based on the one from:
+ // http://proguard.sourceforge.net/manual/retrace/usage.html.
+ // But with the "at" part changed to "(?::|\bat)", to account for lines like:
+ // 06-22 13:58:02.895 4674 4674 E THREAD_STATE: bLA.a(PG:173)
+ // Normal stack trace lines look like:
+ // java.lang.RuntimeException: Intentional Java Crash
+ // at org.chromium.chrome.browser.tab.Tab.handleJavaCrash(Tab.java:682)
+ // at org.chromium.chrome.browser.tab.Tab.loadUrl(Tab.java:644)
+ private static final String LINE_PARSE_REGEX =
+ "(?:.*?(?::|\\bat)\\s+%c\\.%m\\s*\\(%s(?::%l)?\\)\\s*)|(?:(?:.*?[:\"]\\s+)?%c(?::.*)?)";
+
+ public static void main(String[] args) {
+ if (args.length != 1) {
+ System.err.println("Usage: retrace Foo.apk.map < foo.log > bar.log");
+ System.exit(1);
+ }
+
+ File mappingFile = new File(args[0]);
+ try {
+ LineNumberReader reader = new LineNumberReader(
+ new BufferedReader(new InputStreamReader(System.in, "UTF-8")));
+
+ // Enabling autoFlush is the main difference from ReTrace.main().
+ boolean autoFlush = true;
+ PrintWriter writer =
+ new PrintWriter(new OutputStreamWriter(System.out, "UTF-8"), autoFlush);
+
+ boolean verbose = false;
+ new ReTrace(LINE_PARSE_REGEX, verbose, mappingFile).retrace(reader, writer);
+ } catch (IOException ex) {
+ // Print a verbose stack trace.
+ ex.printStackTrace();
+ System.exit(1);
+ }
+
+ System.exit(0);
+ }
+}
« no previous file with comments | « build/android/stacktrace/README.md ('k') | build/android/stacktrace/java_deobfuscate.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698