3.0: unwinder changes

Andrew Haley aph@cambridge.redhat.com
Tue May 29 09:16:00 GMT 2001


This patch fixes unwinding on PPC, i386, and Alpha.

These are my test results:

powerpc-unknown-linux-gnu

                === libjava Summary ===

# of expected passes            1676
# of unexpected successes       10
# of expected failures          14
# of untested testcases         16

alphapca56-unknown-linux-gnu

                === libjava Summary ===

# of expected passes            1676
# of unexpected successes       10
# of expected failures          14
# of untested testcases         16

i686-pc-linux-gnu

                === libjava Summary ===

# of expected passes            1676
# of unexpected successes       10
# of expected failures          14
# of untested testcases         16


I'm going to check this into mainline also, and then there should be
no exception handling differences between mainline and 3.0 branch.

Please let me know if you get test results different from this.

Note that you need new binutils to build on Alpha.

Andrew.

2001-05-29  Andrew Haley  <aph@redhat.com>

        * include/i386-signal.h (MAKE_THROW_FRAME): Don't fix up frame
        pointer: the dwarf unwinder in libgcc will do everything that's
        needed.
        (HANDLE_DIVIDE_OVERFLOW): Tidy.  Don't mess with stack frames any
        more than we absolutely need to.
        * configure.host (EXCEPTIONSPEC): Remove libgcj_sjlj on Alpha.
        * configure.in (SIGNAL_HANDLER): Use include/dwarf2-signal.h on
        Alpha.
        (SIGNAL_HANDLER): Test "$enable_sjlj_exceptions", not
        "$libgcj_sjlj".
        * configure: Rebuilt.
        * include/dwarf2-signal.h (MAKE_THROW_FRAME): Adjust PC
        for Alpha.
        (SIGNAL_HANDLER): Use siginfo style handler.
        (INIT_SEGV): Likewise.
        (INIT_FPE): Likewise.
        * include/ppc-signal.h: Delete whole file.

Index: configure.host
===================================================================
RCS file: /cvs/gcc/gcc/libjava/configure.host,v
retrieving revision 1.15.2.5
diff -p -2 -c -r1.15.2.5 configure.host
*** configure.host	2001/05/21 17:05:28	1.15.2.5
--- configure.host	2001/05/29 16:06:49
*************** case "${host}" in
*** 68,72 ****
  	libgcj_flags="${libgcj_flags} -mieee"
  	libgcj_interpreter=yes
- 	libgcj_sjlj=yes
  	;;
    powerpc*-*)
--- 68,71 ----
Index: configure.in
===================================================================
RCS file: /cvs/gcc/gcc/libjava/configure.in,v
retrieving revision 1.73.2.9
diff -p -2 -c -r1.73.2.9 configure.in
*** configure.in	2001/05/23 17:11:05	1.73.2.9
--- configure.in	2001/05/29 16:06:49
*************** case "${host}" in
*** 747,750 ****
--- 747,753 ----
      SIGNAL_HANDLER=include/dwarf2-signal.h
      ;;
+  alpha*-*-linux*)
+     SIGNAL_HANDLER=include/dwarf2-signal.h
+     ;;
   *)
      SIGNAL_HANDLER=include/default-signal.h
*************** esac
*** 753,757 ****
  
  # If we're using sjlj exceptions, forget what we just learned.
! if test "$libgcj_sjlj" = yes; then
     SIGNAL_HANDLER=include/default-signal.h
  fi
--- 756,760 ----
  
  # If we're using sjlj exceptions, forget what we just learned.
! if test "$enable_sjlj_exceptions" = yes; then
     SIGNAL_HANDLER=include/default-signal.h
  fi
Index: include/dwarf2-signal.h
===================================================================
RCS file: /cvs/gcc/gcc/libjava/include/dwarf2-signal.h,v
retrieving revision 1.1.2.2
diff -p -2 -c -r1.1.2.2 dwarf2-signal.h
*** dwarf2-signal.h	2001/05/21 16:38:08	1.1.2.2
--- dwarf2-signal.h	2001/05/29 16:06:49
***************
*** 5,11 ****
     This file is part of libgcj.
  
!    Use this file for every target for which the dwarf2 unwinder in
!    libgcc can unwind through signal handlers and no special actions
!    are needed.
  
  This software is copyrighted work licensed under the terms of the
--- 5,10 ----
     This file is part of libgcj.
  
!    Use this file for a target for which the dwarf2 unwinder in libgcc
!    can unwind through signal handlers.
  
  This software is copyrighted work licensed under the terms of the
*************** details.  */
*** 23,40 ****
  
  #define SIGNAL_HANDLER(_name)	\
! static void _Jv_##_name (int)
  
  class java::lang::Throwable;
  
  // Unwind the stack to the point at which the signal was generated and
! // then throw an exception.  With the dwarf2 unwinder we don't need to
! // do anything.
  
  #define MAKE_THROW_FRAME(_exception)		\
  do						\
  {						\
  }						\
  while (0)
! 
  
  #define INIT_SEGV						\
--- 22,53 ----
  
  #define SIGNAL_HANDLER(_name)	\
