Loading debuggerd/client/debuggerd_client.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -28,7 +28,9 @@ #include <android-base/file.h> #include <android-base/logging.h> #include <android-base/parseint.h> #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <android-base/unique_fd.h> #include <cutils/sockets.h> Loading Loading @@ -117,6 +119,20 @@ bool debuggerd_trigger_dump(pid_t pid, DebuggerdDumpType dump_type, unsigned int return false; } std::string pipe_size_str; int pipe_buffer_size = 1024 * 1024; if (android::base::ReadFileToString("/proc/sys/fs/pipe-max-size", &pipe_size_str)) { pipe_size_str = android::base::Trim(pipe_size_str); if (!android::base::ParseInt(pipe_size_str.c_str(), &pipe_buffer_size, 0)) { LOG(FATAL) << "failed to parse pipe max size '" << pipe_size_str << "'"; } } if (fcntl(pipe_read.get(), F_SETPIPE_SZ, pipe_buffer_size) != pipe_buffer_size) { PLOG(ERROR) << "failed to set pipe buffer size"; } if (send_fd(set_timeout(sockfd), &req, sizeof(req), std::move(pipe_write)) != sizeof(req)) { PLOG(ERROR) << "libdebuggerd_client: failed to send output fd to tombstoned"; return false; Loading debuggerd/crash_dump.cpp +15 −5 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ #include <android-base/unique_fd.h> #include <cutils/sockets.h> #include <log/log.h> #include <private/android_filesystem_config.h> #include <procinfo/process.h> #include "backtrace.h" Loading Loading @@ -99,8 +100,9 @@ static bool ptrace_seize_thread(int pid_proc_fd, pid_t tid, std::string* error) return true; } static bool activity_manager_notify(int pid, int signal, const std::string& amfd_data) { android::base::unique_fd amfd(socket_local_client("/data/system/ndebugsocket", ANDROID_SOCKET_NAMESPACE_FILESYSTEM, SOCK_STREAM)); static bool activity_manager_notify(pid_t pid, int signal, const std::string& amfd_data) { android::base::unique_fd amfd(socket_local_client( "/data/system/ndebugsocket", ANDROID_SOCKET_NAMESPACE_FILESYSTEM, SOCK_STREAM)); if (amfd.get() == -1) { PLOG(ERROR) << "unable to connect to activity manager"; return false; Loading Loading @@ -207,9 +209,14 @@ int main(int argc, char** argv) { action.sa_handler = signal_handler; debuggerd_register_handlers(&action); sigset_t mask; sigemptyset(&mask); if (sigprocmask(SIG_SETMASK, &mask, nullptr) != 0) { PLOG(FATAL) << "failed to set signal mask"; } if (argc != 4) { LOG(FATAL) << "Wrong number of args: " << argc << " (expected 4)"; return 1; } pid_t main_tid; Loading Loading @@ -264,7 +271,7 @@ int main(int argc, char** argv) { } // Die if we take too long. alarm(20); alarm(2); std::string attach_error; Loading Loading @@ -408,8 +415,11 @@ int main(int argc, char** argv) { } if (fatal_signal) { // Don't try to notify ActivityManager if it just crashed, or we might hang until timeout. if (target_info.name != "system_server" || target_info.uid != AID_SYSTEM) { activity_manager_notify(target, signo, amfd_data); } } // Close stdout before we notify tombstoned of completion. close(STDOUT_FILENO); Loading debuggerd/debuggerd_test.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -119,6 +119,8 @@ static void tombstoned_intercept(pid_t target_pid, unique_fd* intercept_fd, uniq FAIL() << "failed to set pipe size: " << strerror(errno); } ASSERT_GE(pipe_buffer_size, 1024 * 1024); if (send_fd(intercept_fd->get(), &req, sizeof(req), std::move(output_pipe_write)) != sizeof(req)) { FAIL() << "failed to send output fd to tombstoned: " << strerror(errno); } Loading Loading
debuggerd/client/debuggerd_client.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -28,7 +28,9 @@ #include <android-base/file.h> #include <android-base/logging.h> #include <android-base/parseint.h> #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <android-base/unique_fd.h> #include <cutils/sockets.h> Loading Loading @@ -117,6 +119,20 @@ bool debuggerd_trigger_dump(pid_t pid, DebuggerdDumpType dump_type, unsigned int return false; } std::string pipe_size_str; int pipe_buffer_size = 1024 * 1024; if (android::base::ReadFileToString("/proc/sys/fs/pipe-max-size", &pipe_size_str)) { pipe_size_str = android::base::Trim(pipe_size_str); if (!android::base::ParseInt(pipe_size_str.c_str(), &pipe_buffer_size, 0)) { LOG(FATAL) << "failed to parse pipe max size '" << pipe_size_str << "'"; } } if (fcntl(pipe_read.get(), F_SETPIPE_SZ, pipe_buffer_size) != pipe_buffer_size) { PLOG(ERROR) << "failed to set pipe buffer size"; } if (send_fd(set_timeout(sockfd), &req, sizeof(req), std::move(pipe_write)) != sizeof(req)) { PLOG(ERROR) << "libdebuggerd_client: failed to send output fd to tombstoned"; return false; Loading
debuggerd/crash_dump.cpp +15 −5 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ #include <android-base/unique_fd.h> #include <cutils/sockets.h> #include <log/log.h> #include <private/android_filesystem_config.h> #include <procinfo/process.h> #include "backtrace.h" Loading Loading @@ -99,8 +100,9 @@ static bool ptrace_seize_thread(int pid_proc_fd, pid_t tid, std::string* error) return true; } static bool activity_manager_notify(int pid, int signal, const std::string& amfd_data) { android::base::unique_fd amfd(socket_local_client("/data/system/ndebugsocket", ANDROID_SOCKET_NAMESPACE_FILESYSTEM, SOCK_STREAM)); static bool activity_manager_notify(pid_t pid, int signal, const std::string& amfd_data) { android::base::unique_fd amfd(socket_local_client( "/data/system/ndebugsocket", ANDROID_SOCKET_NAMESPACE_FILESYSTEM, SOCK_STREAM)); if (amfd.get() == -1) { PLOG(ERROR) << "unable to connect to activity manager"; return false; Loading Loading @@ -207,9 +209,14 @@ int main(int argc, char** argv) { action.sa_handler = signal_handler; debuggerd_register_handlers(&action); sigset_t mask; sigemptyset(&mask); if (sigprocmask(SIG_SETMASK, &mask, nullptr) != 0) { PLOG(FATAL) << "failed to set signal mask"; } if (argc != 4) { LOG(FATAL) << "Wrong number of args: " << argc << " (expected 4)"; return 1; } pid_t main_tid; Loading Loading @@ -264,7 +271,7 @@ int main(int argc, char** argv) { } // Die if we take too long. alarm(20); alarm(2); std::string attach_error; Loading Loading @@ -408,8 +415,11 @@ int main(int argc, char** argv) { } if (fatal_signal) { // Don't try to notify ActivityManager if it just crashed, or we might hang until timeout. if (target_info.name != "system_server" || target_info.uid != AID_SYSTEM) { activity_manager_notify(target, signo, amfd_data); } } // Close stdout before we notify tombstoned of completion. close(STDOUT_FILENO); Loading
debuggerd/debuggerd_test.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -119,6 +119,8 @@ static void tombstoned_intercept(pid_t target_pid, unique_fd* intercept_fd, uniq FAIL() << "failed to set pipe size: " << strerror(errno); } ASSERT_GE(pipe_buffer_size, 1024 * 1024); if (send_fd(intercept_fd->get(), &req, sizeof(req), std::move(output_pipe_write)) != sizeof(req)) { FAIL() << "failed to send output fd to tombstoned: " << strerror(errno); } Loading