diff options
author | Elliott Hughes <enh@google.com> | 2013-04-04 13:46:46 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2013-04-05 11:24:19 -0700 |
commit | 0d787c1fa18c6a1f29ef9840e28a68cf077be1de (patch) | |
tree | 3f8efc05d80658c9be48513238104a5de01a9951 /linker/debugger.cpp | |
parent | 014c75c78bdcad8acde8d0abb2450aa1f78e1a1f (diff) | |
download | android_bionic-0d787c1fa18c6a1f29ef9840e28a68cf077be1de.tar.gz android_bionic-0d787c1fa18c6a1f29ef9840e28a68cf077be1de.tar.bz2 android_bionic-0d787c1fa18c6a1f29ef9840e28a68cf077be1de.zip |
Make abort messages available to debuggerd.
This adds __libc_fatal, cleans up the internal logging code a bit more,
and switches suitable callers over to __libc_fatal. In addition to logging,
__libc_fatal stashes the message somewhere that the debuggerd signal handler
can find it before calling abort.
In the debuggerd signal handler, we pass this address to debuggerd so that
it can come back with ptrace to read the message and present it to the user.
Bug: 8531731
Change-Id: I416ec1da38a8a1b0d0a582ccd7c8aaa681ed4a29
Diffstat (limited to 'linker/debugger.cpp')
-rw-r--r-- | linker/debugger.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/linker/debugger.cpp b/linker/debugger.cpp index 6fddb1c75..a7c0591d9 100644 --- a/linker/debugger.cpp +++ b/linker/debugger.cpp @@ -52,8 +52,12 @@ enum debugger_action_t { /* message sent over the socket */ struct debugger_msg_t { - debugger_action_t action; - pid_t tid; + // version 1 included: + debugger_action_t action; + pid_t tid; + + // version 2 added: + uintptr_t abort_msg_address; }; // see man(2) prctl, specifically the section about PR_GET_NAME @@ -154,14 +158,14 @@ static bool haveSiginfo(int signum) { sigemptyset(&newact.sa_mask); if (sigaction(signum, &newact, &oldact) < 0) { - __libc_format_log(ANDROID_LOG_FATAL, "libc", "Failed testing for SA_SIGINFO: %s", + __libc_format_log(ANDROID_LOG_WARN, "libc", "Failed testing for SA_SIGINFO: %s", strerror(errno)); - return 0; + return false; } bool ret = (oldact.sa_flags & SA_SIGINFO) != 0; if (sigaction(signum, &oldact, NULL) == -1) { - __libc_format_log(ANDROID_LOG_FATAL, "libc", "Restore failed in test for SA_SIGINFO: %s", + __libc_format_log(ANDROID_LOG_WARN, "libc", "Restore failed in test for SA_SIGINFO: %s", strerror(errno)); } return ret; @@ -186,19 +190,17 @@ void debuggerd_signal_handler(int n, siginfo_t* info, void*) { int s = socket_abstract_client(DEBUGGER_SOCKET_NAME, SOCK_STREAM); if (s >= 0) { - /* debugger knows our pid from the credentials on the - * local socket but we need to tell it our tid. It - * is paranoid and will verify that we are giving a tid - * that's actually in our process - */ - int ret; + // debuggerd knows our pid from the credentials on the + // local socket but we need to tell it the tid of the crashing thread. + // debuggerd will be paranoid and verify that we sent a tid + // that's actually in our process. debugger_msg_t msg; msg.action = DEBUGGER_ACTION_CRASH; msg.tid = tid; - ret = TEMP_FAILURE_RETRY(write(s, &msg, sizeof(msg))); + msg.abort_msg_address = reinterpret_cast<uintptr_t>(gAbortMessage); + int ret = TEMP_FAILURE_RETRY(write(s, &msg, sizeof(msg))); if (ret == sizeof(msg)) { - /* if the write failed, there is no point to read on - * the file descriptor. */ + // if the write failed, there is no point trying to read a response. ret = TEMP_FAILURE_RETRY(read(s, &tid, 1)); int saved_errno = errno; notify_gdb_of_libraries(); |