diff options
4 files changed, 94 insertions, 13 deletions
diff --git a/src/com/android/loganalysis/parser/DmesgParser.java b/src/com/android/loganalysis/parser/DmesgParser.java index ba802cf..bd0d8e4 100644 --- a/src/com/android/loganalysis/parser/DmesgParser.java +++ b/src/com/android/loganalysis/parser/DmesgParser.java @@ -20,7 +20,6 @@ import com.android.loganalysis.item.DmesgActionInfoItem; import com.android.loganalysis.item.DmesgItem; import com.android.loganalysis.item.DmesgServiceInfoItem; import com.android.loganalysis.item.DmesgStageInfoItem; - import com.google.common.annotations.VisibleForTesting; import java.io.BufferedReader; @@ -65,12 +64,10 @@ public class DmesgParser implements IParser { String.format("%s%s", SERVICE_PREFIX, START_STAGE_PREFIX)); // Matches: init: processing action (early-init) - // must not match: init: processing action (vold.decrypt=trigger_restart_framework) private static final String START_PROCESSING_ACTION_PREFIX = String.format( - "processing action \\((?<%s>[^=]+)\\)", ACTION); + "processing action \\((?<%s>.*)\\)", ACTION); // Matches: [ 14.942872] init: processing action (early-init) - // Does not match: [ 22.361049] init: processing action (persist.sys.usb.config=* boot) private static final Pattern START_PROCESSING_ACTION = Pattern.compile( String.format("%s%s", SERVICE_PREFIX, START_PROCESSING_ACTION_PREFIX)); diff --git a/src/com/android/loganalysis/parser/LogcatParser.java b/src/com/android/loganalysis/parser/LogcatParser.java index 96cd1c2..b32536d 100644 --- a/src/com/android/loganalysis/parser/LogcatParser.java +++ b/src/com/android/loganalysis/parser/LogcatParser.java @@ -54,12 +54,18 @@ public class LogcatParser implements IParser { /** * Match a single line of `logcat -v threadtime`, such as: - * 05-26 11:02:36.886 5689 5689 D AndroidRuntime: CheckJNI is OFF + * + * <pre>05-26 11:02:36.886 5689 5689 D AndroidRuntime: CheckJNI is OFF.</pre> */ - private static final Pattern THREADTIME_LINE = Pattern.compile( - "^(\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}.\\d{3})\\s+" + /* timestamp [1] */ - "(\\d+)\\s+(\\d+)\\s+([A-Z])\\s+" + /* pid/tid and log level [2-4] */ - "(.+?)\\s*: (.*)$" /* tag and message [5-6]*/); + private static final Pattern THREADTIME_LINE = + // UID was added to logcat. It could either be a number or a string. + Pattern.compile( + // timestamp[1] + "^(\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}.\\d{3})" + // pid/tid and log level [2-4] + + "(?:\\s+[0-9A-Za-z]+)?\\s+(\\d+)\\s+(\\d+)\\s+([A-Z])\\s+" + // tag and message [5-6] + + "(.+?)\\s*: (.*)$"); /** * Match a single line of `logcat -v time`, such as: diff --git a/tests/src/com/android/loganalysis/parser/DmesgParserTest.java b/tests/src/com/android/loganalysis/parser/DmesgParserTest.java index 4b043e1..2206733 100644 --- a/tests/src/com/android/loganalysis/parser/DmesgParserTest.java +++ b/tests/src/com/android/loganalysis/parser/DmesgParserTest.java @@ -95,7 +95,7 @@ public class DmesgParserTest extends TestCase { dmesgParser.getServiceInfoItems().size()); assertEquals("Stage info items list size should be 2", 2, dmesgParser.getStageInfoItems().size()); - assertEquals("Action info items list size should be 5", 5, + assertEquals("Action info items list size should be 8", 8, dmesgParser.getActionInfoItems().size()); assertEquals(EXPECTED_SERVICE_INFO_ITEMS, actualDmesgItem.getServiceInfoItems()); @@ -115,7 +115,7 @@ public class DmesgParserTest extends TestCase { dmesgParser.getServiceInfoItems().size()); assertEquals("Stage info items list size should be 2", 2, dmesgParser.getStageInfoItems().size()); - assertEquals("Action info items list size should be 5", 5, + assertEquals("Action info items list size should be 8", 8, dmesgParser.getActionInfoItems().size()); } } @@ -207,7 +207,7 @@ public class DmesgParserTest extends TestCase { dmesgParser.parseActionInfo(line); } List<DmesgActionInfoItem> actualActionInfoItems = dmesgParser.getActionInfoItems(); - assertEquals(5, actualActionInfoItems.size()); + assertEquals(8, actualActionInfoItems.size()); assertEquals(EXPECTED_ACTION_INFO_ITEMS, actualActionInfoItems); } @@ -219,8 +219,14 @@ public class DmesgParserTest extends TestCase { new DmesgActionInfoItem("set_kptr_restrict", (long) (Double.parseDouble("47240.083"))), new DmesgActionInfoItem("keychord_init", (long) (Double.parseDouble("47245.778"))), + new DmesgActionInfoItem("persist.sys.usb.config=* boot", + (long) (Double.parseDouble("52361.049"))), new DmesgActionInfoItem("enable_property_trigger", - (long) (Double.parseDouble("52361.108")))); + (long) (Double.parseDouble("52361.108"))), + new DmesgActionInfoItem("security.perf_harden=1", + (long) (Double.parseDouble("52361.313"))), + new DmesgActionInfoItem("ro.debuggable=1", + (long) (Double.parseDouble("52361.495")))); } private static List<DmesgStageInfoItem> getExpectedStageInfoItems() { diff --git a/tests/src/com/android/loganalysis/parser/LogcatParserTest.java b/tests/src/com/android/loganalysis/parser/LogcatParserTest.java index 7adeed6..1d4f72c 100644 --- a/tests/src/com/android/loganalysis/parser/LogcatParserTest.java +++ b/tests/src/com/android/loganalysis/parser/LogcatParserTest.java @@ -442,6 +442,78 @@ public class LogcatParserTest extends TestCase { assertEquals(3064, logcat.getJavaCrashes().get(0).getPid().intValue()); assertEquals(3082, logcat.getJavaCrashes().get(0).getTid().intValue()); + assertEquals( + parseTime("2012-04-25 09:55:47.799"), + logcat.getJavaCrashes().get(0).getEventTime()); + + assertEquals(3065, logcat.getJavaCrashes().get(1).getPid().intValue()); + assertEquals(3090, logcat.getJavaCrashes().get(1).getTid().intValue()); + assertEquals( + parseTime("2012-04-25 09:55:47.799"), + logcat.getJavaCrashes().get(1).getEventTime()); + + assertEquals(3112, logcat.getNativeCrashes().get(0).getPid().intValue()); + assertEquals(3112, logcat.getNativeCrashes().get(0).getTid().intValue()); + assertEquals( + parseTime("2012-04-25 18:33:27.273"), + logcat.getNativeCrashes().get(0).getEventTime()); + + assertEquals(3113, logcat.getNativeCrashes().get(1).getPid().intValue()); + assertEquals(3113, logcat.getNativeCrashes().get(1).getTid().intValue()); + assertEquals( + parseTime("2012-04-25 18:33:27.273"), + logcat.getNativeCrashes().get(1).getEventTime()); + } + + /** Test that including extra uid column still parses the logs. */ + public void testParse_uid() throws ParseException { + List<String> lines = + Arrays.asList( + "04-25 09:55:47.799 wifi 3064 3082 E AndroidRuntime: java.lang.Exception", + "04-25 09:55:47.799 wifi 3064 3082 E AndroidRuntime: \tat class.method1(Class.java:1)", + "04-25 09:55:47.799 wifi 3064 3082 E AndroidRuntime: \tat class.method2(Class.java:2)", + "04-25 09:55:47.799 wifi 3064 3082 E AndroidRuntime: \tat class.method3(Class.java:3)", + "04-25 09:55:47.799 wifi 3065 3090 E AndroidRuntime: java.lang.Exception", + "04-25 09:55:47.799 wifi 3065 3090 E AndroidRuntime: \tat class.method1(Class.java:1)", + "04-25 09:55:47.799 wifi 3065 3090 E AndroidRuntime: \tat class.method2(Class.java:2)", + "04-25 09:55:47.799 wifi 3065 3090 E AndroidRuntime: \tat class.method3(Class.java:3)", + "04-25 17:17:08.445 1337 312 366 E ActivityManager: ANR (application not responding) in process: com.android.package", + "04-25 17:17:08.445 1337 312 366 E ActivityManager: Reason: keyDispatchingTimedOut", + "04-25 17:17:08.445 1337 312 366 E ActivityManager: Load: 0.71 / 0.83 / 0.51", + "04-25 17:17:08.445 1337 312 366 E ActivityManager: 33% TOTAL: 21% user + 11% kernel + 0.3% iowait", + "04-25 17:17:08.445 1337 312 366 E ActivityManager: ANR (application not responding) in process: com.android.package", + "04-25 17:17:08.445 1337 312 366 E ActivityManager: Reason: keyDispatchingTimedOut", + "04-25 17:17:08.445 1337 312 366 E ActivityManager: Load: 0.71 / 0.83 / 0.51", + "04-25 17:17:08.445 1337 312 366 E ActivityManager: 33% TOTAL: 21% user + 11% kernel + 0.3% iowait", + "04-25 18:33:27.273 wifi123 115 115 I DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***", + "04-25 18:33:27.273 wifi123 115 115 I DEBUG : Build fingerprint: 'product:build:target'", + "04-25 18:33:27.273 wifi123 115 115 I DEBUG : pid: 3112, tid: 3112 >>> com.google.android.browser <<<", + "04-25 18:33:27.273 wifi123 115 115 I DEBUG : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000", + "04-25 18:33:27.273 wifi123 117 117 I DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***", + "04-25 18:33:27.273 wifi123 117 117 I DEBUG : Build fingerprint: 'product:build:target'", + "04-25 18:33:27.273 wifi123 117 117 I DEBUG : pid: 3113, tid: 3113 >>> com.google.android.browser <<<", + "04-25 18:33:27.273 wifi123 117 117 I DEBUG : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000"); + + + LogcatItem logcat = new LogcatParser("2012").parse(lines); + assertNotNull(logcat); + assertEquals(parseTime("2012-04-25 09:55:47.799"), logcat.getStartTime()); + assertEquals(parseTime("2012-04-25 18:33:27.273"), logcat.getStopTime()); + assertEquals(6, logcat.getEvents().size()); + assertEquals(2, logcat.getAnrs().size()); + assertEquals(2, logcat.getJavaCrashes().size()); + assertEquals(2, logcat.getNativeCrashes().size()); + + assertEquals(312, logcat.getAnrs().get(0).getPid().intValue()); + assertEquals(366, logcat.getAnrs().get(0).getTid().intValue()); + assertEquals(parseTime("2012-04-25 17:17:08.445"), logcat.getAnrs().get(0).getEventTime()); + + assertEquals(312, logcat.getAnrs().get(1).getPid().intValue()); + assertEquals(366, logcat.getAnrs().get(1).getTid().intValue()); + assertEquals(parseTime("2012-04-25 17:17:08.445"), logcat.getAnrs().get(1).getEventTime()); + + assertEquals(3064, logcat.getJavaCrashes().get(0).getPid().intValue()); + assertEquals(3082, logcat.getJavaCrashes().get(0).getTid().intValue()); assertEquals(parseTime("2012-04-25 09:55:47.799"), logcat.getJavaCrashes().get(0).getEventTime()); |