diff options
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/posix/libc_fatal.c | 35 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/libc_fatal.c | 33 |
2 files changed, 4 insertions, 64 deletions
diff --git a/sysdeps/posix/libc_fatal.c b/sysdeps/posix/libc_fatal.c index 3906af5ee7..9ddbfa7314 100644 --- a/sysdeps/posix/libc_fatal.c +++ b/sysdeps/posix/libc_fatal.c @@ -45,16 +45,6 @@ writev_for_fatal (int fd, const struct iovec *iov, size_t niov, size_t total) } #endif -#ifndef BEFORE_ABORT -# define BEFORE_ABORT before_abort -static void -before_abort (int do_abort __attribute__ ((unused)), - bool written __attribute__ ((unused)), - int fd __attribute__ ((unused))) -{ -} -#endif - struct str_list { const char *str; @@ -75,17 +65,6 @@ __libc_message (enum __libc_message_action action, const char *fmt, ...) FATAL_PREPARE; #endif - /* Don't call __libc_secure_getenv if we aren't doing backtrace, which - may access the corrupted stack. */ - if ((action & do_backtrace)) - { - /* Open a descriptor for /dev/tty unless the user explicitly - requests errors on standard error. */ - const char *on_2 = __libc_secure_getenv ("LIBC_FATAL_STDERR_"); - if (on_2 == NULL || *on_2 == '\0') - fd = __open_nocancel (_PATH_TTY, O_RDWR | O_NOCTTY | O_NDELAY); - } - if (fd == -1) fd = STDERR_FILENO; @@ -129,7 +108,6 @@ __libc_message (enum __libc_message_action action, const char *fmt, ...) ++nlist; } - bool written = false; if (nlist > 0) { struct iovec *iov = alloca (nlist * sizeof (struct iovec)); @@ -143,7 +121,7 @@ __libc_message (enum __libc_message_action action, const char *fmt, ...) list = list->next; } - written = WRITEV_FOR_FATAL (fd, iov, nlist, total); + WRITEV_FOR_FATAL (fd, iov, nlist, total); if ((action & do_abort)) { @@ -173,13 +151,8 @@ __libc_message (enum __libc_message_action action, const char *fmt, ...) va_end (ap); if ((action & do_abort)) - { - if ((action & do_backtrace)) - BEFORE_ABORT (do_abort, written, fd); - - /* Kill the application. */ - abort (); - } + /* Kill the application. */ + abort (); } @@ -188,6 +161,6 @@ __libc_fatal (const char *message) { /* The loop is added only to keep gcc happy. */ while (1) - __libc_message (do_abort | do_backtrace, "%s", message); + __libc_message (do_abort, "%s", message); } libc_hidden_def (__libc_fatal) diff --git a/sysdeps/unix/sysv/linux/libc_fatal.c b/sysdeps/unix/sysv/linux/libc_fatal.c index 56c626339f..50a613e31f 100644 --- a/sysdeps/unix/sysv/linux/libc_fatal.c +++ b/sysdeps/unix/sysv/linux/libc_fatal.c @@ -17,11 +17,6 @@ <http://www.gnu.org/licenses/>. */ #include <errno.h> -#include <execinfo.h> -#include <fcntl.h> -#include <not-cancel.h> -#include <string.h> -#include <sys/mman.h> #include <sys/uio.h> static bool @@ -37,32 +32,4 @@ writev_for_fatal (int fd, const struct iovec *iov, size_t niov, size_t total) } #define WRITEV_FOR_FATAL writev_for_fatal -static void -backtrace_and_maps (int do_abort, bool written, int fd) -{ - if (do_abort > 1 && written) - { - void *addrs[64]; -#define naddrs (sizeof (addrs) / sizeof (addrs[0])) - int n = __backtrace (addrs, naddrs); - if (n > 2) - { -#define strnsize(str) str, strlen (str) -#define writestr(str) __write_nocancel (fd, str) - writestr (strnsize ("======= Backtrace: =========\n")); - __backtrace_symbols_fd (addrs + 1, n - 1, fd); - - writestr (strnsize ("======= Memory map: ========\n")); - int fd2 = __open_nocancel ("/proc/self/maps", O_RDONLY); - char buf[1024]; - ssize_t n2; - while ((n2 = __read_nocancel (fd2, buf, sizeof (buf))) > 0) - if (__write_nocancel (fd, buf, n2) != n2) - break; - __close_nocancel_nostatus (fd2); - } - } -} -#define BEFORE_ABORT backtrace_and_maps - #include <sysdeps/posix/libc_fatal.c> |