summaryrefslogtreecommitdiffstats
path: root/linker
diff options
context:
space:
mode:
authorGuang Zhu <guangzhu@google.com>2013-07-17 03:17:05 +0000
committerGuang Zhu <guangzhu@google.com>2013-07-17 03:17:05 +0000
commitd14dc3b87fbf80553f1cafa453816b7f11366627 (patch)
treeb1a26c875f451b79888f60cf73504aab799874e1 /linker
parentaa754dca90487356cabf07ade0e8d88c2630b784 (diff)
downloadbionic-d14dc3b87fbf80553f1cafa453816b7f11366627.zip
bionic-d14dc3b87fbf80553f1cafa453816b7f11366627.tar.gz
bionic-d14dc3b87fbf80553f1cafa453816b7f11366627.tar.bz2
Revert "Improve stack overflow diagnostics."
This reverts commit aa754dca90487356cabf07ade0e8d88c2630b784. Change-Id: Ifa76eee31f7f44075eb3a48554315b2693062f44
Diffstat (limited to 'linker')
-rw-r--r--linker/debugger.cpp63
1 files changed, 29 insertions, 34 deletions
diff --git a/linker/debugger.cpp b/linker/debugger.cpp
index d72aa39..a7c0591 100644
--- a/linker/debugger.cpp
+++ b/linker/debugger.cpp
@@ -28,15 +28,14 @@
#include "linker.h"
-#include <errno.h>
-#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
-#include <sys/mman.h>
+#include <unistd.h>
+#include <signal.h>
#include <sys/prctl.h>
+#include <errno.h>
#include <sys/socket.h>
#include <sys/un.h>
-#include <unistd.h>
extern "C" int tgkill(int tgid, int tid, int sig);
@@ -110,7 +109,7 @@ static int socket_abstract_client(const char* name, int type) {
* mutex is being held, so we don't want to use any libc functions that
* could allocate memory or hold a lock.
*/
-static void log_signal_summary(int signum, const siginfo_t* info) {
+static void logSignalSummary(int signum, const siginfo_t* info) {
const char* signal_name;
switch (signum) {
case SIGILL: signal_name = "SIGILL"; break;
@@ -150,26 +149,26 @@ static void log_signal_summary(int signum, const siginfo_t* info) {
/*
* Returns true if the handler for signal "signum" has SA_SIGINFO set.
*/
-static bool have_siginfo(int signum) {
- struct sigaction old_action, new_action;
+static bool haveSiginfo(int signum) {
+ struct sigaction oldact, newact;
- memset(&new_action, 0, sizeof(new_action));
- new_action.sa_handler = SIG_DFL;
- new_action.sa_flags = SA_RESTART;
- sigemptyset(&new_action.sa_mask);
+ memset(&newact, 0, sizeof(newact));
+ newact.sa_handler = SIG_DFL;
+ newact.sa_flags = SA_RESTART;
+ sigemptyset(&newact.sa_mask);
- if (sigaction(signum, &new_action, &old_action) < 0) {
+ if (sigaction(signum, &newact, &oldact) < 0) {
__libc_format_log(ANDROID_LOG_WARN, "libc", "Failed testing for SA_SIGINFO: %s",
strerror(errno));
return false;
}
- bool result = (old_action.sa_flags & SA_SIGINFO) != 0;
+ bool ret = (oldact.sa_flags & SA_SIGINFO) != 0;
- if (sigaction(signum, &old_action, NULL) == -1) {
+ if (sigaction(signum, &oldact, NULL) == -1) {
__libc_format_log(ANDROID_LOG_WARN, "libc", "Restore failed in test for SA_SIGINFO: %s",
strerror(errno));
}
- return result;
+ return ret;
}
/*
@@ -181,11 +180,11 @@ void debuggerd_signal_handler(int n, siginfo_t* info, void*) {
* It's possible somebody cleared the SA_SIGINFO flag, which would mean
* our "info" arg holds an undefined value.
*/
- if (!have_siginfo(n)) {
+ if (!haveSiginfo(n)) {
info = NULL;
}
- log_signal_summary(n, info);
+ logSignalSummary(n, info);
pid_t tid = gettid();
int s = socket_abstract_client(DEBUGGER_SOCKET_NAME, SOCK_STREAM);
@@ -246,23 +245,19 @@ void debuggerd_signal_handler(int n, siginfo_t* info, void*) {
}
void debuggerd_init() {
- struct sigaction action;
- memset(&action, 0, sizeof(action));
- sigemptyset(&action.sa_mask);
- action.sa_sigaction = debuggerd_signal_handler;
- action.sa_flags = SA_RESTART | SA_SIGINFO;
-
- // Use the alternate signal stack if available so we can catch stack overflows.
- action.sa_flags |= SA_ONSTACK;
-
- sigaction(SIGABRT, &action, NULL);
- sigaction(SIGBUS, &action, NULL);
- sigaction(SIGFPE, &action, NULL);
- sigaction(SIGILL, &action, NULL);
- sigaction(SIGPIPE, &action, NULL);
- sigaction(SIGSEGV, &action, NULL);
+ struct sigaction act;
+ memset(&act, 0, sizeof(act));
+ act.sa_sigaction = debuggerd_signal_handler;
+ act.sa_flags = SA_RESTART | SA_SIGINFO;
+ sigemptyset(&act.sa_mask);
+
+ sigaction(SIGILL, &act, NULL);
+ sigaction(SIGABRT, &act, NULL);
+ sigaction(SIGBUS, &act, NULL);
+ sigaction(SIGFPE, &act, NULL);
+ sigaction(SIGSEGV, &act, NULL);
#if defined(SIGSTKFLT)
- sigaction(SIGSTKFLT, &action, NULL);
+ sigaction(SIGSTKFLT, &act, NULL);
#endif
- sigaction(SIGTRAP, &action, NULL);
+ sigaction(SIGPIPE, &act, NULL);
}