about summary refs log tree commit diff
path: root/sysdeps/generic
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-08-24 16:46:16 +0000
committerUlrich Drepper <drepper@redhat.com>1998-08-24 16:46:16 +0000
commited1ac6a2d6c744bdbd4751efc86326ceafeac26c (patch)
tree5ca6ee6384dfd1a25493058d4debe985b101a3b0 /sysdeps/generic
parentc2228a513135bb229cd9c9984e38e52143d5f6dd (diff)
downloadglibc-ed1ac6a2d6c744bdbd4751efc86326ceafeac26c.tar.gz
glibc-ed1ac6a2d6c744bdbd4751efc86326ceafeac26c.tar.xz
glibc-ed1ac6a2d6c744bdbd4751efc86326ceafeac26c.zip
Update.
1998-08-24 16:34  Ulrich Drepper  <drepper@cygnus.com>

	* debug/catchsegv.sh: Handle text preceding backtrace better.
	* sysdeps/generic/segfault.c: Allow register dump.  Allow handler
	to be installed for other signals than SIGSEGV.
	* sysdeps/generic/register-dump.h: New file.
	* sysdeps/i386/register-dump.h: New file.
	* sysdeps/powerpc/register-dump.h: New file.

	* sysdeps/unix/sysv/linux/i386/profil-counter.h: Use macros from
	sigcontextinfo.h.
	* sysdeps/unix/sysv/linux/powerpc/profil-counter.h: Use i386 version.

1998-08-24  Geoff Keating  <geoffk@ozemail.com.au>

	* sysdeps/unix/sysv/linux/powerpc/sigcontextinfo.h: New file.

1998-08-09  Geoff Keating  <geoffk@ozemail.com.au>

	* sysdeps/unix/sysv/linux/powerpc/chown.c: New file.
	* sysdeps/unix/sysv/linux/powerpc/lchown.S: New file.
	* sysdeps/unix/sysv/linux/powerpc/syscalls.list: Add chown, remove
	getresuid, getresgid.

1998-08-16  Geoff Keating  <geoffk@ozemail.com.au>

	* sysdeps/unix/sysv/linux/powerpc/clone.S: Fix bugs.  Set up stack
	pointer in userland.

1998-08-21  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* sysdeps/unix/sysv/linux/sys/mount.h (MNT_FORCE): Define as enum
	and fix value.

1998-08-22  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* elf/ldd.bash.in: Add missing quotes around $file.  Make loop
	over arguments Bourne shell compatible.  Don't exit unsuccessfully
	if nonelf returns successfully.  Avoid duplicating most of the
	script.
	* sysdeps/unix/sysv/linux/ldd-rewrite.sed: Add missing quotes
	around $file.

1998-08-24 10:37  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* libio/Versions (_IO_do_write, _IO_file_attach,
	_IO_file_close_it, _IO_file_finish, _IO_file_fopen,
	_IO_file_init, _IO_file_overflow, _IO_file_seekoff,
	_IO_file_setbuf, _IO_file_sync, _IO_file_underflow,
	_IO_file_write, _IO_file_xsputn): Added to GLIBC_2.1.

	* libio/fileops.c (_IO_do_write, _IO_file_attach,
	_IO_file_close_it, _IO_file_finish, _IO_file_fopen,
	_IO_file_init, _IO_file_overflow, _IO_file_seekoff,
	_IO_file_setbuf, _IO_file_sync, _IO_file_underflow,
	_IO_file_write, _IO_file_xsputn): Change the prefix to
	"_IO_new_". Added to GLIBC_2.1.

	* libio/libioP.h (_IO_do_write, _IO_file_attach,
	_IO_file_close_it, _IO_file_finish, _IO_file_fopen,
	_IO_file_init, _IO_file_overflow, _IO_file_seekoff,
	_IO_file_setbuf, _IO_file_sync, _IO_file_underflow,
	_IO_file_write, _IO_file_xsputn): Add prototypes for the prefix
	"_IO_new_".

	* libio/oldfileops.c (_IO_do_write, _IO_file_attach,
	_IO_file_close_it, _IO_file_finish, _IO_file_fopen,
	_IO_file_init, _IO_file_overflow, _IO_file_seekoff,
	_IO_file_setbuf, _IO_file_sync, _IO_file_underflow,
	_IO_file_write, _IO_file_xsputn): Added to GLIBC_2.0.

	* csu/initfini.c: Return to .text before __gmon_start__.
	* elf/elf.h (EM_FAKE_ALPHA): Rename from EM_OLD_ALPHA.
	(STO_MIPS_*): Rename from STO_*.
	(STB_MIPS_SPLIT_COMMON): Rename from STB_SPLIT_COMMON.
	(STO_ALPHA_NOPV, STO_ALPHA_STD_GPLOAD): New.
	* math/atest-exp.c (mpn_bitsize): Fix bit location calculation.
	(main): e3s is negative on zero.
	* math/atest-exp2.c: Likewise.
