summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Rowe <erowe@google.com>2013-03-21 18:53:11 -0700
committerEric Rowe <erowe@google.com>2013-04-19 11:11:45 -0700
commit2a4c870b01c77e0e12a7816f00990ae79f733530 (patch)
tree76b65a995517289b865a4bfb6bd0dd03dfb81e25
parent55036c9ae8fe44883fc090c91c6751242162b329 (diff)
downloadloganalysis-2a4c870b01c77e0e12a7816f00990ae79f733530.tar.gz
Add kernel log parsers to BugreportParser.
Change-Id: I09d9ea43bea3ef6d52a3bb7e5aafbe7e24fafe8c
-rw-r--r--src/com/android/loganalysis/item/BugreportItem.java33
-rw-r--r--src/com/android/loganalysis/parser/BugreportParser.java9
-rw-r--r--tests/src/com/android/loganalysis/parser/BugreportParserTest.java23
3 files changed, 64 insertions, 1 deletions
diff --git a/src/com/android/loganalysis/item/BugreportItem.java b/src/com/android/loganalysis/item/BugreportItem.java
index 95b36a8..ca45c70 100644
--- a/src/com/android/loganalysis/item/BugreportItem.java
+++ b/src/com/android/loganalysis/item/BugreportItem.java
@@ -30,12 +30,15 @@ public class BugreportItem extends GenericItem {
private static final String MEM_INFO = "MEM_INFO";
private static final String PROCRANK = "PROCRANK";
private static final String TOP = "TOP";
+ private static final String KERNEL_LOG = "KERNEL_LOG";
+ private static final String LAST_KMSG = "LAST_KMSG";
private static final String SYSTEM_LOG = "SYSTEM_LOG";
private static final String SYSTEM_PROPS = "SYSTEM_PROPS";
private static final String DUMPSYS = "DUMPSYS";
private static final Set<String> ATTRIBUTES = new HashSet<String>(Arrays.asList(
- TIME, MEM_INFO, PROCRANK, TOP, SYSTEM_LOG, SYSTEM_PROPS, DUMPSYS));
+ TIME, MEM_INFO, PROCRANK, TOP, KERNEL_LOG, LAST_KMSG, SYSTEM_LOG, SYSTEM_PROPS,
+ DUMPSYS));
/**
* The constructor for {@link BugreportItem}.
@@ -101,6 +104,34 @@ public class BugreportItem extends GenericItem {
}
/**
+ * Get the kernel log {@link KernelLogItem} of the bugreport.
+ */
+ public KernelLogItem getKernelLog() {
+ return (KernelLogItem) getAttribute(KERNEL_LOG);
+ }
+
+ /**
+ * Set the kernel log {@link KernelLogItem} of the bugreport.
+ */
+ public void setKernelLog(KernelLogItem systemLog) {
+ setAttribute(KERNEL_LOG, systemLog);
+ }
+
+ /**
+ * Get the last kmsg {@link KernelLogItem} of the bugreport.
+ */
+ public KernelLogItem getLastKmsg() {
+ return (KernelLogItem) getAttribute(LAST_KMSG);
+ }
+
+ /**
+ * Set the last kmsg {@link KernelLogItem} of the bugreport.
+ */
+ public void setLastKmsg(KernelLogItem systemLog) {
+ setAttribute(LAST_KMSG, systemLog);
+ }
+
+ /**
* Get the {@link LogcatItem} of the bugreport.
*/
public LogcatItem getSystemLog() {
diff --git a/src/com/android/loganalysis/parser/BugreportParser.java b/src/com/android/loganalysis/parser/BugreportParser.java
index edb50a6..f4a7383 100644
--- a/src/com/android/loganalysis/parser/BugreportParser.java
+++ b/src/com/android/loganalysis/parser/BugreportParser.java
@@ -20,6 +20,7 @@ import com.android.loganalysis.item.BugreportItem;
import com.android.loganalysis.item.DumpsysItem;
import com.android.loganalysis.item.GenericLogcatItem;
import com.android.loganalysis.item.IItem;
+import com.android.loganalysis.item.KernelLogItem;
import com.android.loganalysis.item.LogcatItem;
import com.android.loganalysis.item.MemInfoItem;
import com.android.loganalysis.item.ProcrankItem;
@@ -44,6 +45,8 @@ import java.util.regex.Pattern;
public class BugreportParser extends AbstractSectionParser {
private static final String MEM_INFO_SECTION_REGEX = "------ MEMORY INFO .*";
private static final String PROCRANK_SECTION_REGEX = "------ PROCRANK .*";
+ private static final String KERNEL_LOG_SECTION_REGEX = "------ KERNEL LOG .*";
+ private static final String LAST_KMSG_SECTION_REGEX = "------ LAST KMSG .*";
private static final String TOP_SECTION_REGEX = "------ CPU INFO .*";
private static final String SYSTEM_PROP_SECTION_REGEX = "------ SYSTEM PROPERTIES .*";
private static final String SYSTEM_LOG_SECTION_REGEX =
@@ -76,6 +79,8 @@ public class BugreportParser extends AbstractSectionParser {
private TopParser mTopParser = new TopParser();
private SystemPropsParser mSystemPropsParser = new SystemPropsParser();
private TracesParser mTracesParser = new TracesParser();
+ private KernelLogParser mKernelLogParser = new KernelLogParser();
+ private KernelLogParser mLastKmsgParser = new KernelLogParser();
private LogcatParser mLogcatParser = new LogcatParser();
private DumpsysParser mDumpsysParser = new DumpsysParser();
private BugreportItem mBugreport = null;
@@ -128,6 +133,8 @@ public class BugreportParser extends AbstractSectionParser {
addSectionParser(mSystemPropsParser, SYSTEM_PROP_SECTION_REGEX);
addSectionParser(mTracesParser, ANR_TRACES_SECTION_REGEX);
addSectionParser(mLogcatParser, SYSTEM_LOG_SECTION_REGEX);
+ addSectionParser(mKernelLogParser, KERNEL_LOG_SECTION_REGEX);
+ addSectionParser(mLastKmsgParser, LAST_KMSG_SECTION_REGEX);
addSectionParser(mDumpsysParser, DUMPSYS_SECTION_REGEX);
addSectionParser(new NoopParser(), NOOP_SECTION_REGEX);
}
@@ -145,6 +152,8 @@ public class BugreportParser extends AbstractSectionParser {
mBugreport.setProcrank((ProcrankItem) getSection(mProcrankParser));
mBugreport.setTop((TopItem) getSection(mTopParser));
mBugreport.setSystemLog((LogcatItem) getSection(mLogcatParser));
+ mBugreport.setKernelLog((KernelLogItem) getSection(mKernelLogParser));
+ mBugreport.setLastKmsg((KernelLogItem) getSection(mLastKmsgParser));
mBugreport.setSystemProps((SystemPropsItem) getSection(mSystemPropsParser));
mBugreport.setDumpsys((DumpsysItem) getSection(mDumpsysParser));
diff --git a/tests/src/com/android/loganalysis/parser/BugreportParserTest.java b/tests/src/com/android/loganalysis/parser/BugreportParserTest.java
index 5edf61a..485de3e 100644
--- a/tests/src/com/android/loganalysis/parser/BugreportParserTest.java
+++ b/tests/src/com/android/loganalysis/parser/BugreportParserTest.java
@@ -49,6 +49,11 @@ public class BugreportParserTest extends TestCase {
"Cached: 86204 kB",
"SwapCached: 0 kB",
"",
+ "------ CPU INFO (top -n 1 -d 1 -m 30 -t) ------",
+ "",
+ "User 3%, System 3%, IOW 0%, IRQ 0%",
+ "User 33 + Nice 0 + Sys 32 + Idle 929 + IOW 0 + IRQ 0 + SIRQ 0 = 994",
+ "",
"------ PROCRANK (procrank) ------",
" PID Vss Rss Pss Uss cmdline",
" 178 87136K 81684K 52829K 50012K system_server",
@@ -59,6 +64,11 @@ public class BugreportParserTest extends TestCase {
"RAM: 731448K total, 415804K free, 9016K buffers, 108548K cached",
"[procrank: 1.6s elapsed]",
"",
+ "------ KERNEL LOG (dmesg) ------",
+ "<6>[ 0.000000] Initializing cgroup subsys cpu",
+ "<3>[ 1.000000] benign message",
+ "",
+ "",
"------ SYSTEM LOG (logcat -v threadtime -d *:v) ------",
"04-25 09:55:47.799 3064 3082 E AndroidRuntime: java.lang.Exception",
"04-25 09:55:47.799 3064 3082 E AndroidRuntime: \tat class.method1(Class.java:1)",
@@ -79,6 +89,10 @@ public class BugreportParserTest extends TestCase {
"[dalvik.vm.heapsize]: [256m]",
"[gsm.version.ril-impl]: [android moto-ril-multimode 1.0]",
"",
+ "------ LAST KMSG (/proc/last_kmsg) ------",
+ "[ 0.000000] Initializing cgroup subsys cpu",
+ "[ 16.203491] benight message",
+ "",
"------ SECTION ------",
"",
"------ VM TRACES AT LAST ANR (/data/anr/traces.txt: 2012-04-25 17:17:08) ------",
@@ -120,9 +134,15 @@ public class BugreportParserTest extends TestCase {
assertNotNull(bugreport.getMemInfo());
assertEquals(5, bugreport.getMemInfo().size());
+ assertNotNull(bugreport.getTop());
+ assertEquals(994, bugreport.getTop().getTotal());
+
assertNotNull(bugreport.getProcrank());
assertEquals(3, bugreport.getProcrank().getPids().size());
+ assertNotNull(bugreport.getKernelLog());
+ assertEquals(1.0, bugreport.getKernelLog().getStopTime(), 0.000005);
+
assertNotNull(bugreport.getSystemLog());
assertEquals(parseTime("2012-04-25 09:55:47.799"), bugreport.getSystemLog().getStartTime());
assertEquals(parseTime("2012-04-25 18:33:27.273"), bugreport.getSystemLog().getStopTime());
@@ -130,6 +150,9 @@ public class BugreportParserTest extends TestCase {
assertEquals(1, bugreport.getSystemLog().getAnrs().size());
assertNotNull(bugreport.getSystemLog().getAnrs().get(0).getTrace());
+ assertNotNull(bugreport.getLastKmsg());
+ assertEquals(16.203491, bugreport.getLastKmsg().getStopTime(), 0.000005);
+
assertNotNull(bugreport.getSystemProps());
assertEquals(4, bugreport.getSystemProps().size());