crash_dump: improve logging for when a process dies prematurely.
If a process that's getting dumped dies before crash_dump starts (e.g.
because seccomp immediately kills it after it execs crash_dump),
improve the error message to not just say "target died before we could
attach".
Bug: http://b/36077710
Test: inserted an exit in the handler, inspected output
Change-Id: I7d394c66d60d328b096b15654b3648e1ed711728
diff --git a/debuggerd/crash_dump.cpp b/debuggerd/crash_dump.cpp
index 6585424..57a6c44 100644
--- a/debuggerd/crash_dump.cpp
+++ b/debuggerd/crash_dump.cpp
@@ -148,7 +148,12 @@
}
}
- dprintf(output_fd.get(), "crash_dump failed to dump process %d: %s\n", target, abort_msg);
+ dprintf(output_fd.get(), "crash_dump failed to dump process");
+ if (target != 1) {
+ dprintf(output_fd.get(), " %d: %s\n", target, abort_msg);
+ } else {
+ dprintf(output_fd.get(), ": %s\n", abort_msg);
+ }
_exit(1);
}
@@ -195,7 +200,7 @@
pid_t pseudothread_tid;
if (target == 1) {
- LOG(FATAL) << "target died before we could attach";
+ LOG(FATAL) << "target died before we could attach (received main tid = " << main_tid << ")";
}
if (!android::base::ParseInt(argv[1], &main_tid, 1, std::numeric_limits<pid_t>::max())) {