Commit c9bffcd5 by Andrew Haley Committed by Andrew Haley

i386-signal.h (MAKE_THROW_FRAME): Don't fix up frame pointer...

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.

From-SVN: r42691
parent 022dae81
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.
2001-05-24 Tom Tromey <tromey@redhat.com>
* java/lang/natString.cc (init): Throw
......
......@@ -757,13 +757,16 @@ case "${host}" in
powerpc-*-linux*)
SIGNAL_HANDLER=include/dwarf2-signal.h
;;
alpha*-*-linux*)
SIGNAL_HANDLER=include/dwarf2-signal.h
;;
*)
SIGNAL_HANDLER=include/default-signal.h
;;
esac
# If we're using sjlj exceptions, forget what we just learned.
if test "$libgcj_sjlj" = yes; then
if test "$enable_sjlj_exceptions" = yes; then
SIGNAL_HANDLER=include/default-signal.h
fi
......
......@@ -4,9 +4,8 @@
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.
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
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
......@@ -22,29 +21,43 @@ details. */
#undef HANDLE_FPE
#define SIGNAL_HANDLER(_name) \
static void _Jv_##_name (int)
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 need to
// do anything.
// 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 \
{ \
nullp = new java::lang::NullPointerException (); \
struct sigaction act; \
act.sa_handler = _Jv_catch_segv; \
act.sa_sigaction = _Jv_catch_segv; \
sigemptyset (&act.sa_mask); \
act.sa_flags = 0; \
act.sa_flags = SA_SIGINFO; \
syscall (SYS_sigaction, SIGSEGV, &act, NULL); \
} \
while (0)
......@@ -55,9 +68,9 @@ do \
arithexception = new java::lang::ArithmeticException \
(JvNewStringLatin1 ("/ by zero")); \
struct sigaction act; \
act.sa_handler = _Jv_catch_fpe; \
act.sa_sigaction = _Jv_catch_fpe; \
sigemptyset (&act.sa_mask); \
act.sa_flags = 0; \
act.sa_flags = SA_SIGINFO; \
syscall (SYS_sigaction, SIGFPE, &act, NULL); \
} \
while (0)
......
......@@ -31,16 +31,11 @@ do \
void **_p = (void **)&_dummy; \
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; \
_regs->eip += 2; \
\
asm volatile ("mov %0, (%%ebp); mov %1, 4(%%ebp)" \
: : "r"(_ebp), "r"(_eip)); \
} \
while (0)
......@@ -63,7 +58,7 @@ do \
* As the instructions are variable length it is necessary to do a \
* little calculation to figure out where the following instruction \
* actually is. \
\
\
*/ \
\
if (_eip[0] == 0xf7) \
......@@ -104,6 +99,9 @@ do \
\
_eip = (unsigned char *)_ebp[1]; \
_ebp = (unsigned long *)_ebp[0]; \
\
asm volatile ("mov %0, (%%ebp); mov %1, 4(%%ebp)" \
: : "r"(_ebp), "r"(_eip)); \
} \
else \
{ \
......@@ -111,12 +109,9 @@ do \
of the instruction: this is because the x86 exception \
handler expects the PC to point to the instruction after a \
call. */ \
_eip += 2; \
_regs->eip += 2; \
} \
} \
\
asm volatile ("mov %0, (%%ebp); mov %1, 4(%%ebp)" \
: : "r"(_ebp), "r"(_eip)); \
} \
while (0)
......
// ppc-signal.h - Catch runtime signals and turn them into exceptions.
/* Copyright (C) 2000 Free Software Foundation
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
#ifndef JAVA_SIGNAL_H
#define JAVA_SIGNAL_H 1
#include <signal.h>
#include <ucontext.h>
#define HANDLE_SEGV 1
#undef HANDLE_FPE
#define SIGNAL_HANDLER(_name) \
__asm ("\t.section\t\".text\"\n" \
"\t.align 2\n" \
"_Jv_" #_name ":\n" \
"\tmr 3, 1\n" \
"\tb _Jv_stub_" #_name "\n"); \
extern "C" void _Jv_##_name (int _dummy); \
extern "C" void _Jv_stub_##_name (char *_sp) \
class java::lang::Throwable;
// Unwind the stack to the point at which the signal was generated and
// then throw an exception.
#define MAKE_THROW_FRAME(_exception) \
do \
{ \
struct sigcontext_struct *_context \
= (struct sigcontext_struct *)(_sp + __SIGNAL_FRAMESIZE); \
long int regs [34]; \
memcpy (regs, &_context->regs->gpr[0], 32 * sizeof (long int)); \
regs[32] = _context->regs->nip + sizeof (long int); \
regs[33] = _context->regs->link; \
\
__asm volatile ( \
"\tmr 31,%0\n" \
"\tmr 3,%1 # exception to throw\n" \
"\tlwz 0,128(31) # ip\n" \
"\tmtlr 0\n" \
"\tlwz 1,4(31) # previous r1\n" \
"\tlwz 0,132(31) # previous lr\n" \
"\tlwz 2,0(1) # previous previous r1\n" \
"\tstw 0,4(2) # save previous lr\n" \
"\tlwz 0,0(31)\n" \
"\tlwz 2,8(31)\n" \
"\tlwz 4,16(31)\n" \
"\tlwz 5,20(31)\n" \
"\tlwz 6,24(31)\n" \
"\tlwz 7,28(31)\n" \
"\tlwz 8,32(31)\n" \
"\tlwz 9,36(31)\n" \
"\tlwz 10,40(31)\n" \
"\tlwz 11,44(31)\n" \
"\tlwz 12,48(31)\n" \
"\tlwz 13,52(31)\n" \
"\tlwz 14,56(31)\n" \
"\tlwz 15,60(31)\n" \
"\tlwz 16,64(31)\n" \
"\tlwz 17,68(31)\n" \
"\tlwz 18,72(31)\n" \
"\tlwz 19,76(31)\n" \
"\tlwz 20,80(31)\n" \
"\tlwz 21,84(31)\n" \
"\tlwz 22,88(31)\n" \
"\tlwz 23,92(31)\n" \
"\tlwz 24,96(31)\n" \
"\tlwz 25,100(31)\n" \
"\tlwz 26,104(31)\n" \
"\tlwz 27,108(31)\n" \
"\tlwz 28,112(31)\n" \
"\tlwz 29,116(31)\n" \
"\tlwz 30,120(31)\n" \
"\tlwz 31,124(31)\n" \
"\tb _Jv_ThrowSignal\n" \
: : "r"(regs), "r"(_exception) \
: "r31", "r3"); \
} \
while (0)
#define INIT_SEGV \
do \
{ \
nullp = new java::lang::NullPointerException (); \
struct sigaction act; \
act.sa_handler = _Jv_catch_segv; \
sigemptyset (&act.sa_mask); \
act.sa_flags = 0; \
__sigaction (SIGSEGV, &act, NULL); \
} \
while (0)
#define INIT_FPE \
do \
{ \
arithexception = new java::lang::ArithmeticException \
(JvNewStringLatin1 ("/ by zero")); \
struct sigaction act; \
act.sa_handler = _Jv_catch_fpe; \
sigemptyset (&act.sa_mask); \
act.sa_flags = 0; \
__sigaction (SIGFPE, &act, NULL); \
} \
while (0)
#endif /* JAVA_SIGNAL_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment