Loading debuggerd/client/debuggerd_client.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -185,7 +185,7 @@ static bool have_siginfo(int signum) { return result; } static void send_debuggerd_packet(siginfo_t* info) { static void send_debuggerd_packet() { // Mutex to prevent multiple crashing threads from trying to talk // to debuggerd at the same time. static pthread_mutex_t crash_mutex = PTHREAD_MUTEX_INITIALIZER; Loading Loading @@ -222,7 +222,6 @@ static void send_debuggerd_packet(siginfo_t* info) { msg.abort_msg_address = reinterpret_cast<uintptr_t>(g_callbacks.get_abort_message()); } msg.original_si_code = (info != nullptr) ? info->si_code : 0; ret = TEMP_FAILURE_RETRY(write(s, &msg, sizeof(msg))); if (ret == sizeof(msg)) { char debuggerd_ack; Loading Loading @@ -254,7 +253,7 @@ static void debuggerd_signal_handler(int signal_number, siginfo_t* info, void*) log_signal_summary(signal_number, info); send_debuggerd_packet(info); send_debuggerd_packet(); // We need to return from the signal handler so that debuggerd can dump the // thread that crashed, but returning here does not guarantee that the signal Loading debuggerd/debuggerd.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -51,6 +51,8 @@ #include <private/android_filesystem_config.h> #include <debuggerd/client.h> #include "backtrace.h" #include "getevent.h" #include "signal_sender.h" Loading @@ -70,7 +72,6 @@ struct debugger_request_t { pid_t pid, tid; uid_t uid, gid; uintptr_t abort_msg_address; int32_t original_si_code; }; static void wait_for_user_action(const debugger_request_t& request) { Loading Loading @@ -222,7 +223,6 @@ static int read_request(int fd, debugger_request_t* out_request) { out_request->uid = cr.uid; out_request->gid = cr.gid; out_request->abort_msg_address = msg.abort_msg_address; out_request->original_si_code = msg.original_si_code; if (msg.action == DEBUGGER_ACTION_CRASH) { // Ensure that the tid reported by the crashing process is valid. Loading Loading @@ -471,8 +471,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, signal, request.original_si_code, request.abort_msg_address, amfd_data); engrave_tombstone(tombstone_fd, backtrace_map, 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"); dump_backtrace(fd, backtrace_map, request.pid, request.tid, siblings, nullptr); Loading @@ -497,8 +497,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, signal, request.original_si_code, request.abort_msg_address, amfd_data); engrave_tombstone(tombstone_fd, backtrace_map, request.pid, request.tid, siblings, request.abort_msg_address, amfd_data); break; default: Loading debuggerd/include/debuggerd/client.h +0 −1 Original line number Diff line number Diff line Loading @@ -44,7 +44,6 @@ typedef struct __attribute__((packed)) { int32_t action; pid_t tid; uint64_t abort_msg_address; int32_t original_si_code; } debugger_msg_t; // These callbacks are called in a signal handler, and thus must be async signal safe. Loading debuggerd/test/tombstone_test.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -595,7 +595,7 @@ TEST_F(TombstoneTest, dump_signal_info_error) { si.si_signo = 0; ptrace_set_fake_getsiginfo(si); dump_signal_info(&log_, 123, SIGSEGV, 10); dump_signal_info(&log_, 123); std::string tombstone_contents; ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0); Loading debuggerd/tombstone.cpp +13 −20 Original line number Diff line number Diff line Loading @@ -176,7 +176,7 @@ static void dump_header_info(log_t* log) { _LOG(log, logtype::HEADER, "ABI: '%s'\n", ABI_STRING); } static void dump_signal_info(log_t* log, pid_t tid, int signal, int si_code) { static void dump_signal_info(log_t* log, pid_t tid) { siginfo_t si; memset(&si, 0, sizeof(si)); if (ptrace(PTRACE_GETSIGINFO, tid, 0, &si) == -1) { Loading @@ -184,18 +184,15 @@ static void dump_signal_info(log_t* log, pid_t tid, int signal, int si_code) { return; } // bionic has to re-raise some signals, which overwrites the si_code with SI_TKILL. si.si_code = si_code; char addr_desc[32]; // ", fault addr 0x1234" if (signal_has_si_addr(signal)) { if (signal_has_si_addr(si.si_signo)) { snprintf(addr_desc, sizeof(addr_desc), "%p", si.si_addr); } else { snprintf(addr_desc, sizeof(addr_desc), "--------"); } _LOG(log, logtype::HEADER, "signal %d (%s), code %d (%s), fault addr %s\n", signal, get_signame(signal), si.si_code, get_sigcode(signal, si.si_code), addr_desc); _LOG(log, logtype::HEADER, "signal %d (%s), code %d (%s), fault addr %s\n", si.si_signo, get_signame(si.si_signo), si.si_code, get_sigcode(si.si_signo, si.si_code), addr_desc); } static void dump_thread_info(log_t* log, pid_t pid, pid_t tid) { Loading Loading @@ -445,17 +442,14 @@ static void dump_backtrace_and_stack(Backtrace* backtrace, log_t* log) { } } static void dump_thread(log_t* log, pid_t pid, pid_t tid, BacktraceMap* map, int signal, int si_code, uintptr_t abort_msg_address, bool primary_thread) { static void dump_thread(log_t* log, pid_t pid, pid_t tid, BacktraceMap* map, uintptr_t abort_msg_address, bool primary_thread) { log->current_tid = tid; if (!primary_thread) { _LOG(log, logtype::THREAD, "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n"); } dump_thread_info(log, pid, tid); if (signal) { dump_signal_info(log, tid, signal, si_code); } dump_signal_info(log, tid); std::unique_ptr<Backtrace> backtrace(Backtrace::Create(pid, tid, map)); if (primary_thread) { Loading Loading @@ -606,8 +600,7 @@ static void dump_logs(log_t* log, pid_t pid, unsigned int tail) { // Dumps all information about the specified pid to the tombstone. static void dump_crash(log_t* log, BacktraceMap* map, pid_t pid, pid_t tid, const std::set<pid_t>& siblings, int signal, int si_code, uintptr_t abort_msg_address) { const std::set<pid_t>& siblings, uintptr_t abort_msg_address) { // don't copy log messages to tombstone unless this is a dev device char value[PROPERTY_VALUE_MAX]; property_get("ro.debuggable", value, "0"); Loading @@ -616,14 +609,14 @@ static void dump_crash(log_t* log, BacktraceMap* map, pid_t pid, pid_t tid, _LOG(log, logtype::HEADER, "*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***\n"); dump_header_info(log); dump_thread(log, pid, tid, map, signal, si_code, abort_msg_address, true); dump_thread(log, pid, tid, map, abort_msg_address, true); if (want_logs) { dump_logs(log, pid, 5); } if (!siblings.empty()) { for (pid_t sibling : siblings) { dump_thread(log, pid, sibling, map, 0, 0, 0, false); dump_thread(log, pid, sibling, map, 0, false); } } Loading Loading @@ -686,8 +679,8 @@ int open_tombstone(std::string* out_path) { } void engrave_tombstone(int tombstone_fd, BacktraceMap* map, pid_t pid, pid_t tid, const std::set<pid_t>& siblings, int signal, int original_si_code, uintptr_t abort_msg_address, std::string* amfd_data) { const std::set<pid_t>& siblings, uintptr_t abort_msg_address, std::string* amfd_data) { log_t log; log.current_tid = tid; log.crashed_tid = tid; Loading @@ -699,5 +692,5 @@ void engrave_tombstone(int tombstone_fd, BacktraceMap* map, pid_t pid, pid_t tid log.tfd = tombstone_fd; log.amfd_data = amfd_data; dump_crash(&log, map, pid, tid, siblings, signal, original_si_code, abort_msg_address); dump_crash(&log, map, pid, tid, siblings, abort_msg_address); } Loading
debuggerd/client/debuggerd_client.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -185,7 +185,7 @@ static bool have_siginfo(int signum) { return result; } static void send_debuggerd_packet(siginfo_t* info) { static void send_debuggerd_packet() { // Mutex to prevent multiple crashing threads from trying to talk // to debuggerd at the same time. static pthread_mutex_t crash_mutex = PTHREAD_MUTEX_INITIALIZER; Loading Loading @@ -222,7 +222,6 @@ static void send_debuggerd_packet(siginfo_t* info) { msg.abort_msg_address = reinterpret_cast<uintptr_t>(g_callbacks.get_abort_message()); } msg.original_si_code = (info != nullptr) ? info->si_code : 0; ret = TEMP_FAILURE_RETRY(write(s, &msg, sizeof(msg))); if (ret == sizeof(msg)) { char debuggerd_ack; Loading Loading @@ -254,7 +253,7 @@ static void debuggerd_signal_handler(int signal_number, siginfo_t* info, void*) log_signal_summary(signal_number, info); send_debuggerd_packet(info); send_debuggerd_packet(); // We need to return from the signal handler so that debuggerd can dump the // thread that crashed, but returning here does not guarantee that the signal Loading
debuggerd/debuggerd.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -51,6 +51,8 @@ #include <private/android_filesystem_config.h> #include <debuggerd/client.h> #include "backtrace.h" #include "getevent.h" #include "signal_sender.h" Loading @@ -70,7 +72,6 @@ struct debugger_request_t { pid_t pid, tid; uid_t uid, gid; uintptr_t abort_msg_address; int32_t original_si_code; }; static void wait_for_user_action(const debugger_request_t& request) { Loading Loading @@ -222,7 +223,6 @@ static int read_request(int fd, debugger_request_t* out_request) { out_request->uid = cr.uid; out_request->gid = cr.gid; out_request->abort_msg_address = msg.abort_msg_address; out_request->original_si_code = msg.original_si_code; if (msg.action == DEBUGGER_ACTION_CRASH) { // Ensure that the tid reported by the crashing process is valid. Loading Loading @@ -471,8 +471,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, signal, request.original_si_code, request.abort_msg_address, amfd_data); engrave_tombstone(tombstone_fd, backtrace_map, 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"); dump_backtrace(fd, backtrace_map, request.pid, request.tid, siblings, nullptr); Loading @@ -497,8 +497,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, signal, request.original_si_code, request.abort_msg_address, amfd_data); engrave_tombstone(tombstone_fd, backtrace_map, request.pid, request.tid, siblings, request.abort_msg_address, amfd_data); break; default: Loading
debuggerd/include/debuggerd/client.h +0 −1 Original line number Diff line number Diff line Loading @@ -44,7 +44,6 @@ typedef struct __attribute__((packed)) { int32_t action; pid_t tid; uint64_t abort_msg_address; int32_t original_si_code; } debugger_msg_t; // These callbacks are called in a signal handler, and thus must be async signal safe. Loading
debuggerd/test/tombstone_test.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -595,7 +595,7 @@ TEST_F(TombstoneTest, dump_signal_info_error) { si.si_signo = 0; ptrace_set_fake_getsiginfo(si); dump_signal_info(&log_, 123, SIGSEGV, 10); dump_signal_info(&log_, 123); std::string tombstone_contents; ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0); Loading
debuggerd/tombstone.cpp +13 −20 Original line number Diff line number Diff line Loading @@ -176,7 +176,7 @@ static void dump_header_info(log_t* log) { _LOG(log, logtype::HEADER, "ABI: '%s'\n", ABI_STRING); } static void dump_signal_info(log_t* log, pid_t tid, int signal, int si_code) { static void dump_signal_info(log_t* log, pid_t tid) { siginfo_t si; memset(&si, 0, sizeof(si)); if (ptrace(PTRACE_GETSIGINFO, tid, 0, &si) == -1) { Loading @@ -184,18 +184,15 @@ static void dump_signal_info(log_t* log, pid_t tid, int signal, int si_code) { return; } // bionic has to re-raise some signals, which overwrites the si_code with SI_TKILL. si.si_code = si_code; char addr_desc[32]; // ", fault addr 0x1234" if (signal_has_si_addr(signal)) { if (signal_has_si_addr(si.si_signo)) { snprintf(addr_desc, sizeof(addr_desc), "%p", si.si_addr); } else { snprintf(addr_desc, sizeof(addr_desc), "--------"); } _LOG(log, logtype::HEADER, "signal %d (%s), code %d (%s), fault addr %s\n", signal, get_signame(signal), si.si_code, get_sigcode(signal, si.si_code), addr_desc); _LOG(log, logtype::HEADER, "signal %d (%s), code %d (%s), fault addr %s\n", si.si_signo, get_signame(si.si_signo), si.si_code, get_sigcode(si.si_signo, si.si_code), addr_desc); } static void dump_thread_info(log_t* log, pid_t pid, pid_t tid) { Loading Loading @@ -445,17 +442,14 @@ static void dump_backtrace_and_stack(Backtrace* backtrace, log_t* log) { } } static void dump_thread(log_t* log, pid_t pid, pid_t tid, BacktraceMap* map, int signal, int si_code, uintptr_t abort_msg_address, bool primary_thread) { static void dump_thread(log_t* log, pid_t pid, pid_t tid, BacktraceMap* map, uintptr_t abort_msg_address, bool primary_thread) { log->current_tid = tid; if (!primary_thread) { _LOG(log, logtype::THREAD, "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n"); } dump_thread_info(log, pid, tid); if (signal) { dump_signal_info(log, tid, signal, si_code); } dump_signal_info(log, tid); std::unique_ptr<Backtrace> backtrace(Backtrace::Create(pid, tid, map)); if (primary_thread) { Loading Loading @@ -606,8 +600,7 @@ static void dump_logs(log_t* log, pid_t pid, unsigned int tail) { // Dumps all information about the specified pid to the tombstone. static void dump_crash(log_t* log, BacktraceMap* map, pid_t pid, pid_t tid, const std::set<pid_t>& siblings, int signal, int si_code, uintptr_t abort_msg_address) { const std::set<pid_t>& siblings, uintptr_t abort_msg_address) { // don't copy log messages to tombstone unless this is a dev device char value[PROPERTY_VALUE_MAX]; property_get("ro.debuggable", value, "0"); Loading @@ -616,14 +609,14 @@ static void dump_crash(log_t* log, BacktraceMap* map, pid_t pid, pid_t tid, _LOG(log, logtype::HEADER, "*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***\n"); dump_header_info(log); dump_thread(log, pid, tid, map, signal, si_code, abort_msg_address, true); dump_thread(log, pid, tid, map, abort_msg_address, true); if (want_logs) { dump_logs(log, pid, 5); } if (!siblings.empty()) { for (pid_t sibling : siblings) { dump_thread(log, pid, sibling, map, 0, 0, 0, false); dump_thread(log, pid, sibling, map, 0, false); } } Loading Loading @@ -686,8 +679,8 @@ int open_tombstone(std::string* out_path) { } void engrave_tombstone(int tombstone_fd, BacktraceMap* map, pid_t pid, pid_t tid, const std::set<pid_t>& siblings, int signal, int original_si_code, uintptr_t abort_msg_address, std::string* amfd_data) { const std::set<pid_t>& siblings, uintptr_t abort_msg_address, std::string* amfd_data) { log_t log; log.current_tid = tid; log.crashed_tid = tid; Loading @@ -699,5 +692,5 @@ void engrave_tombstone(int tombstone_fd, BacktraceMap* map, pid_t pid, pid_t tid log.tfd = tombstone_fd; log.amfd_data = amfd_data; dump_crash(&log, map, pid, tid, siblings, signal, original_si_code, abort_msg_address); dump_crash(&log, map, pid, tid, siblings, abort_msg_address); }