diff options
author | Dan Egnor <egnor@google.com> | 2010-03-08 13:04:13 -0800 |
---|---|---|
committer | Dan Egnor <egnor@google.com> | 2010-03-08 19:21:32 -0800 |
commit | efd13938013099e58f4dcbf818f508c585547817 (patch) | |
tree | af0abf19e17bd334fdd2bf6a6a65110d4c403ade /cmds/dumpstate/utils.c | |
parent | 823961a3191b365cabf3745ee2f5f0cff059cdff (diff) | |
download | frameworks_base-efd13938013099e58f4dcbf818f508c585547817.zip frameworks_base-efd13938013099e58f4dcbf818f508c585547817.tar.gz frameworks_base-efd13938013099e58f4dcbf818f508c585547817.tar.bz2 |
More consistent and clear traces.txt reporting.
Print ANR traces.txt even if it's old.
Print more detailed error messages about VM trace dumps.
Change-Id: I067c90b8f3b3647b6136528eff3120e6cfea5715
Diffstat (limited to 'cmds/dumpstate/utils.c')
-rw-r--r-- | cmds/dumpstate/utils.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/cmds/dumpstate/utils.c b/cmds/dumpstate/utils.c index 6a79c6d..c21dace 100644 --- a/cmds/dumpstate/utils.c +++ b/cmds/dumpstate/utils.c @@ -33,6 +33,7 @@ #include <cutils/properties.h> #include <cutils/sockets.h> +#include <private/android_filesystem_config.h> #include "dumpstate.h" @@ -273,6 +274,20 @@ const char *dump_vm_traces() { return NULL; // Can't rename old traces.txt -- no permission? -- leave it alone instead } + /* make the directory if necessary */ + char anr_traces_dir[PATH_MAX]; + strlcpy(anr_traces_dir, traces_path, sizeof(anr_traces_dir)); + char *slash = strrchr(anr_traces_dir, '/'); + if (slash != NULL) { + *slash = '\0'; + if (!mkdir(anr_traces_dir, 0775)) { + chown(anr_traces_dir, AID_SYSTEM, AID_SYSTEM); + } else if (errno != EEXIST) { + fprintf(stderr, "mkdir(%s): %s\n", anr_traces_dir, strerror(errno)); + return NULL; + } + } + /* create a new, empty traces.txt file to receive stack dumps */ int fd = open(traces_path, O_CREAT | O_WRONLY | O_TRUNC, 0666); /* -rw-rw-rw- */ if (fd < 0) { @@ -302,6 +317,7 @@ const char *dump_vm_traces() { } struct dirent *d; + int dalvik_found = 0; while ((d = readdir(proc))) { int pid = atoi(d->d_name); if (pid <= 0) continue; @@ -319,6 +335,7 @@ const char *dump_vm_traces() { close(fd); if (len <= 0 || !memcmp(data, "zygote", 6)) continue; + ++dalvik_found; if (kill(pid, SIGQUIT)) { fprintf(stderr, "kill(%d, SIGQUIT): %s\n", pid, strerror(errno)); continue; @@ -338,6 +355,9 @@ const char *dump_vm_traces() { } close(ifd); + if (dalvik_found == 0) { + fprintf(stderr, "Warning: no Dalvik processes found to dump stacks\n"); + } static char dump_traces_path[PATH_MAX]; strlcpy(dump_traces_path, traces_path, sizeof(dump_traces_path)); |