文章目录
1. bugreport
编译到/system/bin/bugreport
@frameworks/native/cmds/bugreport/Android.bp
cc_binary {
name: "bugreport",
srcs: ["bugreport.cpp"],
cflags: ["-Wall", "-Werror"],
shared_libs: ["libcutils"],
}
@frameworks/native/cmds/bugreport/bugreport.cpp
int main() {
//1. 不建议使用bugreport,而是使用adb bugreport
fprintf(stderr, "=============================================================================\n");
fprintf(stderr, "WARNING: flat bugreports are deprecated, use adb bugreport <zip_file> instead\n");
fprintf(stderr, "=============================================================================\n\n\n");
//2. 开始dumpstate service,打印Log
// Start the dumpstate service.
property_set("ctl.start", "dumpstate");
//3. 和dumpstate socket通信
// Socket will not be available until service starts.
int s;
for (int i = 0; i < 20; i++) {
s = socket_local_client("dumpstate", ANDROID_SOCKET_NAMESPACE_RESERVED,
SOCK_STREAM);
if (s >= 0)
break;
// Try again in 1 second.
sleep(1);
}
//4. 读写数据
while (1) {
char buffer[65536];
ssize_t bytes_read = TEMP_FAILURE_RETRY(read(s, buffer, sizeof(buffer)));
if (bytes_read == 0) {
break;
} else if (bytes_read == -1) {
// EAGAIN really means time out, so change the errno.
if (errno == EAGAIN) {
errno = ETIMEDOUT;
}
printf("\nBugreport read terminated abnormally (%s).\n", strerror(errno));
break;
}
ssize_t bytes_to_send = bytes_read;
ssize_t bytes_written;
do {
bytes_written = TEMP_FAILURE_RETRY(write(STDOUT_FILENO,
buffer + bytes_read - bytes_to_send,
bytes_to_send));
if (bytes_written == -1) {
printf("Failed to write data to stdout: read %zd, trying to send %zd (%s)\n",
bytes_read, bytes_to_send, strerror(errno));
return 1;
}
bytes_to_send -= bytes_written;
} while (bytes_written != 0 && bytes_to_send > 0);
}
close(s);
return 0;
}
2. bugreportz
/system/bin/bugreportz
@frameworks/native/cmds/bugreportz/Android.mk
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
bugreportz.cpp \
main.cpp \
LOCAL_MODULE:= bugreportz
LOCAL_CFLAGS := -Werror -Wall
LOCAL_SHARED_LIBRARIES := \
libbase \
libcutils \
include $(BUILD_EXECUTABLE)
@frameworks/native/cmds/bugreportz/main.cpp
int main(int argc, char* argv[]) {
bool show_progress = false;
//1. 使用帮助
if (argc > 1) {
/* parse arguments */
int c;
while ((c = getopt(argc, argv, "hpv")) != -1) {
switch (c) {
case 'h':
show_usage();
return EXIT_SUCCESS;
case 'p':
show_progress = true;
break;
case 'v':
show_version();
return EXIT_SUCCESS;
default:
show_usage();
return EXIT_FAILURE;
}
}
}
//2. 开始dumpstate service,打印Log
// Start the dumpstatez service.
property_set("ctl.start", "dumpstatez");
//3. 和dumpstate socket通信
// Socket will not be available until service starts.
int s;
for (int i = 0; i < 20; i++) {
s = socket_local_client("dumpstate", ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM);
if (s >= 0) break;
// Try again in 1 second.
sleep(1);
}
//4. 读写数据
bugreportz(s, show_progress);
}
3. adb bugreport
推荐使用adb bugreport
@system/core/adb/commandline.cpp
} else if (!strcmp(argv[0], "bugreport")) {
Bugreport bugreport;
return bugreport.DoIt(argc, argv);
int Bugreport::DoIt(int argc, const char** argv) {
// Gets bugreportz version.
std::string bugz_stdout, bugz_stderr;
//1. 得到bugreportz版本,不支持使用bugreport
DefaultStandardStreamsCallback version_callback(&bugz_stdout, &bugz_stderr);
int status = SendShellCommand("bugreportz -v", false, &version_callback);
if (status != 0 || bugz_version.empty()) {
D("'bugreportz' -v results: status=%d, stdout='%s', stderr='%s'", status,
bugz_output.c_str(), bugz_version.c_str());
if (argc == 1) {
// Device does not support bugreportz: if called as 'adb bugreport', just falls out to
// the flat-file version.
fprintf(stderr,
"Failed to get bugreportz version, which is only available on devices "
"running Android 7.0 or later.\nTrying a plain-text bug report instead.\n");
return SendShellCommand("bugreport", false);
}
...
}
...
//2. 一般都有bugreportz,使用bugreportz -p
bool show_progress = true;
std::string bugz_command = "bugreportz -p";
...
BugreportStandardStreamsCallback bugz_callback(dest_dir, dest_file, show_progress, this);
return SendShellCommand(bugz_command, false, &bugz_callback);
}
4. dumpstate
@frameworks/native/cmds/dumpstate/Android.bp
cc_binary {
name: "dumpstate",
defaults: ["dumpstate_defaults"],
srcs: [
"dumpstate.cpp",
"main.cpp",
],
init_rc: ["dumpstate.rc"],
}
int run_main(int argc, char* argv[]) {
/* set as high priority, and protect from OOM killer */
setpriority(PRIO_PROCESS, 0, -20);
//1. 建立socket
// If we are going to use a socket, do it as early as possible
// to avoid timeouts from bugreport.
if (use_socket) {
redirect_to_socket(stdout, "dumpstate");
}
if (use_control_socket) {
MYLOGD("Opening control socket\n");
ds.control_socket_fd_ = open_socket("dumpstate");
ds.update_progress_ = 1;
}
...
//2. dump log
dumpstate();
...
return 0;
}
run_main和dumpstate()就会打印LOG,可以对比bugreport.txt
/** Main entry point for dumpstate. */
static void dumpstate() {
DurationReporter duration_reporter("DUMPSTATE");
dump_dev_files("TRUSTY VERSION", "/sys/bus/platform/drivers/trusty", "trusty_version");
RunCommand("UPTIME", {"uptime"});
DumpBlockStatFiles();
dump_emmc_ecsd("/d/mmc0/mmc0:0001/ext_csd");
DumpFile("MEMORY INFO", "/proc/meminfo");
RunCommand("CPU INFO", {"top", "-b", "-n", "1", "-H", "-s", "6", "-o",
"pid,tid,user,pr,ni,%cpu,s,virt,res,pcy,cmd,name"});
RunCommand("PROCRANK", {"procrank"}, AS_ROOT_20);
DumpFile("VIRTUAL MEMORY STATS", "/proc/vmstat");
DumpFile("VMALLOC INFO", "/proc/vmallocinfo");
DumpFile("SLAB INFO", "/proc/slabinfo");
DumpFile("ZONEINFO", "/proc/zoneinfo");
DumpFile("PAGETYPEINFO", "/proc/pagetypeinfo");
DumpFile("BUDDYINFO", "/proc/buddyinfo");
DumpFile("FRAGMENTATION INFO", "/d/extfrag/unusable_index");
DumpFile("KERNEL WAKE SOURCES", "/d/wakeup_sources");
DumpFile("KERNEL CPUFREQ", "/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state");
DumpFile("KERNEL SYNC", "/d/sync");
RunCommand("PROCESSES AND THREADS",
{"ps", "-A", "-T", "-Z", "-O", "pri,nice,rtprio,sched,pcy,time"});
RunCommand("LIBRANK", {"librank"}, CommandOptions::AS_ROOT);
if (ds.IsZipping()) {
RunCommand("HARDWARE HALS", {"lshal"}, CommandOptions::WithTimeout(2).AsRootIfAvailable().Build());
DumpHals();
} else {
RunCommand("HARDWARE HALS", {"lshal", "--debug"}, CommandOptions::WithTimeout(10).AsRootIfAvailable().Build());
}
RunCommand("PRINTENV", {"printenv"});
RunCommand("NETSTAT", {"netstat", "-nW"});
struct stat s;
if (stat("/proc/modules", &s) != 0) {
MYLOGD("Skipping 'lsmod' because /proc/modules does not exist\n");
} else {
RunCommand("LSMOD", {"lsmod"});
}
if (__android_logger_property_get_bool(
"ro.logd.kernel", BOOL_DEFAULT_TRUE | BOOL_DEFAULT_FLAG_ENG | BOOL_DEFAULT_FLAG_SVELTE)) {
DoKernelLogcat();
} else {
do_dmesg();
}
RunCommand("LIST OF OPEN FILES", {"lsof"}, CommandOptions::AS_ROOT);
for_each_pid(do_showmap, "SMAPS OF ALL PROCESSES");
for_each_tid(show_wchan, "BLOCKED PROCESS WAIT-CHANNELS");
for_each_pid(show_showtime, "PROCESS TIMES (pid cmd user system iowait+percentage)");
/* Dump Bluetooth HCI logs */
ds.AddDir("/data/misc/bluetooth/logs", true);
if (!ds.do_early_screenshot_) {
MYLOGI("taking late screenshot\n");
ds.TakeScreenshot();
}
DoLogcat();
AddAnrTraceFiles();
// NOTE: tombstones are always added as separate entries in the zip archive
// and are not interspersed with the main report.
const bool tombstones_dumped = AddDumps(ds.tombstone_data_.begin(), ds.tombstone_data_.end(),
"TOMBSTONE", true /* add_to_zip */);
if (!tombstones_dumped) {
printf("*** NO TOMBSTONES to dump in %s\n\n", TOMBSTONE_DIR.c_str());
}
DumpPacketStats();
DoKmsg();
DumpIpAddrAndRules();
dump_route_tables();
RunCommand("ARP CACHE", {"ip", "-4", "neigh", "show"});
RunCommand("IPv6 ND CACHE", {"ip", "-6", "neigh", "show"});
RunCommand("MULTICAST ADDRESSES", {"ip", "maddr"});
RunDumpsysHigh();
RunCommand("SYSTEM PROPERTIES", {"getprop"});
RunCommand("STORAGED IO INFO", {"storaged", "-u", "-p"});
RunCommand("FILESYSTEMS & FREE SPACE", {"df"});
RunCommand("LAST RADIO LOG", {"parse_radio_log", "/proc/last_radio_log"});
/* Binder state is expensive to look at as it uses a lot of memory. */
DumpFile("BINDER FAILED TRANSACTION LOG", "/sys/kernel/debug/binder/failed_transaction_log");
DumpFile("BINDER TRANSACTION LOG", "/sys/kernel/debug/binder/transaction_log");
DumpFile("BINDER TRANSACTIONS", "/sys/kernel/debug/binder/transactions");
DumpFile("BINDER STATS", "/sys/kernel/debug/binder/stats");
DumpFile("BINDER STATE", "/sys/kernel/debug/binder/state");
/* Add window and surface trace files. */
if (!PropertiesHelper::IsUserBuild()) {
ds.AddDir(WMTRACE_DATA_DIR, false);
}
ds.DumpstateBoard();
/* Migrate the ril_dumpstate to a device specific dumpstate? */
int rilDumpstateTimeout = android::base::GetIntProperty("ril.dumpstate.timeout", 0);
if (rilDumpstateTimeout > 0) {
// su does not exist on user builds, so try running without it.
// This way any implementations of vril-dump that do not require
// root can run on user builds.
CommandOptions::CommandOptionsBuilder options =
CommandOptions::WithTimeout(rilDumpstateTimeout);
if (!PropertiesHelper::IsUserBuild()) {
options.AsRoot();
}
RunCommand("DUMP VENDOR RIL LOGS", {"vril-dump"}, options.Build());
}
printf("========================================================\n");
printf("== Android Framework Services\n");
printf("========================================================\n");
RunDumpsysNormal();
printf("========================================================\n");
printf("== Checkins\n");
printf("========================================================\n");
RunDumpsys("CHECKIN BATTERYSTATS", {"batterystats", "-c"});
RunDumpsys("CHECKIN MEMINFO", {"meminfo", "--checkin"});
RunDumpsys("CHECKIN NETSTATS", {"netstats", "--checkin"});
RunDumpsys("CHECKIN PROCSTATS", {"procstats", "-c"});
RunDumpsys("CHECKIN USAGESTATS", {"usagestats", "-c"});
RunDumpsys("CHECKIN PACKAGE", {"package", "--checkin"});
printf("========================================================\n");
printf("== Running Application Activities\n");
printf("========================================================\n");
// The following dumpsys internally collects output from running apps, so it can take a long
// time. So let's extend the timeout.
const CommandOptions DUMPSYS_COMPONENTS_OPTIONS = CommandOptions::WithTimeout(60).Build();
RunDumpsys("APP ACTIVITIES", {"activity", "-v", "all"}, DUMPSYS_COMPONENTS_OPTIONS);
printf("========================================================\n");
printf("== Running Application Services (platform)\n");
printf("========================================================\n");
RunDumpsys("APP SERVICES PLATFORM", {"activity", "service", "all-platform"},
DUMPSYS_COMPONENTS_OPTIONS);
printf("========================================================\n");
printf("== Running Application Services (non-platform)\n");
printf("========================================================\n");
RunDumpsys("APP SERVICES NON-PLATFORM", {"activity", "service", "all-non-platform"},
DUMPSYS_COMPONENTS_OPTIONS);
printf("========================================================\n");
printf("== Running Application Providers (platform)\n");
printf("========================================================\n");
RunDumpsys("APP PROVIDERS PLATFORM", {"activity", "provider", "all-platform"},
DUMPSYS_COMPONENTS_OPTIONS);
printf("========================================================\n");
printf("== Running Application Providers (non-platform)\n");
printf("========================================================\n");
RunDumpsys("APP PROVIDERS NON-PLATFORM", {"activity", "provider", "all-non-platform"},
DUMPSYS_COMPONENTS_OPTIONS);
printf("========================================================\n");
printf("== Dropbox crashes\n");
printf("========================================================\n");
RunDumpsys("DROPBOX SYSTEM SERVER CRASHES", {"dropbox", "-p", "system_server_crash"});
RunDumpsys("DROPBOX SYSTEM APP CRASHES", {"dropbox", "-p", "system_app_crash"});
printf("========================================================\n");
printf("== Final progress (pid %d): %d/%d (estimated %d)\n", ds.pid_, ds.progress_->Get(),
ds.progress_->GetMax(), ds.progress_->GetInitialMax());
printf("========================================================\n");
printf("== dumpstate: done (id %d)\n", ds.id_);
printf("========================================================\n");
}
文章目录
1. bugreport
编译到/system/bin/bugreport
@frameworks/native/cmds/bugreport/Android.bp
cc_binary {
name: "bugreport",
srcs: ["bugreport.cpp"],
cflags: ["-Wall", "-Werror"],
shared_libs: ["libcutils"],
}
@frameworks/native/cmds/bugreport/bugreport.cpp
int main() {
//1. 不建议使用bugreport,而是使用adb bugreport
fprintf(stderr, "=============================================================================\n");
fprintf(stderr, "WARNING: flat bugreports are deprecated, use adb bugreport <zip_file> instead\n");
fprintf(stderr, "=============================================================================\n\n\n");
//2. 开始dumpstate service,打印Log
// Start the dumpstate service.
property_set("ctl.start", "dumpstate");
//3. 和dumpstate socket通信
// Socket will not be available until service starts.
int s;
for (int i = 0; i < 20; i++) {
s = socket_local_client("dumpstate", ANDROID_SOCKET_NAMESPACE_RESERVED,
SOCK_STREAM);
if (s >= 0)
break;
// Try again in 1 second.
sleep(1);
}
//4. 读写数据
while (1) {
char buffer[65536];
ssize_t bytes_read = TEMP_FAILURE_RETRY(read(s, buffer, sizeof(buffer)));
if (bytes_read == 0) {
break;
} else if (bytes_read == -1) {
// EAGAIN really means time out, so change the errno.
if (errno == EAGAIN) {
errno = ETIMEDOUT;
}
printf("\nBugreport read terminated abnormally (%s).\n", strerror(errno));
break;
}
ssize_t bytes_to_send = bytes_read;
ssize_t bytes_written;
do {
bytes_written = TEMP_FAILURE_RETRY(write(STDOUT_FILENO,
buffer + bytes_read - bytes_to_send,
bytes_to_send));
if (bytes_written == -1) {
printf("Failed to write data to stdout: read %zd, trying to send %zd (%s)\n",
bytes_read, bytes_to_send, strerror(errno));
return 1;
}
bytes_to_send -= bytes_written;
} while (bytes_written != 0 && bytes_to_send > 0);
}
close(s);
return 0;
}
2. bugreportz
/system/bin/bugreportz
@frameworks/native/cmds/bugreportz/Android.mk
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
bugreportz.cpp \
main.cpp \
LOCAL_MODULE:= bugreportz
LOCAL_CFLAGS := -Werror -Wall
LOCAL_SHARED_LIBRARIES := \
libbase \
libcutils \
include $(BUILD_EXECUTABLE)
@frameworks/native/cmds/bugreportz/main.cpp
int main(int argc, char* argv[]) {
bool show_progress = false;
//1. 使用帮助
if (argc > 1) {
/* parse arguments */
int c;
while ((c = getopt(argc, argv, "hpv")) != -1) {
switch (c) {
case 'h':
show_usage();
return EXIT_SUCCESS;
case 'p':
show_progress = true;
break;
case 'v':
show_version();
return EXIT_SUCCESS;
default:
show_usage();
return EXIT_FAILURE;
}
}
}
//2. 开始dumpstate service,打印Log
// Start the dumpstatez service.
property_set("ctl.start", "dumpstatez");
//3. 和dumpstate socket通信
// Socket will not be available until service starts.
int s;
for (int i = 0; i < 20; i++) {
s = socket_local_client("dumpstate", ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM);
if (s >= 0) break;
// Try again in 1 second.
sleep(1);
}
//4. 读写数据
bugreportz(s, show_progress);
}
3. adb bugreport
推荐使用adb bugreport
@system/core/adb/commandline.cpp
} else if (!strcmp(argv[0], "bugreport")) {
Bugreport bugreport;
return bugreport.DoIt(argc, argv);
int Bugreport::DoIt(int argc, const char** argv) {
// Gets bugreportz version.
std::string bugz_stdout, bugz_stderr;
//1. 得到bugreportz版本,不支持使用bugreport
DefaultStandardStreamsCallback version_callback(&bugz_stdout, &bugz_stderr);
int status = SendShellCommand("bugreportz -v", false, &version_callback);
if (status != 0 || bugz_version.empty()) {
D("'bugreportz' -v results: status=%d, stdout='%s', stderr='%s'", status,
bugz_output.c_str(), bugz_version.c_str());
if (argc == 1) {
// Device does not support bugreportz: if called as 'adb bugreport', just falls out to
// the flat-file version.
fprintf(stderr,
"Failed to get bugreportz version, which is only available on devices "
"running Android 7.0 or later.\nTrying a plain-text bug report instead.\n");
return SendShellCommand("bugreport", false);
}
...
}
...
//2. 一般都有bugreportz,使用bugreportz -p
bool show_progress = true;
std::string bugz_command = "bugreportz -p";
...
BugreportStandardStreamsCallback bugz_callback(dest_dir, dest_file, show_progress, this);
return SendShellCommand(bugz_command, false, &bugz_callback);
}
4. dumpstate
@frameworks/native/cmds/dumpstate/Android.bp
cc_binary {
name: "dumpstate",
defaults: ["dumpstate_defaults"],
srcs: [
"dumpstate.cpp",
"main.cpp",
],
init_rc: ["dumpstate.rc"],
}
int run_main(int argc, char* argv[]) {
/* set as high priority, and protect from OOM killer */
setpriority(PRIO_PROCESS, 0, -20);
//1. 建立socket
// If we are going to use a socket, do it as early as possible
// to avoid timeouts from bugreport.
if (use_socket) {
redirect_to_socket(stdout, "dumpstate");
}
if (use_control_socket) {
MYLOGD("Opening control socket\n");
ds.control_socket_fd_ = open_socket("dumpstate");
ds.update_progress_ = 1;
}
...
//2. dump log
dumpstate();
...
return 0;
}
run_main和dumpstate()就会打印LOG,可以对比bugreport.txt
/** Main entry point for dumpstate. */
static void dumpstate() {
DurationReporter duration_reporter("DUMPSTATE");
dump_dev_files("TRUSTY VERSION", "/sys/bus/platform/drivers/trusty", "trusty_version");
RunCommand("UPTIME", {"uptime"});
DumpBlockStatFiles();
dump_emmc_ecsd("/d/mmc0/mmc0:0001/ext_csd");
DumpFile("MEMORY INFO", "/proc/meminfo");
RunCommand("CPU INFO", {"top", "-b", "-n", "1", "-H", "-s", "6", "-o",
"pid,tid,user,pr,ni,%cpu,s,virt,res,pcy,cmd,name"});
RunCommand("PROCRANK", {"procrank"}, AS_ROOT_20);
DumpFile("VIRTUAL MEMORY STATS", "/proc/vmstat");
DumpFile("VMALLOC INFO", "/proc/vmallocinfo");
DumpFile("SLAB INFO", "/proc/slabinfo");
DumpFile("ZONEINFO", "/proc/zoneinfo");
DumpFile("PAGETYPEINFO", "/proc/pagetypeinfo");
DumpFile("BUDDYINFO", "/proc/buddyinfo");
DumpFile("FRAGMENTATION INFO", "/d/extfrag/unusable_index");
DumpFile("KERNEL WAKE SOURCES", "/d/wakeup_sources");
DumpFile("KERNEL CPUFREQ", "/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state");
DumpFile("KERNEL SYNC", "/d/sync");
RunCommand("PROCESSES AND THREADS",
{"ps", "-A", "-T", "-Z", "-O", "pri,nice,rtprio,sched,pcy,time"});
RunCommand("LIBRANK", {"librank"}, CommandOptions::AS_ROOT);
if (ds.IsZipping()) {
RunCommand("HARDWARE HALS", {"lshal"}, CommandOptions::WithTimeout(2).AsRootIfAvailable().Build());
DumpHals();
} else {
RunCommand("HARDWARE HALS", {"lshal", "--debug"}, CommandOptions::WithTimeout(10).AsRootIfAvailable().Build());
}
RunCommand("PRINTENV", {"printenv"});
RunCommand("NETSTAT", {"netstat", "-nW"});
struct stat s;
if (stat("/proc/modules", &s) != 0) {
MYLOGD("Skipping 'lsmod' because /proc/modules does not exist\n");
} else {
RunCommand("LSMOD", {"lsmod"});
}
if (__android_logger_property_get_bool(
"ro.logd.kernel", BOOL_DEFAULT_TRUE | BOOL_DEFAULT_FLAG_ENG | BOOL_DEFAULT_FLAG_SVELTE)) {
DoKernelLogcat();
} else {
do_dmesg();
}
RunCommand("LIST OF OPEN FILES", {"lsof"}, CommandOptions::AS_ROOT);
for_each_pid(do_showmap, "SMAPS OF ALL PROCESSES");
for_each_tid(show_wchan, "BLOCKED PROCESS WAIT-CHANNELS");
for_each_pid(show_showtime, "PROCESS TIMES (pid cmd user system iowait+percentage)");
/* Dump Bluetooth HCI logs */
ds.AddDir("/data/misc/bluetooth/logs", true);
if (!ds.do_early_screenshot_) {
MYLOGI("taking late screenshot\n");
ds.TakeScreenshot();
}
DoLogcat();
AddAnrTraceFiles();
// NOTE: tombstones are always added as separate entries in the zip archive
// and are not interspersed with the main report.
const bool tombstones_dumped = AddDumps(ds.tombstone_data_.begin(), ds.tombstone_data_.end(),
"TOMBSTONE", true /* add_to_zip */);
if (!tombstones_dumped) {
printf("*** NO TOMBSTONES to dump in %s\n\n", TOMBSTONE_DIR.c_str());
}
DumpPacketStats();
DoKmsg();
DumpIpAddrAndRules();
dump_route_tables();
RunCommand("ARP CACHE", {"ip", "-4", "neigh", "show"});
RunCommand("IPv6 ND CACHE", {"ip", "-6", "neigh", "show"});
RunCommand("MULTICAST ADDRESSES", {"ip", "maddr"});
RunDumpsysHigh();
RunCommand("SYSTEM PROPERTIES", {"getprop"});
RunCommand("STORAGED IO INFO", {"storaged", "-u", "-p"});
RunCommand("FILESYSTEMS & FREE SPACE", {"df"});
RunCommand("LAST RADIO LOG", {"parse_radio_log", "/proc/last_radio_log"});
/* Binder state is expensive to look at as it uses a lot of memory. */
DumpFile("BINDER FAILED TRANSACTION LOG", "/sys/kernel/debug/binder/failed_transaction_log");
DumpFile("BINDER TRANSACTION LOG", "/sys/kernel/debug/binder/transaction_log");
DumpFile("BINDER TRANSACTIONS", "/sys/kernel/debug/binder/transactions");
DumpFile("BINDER STATS", "/sys/kernel/debug/binder/stats");
DumpFile("BINDER STATE", "/sys/kernel/debug/binder/state");
/* Add window and surface trace files. */
if (!PropertiesHelper::IsUserBuild()) {
ds.AddDir(WMTRACE_DATA_DIR, false);
}
ds.DumpstateBoard();
/* Migrate the ril_dumpstate to a device specific dumpstate? */
int rilDumpstateTimeout = android::base::GetIntProperty("ril.dumpstate.timeout", 0);
if (rilDumpstateTimeout > 0) {
// su does not exist on user builds, so try running without it.
// This way any implementations of vril-dump that do not require
// root can run on user builds.
CommandOptions::CommandOptionsBuilder options =
CommandOptions::WithTimeout(rilDumpstateTimeout);
if (!PropertiesHelper::IsUserBuild()) {
options.AsRoot();
}
RunCommand("DUMP VENDOR RIL LOGS", {"vril-dump"}, options.Build());
}
printf("========================================================\n");
printf("== Android Framework Services\n");
printf("========================================================\n");
RunDumpsysNormal();
printf("========================================================\n");
printf("== Checkins\n");
printf("========================================================\n");
RunDumpsys("CHECKIN BATTERYSTATS", {"batterystats", "-c"});
RunDumpsys("CHECKIN MEMINFO", {"meminfo", "--checkin"});
RunDumpsys("CHECKIN NETSTATS", {"netstats", "--checkin"});
RunDumpsys("CHECKIN PROCSTATS", {"procstats", "-c"});
RunDumpsys("CHECKIN USAGESTATS", {"usagestats", "-c"});
RunDumpsys("CHECKIN PACKAGE", {"package", "--checkin"});
printf("========================================================\n");
printf("== Running Application Activities\n");
printf("========================================================\n");
// The following dumpsys internally collects output from running apps, so it can take a long
// time. So let's extend the timeout.
const CommandOptions DUMPSYS_COMPONENTS_OPTIONS = CommandOptions::WithTimeout(60).Build();
RunDumpsys("APP ACTIVITIES", {"activity", "-v", "all"}, DUMPSYS_COMPONENTS_OPTIONS);
printf("========================================================\n");
printf("== Running Application Services (platform)\n");
printf("========================================================\n");
RunDumpsys("APP SERVICES PLATFORM", {"activity", "service", "all-platform"},
DUMPSYS_COMPONENTS_OPTIONS);
printf("========================================================\n");
printf("== Running Application Services (non-platform)\n");
printf("========================================================\n");
RunDumpsys("APP SERVICES NON-PLATFORM", {"activity", "service", "all-non-platform"},
DUMPSYS_COMPONENTS_OPTIONS);
printf("========================================================\n");
printf("== Running Application Providers (platform)\n");
printf("========================================================\n");
RunDumpsys("APP PROVIDERS PLATFORM", {"activity", "provider", "all-platform"},
DUMPSYS_COMPONENTS_OPTIONS);
printf("========================================================\n");
printf("== Running Application Providers (non-platform)\n");
printf("========================================================\n");
RunDumpsys("APP PROVIDERS NON-PLATFORM", {"activity", "provider", "all-non-platform"},
DUMPSYS_COMPONENTS_OPTIONS);
printf("========================================================\n");
printf("== Dropbox crashes\n");
printf("========================================================\n");
RunDumpsys("DROPBOX SYSTEM SERVER CRASHES", {"dropbox", "-p", "system_server_crash"});
RunDumpsys("DROPBOX SYSTEM APP CRASHES", {"dropbox", "-p", "system_app_crash"});
printf("========================================================\n");
printf("== Final progress (pid %d): %d/%d (estimated %d)\n", ds.pid_, ds.progress_->Get(),
ds.progress_->GetMax(), ds.progress_->GetInitialMax());
printf("========================================================\n");
printf("== dumpstate: done (id %d)\n", ds.id_);
printf("========================================================\n");
}