resolved conflicts for merge of f79c0518 to jb-mr2-dev-plus-aosp
Change-Id: I106a2aa7ec393a68e51132bf277b22bece155a8e
This commit is contained in:
commit
8a4ae0a873
4 changed files with 54 additions and 12 deletions
|
|
@ -52,6 +52,7 @@ typedef struct {
|
||||||
debugger_action_t action;
|
debugger_action_t action;
|
||||||
pid_t pid, tid;
|
pid_t pid, tid;
|
||||||
uid_t uid, gid;
|
uid_t uid, gid;
|
||||||
|
uintptr_t abort_msg_address;
|
||||||
} debugger_request_t;
|
} debugger_request_t;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
@ -207,13 +208,16 @@ static int read_request(int fd, debugger_request_t* out_request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
debugger_msg_t msg;
|
debugger_msg_t msg;
|
||||||
|
memset(&msg, 0, sizeof(msg));
|
||||||
status = TEMP_FAILURE_RETRY(read(fd, &msg, sizeof(msg)));
|
status = TEMP_FAILURE_RETRY(read(fd, &msg, sizeof(msg)));
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
LOG("read failure? %s (pid=%d uid=%d)\n",
|
LOG("read failure? %s (pid=%d uid=%d)\n",
|
||||||
strerror(errno), cr.pid, cr.uid);
|
strerror(errno), cr.pid, cr.uid);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (status != sizeof(msg)) {
|
if (status == sizeof(debugger_msg_t)) {
|
||||||
|
XLOG("crash request of size %d abort_msg_address=%#08x\n", status, msg.abort_msg_address);
|
||||||
|
} else {
|
||||||
LOG("invalid crash request of size %d (from pid=%d uid=%d)\n",
|
LOG("invalid crash request of size %d (from pid=%d uid=%d)\n",
|
||||||
status, cr.pid, cr.uid);
|
status, cr.pid, cr.uid);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -224,6 +228,7 @@ static int read_request(int fd, debugger_request_t* out_request) {
|
||||||
out_request->pid = cr.pid;
|
out_request->pid = cr.pid;
|
||||||
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;
|
||||||
|
|
||||||
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. */
|
||||||
|
|
@ -267,6 +272,7 @@ static void handle_request(int fd) {
|
||||||
XLOG("handle_request(%d)\n", fd);
|
XLOG("handle_request(%d)\n", fd);
|
||||||
|
|
||||||
debugger_request_t request;
|
debugger_request_t request;
|
||||||
|
memset(&request, 0, sizeof(request));
|
||||||
int status = read_request(fd, &request);
|
int status = read_request(fd, &request);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
XLOG("BOOM: pid=%d uid=%d gid=%d tid=%d\n",
|
XLOG("BOOM: pid=%d uid=%d gid=%d tid=%d\n",
|
||||||
|
|
@ -310,7 +316,7 @@ static void handle_request(int fd) {
|
||||||
if (request.action == DEBUGGER_ACTION_DUMP_TOMBSTONE) {
|
if (request.action == DEBUGGER_ACTION_DUMP_TOMBSTONE) {
|
||||||
XLOG("stopped -- dumping to tombstone\n");
|
XLOG("stopped -- dumping to tombstone\n");
|
||||||
tombstone_path = engrave_tombstone(request.pid, request.tid,
|
tombstone_path = engrave_tombstone(request.pid, request.tid,
|
||||||
signal, true, true, &detach_failed,
|
signal, request.abort_msg_address, true, true, &detach_failed,
|
||||||
&total_sleep_time_usec);
|
&total_sleep_time_usec);
|
||||||
} else if (request.action == DEBUGGER_ACTION_DUMP_BACKTRACE) {
|
} else if (request.action == DEBUGGER_ACTION_DUMP_BACKTRACE) {
|
||||||
XLOG("stopped -- dumping to fd\n");
|
XLOG("stopped -- dumping to fd\n");
|
||||||
|
|
@ -348,8 +354,8 @@ static void handle_request(int fd) {
|
||||||
/* don't dump sibling threads when attaching to GDB because it
|
/* don't dump sibling threads when attaching to GDB because it
|
||||||
* makes the process less reliable, apparently... */
|
* makes the process less reliable, apparently... */
|
||||||
tombstone_path = engrave_tombstone(request.pid, request.tid,
|
tombstone_path = engrave_tombstone(request.pid, request.tid,
|
||||||
signal, !attach_gdb, false, &detach_failed,
|
signal, request.abort_msg_address, !attach_gdb, false,
|
||||||
&total_sleep_time_usec);
|
&detach_failed, &total_sleep_time_usec);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,7 @@ static void dump_fault_addr(log_t* log, pid_t tid, int sig)
|
||||||
siginfo_t si;
|
siginfo_t si;
|
||||||
|
|
||||||
memset(&si, 0, sizeof(si));
|
memset(&si, 0, sizeof(si));
|
||||||
if(ptrace(PTRACE_GETSIGINFO, tid, 0, &si)){
|
if (ptrace(PTRACE_GETSIGINFO, tid, 0, &si)){
|
||||||
_LOG(log, false, "cannot get siginfo: %s\n", strerror(errno));
|
_LOG(log, false, "cannot get siginfo: %s\n", strerror(errno));
|
||||||
} else if (signal_has_address(sig)) {
|
} else if (signal_has_address(sig)) {
|
||||||
_LOG(log, false, "signal %d (%s), code %d (%s), fault addr %08x\n",
|
_LOG(log, false, "signal %d (%s), code %d (%s), fault addr %08x\n",
|
||||||
|
|
@ -622,11 +622,46 @@ static void dump_logs(log_t* log, pid_t pid, bool tailOnly)
|
||||||
dump_log_file(log, pid, "/dev/log/main", tailOnly);
|
dump_log_file(log, pid, "/dev/log/main", tailOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void dump_abort_message(log_t* log, pid_t tid, uintptr_t address) {
|
||||||
|
if (address == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
address += sizeof(size_t); // Skip the buffer length.
|
||||||
|
|
||||||
|
char msg[512];
|
||||||
|
memset(msg, 0, sizeof(msg));
|
||||||
|
char* p = &msg[0];
|
||||||
|
while (p < &msg[sizeof(msg)]) {
|
||||||
|
uint32_t data;
|
||||||
|
if (!try_get_word_ptrace(tid, address, &data)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
address += sizeof(uint32_t);
|
||||||
|
|
||||||
|
if ((*p++ = (data >> 0) & 0xff) == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ((*p++ = (data >> 8) & 0xff) == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ((*p++ = (data >> 16) & 0xff) == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ((*p++ = (data >> 24) & 0xff) == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
msg[sizeof(msg) - 1] = '\0';
|
||||||
|
|
||||||
|
_LOG(log, false, "Abort message: '%s'\n", msg);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Dumps all information about the specified pid to the tombstone.
|
* Dumps all information about the specified pid to the tombstone.
|
||||||
*/
|
*/
|
||||||
static bool dump_crash(log_t* log, pid_t pid, pid_t tid, int signal,
|
static bool dump_crash(log_t* log, pid_t pid, pid_t tid, int signal, uintptr_t abort_msg_address,
|
||||||
bool dump_sibling_threads, int* total_sleep_time_usec)
|
bool dump_sibling_threads, int* total_sleep_time_usec)
|
||||||
{
|
{
|
||||||
/* 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];
|
||||||
|
|
@ -650,9 +685,10 @@ static bool dump_crash(log_t* log, pid_t pid, pid_t tid, int signal,
|
||||||
dump_build_info(log);
|
dump_build_info(log);
|
||||||
dump_revision_info(log);
|
dump_revision_info(log);
|
||||||
dump_thread_info(log, pid, tid, true);
|
dump_thread_info(log, pid, tid, true);
|
||||||
if(signal) {
|
if (signal) {
|
||||||
dump_fault_addr(log, tid, signal);
|
dump_fault_addr(log, tid, signal);
|
||||||
}
|
}
|
||||||
|
dump_abort_message(log, tid, abort_msg_address);
|
||||||
|
|
||||||
ptrace_context_t* context = load_ptrace_context(tid);
|
ptrace_context_t* context = load_ptrace_context(tid);
|
||||||
dump_thread(context, log, tid, true, total_sleep_time_usec);
|
dump_thread(context, log, tid, true, total_sleep_time_usec);
|
||||||
|
|
@ -769,7 +805,7 @@ static int activity_manager_connect() {
|
||||||
return amfd;
|
return amfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* engrave_tombstone(pid_t pid, pid_t tid, int signal,
|
char* engrave_tombstone(pid_t pid, pid_t tid, int signal, uintptr_t abort_msg_address,
|
||||||
bool dump_sibling_threads, bool quiet, bool* detach_failed,
|
bool dump_sibling_threads, bool quiet, bool* detach_failed,
|
||||||
int* total_sleep_time_usec) {
|
int* total_sleep_time_usec) {
|
||||||
mkdir(TOMBSTONE_DIR, 0755);
|
mkdir(TOMBSTONE_DIR, 0755);
|
||||||
|
|
@ -791,7 +827,7 @@ char* engrave_tombstone(pid_t pid, pid_t tid, int signal,
|
||||||
log.tfd = fd;
|
log.tfd = fd;
|
||||||
log.amfd = activity_manager_connect();
|
log.amfd = activity_manager_connect();
|
||||||
log.quiet = quiet;
|
log.quiet = quiet;
|
||||||
*detach_failed = dump_crash(&log, pid, tid, signal, dump_sibling_threads,
|
*detach_failed = dump_crash(&log, pid, tid, signal, abort_msg_address, dump_sibling_threads,
|
||||||
total_sleep_time_usec);
|
total_sleep_time_usec);
|
||||||
|
|
||||||
close(log.amfd);
|
close(log.amfd);
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
/* Creates a tombstone file and writes the crash dump to it.
|
/* Creates a tombstone file and writes the crash dump to it.
|
||||||
* Returns the path of the tombstone, which must be freed using free(). */
|
* Returns the path of the tombstone, which must be freed using free(). */
|
||||||
char* engrave_tombstone(pid_t pid, pid_t tid, int signal,
|
char* engrave_tombstone(pid_t pid, pid_t tid, int signal, uintptr_t abort_msg_address,
|
||||||
bool dump_sibling_threads, bool quiet, bool* detach_failed, int* total_sleep_time_usec);
|
bool dump_sibling_threads, bool quiet, bool* detach_failed, int* total_sleep_time_usec);
|
||||||
|
|
||||||
#endif // _DEBUGGERD_TOMBSTONE_H
|
#endif // _DEBUGGERD_TOMBSTONE_H
|
||||||
|
|
|
||||||
|
|
@ -34,10 +34,10 @@ typedef enum {
|
||||||
DEBUGGER_ACTION_DUMP_BACKTRACE,
|
DEBUGGER_ACTION_DUMP_BACKTRACE,
|
||||||
} debugger_action_t;
|
} debugger_action_t;
|
||||||
|
|
||||||
/* message sent over the socket */
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
debugger_action_t action;
|
debugger_action_t action;
|
||||||
pid_t tid;
|
pid_t tid;
|
||||||
|
uintptr_t abort_msg_address;
|
||||||
} debugger_msg_t;
|
} debugger_msg_t;
|
||||||
|
|
||||||
/* Dumps a process backtrace, registers, and stack to a tombstone file (requires root).
|
/* Dumps a process backtrace, registers, and stack to a tombstone file (requires root).
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue