summaryrefslogtreecommitdiff
path: root/debuggerd/debuggerd.cpp
diff options
context:
space:
mode:
authorRichard Uhler <ruhler@google.com>2016-10-28 16:37:33 +0100
committerRichard Uhler <ruhler@google.com>2016-11-21 11:40:42 +0000
commit53fb32f05cc17848f239dec6b8c821b7c5124ef4 (patch)
tree7b982e41f907096c0696987837c2c588d8dc027a /debuggerd/debuggerd.cpp
parente133feb6b4c25ea3f28ca34a9cde2d8c1361b7b0 (diff)
debuggerd: Dump list of open files on process crash.
Test: Open a bunch of files, wait for the process to crash, verify dubuggerd includes the list of open files the tombstone it generates. Test: Added OpenFilesListTest to debuggerd_test. Bug: 32013594 Change-Id: I6f939ae1d04dc58dc99abff0ed930da9e0ef0d1c
Diffstat (limited to 'debuggerd/debuggerd.cpp')
-rw-r--r--debuggerd/debuggerd.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/debuggerd/debuggerd.cpp b/debuggerd/debuggerd.cpp
index 5ae66db5c..272fbf689 100644
--- a/debuggerd/debuggerd.cpp
+++ b/debuggerd/debuggerd.cpp
@@ -55,6 +55,7 @@
#include "backtrace.h"
#include "getevent.h"
+#include "open_files_list.h"
#include "signal_sender.h"
#include "tombstone.h"
#include "utility.h"
@@ -452,7 +453,8 @@ static void ptrace_siblings(pid_t pid, pid_t main_tid, pid_t ignore_tid, std::se
}
static bool perform_dump(const debugger_request_t& request, int fd, int tombstone_fd,
- BacktraceMap* backtrace_map, const std::set<pid_t>& siblings,
+ BacktraceMap* backtrace_map, const OpenFilesList& open_files,
+ const std::set<pid_t>& siblings,
int* crash_signal, std::string* amfd_data) {
if (TEMP_FAILURE_RETRY(write(fd, "\0", 1)) != 1) {
ALOGE("debuggerd: failed to respond to client: %s\n", strerror(errno));
@@ -471,7 +473,8 @@ static bool perform_dump(const debugger_request_t& request, int fd, int tombston
case SIGSTOP:
if (request.action == DEBUGGER_ACTION_DUMP_TOMBSTONE) {
ALOGV("debuggerd: stopped -- dumping to tombstone");
- engrave_tombstone(tombstone_fd, backtrace_map, request.pid, request.tid, siblings,
+ engrave_tombstone(tombstone_fd, backtrace_map, open_files,
+ request.pid, request.tid, siblings,
request.abort_msg_address, amfd_data);
} else if (request.action == DEBUGGER_ACTION_DUMP_BACKTRACE) {
ALOGV("debuggerd: stopped -- dumping to fd");
@@ -498,7 +501,8 @@ static bool perform_dump(const debugger_request_t& request, int fd, int tombston
case SIGTRAP:
ALOGV("stopped -- fatal signal\n");
*crash_signal = signal;
- engrave_tombstone(tombstone_fd, backtrace_map, request.pid, request.tid, siblings,
+ engrave_tombstone(tombstone_fd, backtrace_map, open_files,
+ request.pid, request.tid, siblings,
request.abort_msg_address, amfd_data);
break;
@@ -593,6 +597,10 @@ static void worker_process(int fd, debugger_request_t& request) {
// Generate the backtrace map before dropping privileges.
std::unique_ptr<BacktraceMap> backtrace_map(BacktraceMap::Create(request.pid));
+ // Collect the list of open files before dropping privileges.
+ OpenFilesList open_files;
+ populate_open_files_list(request.pid, &open_files);
+
int amfd = -1;
std::unique_ptr<std::string> amfd_data;
if (request.action == DEBUGGER_ACTION_CRASH) {
@@ -610,8 +618,8 @@ static void worker_process(int fd, debugger_request_t& request) {
}
int crash_signal = SIGKILL;
- succeeded = perform_dump(request, fd, tombstone_fd, backtrace_map.get(), siblings,
- &crash_signal, amfd_data.get());
+ succeeded = perform_dump(request, fd, tombstone_fd, backtrace_map.get(), open_files,
+ siblings, &crash_signal, amfd_data.get());
if (succeeded) {
if (request.action == DEBUGGER_ACTION_DUMP_TOMBSTONE) {
if (!tombstone_path.empty()) {