1 /* src/vm/jit/i386/freebsd/md-os.c - machine dependent i386 FreeBSD functions
3 Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, 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., 51 Franklin Street, Fifth Floor, Boston, MA
25 Contact: cacao@cacaojvm.org
27 Authors: Christian Thalinger
38 #include "vm/jit/i386/md-abi.h"
40 #include "vm/exceptions.h"
41 #include "vm/signallocal.h"
42 #include "vm/jit/asmpart.h"
43 #include "vm/jit/stacktrace.h"
46 /* md_signal_handler_sigsegv ***************************************************
48 NullPointerException signal handler for hardware null pointer
51 *******************************************************************************/
53 void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
61 _uc = (ucontext_t *) _p;
62 _mc = &_uc->uc_mcontext;
64 sp = (u1 *) _mc->mc_esp;
65 xpc = (u1 *) _mc->mc_eip;
66 ra = xpc; /* return address is equal to xpc */
69 (ptrint) stacktrace_hardware_nullpointerexception(NULL, sp, ra, xpc);
71 _mc->mc_ecx = (ptrint) xpc; /* REG_ITMP2_XPC */
72 _mc->mc_eip = (ptrint) asm_handle_exception;
76 /* md_signal_handler_sigfpe ****************************************************
78 ArithmeticException signal handler for hardware divide by zero
81 *******************************************************************************/
83 void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
91 _uc = (ucontext_t *) _p;
92 _mc = &_uc->uc_mcontext;
94 sp = (u1 *) _mc->mc_esp;
95 xpc = (u1 *) _mc->mc_eip;
96 ra = xpc; /* return address is equal to xpc */
99 (ptrint) stacktrace_hardware_arithmeticexception(NULL, sp, ra, xpc);
101 _mc->mc_ecx = (ptrint) xpc; /* REG_ITMP2_XPC */
102 _mc->mc_eip = (ptrint) asm_handle_exception;
106 #if defined(ENABLE_THREADS)
107 void thread_restartcriticalsection(ucontext_t *uc)
111 critical = critical_find_restart_point((void *) uc->uc_mcontext.mc_eip);
114 uc->uc_mcontext.mc_eip = (ptrint) critical;
120 * These are local overrides for various environment variables in Emacs.
121 * Please do not remove this and leave it at the end of the file, where
122 * Emacs will automagically detect them.
123 * ---------------------------------------------------------------------
126 * indent-tabs-mode: t