! static void _Jv_##_name (int, siginfo_t *, void *_p)
  
  class java::lang::Throwable;
  
  // Unwind the stack to the point at which the signal was generated and
! // then throw an exception.  With the dwarf2 unwinder we don't usually
! // need to do anything, with some minor exceptions.
  
+ #ifdef __alpha__
+ #define MAKE_THROW_FRAME(_exception)					\
+ do									\
+ {									\
+   /* Alpha either leaves PC pointing at a faulting instruction or the	\
+    following instruction, depending on the signal.  SEGV always does	\
+    the former, so we adjust the saved PC to point to the following	\
+    instruction; this is what the handler in libgcc expects.  */		\
+   struct sigcontext *_sc = (struct sigcontext *)_p;			\
+   _sc->sc_pc += 4;							\
+ }									\
+ while (0)
+ #else
  #define MAKE_THROW_FRAME(_exception)		\
  do						\
  {						\
+   (void)_p;					\
  }						\
  while (0)
! #endif
  
  #define INIT_SEGV						\
*************** do								\
*** 43,49 ****
      nullp = new java::lang::NullPointerException ();    	\
      struct sigaction act;					\
!     act.sa_handler = _Jv_catch_segv;				\
      sigemptyset (&act.sa_mask);					\
!     act.sa_flags = 0;						\
      syscall (SYS_sigaction, SIGSEGV, &act, NULL);		\
    }								\
--- 56,62 ----
      nullp = new java::lang::NullPointerException ();    	\
      struct sigaction act;					\
!     act.sa_sigaction = _Jv_catch_segv;      			\
      sigemptyset (&act.sa_mask);					\
!     act.sa_flags = SA_SIGINFO;	       				\
      syscall (SYS_sigaction, SIGSEGV, &act, NULL);		\
    }								\
*************** do								\
*** 56,62 ****
        (JvNewStringLatin1 ("/ by zero"));			\
      struct sigaction act;					\
!     act.sa_handler = _Jv_catch_fpe;				\
      sigemptyset (&act.sa_mask);					\
!     act.sa_flags = 0;						\
      syscall (SYS_sigaction, SIGFPE, &act, NULL);		\
    }								\
--- 69,75 ----
        (JvNewStringLatin1 ("/ by zero"));			\
      struct sigaction act;					\
!     act.sa_sigaction = _Jv_catch_fpe;				\
      sigemptyset (&act.sa_mask);					\
!     act.sa_flags = SA_SIGINFO;		       			\
      syscall (SYS_sigaction, SIGFPE, &act, NULL);		\
    }								\
Index: include/i386-signal.h
===================================================================
RCS file: /cvs/gcc/gcc/libjava/include/i386-signal.h,v
retrieving revision 1.9.2.2
diff -p -2 -c -r1.9.2.2 i386-signal.h
*** i386-signal.h	2001/02/16 00:36:02	1.9.2.2
--- i386-signal.h	2001/05/29 16:06:49
*************** do									\
*** 32,45 ****
    struct sigcontext_struct *_regs = (struct sigcontext_struct *)++_p;	\
  									\
-   register unsigned long _ebp = _regs->ebp;				\
-   register unsigned char *_eip = (unsigned char *)_regs->eip;		\
- 									\
    /* Advance the program counter so that it is after the start of the	\
       instruction:  the x86 exception handler expects			\
       the PC to point to the instruction after a call. */		\
!   _eip += 2;								\
  									\
-   asm volatile ("mov %0, (%%ebp); mov %1, 4(%%ebp)"			\
- 		: : "r"(_ebp), "r"(_eip));				\
  }									\
  while (0)
--- 32,40 ----
    struct sigcontext_struct *_regs = (struct sigcontext_struct *)++_p;	\
  									\
    /* Advance the program counter so that it is after the start of the	\
       instruction:  the x86 exception handler expects			\
       the PC to point to the instruction after a call. */		\
!   _regs->eip += 2;							\
  									\
  }									\
  while (0)
*************** do									\
*** 64,68 ****
     * little calculation to figure out where the following instruction	\
     * actually is.							\
!   									\
     */									\
  									\
--- 59,63 ----
     * little calculation to figure out where the following instruction	\
     * actually is.							\
! 									\
     */									\
  									\
*************** do									\
*** 105,108 ****
--- 100,106 ----
  	  _eip = (unsigned char *)_ebp[1];				\
  	  _ebp = (unsigned long *)_ebp[0];				\
+ 									\
+ 	  asm volatile ("mov %0, (%%ebp); mov %1, 4(%%ebp)"		\
+ 			: : "r"(_ebp), "r"(_eip));			\
  	}								\
        else								\
*************** do									\
*** 112,121 ****
  	     handler expects the PC to point to the instruction after a	\
  	     call. */							\
! 	  _eip += 2;							\
  	}								\
      }									\
- 									\
-   asm volatile ("mov %0, (%%ebp); mov %1, 4(%%ebp)"			\
- 		: : "r"(_ebp), "r"(_eip));				\
  }									\
  while (0)
--- 110,116 ----
  	     handler expects the PC to point to the instruction after a	\
  	     call. */							\
! 	  _regs->eip += 2;						\
  	}								\
      }									\
  }									\
  while (0)



More information about the Java mailing list