summaryrefslogtreecommitdiffstats
path: root/debuggerd/crash_dump.cpp
diff options
context:
space:
mode:
authorJosh Gao <jmgao@google.com>2017-03-01 17:23:22 -0800
committerJosh Gao <jmgao@google.com>2017-03-09 11:26:05 -0800
commite1aa0ca58a2a356039047ffcc8a98d85d1bce8ed (patch)
tree46c90399acd3b3fa76538e26b528ee005cbb8872 /debuggerd/crash_dump.cpp
parent4e5e797d26272dc08b6336def8d7878443881f0e (diff)
downloadsystem_core-e1aa0ca58a2a356039047ffcc8a98d85d1bce8ed.tar.gz
system_core-e1aa0ca58a2a356039047ffcc8a98d85d1bce8ed.tar.bz2
system_core-e1aa0ca58a2a356039047ffcc8a98d85d1bce8ed.zip
debuggerd_handler: implement missing fallback functionality.
Allow the fallback implementation to dump traces and create tombstones in seccomped processes. Bug: http://b/35858739 Test: debuggerd -b `pidof media.codec`; killall -ABRT media.codec Change-Id: I381b283de39a66d8900f1c320d32497d6f2b4ec4
Diffstat (limited to 'debuggerd/crash_dump.cpp')
-rw-r--r--debuggerd/crash_dump.cpp50
1 files changed, 1 insertions, 49 deletions
diff --git a/debuggerd/crash_dump.cpp b/debuggerd/crash_dump.cpp
index 0e154728a..65854247e 100644
--- a/debuggerd/crash_dump.cpp
+++ b/debuggerd/crash_dump.cpp
@@ -48,6 +48,7 @@
#include "debuggerd/handler.h"
#include "debuggerd/protocol.h"
+#include "debuggerd/tombstoned.h"
#include "debuggerd/util.h"
using android::base::unique_fd;
@@ -128,55 +129,6 @@ static bool activity_manager_notify(int pid, int signal, const std::string& amfd
return true;
}
-static bool tombstoned_connect(pid_t pid, unique_fd* tombstoned_socket, unique_fd* output_fd) {
- unique_fd sockfd(socket_local_client(kTombstonedCrashSocketName,
- ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_SEQPACKET));
- if (sockfd == -1) {
- PLOG(ERROR) << "failed to connect to tombstoned";
- return false;
- }
-
- TombstonedCrashPacket packet = {};
- packet.packet_type = CrashPacketType::kDumpRequest;
- packet.packet.dump_request.pid = pid;
- if (TEMP_FAILURE_RETRY(write(sockfd, &packet, sizeof(packet))) != sizeof(packet)) {
- PLOG(ERROR) << "failed to write DumpRequest packet";
- return false;
- }
-
- unique_fd tmp_output_fd;
- ssize_t rc = recv_fd(sockfd, &packet, sizeof(packet), &tmp_output_fd);
- if (rc == -1) {
- PLOG(ERROR) << "failed to read response to DumpRequest packet";
- return false;
- } else if (rc != sizeof(packet)) {
- LOG(ERROR) << "read DumpRequest response packet of incorrect length (expected "
- << sizeof(packet) << ", got " << rc << ")";
- return false;
- }
-
- // Make the fd O_APPEND so that our output is guaranteed to be at the end of a file.
- // (This also makes selinux rules consistent, because selinux distinguishes between writing to
- // a regular fd, and writing to an fd with O_APPEND).
- int flags = fcntl(tmp_output_fd.get(), F_GETFL);
- if (fcntl(tmp_output_fd.get(), F_SETFL, flags | O_APPEND) != 0) {
- PLOG(WARNING) << "failed to set output fd flags";
- }
-
- *tombstoned_socket = std::move(sockfd);
- *output_fd = std::move(tmp_output_fd);
- return true;
-}
-
-static bool tombstoned_notify_completion(int tombstoned_socket) {
- TombstonedCrashPacket packet = {};
- packet.packet_type = CrashPacketType::kCompletedDump;
- if (TEMP_FAILURE_RETRY(write(tombstoned_socket, &packet, sizeof(packet))) != sizeof(packet)) {
- return false;
- }
- return true;
-}
-
static void signal_handler(int) {
// We can't log easily, because the heap might be corrupt.
// Just die and let the surrounding log context explain things.