1 /* src/vm/signal.c - machine independent signal functions
3 Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4 R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5 C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6 Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 Contact: cacao@complang.tuwien.ac.at
27 Authors: Christian Thalinger
31 $Id: signal.c 2794 2005-06-23 09:34:21Z twisti $
40 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
41 # include "threads/native/threads.h"
44 #include "vm/options.h"
45 #include "vm/jit/stacktrace.h"
48 /* function prototypes ********************************************************/
50 void signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p);
51 void signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p);
52 void signal_handler_sigquit(int sig, siginfo_t *siginfo, void *_p);
53 void signal_handler_sigusr1(int sig, siginfo_t *siginfo, void *_p);
56 /* signal_init *****************************************************************
58 Initializes the signal subsystem and installs the signal handler.
60 *******************************************************************************/
62 void signal_init(void)
66 /* install signal handlers we need to convert to exceptions */
68 sigemptyset(&act.sa_mask);
71 /* catch NullPointerException/StackOverFlowException */
74 act.sa_sigaction = signal_handler_sigsegv;
75 act.sa_flags = SA_SIGINFO;
78 sigaction(SIGSEGV, &act, NULL);
82 sigaction(SIGBUS, &act, NULL);
87 /* catch ArithmeticException */
89 #if defined(__I386__) || defined(__X86_64__)
90 act.sa_sigaction = signal_handler_sigfpe;
91 act.sa_flags = SA_SIGINFO;
92 sigaction(SIGFPE, &act, NULL);
96 /* catch SIGQUIT for thread dump */
98 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
99 act.sa_sigaction = signal_handler_sigquit;
100 act.sa_flags = SA_SIGINFO;
101 sigaction(SIGQUIT, &act, NULL);
103 act.sa_sigaction = signal_handler_sigusr1;
104 act.sa_flags = SA_SIGINFO;
105 sigaction(SIGUSR1, &act, NULL);
110 /* signal_handler_sigquit ******************************************************
114 *******************************************************************************/
116 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
117 void signal_handler_sigquit(int sig, siginfo_t *siginfo, void *_p)
126 /* signal_handler_sigusr1 ******************************************************
130 *******************************************************************************/
132 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
133 void signal_handler_sigusr1(int sig, siginfo_t *siginfo, void *_p)
135 /* call stacktrace function */
137 stacktrace_dump_trace();
143 * These are local overrides for various environment variables in Emacs.
144 * Please do not remove this and leave it at the end of the file, where
145 * Emacs will automagically detect them.
146 * ---------------------------------------------------------------------
149 * indent-tabs-mode: t