static char cmdline_buf[16384] = "(unknown)";
static const char *dump_traces_path = NULL;
-// TODO: should be part of dumpstate object
+// TODO: variables below should be part of dumpstate object
static unsigned long id;
static char build_type[PROPERTY_VALUE_MAX];
static time_t now;
static bool add_zip_entry(const std::string& entry_name, const std::string& entry_path);
static bool add_zip_entry_from_fd(const std::string& entry_name, int fd);
static int control_socket_fd;
+/* full path of the directory where the bugreport files will be written */
+static std::string bugreport_dir;
+/* suffix of the bugreport files - it's typically the date (when invoked with -d),
+ * although it could be changed by the user using a system property */
+static std::string suffix;
#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"
closedir(d);
}
-static void dump_systrace(const std::string& systrace_path) {
+static void dump_systrace() {
if (!zip_writer) {
MYLOGD("Not dumping systrace because zip_writer is not set\n");
return;
}
+ std::string systrace_path = bugreport_dir + "/systrace-" + suffix + ".txt";
if (systrace_path.empty()) {
MYLOGE("Not dumping systrace because path is empty\n");
return;
}
}
+static void dump_raft() {
+ if (is_user_build()) {
+ return;
+ }
+
+ std::string raft_log_path = bugreport_dir + "/raft_log.txt";
+ 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\n", 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);
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);
control_socket_fd = open_socket("dumpstate");
}
- /* full path of the directory where the bugreport files will be written */
- std::string bugreport_dir;
-
/* full path of the temporary file containing the bugreport */
std::string tmp_path;
/* base name (without suffix or extensions) of the bugreport files */
std::string base_name;
- /* suffix of the bugreport files - it's typically the date (when invoked with -d),
- * although it could be changed by the user using a system property */
- std::string suffix;
-
/* pointer to the actual path, be it zip or text */
std::string path;
tmp_path = bugreport_dir + "/" + base_name + "-" + suffix + ".tmp";
log_path = bugreport_dir + "/dumpstate_log-" + suffix + "-"
+ std::to_string(getpid()) + ".txt";
- systrace_path = bugreport_dir + "/systrace-" + suffix + ".txt";
MYLOGD("Bugreport dir: %s\n"
"Base name: %s\n"
print_header(version);
// Dumps systrace right away, otherwise it will be filled with unnecessary events.
- dump_systrace(systrace_path);
+ dump_systrace();
+
+ // TODO: Drop root user and move into dumpstate() once b/28633932 is fixed.
+ dump_raft();
// Invoking the following dumpsys calls before dump_traces() to try and
// keep the system stats as close to its initial state as possible.
{ AKEYCODE_DPAD_RIGHT, AKEYCODE_DPAD_UP, AKEYCODE_DPAD_LEFT, AKEYCODE_DPAD_DOWN },
{ AKEYCODE_DPAD_UP, AKEYCODE_DPAD_LEFT, AKEYCODE_DPAD_DOWN, AKEYCODE_DPAD_RIGHT },
{ AKEYCODE_DPAD_LEFT, AKEYCODE_DPAD_DOWN, AKEYCODE_DPAD_RIGHT, AKEYCODE_DPAD_UP },
+ { AKEYCODE_FP_NAV_DOWN, AKEYCODE_FP_NAV_RIGHT, AKEYCODE_FP_NAV_UP, AKEYCODE_FP_NAV_LEFT },
+ { AKEYCODE_FP_NAV_RIGHT, AKEYCODE_FP_NAV_UP, AKEYCODE_FP_NAV_LEFT, AKEYCODE_FP_NAV_DOWN },
+ { AKEYCODE_FP_NAV_UP, AKEYCODE_FP_NAV_LEFT, AKEYCODE_FP_NAV_DOWN, AKEYCODE_FP_NAV_RIGHT },
+ { AKEYCODE_FP_NAV_LEFT, AKEYCODE_FP_NAV_DOWN, AKEYCODE_FP_NAV_RIGHT, AKEYCODE_FP_NAV_UP },
};
static const size_t keyCodeRotationMapSize =
sizeof(keyCodeRotationMap) / sizeof(keyCodeRotationMap[0]);