summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2015-01-14 13:23:30 -0800
committerChristopher Ferris <cferris@google.com>2015-01-15 15:35:40 -0800
commit31ef85529d86a9db68b002f51ec84fd9938908ab (patch)
tree1d6413a8fb092d0db330301f1abe11ef5e171216
parent4df903dbc71c48e2db6fae9390795b81782470b4 (diff)
downloadframeworks_native-31ef85529d86a9db68b002f51ec84fd9938908ab.zip
frameworks_native-31ef85529d86a9db68b002f51ec84fd9938908ab.tar.gz
frameworks_native-31ef85529d86a9db68b002f51ec84fd9938908ab.tar.bz2
Use the timeout stack dump functions.
Use the native stack dumping functions that allows time outs. If debuggerd locks up, before a bugreport would hang forever. Now it will timeout properly and still get all of the other information. Bug: 18766581 (cherry picked from commit 457731f69e3106b5aae8fc04f9565af1d875876c) Change-Id: I39e8e9c60209e3ef9efac795fedb8e1edce2bd3e
-rw-r--r--cmds/dumpstate/utils.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/cmds/dumpstate/utils.c b/cmds/dumpstate/utils.c
index 81cdd12..3e0b24b 100644
--- a/cmds/dumpstate/utils.c
+++ b/cmds/dumpstate/utils.c
@@ -619,20 +619,28 @@ const char *dump_traces() {
if (lseek(fd, 0, SEEK_END) < 0) {
fprintf(stderr, "lseek: %s\n", strerror(errno));
} else {
- snprintf(data, sizeof(data), "[dump dalvik stack %d: %.3fs elapsed]\n",
+ dprintf(fd, "[dump dalvik stack %d: %.3fs elapsed]\n",
pid, (float)(nanotime() - start) / NANOS_PER_SEC);
- write(fd, data, strlen(data));
}
} else if (should_dump_native_traces(data)) {
/* dump native process if appropriate */
if (lseek(fd, 0, SEEK_END) < 0) {
fprintf(stderr, "lseek: %s\n", strerror(errno));
} else {
+ static uint16_t timeout_failures = 0;
int64_t start = nanotime();
- dump_backtrace_to_file(pid, fd);
- snprintf(data, sizeof(data), "[dump native stack %d: %.3fs elapsed]\n",
+
+ /* If 3 backtrace dumps fail in a row, consider debuggerd dead. */
+ if (timeout_failures == 3) {
+ dprintf(fd, "too many stack dump failures, skipping...\n");
+ } else if (dump_backtrace_to_file_timeout(pid, fd, 20) == -1) {
+ dprintf(fd, "dumping failed, likely due to a timeout\n");
+ timeout_failures++;
+ } else {
+ timeout_failures = 0;
+ }
+ dprintf(fd, "[dump native stack %d: %.3fs elapsed]\n",
pid, (float)(nanotime() - start) / NANOS_PER_SEC);
- write(fd, data, strlen(data));
}
}
}