1998-08-23  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

	* Makerules (install): Add comment about absolute paths.
Diffstat (limited to 'sysdeps/generic')
-rw-r--r--sysdeps/generic/register-dump.h21
-rw-r--r--sysdeps/generic/segfault.c55
2 files changed, 70 insertions, 6 deletions
diff --git a/sysdeps/generic/register-dump.h b/sysdeps/generic/register-dump.h
new file mode 100644
index 0000000000..42c222c2ed
--- /dev/null
+++ b/sysdeps/generic/register-dump.h
@@ -0,0 +1,21 @@
+/* Dump registers.
+   Copyright (C) 1998 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+/* In general we cannot do anything.  */
diff --git a/sysdeps/generic/segfault.c b/sysdeps/generic/segfault.c
index 6504123e18..090f91a657 100644
--- a/sysdeps/generic/segfault.c
+++ b/sysdeps/generic/segfault.c
@@ -18,16 +18,21 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+#include <ctype.h>
 #include <execinfo.h>
 #include <fcntl.h>
 #include <signal.h>
 #include <stdlib.h>
+#include <string.h>
 #include <unistd.h>
 
 /* This file defines macros to access the content of the sigcontext element
    passed up by the signal handler.  */
 #include <sigcontextinfo.h>
 
+/* Get code to possibly dump the content of all registers.  */
+#include <register-dump.h>
+
 /* This is a global variable set at program start time.  It marks the
    highest used stack address.  */
 extern void *__libc_stack_end;
@@ -76,6 +81,8 @@ catch_segfault (int signal, SIGCONTEXT ctx)
   int fd;
   void **arr;
   size_t cnt;
+  struct sigaction sa;
+  const char *sigstring;
 
   /* This is the name of the file we are writing to.  If none is given
      or we cannot write to this file write to stderr.  */
@@ -88,9 +95,17 @@ catch_segfault (int signal, SIGCONTEXT ctx)
 	fd = 2;
     }
 
-#define WRITE_STRING(s) write (fd, s, sizeof (s) - 1)
-  WRITE_STRING ("*** Segmentation Fault\n");
-  WRITE_STRING ("Backtrace:\n");
+#define WRITE_STRING(s) write (fd, s, strlen (s))
+  WRITE_STRING ("*** ");
+  sigstring = strsignal (signal);
+  WRITE_STRING (sigstring);
+  WRITE_STRING ("\n");
+
+#ifdef REGISTER_DUMP
+  REGISTER_DUMP;
+#endif
+
+  WRITE_STRING ("\nBacktrace:\n");
 
   top_frame = GET_FRAME (ctx);
   top_stack = GET_STACK (ctx);
@@ -124,8 +139,12 @@ catch_segfault (int signal, SIGCONTEXT ctx)
   /* Now generate nicely formatted output.  */
   __backtrace_symbols_fd (arr, cnt, fd);
 
-  /* Nothing else to do.  */
-  _exit (128 + SIGSEGV);
+  /* Pass on the signal (so that a core file is produced).  */
+  sa.sa_handler = SIG_DFL;
+  sigemptyset (&sa.sa_mask);
+  sa.sa_flags = 0;
+  sigaction (signal, &sa, NULL);
+  raise (signal);
 }
 
 
@@ -134,12 +153,36 @@ __attribute__ ((constructor))
 install_handler (void)
 {
   struct sigaction sa;
+  const char *sigs = getenv ("SEGFAULT_SIGNALS");
 
   sa.sa_handler = (void *) catch_segfault;
   sigemptyset (&sa.sa_mask);
   sa.sa_flags = SA_RESTART;
 
-  sigaction (SIGSEGV, &sa, NULL);
+  if (sigs == NULL)
+    sigaction (SIGSEGV, &sa, NULL);
+  else if (sigs[0] == '\0')
+    /* Do not do anything.  */
+    return;
+  else
+    {
+      const char *where;
+      int all = __strcasecmp (sigs, "all");
+
+#define INSTALL_FOR_SIG(sig, name) \
+      where = __strcasestr (sigs, name);				      \
+      if (all || (where != NULL						      \
+		  && (where == sigs || !isalnum (where[-1]))		      \
+		  && !isalnum (where[sizeof (name) - 1])))		      \
+	sigaction (sig, &sa, NULL);
+
+      INSTALL_FOR_SIG (SIGSEGV, "segv");
+      INSTALL_FOR_SIG (SIGILL, "ill");
+      INSTALL_FOR_SIG (SIGBUS, "bus");
+      INSTALL_FOR_SIG (SIGSTKFLT, "stkflt");
+      INSTALL_FOR_SIG (SIGABRT, "abrt");
+      INSTALL_FOR_SIG (SIGFPE, "fpe");
+    }
 
   /* Maybe we are expected to use an alternative stack.  */
   if (getenv ("SEGFAULT_USE_ALTSTACK") != 0)