OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.build; |
| 6 |
| 7 import java.io.BufferedReader; |
| 8 import java.io.File; |
| 9 import java.io.IOException; |
| 10 import java.io.InputStreamReader; |
| 11 import java.io.LineNumberReader; |
| 12 import java.io.OutputStreamWriter; |
| 13 import java.io.PrintWriter; |
| 14 |
| 15 import proguard.retrace.ReTrace; |
| 16 |
| 17 /** |
| 18 * A wrapper around ReTrace that: |
| 19 * 1. Hardcodes a more useful line regular expression |
| 20 * 2. Disables output buffering |
| 21 */ |
| 22 public class FlushingReTrace { |
| 23 // This regex is based on the one from: |
| 24 // http://proguard.sourceforge.net/manual/retrace/usage.html. |
| 25 // But with the "at" part changed to "(?::|\bat)", to account for lines like
: |
| 26 // 06-22 13:58:02.895 4674 4674 E THREAD_STATE: bLA.a(PG:173) |
| 27 // Normal stack trace lines look like: |
| 28 // java.lang.RuntimeException: Intentional Java Crash |
| 29 // at org.chromium.chrome.browser.tab.Tab.handleJavaCrash(Tab.java:682) |
| 30 // at org.chromium.chrome.browser.tab.Tab.loadUrl(Tab.java:644) |
| 31 private static final String LINE_PARSE_REGEX = |
| 32 "(?:.*?(?::|\\bat)\\s+%c\\.%m\\s*\\(%s(?::%l)?\\)\\s*)|(?:(?:.*?[:\"
]\\s+)?%c(?::.*)?)"; |
| 33 |
| 34 public static void main(String[] args) { |
| 35 if (args.length != 1) { |
| 36 System.err.println("Usage: retrace Foo.apk.map < foo.log > bar.log")
; |
| 37 System.exit(1); |
| 38 } |
| 39 |
| 40 File mappingFile = new File(args[0]); |
| 41 try { |
| 42 LineNumberReader reader = new LineNumberReader( |
| 43 new BufferedReader(new InputStreamReader(System.in, "UTF-8")
)); |
| 44 |
| 45 // Enabling autoFlush is the main difference from ReTrace.main(). |
| 46 boolean autoFlush = true; |
| 47 PrintWriter writer = |
| 48 new PrintWriter(new OutputStreamWriter(System.out, "UTF-8"),
autoFlush); |
| 49 |
| 50 boolean verbose = false; |
| 51 new ReTrace(LINE_PARSE_REGEX, verbose, mappingFile).retrace(reader,
writer); |
| 52 } catch (IOException ex) { |
| 53 // Print a verbose stack trace. |
| 54 ex.printStackTrace(); |
| 55 System.exit(1); |
| 56 } |
| 57 |
| 58 System.exit(0); |
| 59 } |
| 60 } |
OLD | NEW |