Merge "debuggerd: remove unnecessary arguments."

am: 7a746f3a68

Change-Id: I0a01639dd3096372eb5bbbe28362cdbf1c1da4af
This commit is contained in:
Josh Gao 2016-08-13 00:38:54 +00:00 committed by android-build-merger
commit 60083bed75
6 changed files with 24 additions and 33 deletions

View file

@ -185,7 +185,7 @@ static bool have_siginfo(int signum) {
return result; 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 // Mutex to prevent multiple crashing threads from trying to talk
// to debuggerd at the same time. // to debuggerd at the same time.
static pthread_mutex_t crash_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t crash_mutex = PTHREAD_MUTEX_INITIALIZER;
@ -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.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))); ret = TEMP_FAILURE_RETRY(write(s, &msg, sizeof(msg)));
if (ret == sizeof(msg)) { if (ret == sizeof(msg)) {
char debuggerd_ack; char debuggerd_ack;
@ -254,7 +253,7 @@ static void debuggerd_signal_handler(int signal_number, siginfo_t* info, void*)
log_signal_summary(signal_number, info); 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 // 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 // thread that crashed, but returning here does not guarantee that the signal

View file

@ -51,6 +51,8 @@
#include <private/android_filesystem_config.h> #include <private/android_filesystem_config.h>
#include <debuggerd/client.h>
#include "backtrace.h" #include "backtrace.h"
#include "getevent.h" #include "getevent.h"
#include "signal_sender.h" #include "signal_sender.h"
@ -70,7 +72,6 @@ struct debugger_request_t {
pid_t pid, tid; pid_t pid, tid;
uid_t uid, gid; uid_t uid, gid;
uintptr_t abort_msg_address; uintptr_t abort_msg_address;
int32_t original_si_code;
}; };
static void wait_for_user_action(const debugger_request_t& request) { static void wait_for_user_action(const debugger_request_t& request) {
@ -222,7 +223,6 @@ static int read_request(int fd, debugger_request_t* out_request) {
out_request->uid = cr.uid; out_request->uid = cr.uid;
out_request->gid = cr.gid; out_request->gid = cr.gid;
out_request->abort_msg_address = msg.abort_msg_address; out_request->abort_msg_address = msg.abort_msg_address;
out_request->original_si_code = msg.original_si_code;
if (msg.action == DEBUGGER_ACTION_CRASH) { if (msg.action == DEBUGGER_ACTION_CRASH) {
// Ensure that the tid reported by the crashing process is valid. // Ensure that the tid reported by the crashing process is valid.
@ -471,8 +471,8 @@ static bool perform_dump(const debugger_request_t& request, int fd, int tombston
case SIGSTOP: case SIGSTOP:
if (request.action == DEBUGGER_ACTION_DUMP_TOMBSTONE) { if (request.action == DEBUGGER_ACTION_DUMP_TOMBSTONE) {
ALOGV("debuggerd: stopped -- dumping to tombstone"); ALOGV("debuggerd: stopped -- dumping to tombstone");
engrave_tombstone(tombstone_fd, backtrace_map, request.pid, request.tid, siblings, signal, engrave_tombstone(tombstone_fd, backtrace_map, request.pid, request.tid, siblings,
request.original_si_code, request.abort_msg_address, amfd_data); request.abort_msg_address, amfd_data);
} else if (request.action == DEBUGGER_ACTION_DUMP_BACKTRACE) { } else if (request.action == DEBUGGER_ACTION_DUMP_BACKTRACE) {
ALOGV("debuggerd: stopped -- dumping to fd"); ALOGV("debuggerd: stopped -- dumping to fd");
dump_backtrace(fd, backtrace_map, request.pid, request.tid, siblings, nullptr); dump_backtrace(fd, backtrace_map, request.pid, request.tid, siblings, nullptr);
@ -498,8 +498,8 @@ static bool perform_dump(const debugger_request_t& request, int fd, int tombston
case SIGTRAP: case SIGTRAP:
ALOGV("stopped -- fatal signal\n"); ALOGV("stopped -- fatal signal\n");
*crash_signal = signal; *crash_signal = signal;
engrave_tombstone(tombstone_fd, backtrace_map, request.pid, request.tid, siblings, signal, engrave_tombstone(tombstone_fd, backtrace_map, request.pid, request.tid, siblings,
request.original_si_code, request.abort_msg_address, amfd_data); request.abort_msg_address, amfd_data);
break; break;
default: default:

View file

@ -44,7 +44,6 @@ typedef struct __attribute__((packed)) {
int32_t action; int32_t action;
pid_t tid; pid_t tid;
uint64_t abort_msg_address; uint64_t abort_msg_address;
int32_t original_si_code;
} debugger_msg_t; } debugger_msg_t;
// These callbacks are called in a signal handler, and thus must be async signal safe. // These callbacks are called in a signal handler, and thus must be async signal safe.

View file

@ -595,7 +595,7 @@ TEST_F(TombstoneTest, dump_signal_info_error) {
si.si_signo = 0; si.si_signo = 0;
ptrace_set_fake_getsiginfo(si); ptrace_set_fake_getsiginfo(si);
dump_signal_info(&log_, 123, SIGSEGV, 10); dump_signal_info(&log_, 123);
std::string tombstone_contents; std::string tombstone_contents;
ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0); ASSERT_TRUE(lseek(log_.tfd, 0, SEEK_SET) == 0);

View file

@ -176,7 +176,7 @@ static void dump_header_info(log_t* log) {
_LOG(log, logtype::HEADER, "ABI: '%s'\n", ABI_STRING); _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; siginfo_t si;
memset(&si, 0, sizeof(si)); memset(&si, 0, sizeof(si));
if (ptrace(PTRACE_GETSIGINFO, tid, 0, &si) == -1) { if (ptrace(PTRACE_GETSIGINFO, tid, 0, &si) == -1) {
@ -184,18 +184,15 @@ static void dump_signal_info(log_t* log, pid_t tid, int signal, int si_code) {
return; 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" 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); snprintf(addr_desc, sizeof(addr_desc), "%p", si.si_addr);
} else { } else {
snprintf(addr_desc, sizeof(addr_desc), "--------"); snprintf(addr_desc, sizeof(addr_desc), "--------");
} }
_LOG(log, logtype::HEADER, "signal %d (%s), code %d (%s), fault addr %s\n", _LOG(log, logtype::HEADER, "signal %d (%s), code %d (%s), fault addr %s\n", si.si_signo,
signal, get_signame(signal), si.si_code, get_sigcode(signal, si.si_code), addr_desc); 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) { static void dump_thread_info(log_t* log, pid_t pid, pid_t tid) {
@ -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, static void dump_thread(log_t* log, pid_t pid, pid_t tid, BacktraceMap* map,
int si_code, uintptr_t abort_msg_address, bool primary_thread) { uintptr_t abort_msg_address, bool primary_thread) {
log->current_tid = tid; log->current_tid = tid;
if (!primary_thread) { if (!primary_thread) {
_LOG(log, logtype::THREAD, "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n"); _LOG(log, logtype::THREAD, "--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---\n");
} }
dump_thread_info(log, pid, tid); dump_thread_info(log, pid, tid);
dump_signal_info(log, tid);
if (signal) {
dump_signal_info(log, tid, signal, si_code);
}
std::unique_ptr<Backtrace> backtrace(Backtrace::Create(pid, tid, map)); std::unique_ptr<Backtrace> backtrace(Backtrace::Create(pid, tid, map));
if (primary_thread) { if (primary_thread) {
@ -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. // 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, 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, const std::set<pid_t>& siblings, uintptr_t abort_msg_address) {
uintptr_t abort_msg_address) {
// don't copy log messages to tombstone unless this is a dev device // don't copy log messages to tombstone unless this is a dev device
char value[PROPERTY_VALUE_MAX]; char value[PROPERTY_VALUE_MAX];
property_get("ro.debuggable", value, "0"); property_get("ro.debuggable", value, "0");
@ -616,14 +609,14 @@ static void dump_crash(log_t* log, BacktraceMap* map, pid_t pid, pid_t tid,
_LOG(log, logtype::HEADER, _LOG(log, logtype::HEADER,
"*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***\n"); "*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***\n");
dump_header_info(log); 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) { if (want_logs) {
dump_logs(log, pid, 5); dump_logs(log, pid, 5);
} }
if (!siblings.empty()) { if (!siblings.empty()) {
for (pid_t sibling : siblings) { for (pid_t sibling : siblings) {
dump_thread(log, pid, sibling, map, 0, 0, 0, false); dump_thread(log, pid, sibling, map, 0, false);
} }
} }
@ -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, 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, const std::set<pid_t>& siblings, uintptr_t abort_msg_address,
uintptr_t abort_msg_address, std::string* amfd_data) { std::string* amfd_data) {
log_t log; log_t log;
log.current_tid = tid; log.current_tid = tid;
log.crashed_tid = tid; log.crashed_tid = tid;
@ -699,5 +692,5 @@ void engrave_tombstone(int tombstone_fd, BacktraceMap* map, pid_t pid, pid_t tid
log.tfd = tombstone_fd; log.tfd = tombstone_fd;
log.amfd_data = amfd_data; 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);
} }

View file

@ -33,7 +33,7 @@ int open_tombstone(std::string* path);
/* Creates a tombstone file and writes the crash dump to it. */ /* Creates a tombstone file and writes the crash dump to it. */
void engrave_tombstone(int tombstone_fd, BacktraceMap* map, pid_t pid, pid_t tid, 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, const std::set<pid_t>& siblings, uintptr_t abort_msg_address,
uintptr_t abort_msg_address, std::string* amfd_data); std::string* amfd_data);
#endif // _DEBUGGERD_TOMBSTONE_H #endif // _DEBUGGERD_TOMBSTONE_H