CACAO
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
File List
Globals
source
cacao
src
vm
jit
x86_64
freebsd
md-os.cpp
Go to the documentation of this file.
1
/* src/vm/jit/x86_64/freebsd/md-os.cpp - machine dependent x86_64 FreeBSD functions
2
3
Copyright (C) 1996-2013
4
CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5
Copyright (C) 2009 Theobroma Systems Ltd.
6
7
This file is part of CACAO.
8
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.
13
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.
18
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
22
02110-1301, USA.
23
24
*/
25
26
27
#include "config.h"
28
29
#include <cassert>
30
#include <cstdlib>
31
#include <
ucontext.h
>
32
33
#include "
threads/thread.hpp
"
34
35
#include "
vm/signallocal.hpp
"
36
37
#include "
vm/jit/asmpart.hpp
"
38
#include "
vm/jit/stacktrace.hpp
"
39
40
41
/* md_signal_handler_sigsegv ***************************************************
42
43
NullPointerException signal handler for hardware null pointer
44
check.
45
46
*******************************************************************************/
47
48
void
md_signal_handler_sigsegv
(
int
sig, siginfo_t *siginfo,
void
*_p)
49
{
50
ucontext_t
*_uc;
51
mcontext_t
*_mc;
52
u1
*
sp
;
53
u1
*
ra
;
54
u1
*
xpc
;
55
56
_uc = (
ucontext_t
*) _p;
57
_mc = &_uc->
uc_mcontext
;
58
59
sp = (
u1
*) _mc->mc_rsp;
60
xpc = (
u1
*) _mc->mc_rip;
61
ra =
xpc
;
/* return address is equal to xpc */
62
63
#if 0
64
/* check for StackOverflowException */
65
66
threads_check_stackoverflow(sp);
67
#endif
68
69
_mc->mc_rax =
70
(
ptrint
) stacktrace_hardware_nullpointerexception(NULL, sp, ra, xpc);
71
72
_mc->mc_r10 = (
ptrint
) xpc;
/* REG_ITMP2_XPC */
73
_mc->mc_rip = (
ptrint
)
asm_handle_exception
;
74
}
75
76
77
/* md_signal_handler_sigfpe ****************************************************
78
79
ArithmeticException signal handler for hardware divide by zero
80
check.
81
82
*******************************************************************************/
83
84
void
md_signal_handler_sigfpe
(
int
sig, siginfo_t *siginfo,
void
*_p)
85
{
86
ucontext_t
*_uc;
87
mcontext_t
*_mc;
88
u1
*
sp
;
89
u1
*
ra
;
90
u1
*
xpc
;
91
92
_uc = (
ucontext_t
*) _p;
93
_mc = &_uc->
uc_mcontext
;
94
95
sp = (
u1
*) _mc->mc_rsp;
96
xpc = (
u1
*) _mc->mc_rip;
97
ra =
xpc
;
/* return address is equal to xpc */
98
99
_mc->mc_rax =
100
(
ptrint
) stacktrace_hardware_arithmeticexception(NULL, sp, ra, xpc);
101
102
_mc->mc_r10 = (
ptrint
) xpc;
/* REG_ITMP2_XPC */
103
_mc->mc_rip = (
ptrint
)
asm_handle_exception
;
104
}
105
106
107
/* md_signal_handler_sigusr2 ***************************************************
108
109
Signal handler for profiling sampling.
110
111
*******************************************************************************/
112
113
void
md_signal_handler_sigusr2
(
int
sig, siginfo_t *siginfo,
void
*_p)
114
{
115
threadobject
*t;
116
ucontext_t
*_uc;
117
mcontext_t
*_mc;
118
u1
*
pc
;
119
120
t =
THREADOBJECT
;
121
122
_uc = (
ucontext_t
*) _p;
123
_mc = &_uc->
uc_mcontext
;
124
125
pc = (
u1
*) _mc->mc_rip;
126
127
t->
pc
= pc;
128
}
129
130
131
/*
132
* These are local overrides for various environment variables in Emacs.
133
* Please do not remove this and leave it at the end of the file, where
134
* Emacs will automagically detect them.
135
* ---------------------------------------------------------------------
136
* Local variables:
137
* mode: c++
138
* indent-tabs-mode: t
139
* c-basic-offset: 4
140
* tab-width: 4
141
* End:
142
* vim:noexpandtab:sw=4:ts=4:
143
*/
ra
#define ra
Definition:
md-asm.hpp:62
md_signal_handler_sigsegv
void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
NullPointerException signal handler for hardware null pointer check.
Definition:
md-os.cpp:50
ucontext::uc_mcontext
struct sigcontext uc_mcontext
Definition:
md-os.cpp:42
u1
uint8_t u1
Definition:
types.hpp:40
md_signal_handler_sigfpe
void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
Definition:
md-os.cpp:59
ucontext
Definition:
md-os.cpp:38
xpc
#define xpc
Definition:
md-asm.hpp:51
md_signal_handler_sigusr2
void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
Definition:
md-os.cpp:83
stacktrace.hpp
signallocal.hpp
asmpart.hpp
thread.hpp
asm_handle_exception
void asm_handle_exception(void)
mcontext_t
CONTEXT mcontext_t
Definition:
ucontext.h:27
sp
#define sp
Definition:
md-asm.hpp:81
threadobject
Definition:
thread.hpp:89
pc
#define pc
Definition:
md-asm.hpp:56
threadobject::pc
u1 * pc
Definition:
thread.hpp:126
ucontext.h
ptrint
uintptr_t ptrint
Definition:
types.hpp:54
THREADOBJECT
#define THREADOBJECT
Definition:
thread-none.hpp:47
Generated on Fri Aug 4 2017 03:01:49 for CACAO by
1.8.5