acme
Foundational cross-platform layer of the ca2 framework
Toggle main menu visibility
Loading...
Searching...
No Matches
standard_exception.h
1
//
2
// Created by camilo on 25/06/2023. <3ThomasBorregaardSorensen!!
3
//
4
5
/*
6
Copyright (ca) 2001
7
Author: Konstantin Boukreev
8
E-mail:
[email protected]
9
Created: 25.12.2001 14:47:20
10
Version: 1.0.0
11
12
Permission to use, copy, modify, distribute and sell this software
13
and its documentation for any purpose is hereby granted without fee,
14
provided that the above copyright notice appear in all copies and
15
that both that copyright notice and this permission notice appear
16
in supporting documentation. Konstantin Boukreev makes no representations
17
about the suitability of this software for any purpose.
18
It is provided "as is" without express or implied warranty.
19
20
wrapper class for _set_standard_translator API
21
maps Win32 exceptions (C structured exceptions) into C++ typed exceptions.
22
*/
23
#pragma once
24
25
26
//#include "exception.h"
27
28
29
#include <signal.h>
30
//#include <ucontext.h>
31
32
33
34
#if defined(__ANDROID__)
35
36
#include <signal.h>
37
//#ifndef
38
//#include <ucontext.h>
39
40
41
#if OSBIT == 64
42
43
#define DEFAULT_SE_EXCEPTION_CALLSTACK_SKIP 3000
44
45
#else
46
47
#define DEFAULT_SE_EXCEPTION_CALLSTACK_SKIP 0
48
49
#endif
50
51
#elif defined(WINDOWS)
52
53
#elif defined(__APPLE__)
54
55
56
#include <sys/ucontext.h>
57
#include <signal.h>
58
59
#if OSBIT == 64
60
61
#define DEFAULT_SE_EXCEPTION_CALLSTACK_SKIP 3000
62
63
#else
64
65
#define DEFAULT_SE_EXCEPTION_CALLSTACK_SKIP 0
66
67
#endif
68
69
#else
70
71
72
//#if OSBIT == 64
73
//
74
//#define DEFAULT_SE_EXCEPTION_CALLSTACK_SKIP 3000
75
//
76
//#else
77
//
78
//#define DEFAULT_SE_EXCEPTION_CALLSTACK_SKIP 0
79
//
80
//#endif
81
82
#endif
83
84
85
class
CLASS_DECL_ACME
standard_exception
:
86
public
::exception
87
{
88
public
:
89
90
91
friend
class ::exception_translator;
92
93
94
#ifdef WINDOWS
95
//EXCEPTION_POINTERS * m_ppointers;
96
#else
97
::i32 m_iSignal;
98
void
* m_psiginfo;
99
#ifndef __ANDROID__
100
ucontext_t m_ucontext;
101
#endif
102
#endif
103
104
105
#ifdef WINDOWS
106
//EXCEPTION_POINTERS * info() const { return m_ppointers; }
107
#else
108
::u32 code()
const
;
109
void
* address()
const
;
110
const
void
* info()
const
;
// siginfo_t *
111
const_char_pointer pszName()
const
;
112
const_char_pointer description()
const
;
113
#ifndef __ANDROID__
114
const ::ucontext_t * ucontext()
const
;
115
#endif
116
#endif
117
118
119
120
#if !defined(WINDOWS)
121
122
static
void
* siginfodup(
void
* psiginfo);
123
static
void
siginfofree(
void
* psiginfo);
124
125
#ifdef __ANDROID__
126
127
standard_exception(::i32 iSignal,
void
* psiginfo,
void
* pc, ::i32 iSkip = DEFAULT_SE_EXCEPTION_CALLSTACK_SKIP,
128
void
* caller_address =
nullptr
);
129
// ::exception(error_exception, nullptr, nullptr, iSkip),
130
// m_iSignal(iSignal),
131
// m_psiginfo(siginfodup(psiginfo))
132
// {
133
//
134
// /*_ASSERTE(psiginfo != 0);*/
135
//
136
// }
137
138
#else
139
140
standard_exception(::i32 iSignal,
void
* psiginfo,
void
* pc, ::i32 iSkip = -1,
void
* caller_address =
nullptr
);
141
142
#endif
143
144
#endif
145
146
147
virtual
~standard_exception
()
148
{
149
150
#ifndef WINDOWS
151
152
siginfofree(m_psiginfo);
153
154
#endif
155
156
}
157
158
159
};
160
161
#if defined(LINUX)
162
163
typedef
struct
_sig_ucontext
164
{
165
ulong uc_flags;
166
struct
ucontext *uc_link;
167
stack_t uc_stack;
168
sigcontext uc_mcontext;
169
sigset_t uc_sigmask;
170
171
} sig_ucontext_t;
172
173
#endif
174
175
//namespace exception
176
//{
177
//
178
class
standard_access_violation
:
public
standard_exception
179
{
180
public
:
181
182
183
standard_access_violation (::i32 signal,
void
* psiginfo,
void
* pc);
184
185
};
186
187
188
189
//#if defined(__ANDROID__) || defined(RASPBERRYPIOS)
190
191
class
standard_sigfpe :
public
standard_exception
192
{
193
public
:
194
195
196
standard_sigfpe(::i32 iSignal,
void
* psiginfo,
void
* pc):
197
standard_exception(iSignal, psiginfo, pc)
198
{
199
200
}
201
202
203
204
// bool is_read_op() const { return !info()->ExceptionRecord->ExceptionInformation [0]; }
205
// uptr inaccessible_address() const { return info()->ExceptionRecord->ExceptionInformation [1]; }
206
};
207
208
//#elif defined(FREEBSD) || defined(OPENBSD)
209
//
210
//class standard_sigfpe : public standard_exception
211
// {
212
// public:
213
// standard_sigfpe (::i32 iSignal, siginfo_t * psiginfo, void * pc) :
214
// //standard_exception(iSignal, psiginfo, pc, 3, (void *) ((sig_ucontext_t *) pc)->uc_mcontext.rip),
215
// standard_exception(iSignal, psiginfo, pc, 3, (void *) ((ucontext_t *) pc)->uc_mcontext.mc_rip)
216
// //::callstack(3, (void *) ((sig_ucontext_t *) pc)->uc_mcontext.eip),
217
// {
218
//
219
// }
220
//
221
//
222
// public:
223
// // bool is_read_op() const { return !info()->ExceptionRecord->ExceptionInformation [0]; }
224
// // uptr inaccessible_address() const { return info()->ExceptionRecord->ExceptionInformation [1]; }
225
// };
226
//
227
//
228
//#elif defined(LINUX) || defined(__APPLE__)
229
230
//class standard_sigfpe : public standard_exception
231
// {
232
// public:
233
// standard_sigfpe (::i32 iSignal, siginfo_t * psiginfo, void * pc) :
234
//#ifdef LINUX
235
//#ifdef _LP64
236
// standard_exception(iSignal, psiginfo, pc, 3, (void *) ((sig_ucontext_t *) pc)->uc_mcontext.rip)
237
// //::callstack(3, (void *) ((sig_ucontext_t *) pc)->uc_mcontext.rip),
238
//#else
239
//#ifdef __arm__
240
// standard_exception(iSignal, psiginfo, pc, 3, (void *) ((sig_ucontext_t *) pc)->uc_mcontext.arm_ip)
241
// //::callstack(3, (void *) ((sig_ucontext_t *) pc)->uc_mcontext.eip),
242
//#else
243
// standard_exception(iSignal, psiginfo, pc, 3, (void *) ((sig_ucontext_t *) pc)->uc_mcontext.rip)
244
// //::callstack(3, (void *) ((sig_ucontext_t *) pc)->uc_mcontext.eip),
245
//
246
//#endif
247
//#endif
248
//#else
249
//#ifdef _LP64
250
//
251
//#ifdef __ARM_ARCH_ISA_A64
252
// standard_exception(iSignal, psiginfo, pc, 3, (void *) ((ucontext_t *) pc)->uc_mcontext->__ss.__pc)
253
//#else
254
// standard_exception(iSignal, psiginfo, pc, 3, (void *) ((ucontext_t *) pc)->uc_mcontext->__ss.__rip)
255
//
256
//#endif
257
//
258
//#else
259
//#if defined(APPLE_IOS)
260
// ::callstack(3, nullptr),
261
//#else
262
// //::callstack(3, (void *) ((ucontext_t *) pc)->uc_mcontext.eip),
263
//#endif
264
//#endif
265
//#endif
268
// {
269
//
270
// }
271
//
272
//
273
// public:
274
// // bool is_read_op() const { return !info()->ExceptionRecord->ExceptionInformation [0]; }
275
// // uptr inaccessible_address() const { return info()->ExceptionRecord->ExceptionInformation [1]; }
276
// };
277
278
//#endif
279
280
281
//} // namespace exception
282
283
/*#else
284
285
286
#include "translator.h"
287
#if !defined(__APPLE__)
288
#include <ucontext.h>
289
#include <sys/ucontext.h>
290
#endif*/
291
292
/*class CLASS_DECL_ACME standard_exception :
293
public bastandard_exception
294
{
295
public:
296
friend class translator;
297
298
299
~standard_exception() {}
300
301
protected:
302
303
private:
304
};*/
305
306
/*class standard_sigsegv : public standard_exception
307
{
308
friend class translator;
309
protected:
310
standard_sigsegv (siginfo_t * psiginfo, void * pc) : ::matter(pparticle), standard_exception(psiginfo, pc) {}
311
public:
312
//bool is_read_op() const { return !info()->ExceptionRecord->ExceptionInformation [0]; }
313
//uptr inaccessible_address() const { return info()->ExceptionRecord->ExceptionInformation [1]; }
314
};*/
315
316
/*class standard_sigfpe : public standard_exception
317
{
318
friend class translator;
319
protected:
320
standard_sigfpe (siginfo_t * psiginfo, void * pc) : ::matter(pparticle), standard_exception(psiginfo, pc) {}
321
public:
322
// bool is_read_op() const { return !info()->ExceptionRecord->ExceptionInformation [0]; }
323
// uptr inaccessible_address() const { return info()->ExceptionRecord->ExceptionInformation [1]; }
324
};
325
326
#endif*/
327
328
329
standard_access_violation
Definition
aaa_standard.h:168
standard_exception
Definition
aaa_standard.h:77
standard_exception::~standard_exception
virtual ~standard_exception()
def(WINDOWS)
Definition
standard_exception.h:147
operating_system
android
standard_exception.h
Generated by
1.17.0