OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [include/] [dwarf2-signal.h] - Blame information for rev 766

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 757 jeremybenn
// dwarf2-signal.h - Catch runtime signals and turn them into exceptions.
2
 
3
/* Copyright (C) 2000, 2001, 2009  Free Software Foundation
4
 
5
   This file is part of libgcj.
6
 
7
   Use this file for a target for which the dwarf2 unwinder in libgcc
8
   can unwind through signal handlers.
9
 
10
This software is copyrighted work licensed under the terms of the
11
Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
12
details.  */
13
 
14
#ifndef JAVA_SIGNAL_H
15
#define JAVA_SIGNAL_H 1
16
 
17
#include <signal.h>
18
#include <sys/syscall.h>
19
 
20
#define HANDLE_SEGV 1
21
#undef HANDLE_FPE
22
 
23
#define SIGNAL_HANDLER(_name)   \
24
static void _Jv_##_name (int, siginfo_t *_sip, void *_p)
25
 
26
class java::lang::Throwable;
27
 
28
// Unwind the stack to the point at which the signal was generated and
29
// then throw an exception.  With the dwarf2 unwinder we don't usually
30
// need to do anything, with some minor exceptions.
31
 
32
#ifdef __ia64__
33
 
34
#define MAKE_THROW_FRAME(_exception)                                    \
35
do                                                                      \
36
{                                                                       \
37
  /* IA-64 either leaves PC pointing at a faulting instruction or the   \
38
   following instruction, depending on the signal.  SEGV always does    \
39
   the former, so we adjust the saved PC to point to the following      \
40
   instruction; this is what the handler in libgcc expects.  */         \
41
  /* Note that we are lying to the unwinder here, which expects the     \
42
   faulting pc, not pc+1.  But we claim the unwind information can't    \
43
   be changed by such a ld or st instruction, so it doesn't matter. */  \
44
  struct sigcontext *_sc = (struct sigcontext *)_p;                     \
45
  _sc->sc_ip++;                                                         \
46
}                                                                       \
47
while (0)
48
 
49
#else
50
#define MAKE_THROW_FRAME(_exception)            \
51
do                                              \
52
{                                               \
53
  (void)_p;                                     \
54
}                                               \
55
while (0)
56
#endif
57
 
58
#if defined(__sparc__)
59
#if defined(__arch64__)
60
extern "C" {
61
    static void __rt_sigreturn_stub(void)
62
    {
63
      __asm__("mov %0, %%g1\n\t"
64
              "ta  0x6d\n\t"
65
              : /* no outputs */
66
              : "i" (__NR_rt_sigreturn));
67
    }
68
    struct kernel_sigaction
69
    {
70
      void (*k_sa_sigaction)(int,siginfo_t *,void *);
71
      unsigned long k_sa_flags;
72
      void (*k_sa_restorer)(void);
73
      sigset_t k_sa_mask;
74
    };
75
}
76
#define INIT_SEGV                                               \
77
do                                                              \
78
  {                                                             \
79
    struct kernel_sigaction act;                                \
80
    unsigned long stub = ((unsigned long)&__rt_sigreturn_stub); \
81
    act.k_sa_sigaction = _Jv_catch_segv;                        \
82
    sigemptyset (&act.k_sa_mask);                               \
83
    act.k_sa_flags = SA_SIGINFO;                                \
84
    act.k_sa_restorer = NULL;                                   \
85
    syscall (SYS_rt_sigaction, SIGSEGV, &act, NULL,             \
86
             stub - 8, _NSIG / 8);                              \
87
  }                                                             \
88
while (0)
89
 
90
#define INIT_FPE                                                \
91
do                                                              \
92
  {                                                             \
93
    struct kernel_sigaction act;                                \
94
    unsigned long stub = ((unsigned long)&__rt_sigreturn_stub); \
95
    act.k_sa_sigaction = _Jv_catch_fpe;                         \
96
    sigemptyset (&act.k_sa_mask);                               \
97
    act.k_sa_flags = SA_SIGINFO;                                \
98
    act.k_sa_restorer = NULL;                                   \
99
    syscall (SYS_rt_sigaction, SIGFPE, &act, NULL,              \
100
             stub - 8, _NSIG / 8);                              \
101
  }                                                             \
