summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Gao2017-03-01 19:23:22 -0600
committerJosh Gao2017-03-09 13:26:05 -0600
commite1aa0ca58a2a356039047ffcc8a98d85d1bce8ed (patch)
tree46c90399acd3b3fa76538e26b528ee005cbb8872 /debuggerd/util.cpp
parent4e5e797d26272dc08b6336def8d7878443881f0e (diff)
downloadplatform-system-core-e1aa0ca58a2a356039047ffcc8a98d85d1bce8ed.tar.gz
platform-system-core-e1aa0ca58a2a356039047ffcc8a98d85d1bce8ed.tar.xz
platform-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/util.cpp')
-rw-r--r--debuggerd/util.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/debuggerd/util.cpp b/debuggerd/util.cpp
index 738abdf7b..4c015d70a 100644
--- a/debuggerd/util.cpp
+++ b/debuggerd/util.cpp
@@ -22,8 +22,13 @@
22 22
23#include <android-base/unique_fd.h> 23#include <android-base/unique_fd.h>
24#include <cutils/sockets.h> 24#include <cutils/sockets.h>
25#include <debuggerd/protocol.h>
25 26
26ssize_t send_fd(int sockfd, const void* data, size_t len, android::base::unique_fd fd) { 27#include "private/libc_logging.h"
28
29using android::base::unique_fd;
30
31ssize_t send_fd(int sockfd, const void* data, size_t len, unique_fd fd) {
27 char cmsg_buf[CMSG_SPACE(sizeof(int))]; 32 char cmsg_buf[CMSG_SPACE(sizeof(int))];
28 33
29 iovec iov = { .iov_base = const_cast<void*>(data), .iov_len = len }; 34 iovec iov = { .iov_base = const_cast<void*>(data), .iov_len = len };
@@ -39,8 +44,7 @@ ssize_t send_fd(int sockfd, const void* data, size_t len, android::base::unique_
39 return TEMP_FAILURE_RETRY(sendmsg(sockfd, &msg, 0)); 44 return TEMP_FAILURE_RETRY(sendmsg(sockfd, &msg, 0));
40} 45}
41 46
42ssize_t recv_fd(int sockfd, void* _Nonnull data, size_t len, 47ssize_t recv_fd(int sockfd, void* _Nonnull data, size_t len, unique_fd* _Nullable out_fd) {
43 android::base::unique_fd* _Nullable out_fd) {
44 char cmsg_buf[CMSG_SPACE(sizeof(int))]; 48 char cmsg_buf[CMSG_SPACE(sizeof(int))];
45 49
46 iovec iov = { .iov_base = const_cast<void*>(data), .iov_len = len }; 50 iovec iov = { .iov_base = const_cast<void*>(data), .iov_len = len };
@@ -61,7 +65,7 @@ ssize_t recv_fd(int sockfd, void* _Nonnull data, size_t len,
61 return -1; 65 return -1;
62 } 66 }
63 67
64 android::base::unique_fd fd; 68 unique_fd fd;
65 bool received_fd = msg.msg_controllen == sizeof(cmsg_buf); 69 bool received_fd = msg.msg_controllen == sizeof(cmsg_buf);
66 if (received_fd) { 70 if (received_fd) {
67 fd.reset(*reinterpret_cast<int*>(CMSG_DATA(cmsg))); 71 fd.reset(*reinterpret_cast<int*>(CMSG_DATA(cmsg)));
@@ -85,7 +89,7 @@ ssize_t recv_fd(int sockfd, void* _Nonnull data, size_t len,
85 return result; 89 return result;
86} 90}
87 91
88bool Pipe(android::base::unique_fd* read, android::base::unique_fd* write) { 92bool Pipe(unique_fd* read, unique_fd* write) {
89 int pipefds[2]; 93 int pipefds[2];
90 if (pipe(pipefds) != 0) { 94 if (pipe(pipefds) != 0) {
91 return false; 95 return false;