summaryrefslogtreecommitdiff
path: root/cmds/dumpstate/dumpstate.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmds/dumpstate/dumpstate.c')
-rw-r--r--cmds/dumpstate/dumpstate.c127
1 files changed, 97 insertions, 30 deletions
diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c
index cc951c1bcbd1..642c943ffd36 100644
--- a/cmds/dumpstate/dumpstate.c
+++ b/cmds/dumpstate/dumpstate.c
@@ -20,12 +20,18 @@
#include <unistd.h>
#include <sys/stat.h>
#include <limits.h>
+#include <errno.h>
#include <fcntl.h>
#include <sys/time.h>
#include <sys/resource.h>
+#include <cutils/sockets.h>
#include "private/android_filesystem_config.h"
+#define LOG_NDEBUG 0
+#define LOG_TAG "dumpstate"
+#include <utils/Log.h>
+
#include "dumpstate.h"
static char* const gzip_args[] = { "gzip", "-6", 0 };
@@ -34,6 +40,8 @@ static int end_pattern[] = { 75, 50, 75, 50, 75, 0 };
static struct tm now;
+static void dump_kernel_log(const char *path, const char *title) ;
+
/* dumps the current system state to stdout */
static void dumpstate(int full) {
if (full) {
@@ -48,6 +56,8 @@ static void dumpstate(int full) {
EXEC_XBIN("procrank");
PRINT("------ VIRTUAL MEMORY STATS ------");
DUMP("/proc/vmstat");
+ PRINT("------ VMALLOC INFO ------");
+ DUMP("/proc/vmallocinfo");
PRINT("------ SLAB INFO ------");
DUMP("/proc/slabinfo");
PRINT("------ ZONEINFO ------");
@@ -76,9 +86,9 @@ static void dumpstate(int full) {
DUMP("/proc/wakelocks");
PRINT("");
PRINT("------ PROCESSES ------");
- EXEC("ps");
+ EXEC1("ps", "-P");
PRINT("------ PROCESSES AND THREADS ------");
- EXEC2("ps", "-t", "-p");
+ EXEC3("ps", "-t", "-p", "-P");
PRINT("------ LIBRANK ------");
EXEC_XBIN("librank");
PRINT("------ BINDER FAILED TRANSACTION LOG ------");
@@ -101,8 +111,19 @@ static void dumpstate(int full) {
DUMP("/data/system/packages.xml");
PRINT("------ PACKAGE UID ERRORS ------");
DUMP("/data/system/uiderrors.txt");
- PRINT("------ LAST KERNEL LOG ------");
- DUMP("/proc/last_kmsg");
+
+ dump_kernel_log("/data/dontpanic/last_kmsg", "LAST KMSG");
+ dump_kernel_log("/data/dontpanic/apanic_console",
+ "PANIC CONSOLE");
+ dump_kernel_log("/data/dontpanic/apanic_threads",
+ "PANIC THREADS");
+
+ PRINT("------ BACKLIGHTS ------");
+ DUMP_PROMPT("LCD brightness=", "/sys/class/leds/lcd-backlight/brightness");
+ DUMP_PROMPT("Button brightness=", "/sys/class/leds/button-backlight/brightness");
+ DUMP_PROMPT("Keyboard brightness=", "/sys/class/leds/keyboard-backlight/brightness");
+ DUMP_PROMPT("ALS mode=", "/sys/class/leds/lcd-backlight/als");
+ DUMP_PROMPT("LCD driver registers:\n", "/sys/class/leds/lcd-backlight/registers");
}
PRINT("========================================================");
PRINT("== build.prop");
@@ -157,47 +178,50 @@ static int check_command_name(const char* name, const char* test) {
int main(int argc, char *argv[]) {
int dumpcrash = check_command_name(argv[0], "dumpcrash");
- int bugreport = check_command_name(argv[0], "bugreport");
int add_date = 0;
char* outfile = 0;
int vibrate = 0;
int compress = 0;
+ int socket = 0;
int c, fd, vibrate_fd, fds[2];
char path[PATH_MAX];
pid_t pid;
gid_t groups[] = { AID_LOG, AID_SDCARD_RW };
+ LOGI("begin\n");
+
/* set as high priority, and protect from OOM killer */
setpriority(PRIO_PROCESS, 0, -20);
protect_from_oom_killer();
get_time(&now);
- if (bugreport) {
- do {
- c = getopt(argc, argv, "do:vz");
- if (c == EOF)
+ do {
+ c = getopt(argc, argv, "do:svz");
+ if (c == EOF)
+ break;
+ switch (c) {
+ case 'd':
+ add_date = 1;
break;
- switch (c) {
- case 'd':
- add_date = 1;
- break;
- case 'o':
- outfile = optarg;
- break;
- case 'v':
- vibrate = 1;
- break;
- case 'z':
- compress = 1;
- break;
- case '?':
- fprintf(stderr, "%s: invalid option -%c\n",
- argv[0], optopt);
- exit(1);
- }
- } while (1);
- }
+ case 'o':
+ outfile = optarg;
+ break;
+ case 'v':
+ vibrate = 1;
+ break;
+ case 'z':
+ compress = 1;
+ break;
+ case 's':
+ socket = 1;
+ break;
+ case '?':
+ fprintf(stderr, "%s: invalid option -%c\n",
+ argv[0], optopt);
+ exit(1);
+ }
+ } while (1);
/* open vibrator before switching user */
if (vibrate) {
@@ -214,7 +238,31 @@ int main(int argc, char *argv[]) {
/* make it safe to use both printf and STDOUT_FILENO */
setvbuf(stdout, 0, _IONBF, 0);
- if (outfile) {
+ if (socket) {
+ struct sockaddr addr;
+ socklen_t alen;
+
+ int s = android_get_control_socket("dumpstate");
+ if (s < 0) {
+ fprintf(stderr, "could not open dumpstate socket\n");
+ exit(1);
+ }
+ if (listen(s, 4) < 0) {
+ fprintf(stderr, "could not listen on dumpstate socket\n");
+ exit(1);
+ }
+
+ alen = sizeof(addr);
+ fd = accept(s, &addr, &alen);
+ if (fd < 0) {
+ fprintf(stderr, "could not accept dumpstate socket\n");
+ exit(1);
+ }
+
+ /* redirect stdout to the socket */
+ dup2(fd, STDOUT_FILENO);
+ close(fd);
+ } else if (outfile) {
if (strlen(outfile) > sizeof(path) - 100)
exit(1);
@@ -292,6 +340,25 @@ int main(int argc, char *argv[]) {
/* so gzip will terminate */
close(STDOUT_FILENO);
+ LOGI("done\n");
+
return 0;
}
+static void dump_kernel_log(const char *path, const char *title)
+
+{
+ printf("------ KERNEL %s LOG ------\n", title);
+ if (access(path, R_OK) < 0)
+ printf("%s: %s\n", path, strerror(errno));
+ else {
+ struct stat sbuf;
+
+ if (stat(path, &sbuf) < 0)
+ printf("%s: stat failed (%s)\n", path, strerror(errno));
+ else
+ printf("Harvested %s", ctime(&sbuf.st_mtime));
+
+ DUMP(path);
+ }
+}