4 |
|
* Derived from Bruno Haible's work on his SIGSEGV library for clisp |
5 |
|
* <http://clisp.sourceforge.net/> |
6 |
|
* |
7 |
< |
* Basilisk II (C) 1997-2005 Christian Bauer |
7 |
> |
* Basilisk II (C) 1997-2008 Christian Bauer |
8 |
|
* |
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 |
24 |
|
#ifndef SIGSEGV_H |
25 |
|
#define SIGSEGV_H |
26 |
|
|
27 |
+ |
#define SIGSEGV_MAJOR_VERSION 1 |
28 |
+ |
#define SIGSEGV_MINOR_VERSION 0 |
29 |
+ |
#define SIGSEGV_MICRO_VERSION 0 |
30 |
+ |
|
31 |
+ |
#define SIGSEGV_CHECK_VERSION(MAJOR, MINOR, MICRO) \ |
32 |
+ |
(SIGSEGV_MAJOR_VERSION > (MAJOR) || \ |
33 |
+ |
(SIGSEGV_MAJOR_VERSION == (MAJOR) && SIGSEGV_MINOR_VERSION > (MINOR)) || \ |
34 |
+ |
(SIGSEGV_MAJOR_VERSION == (MAJOR) && SIGSEGV_MINOR_VERSION == (MINOR) && SIGSEGV_MICRO_VERSION >= (MICRO))) |
35 |
+ |
|
36 |
|
// Address type |
37 |
< |
typedef char * sigsegv_address_t; |
37 |
> |
typedef char *sigsegv_address_t; |
38 |
> |
|
39 |
> |
// SIGSEGV handler argument (forward declaration) |
40 |
> |
struct sigsegv_info_t; |
41 |
|
|
42 |
|
// SIGSEGV handler return state |
43 |
|
enum sigsegv_return_t { |
47 |
|
}; |
48 |
|
|
49 |
|
// Type of a SIGSEGV handler. Returns boolean expressing successful operation |
50 |
< |
typedef sigsegv_return_t (*sigsegv_fault_handler_t)(sigsegv_address_t fault_address, sigsegv_address_t instruction_address); |
50 |
> |
typedef sigsegv_return_t (*sigsegv_fault_handler_t)(sigsegv_info_t *sip); |
51 |
|
|
52 |
|
// Type of a SIGSEGV state dump function |
53 |
< |
typedef void (*sigsegv_state_dumper_t)(sigsegv_address_t fault_address, sigsegv_address_t instruction_address); |
53 |
> |
typedef void (*sigsegv_state_dumper_t)(sigsegv_info_t *sip); |
54 |
|
|
55 |
|
// Install a SIGSEGV handler. Returns boolean expressing success |
56 |
|
extern bool sigsegv_install_handler(sigsegv_fault_handler_t handler); |
61 |
|
// Set callback function when we cannot handle the fault |
62 |
|
extern void sigsegv_set_dump_state(sigsegv_state_dumper_t handler); |
63 |
|
|
64 |
+ |
// Return the address of the invalid memory reference |
65 |
+ |
extern sigsegv_address_t sigsegv_get_fault_address(sigsegv_info_t *sip); |
66 |
+ |
|
67 |
+ |
// Return the address of the instruction that caused the fault, or |
68 |
+ |
// SIGSEGV_INVALID_ADDRESS if we could not retrieve this information |
69 |
+ |
extern sigsegv_address_t sigsegv_get_fault_instruction_address(sigsegv_info_t *sip); |
70 |
+ |
|
71 |
|
// Define an address that is bound to be invalid for a program counter |
72 |
< |
const sigsegv_address_t SIGSEGV_INVALID_PC = (sigsegv_address_t)(-1); |
72 |
> |
const sigsegv_address_t SIGSEGV_INVALID_ADDRESS = (sigsegv_address_t)(-1UL); |
73 |
|
|
74 |
|
#endif /* SIGSEGV_H */ |