diff options
author | Eric Rowe <erowe@google.com> | 2015-06-08 12:08:33 -0700 |
---|---|---|
committer | Eric Rowe <erowe@google.com> | 2015-06-08 12:08:33 -0700 |
commit | 69155df867ac697a430ab9a998400ef727cffa1b (patch) | |
tree | 09931b205bd7ba41782d409b864f71c202856b98 | |
parent | c62fad09df43054df2d755ef7e43d6085656c04b (diff) | |
download | loganalysis-69155df867ac697a430ab9a998400ef727cffa1b.tar.gz |
Start parsing NCs from build fingerprint
Native crashes used to always start with "*** *** ... ***" but not anymore.
The next line is always "Build fingerprint: ..." so start with that.
Bug: 21642733
Change-Id: I0e1b7c6a70f646ea27f7da62f141d14b6c75dd58
3 files changed, 8 insertions, 16 deletions
diff --git a/src/com/android/loganalysis/parser/LogcatParser.java b/src/com/android/loganalysis/parser/LogcatParser.java index 3c0f774..f64936c 100644 --- a/src/com/android/loganalysis/parser/LogcatParser.java +++ b/src/com/android/loganalysis/parser/LogcatParser.java @@ -274,13 +274,13 @@ public class LogcatParser implements IParser { data.mLines.add(msg); } - // Native crashes are separated either by different PID/TIDs or when NativeCrashParser.START - // matches a line. The newest entry is kept in the dataMap for quick lookup while all - // entries are added to the list. + // Native crashes are separated either by different PID/TIDs or when + // NativeCrashParser.FINGERPRINT matches a line. The newest entry is kept in the dataMap + // for quick lookup while all entries are added to the list. if (anyNativeCrashTagMatches(level, tag)) { String key = encodeLine(pid, tid, level, tag); LogcatData data; - if (!mDataMap.containsKey(key) || NativeCrashParser.START.matcher(msg).matches()) { + if (!mDataMap.containsKey(key) || NativeCrashParser.FINGERPRINT.matcher(msg).matches()) { data = new LogcatData(pid, tid, time, level, tag, mPreambleUtil.getLastTail(), mPreambleUtil.getIdTail(pid)); mDataMap.put(key, data); diff --git a/src/com/android/loganalysis/parser/NativeCrashParser.java b/src/com/android/loganalysis/parser/NativeCrashParser.java index 3ad3034..f054504 100644 --- a/src/com/android/loganalysis/parser/NativeCrashParser.java +++ b/src/com/android/loganalysis/parser/NativeCrashParser.java @@ -26,15 +26,12 @@ import java.util.regex.Pattern; */ public class NativeCrashParser implements IParser { - /** Matches: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ - public static final Pattern START = Pattern.compile("^(?:\\*\\*\\* ){15}\\*\\*\\*$"); /** Matches: Build fingerprint: 'fingerprint' */ - private static final Pattern FINGERPRINT = Pattern.compile("^Build fingerprint: '(.*)'$"); + public static final Pattern FINGERPRINT = Pattern.compile("^Build fingerprint: '(.*)'$"); /** Matches: pid: 957, tid: 963 >>> com.android.camera <<< */ private static final Pattern APP = Pattern.compile( "^pid: (\\d+), tid: (\\d+)(, name: .+)? >>> (\\S+) <<<$"); - /** * {@inheritDoc} * @@ -46,16 +43,13 @@ public class NativeCrashParser implements IParser { StringBuilder stack = new StringBuilder(); for (String line : lines) { - Matcher m = START.matcher(line); + Matcher m = FINGERPRINT.matcher(line); if (m.matches()) { nc = new NativeCrashItem(); - } + nc.setFingerprint(m.group(1)); + } if (nc != null) { - m = FINGERPRINT.matcher(line); - if (m.matches()) { - nc.setFingerprint(m.group(1)); - } m = APP.matcher(line); if (m.matches()) { nc.setPid(Integer.valueOf(m.group(1))); diff --git a/tests/src/com/android/loganalysis/parser/LogcatParserTest.java b/tests/src/com/android/loganalysis/parser/LogcatParserTest.java index aa669de..d45b06c 100644 --- a/tests/src/com/android/loganalysis/parser/LogcatParserTest.java +++ b/tests/src/com/android/loganalysis/parser/LogcatParserTest.java @@ -287,7 +287,6 @@ public class LogcatParserTest extends TestCase { */ public void testParse_native_crash_info() throws ParseException { List<String> lines = Arrays.asList( - "04-25 18:33:27.273 115 115 I DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***", "04-25 18:33:27.273 115 115 I DEBUG : Build fingerprint: 'product:build:target'", "04-25 18:33:27.273 115 115 I DEBUG : pid: 3112, tid: 3112 >>> com.google.android.browser <<<", "04-25 18:33:27.273 115 115 I DEBUG : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000"); @@ -312,7 +311,6 @@ public class LogcatParserTest extends TestCase { */ public void testParse_native_crash_fatal() throws ParseException { List<String> lines = Arrays.asList( - "04-25 18:33:27.273 115 115 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***", "04-25 18:33:27.273 115 115 F DEBUG : Build fingerprint: 'product:build:target'", "04-25 18:33:27.273 115 115 F DEBUG : pid: 3112, tid: 3112, name: Name >>> com.google.android.browser <<<", "04-25 18:33:27.273 115 115 F DEBUG : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000"); |