Loading cmds/dumpstate/dumpstate.cpp +114 −86 Original line number Diff line number Diff line Loading @@ -820,9 +820,63 @@ static void dump_iptables() { run_command("IP6TABLES RAW", 10, "ip6tables", "-t", "raw", "-L", "-nvx", NULL); } static void do_kmsg() { struct stat st; if (!stat(PSTORE_LAST_KMSG, &st)) { /* Also TODO: Make console-ramoops CAP_SYSLOG protected. */ dump_file("LAST KMSG", PSTORE_LAST_KMSG); } else if (!stat(ALT_PSTORE_LAST_KMSG, &st)) { dump_file("LAST KMSG", ALT_PSTORE_LAST_KMSG); } else { /* TODO: Make last_kmsg CAP_SYSLOG protected. b/5555691 */ dump_file("LAST KMSG", "/proc/last_kmsg"); } } static void do_logcat() { unsigned long timeout; // dump_file("EVENT LOG TAGS", "/etc/event-log-tags"); // calculate timeout timeout = logcat_timeout("main") + logcat_timeout("system") + logcat_timeout("crash"); if (timeout < 20000) { timeout = 20000; } run_command("SYSTEM LOG", timeout / 1000, "logcat", "-v", "threadtime", "-v", "printable", "-d", "*:v", NULL); timeout = logcat_timeout("events"); if (timeout < 20000) { timeout = 20000; } run_command("EVENT LOG", timeout / 1000, "logcat", "-b", "events", "-v", "threadtime", "-v", "printable", "-d", "*:v", NULL); timeout = logcat_timeout("radio"); if (timeout < 20000) { timeout = 20000; } run_command("RADIO LOG", timeout / 1000, "logcat", "-b", "radio", "-v", "threadtime", "-v", "printable", "-d", "*:v", NULL); run_command("LOG STATISTICS", 10, "logcat", "-b", "all", "-S", NULL); /* kernels must set CONFIG_PSTORE_PMSG, slice up pstore with device tree */ run_command("LAST LOGCAT", 10, "logcat", "-L", "-b", "all", "-v", "threadtime", "-v", "printable", "-d", "*:v", NULL); } static void dumpstate(const std::string& screenshot_path, const std::string& version) { DurationReporter duration_reporter("DUMPSTATE"); unsigned long timeout; dump_dev_files("TRUSTY VERSION", "/sys/bus/platform/drivers/trusty", "trusty_version"); run_command("UPTIME", 10, "uptime", NULL); Loading Loading @@ -868,36 +922,7 @@ static void dumpstate(const std::string& screenshot_path, const std::string& ver MYLOGI("wrote screenshot: %s\n", screenshot_path.c_str()); } // dump_file("EVENT LOG TAGS", "/etc/event-log-tags"); // calculate timeout timeout = logcat_timeout("main") + logcat_timeout("system") + logcat_timeout("crash"); if (timeout < 20000) { timeout = 20000; } run_command("SYSTEM LOG", timeout / 1000, "logcat", "-v", "threadtime", "-v", "printable", "-d", "*:v", NULL); timeout = logcat_timeout("events"); if (timeout < 20000) { timeout = 20000; } run_command("EVENT LOG", timeout / 1000, "logcat", "-b", "events", "-v", "threadtime", "-v", "printable", "-d", "*:v", NULL); timeout = logcat_timeout("radio"); if (timeout < 20000) { timeout = 20000; } run_command("RADIO LOG", timeout / 1000, "logcat", "-b", "radio", "-v", "threadtime", "-v", "printable", "-d", "*:v", NULL); run_command("LOG STATISTICS", 10, "logcat", "-b", "all", "-S", NULL); do_logcat(); /* show the traces we collected in main(), if that was done */ if (dump_traces_path != NULL) { Loading Loading @@ -965,23 +990,7 @@ static void dumpstate(const std::string& screenshot_path, const std::string& ver dump_file("QTAGUID CTRL INFO", "/proc/net/xt_qtaguid/ctrl"); dump_file("QTAGUID STATS INFO", "/proc/net/xt_qtaguid/stats"); if (!stat(PSTORE_LAST_KMSG, &st)) { /* Also TODO: Make console-ramoops CAP_SYSLOG protected. */ dump_file("LAST KMSG", PSTORE_LAST_KMSG); } else if (!stat(ALT_PSTORE_LAST_KMSG, &st)) { dump_file("LAST KMSG", ALT_PSTORE_LAST_KMSG); } else { /* TODO: Make last_kmsg CAP_SYSLOG protected. b/5555691 */ dump_file("LAST KMSG", "/proc/last_kmsg"); } /* kernels must set CONFIG_PSTORE_PMSG, slice up pstore with device tree */ run_command("LAST LOGCAT", 10, "logcat", "-L", "-b", "all", "-v", "threadtime", "-v", "printable", "-d", "*:v", NULL); do_kmsg(); /* The following have a tendency to get wedged when wifi drivers/fw goes belly-up. */ Loading Loading @@ -1129,14 +1138,15 @@ static void dumpstate(const std::string& screenshot_path, const std::string& ver static void usage() { fprintf(stderr, "usage: dumpstate [-h] [-b soundfile] [-e soundfile] [-o file [-d] [-p] " "[-z]] [-s] [-S] [-q] [-B] [-P] [-R] [-V version]\n" "usage: dumpstate [-h] [-b soundfile] [-e soundfile] [-o file [-d] [-p] [-t]" "[-z] [-s] [-S] [-q] [-B] [-P] [-R] [-V version]\n" " -h: display this help message\n" " -b: play sound file instead of vibrate, at beginning of job\n" " -e: play sound file instead of vibrate, at end of job\n" " -o: write to file (instead of stdout)\n" " -d: append date to filename (requires -o)\n" " -p: capture screenshot to filename.png (requires -o)\n" " -t: only captures telephony sections\n" " -z: generate zipped file (requires -o)\n" " -s: write output to control socket (for init)\n" " -S: write file location to control socket (for init; requires -o and -z)" Loading Loading @@ -1234,6 +1244,8 @@ int main(int argc, char *argv[]) { int do_broadcast = 0; int do_early_screenshot = 0; int is_remote_mode = 0; bool telephony_only = false; std::string version = VERSION_DEFAULT; now = time(NULL); Loading Loading @@ -1274,9 +1286,10 @@ int main(int argc, char *argv[]) { format_args(argc, const_cast<const char **>(argv), &args); MYLOGD("Dumpstate command line: %s\n", args.c_str()); int c; while ((c = getopt(argc, argv, "dho:svqzpPBRSV:")) != -1) { while ((c = getopt(argc, argv, "dho:svqzptPBRSV:")) != -1) { switch (c) { case 'd': do_add_date = 1; break; case 't': telephony_only = true; break; case 'z': do_zip_file = 1; break; case 'o': use_outfile = optarg; break; case 's': use_socket = 1; break; Loading Loading @@ -1373,6 +1386,9 @@ int main(int argc, char *argv[]) { char build_id[PROPERTY_VALUE_MAX]; property_get("ro.build.id", build_id, "UNKNOWN_BUILD"); base_name = base_name + "-" + build_id; if (telephony_only) { base_name = base_name + "-telephony"; } if (do_fb) { // TODO: if dumpstate was an object, the paths could be internal variables and then // we could have a function to calculate the derived values, such as: Loading Loading @@ -1482,6 +1498,17 @@ int main(int argc, char *argv[]) { // duration is logged into MYLOG instead. print_header(version); if (telephony_only) { dump_iptables(); if (!drop_root_user()) { return -1; } do_dmesg(); do_logcat(); do_kmsg(); dumpstate_board(); dump_modem_logs(); } else { // Dumps systrace right away, otherwise it will be filled with unnecessary events. // First try to dump anrd trace if the daemon is running. Otherwise, dump // the raw trace. Loading Loading @@ -1523,6 +1550,7 @@ int main(int argc, char *argv[]) { } dumpstate(do_early_screenshot ? "": screenshot_path, version); } /* close output if needed */ if (is_redirecting) { Loading cmds/dumpstate/dumpstate.rc +8 −0 Original line number Diff line number Diff line Loading @@ -46,3 +46,11 @@ service bugreportwear /system/bin/dumpstate -d -B -P -p -z \ class main disabled oneshot # bugreportelefony is a lightweight version of bugreport that only includes a few, urgent # sections used to report telephony bugs. service bugreportelefony /system/bin/dumpstate -t -d -B -z \ -o /data/user_de/0/com.android.shell/files/bugreports/bugreport class main disabled oneshot Loading
cmds/dumpstate/dumpstate.cpp +114 −86 Original line number Diff line number Diff line Loading @@ -820,9 +820,63 @@ static void dump_iptables() { run_command("IP6TABLES RAW", 10, "ip6tables", "-t", "raw", "-L", "-nvx", NULL); } static void do_kmsg() { struct stat st; if (!stat(PSTORE_LAST_KMSG, &st)) { /* Also TODO: Make console-ramoops CAP_SYSLOG protected. */ dump_file("LAST KMSG", PSTORE_LAST_KMSG); } else if (!stat(ALT_PSTORE_LAST_KMSG, &st)) { dump_file("LAST KMSG", ALT_PSTORE_LAST_KMSG); } else { /* TODO: Make last_kmsg CAP_SYSLOG protected. b/5555691 */ dump_file("LAST KMSG", "/proc/last_kmsg"); } } static void do_logcat() { unsigned long timeout; // dump_file("EVENT LOG TAGS", "/etc/event-log-tags"); // calculate timeout timeout = logcat_timeout("main") + logcat_timeout("system") + logcat_timeout("crash"); if (timeout < 20000) { timeout = 20000; } run_command("SYSTEM LOG", timeout / 1000, "logcat", "-v", "threadtime", "-v", "printable", "-d", "*:v", NULL); timeout = logcat_timeout("events"); if (timeout < 20000) { timeout = 20000; } run_command("EVENT LOG", timeout / 1000, "logcat", "-b", "events", "-v", "threadtime", "-v", "printable", "-d", "*:v", NULL); timeout = logcat_timeout("radio"); if (timeout < 20000) { timeout = 20000; } run_command("RADIO LOG", timeout / 1000, "logcat", "-b", "radio", "-v", "threadtime", "-v", "printable", "-d", "*:v", NULL); run_command("LOG STATISTICS", 10, "logcat", "-b", "all", "-S", NULL); /* kernels must set CONFIG_PSTORE_PMSG, slice up pstore with device tree */ run_command("LAST LOGCAT", 10, "logcat", "-L", "-b", "all", "-v", "threadtime", "-v", "printable", "-d", "*:v", NULL); } static void dumpstate(const std::string& screenshot_path, const std::string& version) { DurationReporter duration_reporter("DUMPSTATE"); unsigned long timeout; dump_dev_files("TRUSTY VERSION", "/sys/bus/platform/drivers/trusty", "trusty_version"); run_command("UPTIME", 10, "uptime", NULL); Loading Loading @@ -868,36 +922,7 @@ static void dumpstate(const std::string& screenshot_path, const std::string& ver MYLOGI("wrote screenshot: %s\n", screenshot_path.c_str()); } // dump_file("EVENT LOG TAGS", "/etc/event-log-tags"); // calculate timeout timeout = logcat_timeout("main") + logcat_timeout("system") + logcat_timeout("crash"); if (timeout < 20000) { timeout = 20000; } run_command("SYSTEM LOG", timeout / 1000, "logcat", "-v", "threadtime", "-v", "printable", "-d", "*:v", NULL); timeout = logcat_timeout("events"); if (timeout < 20000) { timeout = 20000; } run_command("EVENT LOG", timeout / 1000, "logcat", "-b", "events", "-v", "threadtime", "-v", "printable", "-d", "*:v", NULL); timeout = logcat_timeout("radio"); if (timeout < 20000) { timeout = 20000; } run_command("RADIO LOG", timeout / 1000, "logcat", "-b", "radio", "-v", "threadtime", "-v", "printable", "-d", "*:v", NULL); run_command("LOG STATISTICS", 10, "logcat", "-b", "all", "-S", NULL); do_logcat(); /* show the traces we collected in main(), if that was done */ if (dump_traces_path != NULL) { Loading Loading @@ -965,23 +990,7 @@ static void dumpstate(const std::string& screenshot_path, const std::string& ver dump_file("QTAGUID CTRL INFO", "/proc/net/xt_qtaguid/ctrl"); dump_file("QTAGUID STATS INFO", "/proc/net/xt_qtaguid/stats"); if (!stat(PSTORE_LAST_KMSG, &st)) { /* Also TODO: Make console-ramoops CAP_SYSLOG protected. */ dump_file("LAST KMSG", PSTORE_LAST_KMSG); } else if (!stat(ALT_PSTORE_LAST_KMSG, &st)) { dump_file("LAST KMSG", ALT_PSTORE_LAST_KMSG); } else { /* TODO: Make last_kmsg CAP_SYSLOG protected. b/5555691 */ dump_file("LAST KMSG", "/proc/last_kmsg"); } /* kernels must set CONFIG_PSTORE_PMSG, slice up pstore with device tree */ run_command("LAST LOGCAT", 10, "logcat", "-L", "-b", "all", "-v", "threadtime", "-v", "printable", "-d", "*:v", NULL); do_kmsg(); /* The following have a tendency to get wedged when wifi drivers/fw goes belly-up. */ Loading Loading @@ -1129,14 +1138,15 @@ static void dumpstate(const std::string& screenshot_path, const std::string& ver static void usage() { fprintf(stderr, "usage: dumpstate [-h] [-b soundfile] [-e soundfile] [-o file [-d] [-p] " "[-z]] [-s] [-S] [-q] [-B] [-P] [-R] [-V version]\n" "usage: dumpstate [-h] [-b soundfile] [-e soundfile] [-o file [-d] [-p] [-t]" "[-z] [-s] [-S] [-q] [-B] [-P] [-R] [-V version]\n" " -h: display this help message\n" " -b: play sound file instead of vibrate, at beginning of job\n" " -e: play sound file instead of vibrate, at end of job\n" " -o: write to file (instead of stdout)\n" " -d: append date to filename (requires -o)\n" " -p: capture screenshot to filename.png (requires -o)\n" " -t: only captures telephony sections\n" " -z: generate zipped file (requires -o)\n" " -s: write output to control socket (for init)\n" " -S: write file location to control socket (for init; requires -o and -z)" Loading Loading @@ -1234,6 +1244,8 @@ int main(int argc, char *argv[]) { int do_broadcast = 0; int do_early_screenshot = 0; int is_remote_mode = 0; bool telephony_only = false; std::string version = VERSION_DEFAULT; now = time(NULL); Loading Loading @@ -1274,9 +1286,10 @@ int main(int argc, char *argv[]) { format_args(argc, const_cast<const char **>(argv), &args); MYLOGD("Dumpstate command line: %s\n", args.c_str()); int c; while ((c = getopt(argc, argv, "dho:svqzpPBRSV:")) != -1) { while ((c = getopt(argc, argv, "dho:svqzptPBRSV:")) != -1) { switch (c) { case 'd': do_add_date = 1; break; case 't': telephony_only = true; break; case 'z': do_zip_file = 1; break; case 'o': use_outfile = optarg; break; case 's': use_socket = 1; break; Loading Loading @@ -1373,6 +1386,9 @@ int main(int argc, char *argv[]) { char build_id[PROPERTY_VALUE_MAX]; property_get("ro.build.id", build_id, "UNKNOWN_BUILD"); base_name = base_name + "-" + build_id; if (telephony_only) { base_name = base_name + "-telephony"; } if (do_fb) { // TODO: if dumpstate was an object, the paths could be internal variables and then // we could have a function to calculate the derived values, such as: Loading Loading @@ -1482,6 +1498,17 @@ int main(int argc, char *argv[]) { // duration is logged into MYLOG instead. print_header(version); if (telephony_only) { dump_iptables(); if (!drop_root_user()) { return -1; } do_dmesg(); do_logcat(); do_kmsg(); dumpstate_board(); dump_modem_logs(); } else { // Dumps systrace right away, otherwise it will be filled with unnecessary events. // First try to dump anrd trace if the daemon is running. Otherwise, dump // the raw trace. Loading Loading @@ -1523,6 +1550,7 @@ int main(int argc, char *argv[]) { } dumpstate(do_early_screenshot ? "": screenshot_path, version); } /* close output if needed */ if (is_redirecting) { Loading
cmds/dumpstate/dumpstate.rc +8 −0 Original line number Diff line number Diff line Loading @@ -46,3 +46,11 @@ service bugreportwear /system/bin/dumpstate -d -B -P -p -z \ class main disabled oneshot # bugreportelefony is a lightweight version of bugreport that only includes a few, urgent # sections used to report telephony bugs. service bugreportelefony /system/bin/dumpstate -t -d -B -z \ -o /data/user_de/0/com.android.shell/files/bugreports/bugreport class main disabled oneshot