102
while (0)
103
#else /* __arch64__ */
104
 
105
extern "C" {
106
    struct kernel_sigaction
107
    {
108
      void (*k_sa_sigaction)(int,siginfo_t *,void *);
109
      unsigned long k_sa_mask, k_sa_flags;
110
      void (*k_sa_restorer)(void);
111
    };
112
}
113
 
114
#define INIT_SEGV                                               \
115
do                                                              \
116
  {                                                             \
117
    struct kernel_sigaction act;                                \
118
    act.k_sa_sigaction = _Jv_catch_segv;                        \
119
    act.k_sa_mask = 0;                                           \
120
    act.k_sa_flags = SA_SIGINFO;                                \
121
    act.k_sa_restorer = NULL;                                   \
122
    syscall (SYS_sigaction, -SIGSEGV, &act, NULL);              \
123
  }                                                             \
124
while (0)
125
 
126
#define INIT_FPE                                                \
127
do                                                              \
128
  {                                                             \
129
    struct kernel_sigaction act;                                \
130
    act.k_sa_sigaction = _Jv_catch_fpe;                         \
131
    act.k_sa_mask = 0;                                           \
132
    act.k_sa_flags = SA_SIGINFO;                                \
133
    act.k_sa_restorer = NULL;                                   \
134
    syscall (SYS_sigaction, -SIGFPE, &act, NULL);               \
135
  }                                                             \
136
while (0)
137
#endif
138
#elif !defined(__ia64__)
139
#define INIT_SEGV                                               \
140
do                                                              \
141
  {                                                             \
142
    struct sigaction act;                                       \
143
    act.sa_sigaction = _Jv_catch_segv;                          \
144
    sigemptyset (&act.sa_mask);                                 \
145
    act.sa_flags = SA_SIGINFO;                                  \
146
    syscall (SYS_sigaction, SIGSEGV, &act, NULL);               \
147
  }                                                             \
148
while (0)
149
 
150
#define INIT_FPE                                                \
151
do                                                              \
152
  {                                                             \
153
    struct sigaction act;                                       \
154
    act.sa_sigaction = _Jv_catch_fpe;                           \
155
    sigemptyset (&act.sa_mask);                                 \
156
    act.sa_flags = SA_SIGINFO;                                  \
157
    syscall (SYS_sigaction, SIGFPE, &act, NULL);                \
158
  }                                                             \
159
while (0)
160
 
161
/* We use syscall(SYS_sigaction) in INIT_SEGV and INIT_FPE instead of
162
 * sigaction() because on some systems the pthreads wrappers for
163
 * signal handlers are not compiled with unwind information, so it's
164
 * not possible to unwind through them.  This is a problem that will
165
 * go away once all systems have pthreads libraries that are
166
 * compiled with full unwind info.  */
167
 
168
#else  /* __ia64__ */
169
 
170
// On IA64, unwind information is mandatory, so we can unwind
171
// correctly through glibc frames.  Thus we call the ordinary
172
// sigaction.
173
 
174
#define INIT_SEGV                                               \
175
do                                                              \
176
  {                                                             \
177
    struct sigaction act;                                       \
178
    act.sa_sigaction = _Jv_catch_segv;                          \
179
    sigemptyset (&act.sa_mask);                                 \
180
    act.sa_flags = SA_SIGINFO;                                  \
181
    sigaction (SIGSEGV, &act, NULL);                            \
182
  }                                                             \
183
while (0)
184
 
185
#define INIT_FPE                                                \
186
do                                                              \
187
  {                                                             \
188
    struct sigaction act;                                       \
189
    act.sa_sigaction = _Jv_catch_fpe;                           \
190
    sigemptyset (&act.sa_mask);                                 \
191
    act.sa_flags = SA_SIGINFO;                                  \
192
    sigaction (SIGFPE, &act, NULL);                             \
193
  }                                                             \
194
while (0)
195
#endif /* __ia64__ || __sparc__ */
196
#endif /* JAVA_SIGNAL_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.