[PATCH] Fix and cleanup libjava/include/dwarf2-signal.h
Franz Sirl
Franz.Sirl-kernel@lauterbach.com
Tue Jun 17 17:09:00 GMT 2003
On Friday 13 June 2003 14:21, Andrew Haley wrote:
> This is the wrong list for this patch; I have redirected accordingly.
You had a typo in the redirection and I think my reply on Friday didn't reach
you (can't find it in the lists).
> Franz Sirl writes:
> > Hi,
> >
> > the INIT_SEGV and INIT_FPE macros in dwarf2-signal.h are broken for
> > Linux where the userspace and kernelspace struct sigaction differ. Due
> > to this the SA_SIGINFO flag is never honored.
> > The appended patch fixes that and adds a reference to MAKE_THROW_FRAME
> > to the MD_FALLBACK_FRAME_STATE_FOR documentation. I also took the
> > opportunity to cleanup, reorder and indent the #if/#elif/#endif maze in
> > dwarf2-signal.h, as discussed on IRC.
>
> Good. It's much tidier if each machine has its own signal handler in
> include/machine.h.
>
> > In a followup patch I will add a MAKE_THROW_FRAME for ppc-linux and fix
> > MD_FALLBACK_FRAME_STATE_FOR in rs6000/linux.h accordingly.
> >
> > Bootstrapped and regtested on i686-linux.
>
> i686-linux uses include/i386-signal.h, so regtesting on that platform
> didn't test much.
>
> > OK to commit to mainline and 3.3?
>
> OK. However, this patch conflicts with the cleanup I posted
> yesterday. You'll need to do a 'cvs update' on mainline.
Hi Andrew,
for now I've only committed the doc part. I retract my original patch to
dwarf2-signal.h, as it will break alpha-linux (I looked closer after you
pointed out that i386-linux is no valid test platform).
Since I already did the tidyup work, here the patch again with the "#elif
defined(__linux__)" hunk removed, thus it's only a reformatting patch now.
OK to commit to mainline?
Nevertheless signal-handling on alpha-linux should be fixed, but I'll leave
this to Richard or someone else who can test it on alpha-linux.
Franz.
* include/dwarf2-signal.h: Tidy and reorder.
-------------- next part --------------
Index: libjava/include/dwarf2-signal.h
===================================================================
RCS file: /cvs/gcc/gcc/libjava/include/dwarf2-signal.h,v
retrieving revision 1.14
diff -u -p -r1.14 dwarf2-signal.h
--- libjava/include/dwarf2-signal.h 13 Jun 2003 12:20:45 -0000 1.14
+++ libjava/include/dwarf2-signal.h 17 Jun 2003 17:06:37 -0000
@@ -1,6 +1,6 @@
// dwarf2-signal.h - Catch runtime signals and turn them into exceptions.
-/* Copyright (C) 2000, 2001 Free Software Foundation
+/* Copyright (C) 2000, 2001, 2003 Free Software Foundation
This file is part of libgcj.
@@ -12,15 +12,15 @@ Libgcj License. Please consult the file
details. */
#ifndef JAVA_SIGNAL_H
-#define JAVA_SIGNAL_H 1
+# define JAVA_SIGNAL_H 1
-#include <signal.h>
-#include <sys/syscall.h>
+# include <signal.h>
+# include <sys/syscall.h>
-#define HANDLE_SEGV 1
-#undef HANDLE_FPE
+# define HANDLE_SEGV 1
+# undef HANDLE_FPE
-#define SIGNAL_HANDLER(_name) \
+# define SIGNAL_HANDLER(_name) \
static void _Jv_##_name (int, siginfo_t *_sip, void *_p)
class java::lang::Throwable;
@@ -29,8 +29,8 @@ class java::lang::Throwable;
// 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) \
+# ifdef __alpha__
+# define MAKE_THROW_FRAME(_exception) \
do \
{ \
/* Alpha either leaves PC pointing at a faulting instruction or the \
@@ -42,9 +42,9 @@ do \
} \
while (0)
-#elif defined(__ia64__)
+# elif defined(__ia64__)
-#define MAKE_THROW_FRAME(_exception) \
+# define MAKE_THROW_FRAME(_exception) \
do \
{ \
/* IA-64 either leaves PC pointing at a faulting instruction or the \
@@ -58,12 +58,12 @@ do \
_sc->sc_ip++; \
} \
while (0)
-#elif defined(__sparc__)
+# elif defined(__sparc__)
/* We could do the unwind of the signal frame quickly by hand here like
sparc-signal.h does under Solaris, but that makes debugging unwind
failures almost impossible. */
-#if !defined(__arch64__)
-#define MAKE_THROW_FRAME(_exception) \
+# if !defined(__arch64__)
+# define MAKE_THROW_FRAME(_exception) \
do \
{ \
/* Sparc-32 leaves PC pointing at a faulting instruction \
@@ -90,8 +90,8 @@ do \
regp->pc = ((regp->pc + 4) - 8); \
} \
while (0)
-#else
-#define MAKE_THROW_FRAME(_exception) \
+# else
+# define MAKE_THROW_FRAME(_exception) \
do \
{ \
/* Sparc-64 leaves PC pointing at a faulting instruction \
@@ -112,18 +112,25 @@ do \
regp->tpc = ((regp->tpc + 4) - 8); \
} \
while (0)
-#endif
-#else
-#define MAKE_THROW_FRAME(_exception) \
+# endif
+# else
+# define MAKE_THROW_FRAME(_exception) \
do \
{ \
(void)_p; \
} \
while (0)
-#endif
+# endif
-#if defined(__sparc__)
-#if defined(__arch64__)
+/* We use syscall(SYS_sigaction) in INIT_SEGV and INIT_FPE instead of
+ sigaction() because on some systems the pthreads wrappers for
+ signal handlers are not compiled with unwind information, so it's
+ not possible to unwind through them. This is a problem that will
+ go away once all systems have pthreads libraries that are
+ compiled with full unwind info. */
+
+# if defined(__sparc__)
+# if defined(__arch64__)
extern "C" {
static void __rt_sigreturn_stub(void)
{
@@ -140,7 +147,7 @@ extern "C" {
sigset_t k_sa_mask;
};
}
-#define INIT_SEGV \
+# define INIT_SEGV \
do \
{ \
struct kernel_sigaction act; \
@@ -154,7 +161,7 @@ do \
} \
while (0)
-#define INIT_FPE \
+# define INIT_FPE \
do \
{ \
struct kernel_sigaction act; \
@@ -167,7 +174,7 @@ do \
stub - 8, _NSIG / 8); \
} \
while (0)
-#else /* __arch64__ */
+# else /* __arch64__ */
extern "C" {
struct kernel_sigaction
@@ -178,7 +185,7 @@ extern "C" {
};
}
-#define INIT_SEGV \
+# define INIT_SEGV \
do \
{ \
struct kernel_sigaction act; \
@@ -190,7 +197,7 @@ do \
} \
while (0)
-#define INIT_FPE \
+# define INIT_FPE \
do \
{ \
struct kernel_sigaction act; \
@@ -201,63 +208,57 @@ do \
syscall (SYS_sigaction, -SIGFPE, &act, NULL); \
} \
while (0)
-#endif
-#elif !defined(__ia64__)
-#define INIT_SEGV \
+# endif
+# elif defined(__ia64__)
+
+// On IA64, unwind information is mandatory, so we can unwind
+// correctly through glibc frames. Thus we call the ordinary
+// sigaction.
+
+# define INIT_SEGV \
do \
{ \
struct sigaction act; \
act.sa_sigaction = _Jv_catch_segv; \
sigemptyset (&act.sa_mask); \
act.sa_flags = SA_SIGINFO; \
- syscall (SYS_sigaction, SIGSEGV, &act, NULL); \
+ sigaction (SIGSEGV, &act, NULL); \
} \
while (0)
-#define INIT_FPE \
+# define INIT_FPE \
do \
{ \
struct sigaction act; \
act.sa_sigaction = _Jv_catch_fpe; \
sigemptyset (&act.sa_mask); \
act.sa_flags = SA_SIGINFO; \
- syscall (SYS_sigaction, SIGFPE, &act, NULL); \
+ sigaction (SIGFPE, &act, NULL); \
} \
while (0)
-/* We use syscall(SYS_sigaction) in INIT_SEGV and INIT_FPE instead of
- * sigaction() because on some systems the pthreads wrappers for
- * signal handlers are not compiled with unwind information, so it's
- * not possible to unwind through them. This is a problem that will
- * go away once all systems have pthreads libraries that are
- * compiled with full unwind info. */
-
-#else /* __ia64__ */
-
-// On IA64, unwind information is mandatory, so we can unwind
-// correctly through glibc frames. Thus we call the ordinary
-// sigaction.
-
-#define INIT_SEGV \
+# else
+# define INIT_SEGV \
do \
{ \
struct sigaction act; \
act.sa_sigaction = _Jv_catch_segv; \
sigemptyset (&act.sa_mask); \
act.sa_flags = SA_SIGINFO; \
- sigaction (SIGSEGV, &act, NULL); \
+ syscall (SYS_sigaction, SIGSEGV, &act, NULL); \
} \
while (0)
-#define INIT_FPE \
+# define INIT_FPE \
do \
{ \
struct sigaction act; \
act.sa_sigaction = _Jv_catch_fpe; \
sigemptyset (&act.sa_mask); \
act.sa_flags = SA_SIGINFO; \
- sigaction (SIGFPE, &act, NULL); \
+ syscall (SYS_sigaction, SIGFPE, &act, NULL); \
} \
while (0)
-#endif /* __ia64__ || __sparc__ */
+
+# endif
#endif /* JAVA_SIGNAL_H */
More information about the Java-patches
mailing list