diff options
author | Dan Egnor <egnor@google.com> | 2010-03-08 19:23:01 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-03-08 19:23:01 -0800 |
commit | ca14320fa28b818d755cff8f0c2ff4c780d30105 (patch) | |
tree | c12dc28487f09261933b9e7e9188914219e81a05 /cmds | |
parent | eb6a592a283012fa3a93aad4a137b93ab9aa07ee (diff) | |
parent | efd13938013099e58f4dcbf818f508c585547817 (diff) | |
download | frameworks_base-ca14320fa28b818d755cff8f0c2ff4c780d30105.zip frameworks_base-ca14320fa28b818d755cff8f0c2ff4c780d30105.tar.gz frameworks_base-ca14320fa28b818d755cff8f0c2ff4c780d30105.tar.bz2 |
Merge "More consistent and clear traces.txt reporting."
Diffstat (limited to 'cmds')
-rw-r--r-- | cmds/dumpstate/dumpstate.c | 7 | ||||
-rw-r--r-- | cmds/dumpstate/utils.c | 20 |
2 files changed, 26 insertions, 1 deletions
diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c index eaa34c8..cc1167f 100644 --- a/cmds/dumpstate/dumpstate.c +++ b/cmds/dumpstate/dumpstate.c @@ -23,6 +23,7 @@ #include <sys/resource.h> #include <sys/stat.h> #include <sys/time.h> +#include <sys/wait.h> #include <unistd.h> #include <cutils/properties.h> @@ -86,7 +87,11 @@ static void dumpstate() { struct stat st; char anr_traces_path[PATH_MAX]; property_get("dalvik.vm.stack-trace-file", anr_traces_path, ""); - if (anr_traces_path[0] && !stat(anr_traces_path, &st) && time(NULL) - st.st_mtime < 15 * 60) { + if (!anr_traces_path[0]) { + printf("*** NO VM TRACES FILE DEFINED (dalvik.vm.stack-trace-file)\n\n"); + } else if (stat(anr_traces_path, &st)) { + printf("*** NO ANR VM TRACES FILE (%s): %s\n\n", anr_traces_path, strerror(errno)); + } else { dump_file("VM TRACES AT LAST ANR", anr_traces_path); } 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)); |