1 /* src/vm/jit/x86_64/freebsd/md-os.c - machine dependent x86_64 FreeBSD functions
3 Copyright (C) 2007, 2008
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5 Copyright (C) 2009 Theobroma Systems Ltd.
7 This file is part of CACAO.
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2, or (at
12 your option) any later version.
14 This program is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
33 #include "threads/thread.hpp"
35 #include "vm/signallocal.hpp"
37 #include "vm/jit/asmpart.h"
38 #include "vm/jit/stacktrace.hpp"
41 /* md_signal_handler_sigsegv ***************************************************
43 NullPointerException signal handler for hardware null pointer
46 *******************************************************************************/
48 void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
56 _uc = (ucontext_t *) _p;
57 _mc = &_uc->uc_mcontext;
59 sp = (u1 *) _mc->mc_rsp;
60 xpc = (u1 *) _mc->mc_rip;
61 ra = xpc; /* return address is equal to xpc */
64 /* check for StackOverflowException */
66 threads_check_stackoverflow(sp);
70 (ptrint) stacktrace_hardware_nullpointerexception(NULL, sp, ra, xpc);
72 _mc->mc_r10 = (ptrint) xpc; /* REG_ITMP2_XPC */
73 _mc->mc_rip = (ptrint) asm_handle_exception;
77 /* md_signal_handler_sigfpe ****************************************************
79 ArithmeticException signal handler for hardware divide by zero
82 *******************************************************************************/
84 void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
92 _uc = (ucontext_t *) _p;
93 _mc = &_uc->uc_mcontext;
95 sp = (u1 *) _mc->mc_rsp;
96 xpc = (u1 *) _mc->mc_rip;
97 ra = xpc; /* return address is equal to xpc */
100 (ptrint) stacktrace_hardware_arithmeticexception(NULL, sp, ra, xpc);
102 _mc->mc_r10 = (ptrint) xpc; /* REG_ITMP2_XPC */
103 _mc->mc_rip = (ptrint) asm_handle_exception;
107 /* md_signal_handler_sigusr2 ***************************************************
109 Signal handler for profiling sampling.
111 *******************************************************************************/
113 #if defined(ENABLE_THREADS)
114 void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
123 _uc = (ucontext_t *) _p;
124 _mc = &_uc->uc_mcontext;
126 pc = (u1 *) _mc->mc_rip;
134 * These are local overrides for various environment variables in Emacs.
135 * Please do not remove this and leave it at the end of the file, where
136 * Emacs will automagically detect them.
137 * ---------------------------------------------------------------------
140 * indent-tabs-mode: t
144 * vim:noexpandtab:sw=4:ts=4: