forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
android: Convert java_deobfuscate.py to Java
This allows it to not buffer output lines, which is essential when piping logcat through it. BUG=713710 Review-Url: https://codereview.chromium.org/2956153003 Cr-Commit-Position: refs/heads/master@{#484281}
- Loading branch information
Showing
9 changed files
with
133 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# 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. | ||
|
||
import("//build/config/android/rules.gni") | ||
|
||
java_binary("java_deobfuscate") { | ||
main_class = "org.chromium.build.FlushingReTrace" | ||
java_files = [ "java/org/chromium/build/FlushingReTrace.java" ] | ||
deps = [ | ||
"//third_party/proguard:retrace_java", | ||
] | ||
data = [ | ||
"$root_build_dir/lib.java/build/android/stacktrace/java_deobfuscate.jar", | ||
"$root_build_dir/bin/java_deobfuscate", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# java_deobfuscate | ||
|
||
A wrapper around ProGuard's ReTrace tool, which: | ||
|
||
1) Updates the regular expression used to identify stack lines, and | ||
2) Streams its output. | ||
|
||
The second point here is what allows you to run: | ||
|
||
adb logcat | out/Default/bin/java_deobfuscate | ||
|
||
And have it actually show output without logcat terminating. | ||
|
||
|
||
# stackwalker.py | ||
|
||
Extracts Breakpad microdumps from a log file and uses `stackwalker` to symbolize | ||
them. |
60 changes: 60 additions & 0 deletions
60
build/android/stacktrace/java/org/chromium/build/FlushingReTrace.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# 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. | ||
|
||
import("//build/config/android/rules.gni") | ||
|
||
java_prebuilt("proguard_java") { | ||
jar_path = "lib/proguard.jar" | ||
data = [ | ||
"$root_build_dir/lib.java/third_party/proguard/proguard.jar", | ||
] | ||
} | ||
|
||
java_prebuilt("retrace_java") { | ||
jar_path = "lib/retrace.jar" | ||
deps = [ | ||
":proguard_java", | ||
] | ||
data = [ | ||
"$root_build_dir/lib.java/third_party/proguard/retrace.jar", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
agrieve@chromium.org | ||
torne@chromium.org | ||
yfriedman@chromium.org |