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
This commit is contained in:
Josh Gao 2017-03-10 14:49:19 -08:00
parent ec91809dae
commit 428daafc5b
1 changed files with 7 additions and 2 deletions

View File

@ -148,7 +148,12 @@ static void abort_handler(pid_t target, const bool& tombstoned_connected,
}
}
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 @@ int main(int argc, char** argv) {
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())) {