Dump the raft logs into the bugreport zip file.
b/28430346
Change-Id: I3821dad5d33cdb38234f0ee6768f7d24159a4283
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index b731c53..2d17318 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -67,7 +67,7 @@
#define PSTORE_LAST_KMSG "/sys/fs/pstore/console-ramoops"
-#define RAFT_DIR "/data/misc/raft/"
+#define RAFT_DIR "/data/misc/raft"
#define RECOVERY_DIR "/cache/recovery"
#define RECOVERY_DATA_DIR "/data/misc/recovery"
#define LOGPERSIST_DATA_DIR "/data/misc/logd"
@@ -215,6 +215,31 @@
}
}
+static void dump_raft(const std::string raft_log_path) {
+ if (is_user_build()) {
+ return;
+ }
+
+ if (raft_log_path.empty()) {
+ MYLOGD("raft_log_path is empty\n");
+ return;
+ }
+ if (!zip_writer) {
+ MYLOGD("Not dumping raft because zip_writer is not set\n");
+ return;
+ }
+
+ run_command("RAFT LOGS", 600, "logcompressor", "-n", "-r", RAFT_DIR,
+ "-o", raft_log_path.c_str(), NULL);
+ if (!add_zip_entry("raft_log.txt", raft_log_path)) {
+ MYLOGE("Unable to add raft log %s to zip file\n", raft_log_path.c_str());
+ } else {
+ if (remove(raft_log_path.c_str())) {
+ MYLOGE("Error removing raft file %s: %s", raft_log_path.c_str(), strerror(errno));
+ }
+ }
+}
+
static bool skip_not_stat(const char *path) {
static const char stat[] = "/stat";
size_t len = strlen(path);
@@ -700,8 +725,6 @@
run_command("LOG STATISTICS", 10, "logcat", "-b", "all", "-S", NULL);
- run_command("RAFT LOGS", 600, SU_PATH, "root", "logcompressor", "-r", RAFT_DIR, NULL);
-
/* show the traces we collected in main(), if that was done */
if (dump_traces_path != NULL) {
dump_file("VM TRACES JUST NOW", dump_traces_path);
@@ -1140,6 +1163,9 @@
/* full path of the file containing the dumpstate logs*/
std::string log_path;
+ /* full path of the file containing the raft logs */
+ std::string raft_log_path;
+
/* full path of the systrace file, when enabled */
std::string systrace_path;
@@ -1185,6 +1211,7 @@
log_path = bugreport_dir + "/dumpstate_log-" + suffix + "-"
+ std::to_string(getpid()) + ".txt";
systrace_path = bugreport_dir + "/systrace-" + suffix + ".txt";
+ raft_log_path = bugreport_dir + "/raft_log.txt";
MYLOGD("Bugreport dir: %s\n"
"Base name: %s\n"
@@ -1281,6 +1308,9 @@
// Dumps systrace right away, otherwise it will be filled with unnecessary events.
dump_systrace(systrace_path);
+ // TODO: Drop root user and move into dumpstate() once b/28633932 is fixed.
+ dump_raft(raft_log_path);
+
// Invoking the following dumpsys calls before dump_traces() to try and
// keep the system stats as close to its initial state as possible.
run_command_as_shell("DUMPSYS MEMINFO", 30, "dumpsys", "-t", "30", "meminfo", "-a", NULL);