From 54d3cd2cc5349ef02eaa59a161421b12f141409d Mon Sep 17 00:00:00 2001 From: Lisa Liu Date: Tue, 1 Nov 2022 02:05:52 +0000 Subject: Add mount_all command parsing to DmesgParser [ 2.295667] init: Command 'mount_all --late' action=late-fs (/vendor/etc/init/init.rc:347) took 250ms and succeeded Bug: 233968506 Test: loganalysis-tests Change-Id: I976c66f0df6607019c7de71ca66895bb1d7f1152 --- .../android/loganalysis/parser/DmesgParser.java | 65 +++++++++++++++------- 1 file changed, 44 insertions(+), 21 deletions(-) (limited to 'src/com/android/loganalysis/parser/DmesgParser.java') diff --git a/src/com/android/loganalysis/parser/DmesgParser.java b/src/com/android/loganalysis/parser/DmesgParser.java index 53514d2..f7aac4d 100644 --- a/src/com/android/loganalysis/parser/DmesgParser.java +++ b/src/com/android/loganalysis/parser/DmesgParser.java @@ -47,6 +47,7 @@ public class DmesgParser implements IParser { private static final String INIT = "init"; private static final String WAIT_PROPERTY = "Wait for property "; private static final String TOTAL_MODULE = "TOTAL_MODULE"; + private static final String MOUNT_ALL = "mount_all"; // Matches: [ 14.822691] init: private static final String SERVICE_PREFIX = String.format("^\\[\\s+(?<%s>.*)\\] init:\\s+", @@ -106,8 +107,8 @@ public class DmesgParser implements IParser { "%sLoaded kernel module \\S+\\/(?\\S+)\\.ko", SERVICE_PREFIX)); // Matches: [ 3.791635] ueventd: Coldboot took 0.695055 seconds - private static final String STAGE_SUFFIX= String.format( - "(?<%s>.*)\\s+took\\s+(?<%s>.*)\\s+seconds$", STAGE, DURATION); + private static final String STAGE_SUFFIX = + String.format("(?<%s>.*)\\s+took\\s+(?<%s>.*)\\s+seconds$", STAGE, DURATION); private static final Pattern UEVENTD_STAGE_INFO = Pattern.compile( String.format("%s%s", UEVENTD_PREFIX, STAGE_SUFFIX)); @@ -117,6 +118,15 @@ public class DmesgParser implements IParser { private static final Pattern WAIT_FOR_PROPERTY_INFO = Pattern.compile( String.format("%s%s", SERVICE_PREFIX, PROPERTY_SUFFIX)); + // Matches: [ 2.295667] init: Command 'mount_all --late' action=late-fs + // (/vendor/etc/init/init.rc:347) took 250ms and succeeded + private static final String MOUNT_SUFFIX = + String.format( + "Command 'mount_all (?<%s>/\\S+|.*)?--(?<%s>.+)'.* took (?<%s>\\d+)ms.*", + SOURCE, STAGE, DURATION); + private static final Pattern MOUNT_STAGE_INFO = + Pattern.compile(String.format("%s%s", SERVICE_PREFIX, MOUNT_SUFFIX)); + private DmesgItem mDmesgItem = new DmesgItem(); /** @@ -134,10 +144,10 @@ public class DmesgParser implements IParser { /** * Parse the kernel log till EOF to retrieve the duration of the service calls, start times of * different boot stages and actions taken. Besides, while parsing these informations are stored - * in the intermediate {@link DmesgServiceInfoItem}, {@link DmesgStageInfoItem} and - * {@link DmesgActionInfoItem} objects + * in the intermediate {@link DmesgServiceInfoItem}, {@link DmesgStageInfoItem} and {@link + * DmesgActionInfoItem} objects * - * @param input dmesg log + * @param bufferedLog dmesg log * @throws IOException */ public DmesgItem parseInfo(BufferedReader bufferedLog) throws IOException { @@ -184,9 +194,9 @@ public class DmesgParser implements IParser { * log and store the {@code duration} it took to complete the service if the end time stamp is * available in {@link DmesgServiceInfoItem}. * - * @param individual line of the dmesg log - * @return {@code true}, if the {@code line} indicates start or end of a service, - * {@code false}, otherwise + * @param line individual line of the dmesg log + * @return {@code true}, if the {@code line} indicates start or end of a service, {@code false}, + * otherwise */ @VisibleForTesting boolean parseServiceInfo(String line) { @@ -211,13 +221,12 @@ public class DmesgParser implements IParser { } /** - * Parse init stages log from each {@code line} of dmesg log and - * store the stage name, start time and duration if available in a - * {@link DmesgStageInfoItem} object + * Parse init stages log from each {@code line} of dmesg log and store the stage name, start + * time and duration if available in a {@link DmesgStageInfoItem} object * - * @param individual line of the dmesg log - * @return {@code true}, if the {@code line} indicates start of a boot stage, - * {@code false}, otherwise + * @param line individual line of the dmesg log + * @return {@code true}, if the {@code line} indicates start of a boot stage, {@code false}, + * otherwise */ @VisibleForTesting boolean parseStageInfo(String line) { @@ -246,17 +255,31 @@ public class DmesgParser implements IParser { mDmesgItem.addStageInfoItem(stageInfoItem); return true; } - + if ((match = matches(MOUNT_STAGE_INFO, line)) != null) { + DmesgStageInfoItem stageInfoItem = new DmesgStageInfoItem(); + if (match.group(SOURCE).isEmpty()) { + stageInfoItem.setStageName( + String.format("%s_%s_%s", INIT, MOUNT_ALL, match.group(STAGE))); + } else { + stageInfoItem.setStageName( + String.format( + "%s_%s_%s_%s", + INIT, MOUNT_ALL, match.group(STAGE), match.group(SOURCE).trim())); + } + stageInfoItem.setDuration((long) Double.parseDouble(match.group(DURATION))); + mDmesgItem.addStageInfoItem(stageInfoItem); + return true; + } return false; } /** - * Parse action from each {@code line} of dmesg log and store the action name and start time - * in {@link DmesgActionInfoItem} object + * Parse action from each {@code line} of dmesg log and store the action name and start time in + * {@link DmesgActionInfoItem} object * - * @param individual {@code line} of the dmesg log - * @return {@code true}, if {@code line} indicates starting of processing of action - * {@code false}, otherwise + * @param line individual {@code line} of the dmesg log + * @return {@code true}, if {@code line} indicates starting of processing of action {@code + * false}, otherwise */ @VisibleForTesting boolean parseActionInfo(String line) { @@ -279,7 +302,7 @@ public class DmesgParser implements IParser { * Parse modules from each {@code line} of dmesg log and store the module name and loading time * in {@link DmesgModuleInfoItem} object * - * @param individual {@code line} of the dmesg log + * @param line individual {@code line} of the dmesg log * @return {@code true}, if {@code line} indicates start, end of a module loading or the summary * {@code false}, otherwise */ -- cgit v1.2.3