1 |
gbeauche |
1.1 |
/* |
2 |
|
|
* sigsegv.h - SIGSEGV signals support |
3 |
|
|
* |
4 |
|
|
* Derived from Bruno Haible's work on his SIGSEGV library for clisp |
5 |
|
|
* <http://clisp.sourceforge.net/> |
6 |
|
|
* |
7 |
cebix |
1.2 |
* Basilisk II (C) 1997-2002 Christian Bauer |
8 |
gbeauche |
1.1 |
* |
9 |
|
|
* This program is free software; you can redistribute it and/or modify |
10 |
|
|
* it under the terms of the GNU General Public License as published by |
11 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
12 |
|
|
* (at your option) any later version. |
13 |
|
|
* |
14 |
|
|
* This program is distributed in the hope that it will be useful, |
15 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 |
|
|
* GNU 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22 |
|
|
*/ |
23 |
|
|
|
24 |
|
|
#ifndef SIGSEGV_H |
25 |
|
|
#define SIGSEGV_H |
26 |
|
|
|
27 |
|
|
// Address type |
28 |
|
|
typedef char * sigsegv_address_t; |
29 |
|
|
|
30 |
gbeauche |
1.5 |
// Transfer type (intended to be used a mask for sigsegv_*_ignore_range()) |
31 |
|
|
enum sigsegv_transfer_type_t { |
32 |
|
|
SIGSEGV_TRANSFER_UNKNOWN = 0, |
33 |
|
|
SIGSEGV_TRANSFER_LOAD = 1, |
34 |
|
|
SIGSEGV_TRANSFER_STORE = 2, |
35 |
|
|
}; |
36 |
|
|
|
37 |
gbeauche |
1.1 |
// Type of a SIGSEGV handler. Returns boolean expressing successful operation |
38 |
gbeauche |
1.4 |
typedef bool (*sigsegv_fault_handler_t)(sigsegv_address_t fault_address, sigsegv_address_t instruction_address); |
39 |
|
|
|
40 |
|
|
// Type of a SIGSEGV state dump function |
41 |
|
|
typedef void (*sigsegv_state_dumper_t)(sigsegv_address_t fault_address, sigsegv_address_t instruction_address); |
42 |
gbeauche |
1.1 |
|
43 |
|
|
// Install a SIGSEGV handler. Returns boolean expressing success |
44 |
gbeauche |
1.4 |
extern bool sigsegv_install_handler(sigsegv_fault_handler_t handler); |
45 |
gbeauche |
1.1 |
|
46 |
|
|
// Remove the user SIGSEGV handler, revert to default behavior |
47 |
|
|
extern void sigsegv_uninstall_handler(void); |
48 |
|
|
|
49 |
gbeauche |
1.5 |
// Add SIGSEGV ignore range |
50 |
|
|
extern void sigsegv_add_ignore_range(sigsegv_address_t address, unsigned long length, int transfer_type); |
51 |
|
|
|
52 |
|
|
// Remove SIGSEGV ignore range. Range must match installed one, otherwise FALSE is returned. |
53 |
|
|
extern bool sigsegv_remove_ignore_range(sigsegv_address_t address, unsigned long length, int transfer_type); |
54 |
gbeauche |
1.3 |
|
55 |
|
|
// Set callback function when we cannot handle the fault |
56 |
gbeauche |
1.4 |
extern void sigsegv_set_dump_state(sigsegv_state_dumper_t handler); |
57 |
gbeauche |
1.3 |
|
58 |
gbeauche |
1.1 |
// Define an address that is bound to be invalid for a program counter |
59 |
|
|
const sigsegv_address_t SIGSEGV_INVALID_PC = (sigsegv_address_t)(-1); |
60 |
|
|
|
61 |
|
|
#endif /* SIGSEGV_H */ |