73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
-
+
-
+
-
+
+
-
+
|
struct backtrace_ctx {
void **backtrace;
uint8_t i;
};
extern _Unwind_Reason_Code _Unwind_Backtrace(
_Unwind_Reason_Code(*)(struct _Unwind_Context*, void*), void*);
_Unwind_Reason_Code (*)(struct _Unwind_Context *, void *), void *);
# ifndef HAVE_ARM_EHABI_EXCEPTIONS
extern uintptr_t _Unwind_GetIP(struct _Unwind_Context*);
extern uintptr_t _Unwind_GetIP(struct _Unwind_Context *);
# else
extern int _Unwind_VRS_Get(struct _Unwind_Context*, int, uint32_t, int, void*);
extern int _Unwind_VRS_Get(struct _Unwind_Context *, int, uint32_t, int,
void *);
# endif
#endif
#if !defined(HAVE_STRERROR_R) && defined(OF_HAVE_THREADS)
static of_mutex_t mutex;
OF_CONSTRUCTOR()
{
if (!of_mutex_new(&mutex))
@throw [OFInitializationFailedException exception];
}
#endif
OFString*
OFString *
of_strerror(int errNo)
{
OFString *ret;
#ifdef HAVE_STRERROR_R
char buffer[256];
#endif
|
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
|
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
|
-
+
-
+
|
static _Unwind_Reason_Code
backtrace_callback(struct _Unwind_Context *ctx, void *data)
{
struct backtrace_ctx *bt = data;
if (bt->i < OF_BACKTRACE_SIZE) {
# ifndef HAVE_ARM_EHABI_EXCEPTIONS
bt->backtrace[bt->i++] = (void*)_Unwind_GetIP(ctx);
bt->backtrace[bt->i++] = (void *)_Unwind_GetIP(ctx);
# else
uintptr_t ip;
_Unwind_VRS_Get(ctx, 0, 15, 0, &ip);
bt->backtrace[bt->i++] = (void*)(ip & ~1);
bt->backtrace[bt->i++] = (void *)(ip & ~1);
# endif
return _URC_OK;
}
return _URC_END_OF_STACK;
}
#endif
|
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
|
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
|
-
+
-
+
-
-
+
+
|
ctx.i = 0;
_Unwind_Backtrace(backtrace_callback, &ctx);
return self;
}
#endif
- (OFString*)description
- (OFString *)description
{
return [OFString stringWithFormat:
@"An exception of type %@ occurred!", [self class]];
}
- (OFArray*)backtrace
- (OFArray *)backtrace
{
#ifdef HAVE_DWARF_EXCEPTIONS
OFMutableArray *backtrace = [OFMutableArray array];
void *pool = objc_autoreleasePoolPush();
for (uint8_t i = 0;
i < OF_BACKTRACE_SIZE && _backtrace[i] != NULL; i++) {
# ifdef HAVE_DLADDR
Dl_info info;
if (dladdr(_backtrace[i], &info)) {
OFString *frame;
if (info.dli_sname != NULL) {
ptrdiff_t offset = (char*)_backtrace[i] -
(char*)info.dli_saddr;
ptrdiff_t offset = (char *)_backtrace[i] -
(char *)info.dli_saddr;
frame = [OFString stringWithFormat:
@"%p <%s+%td> at %s",
_backtrace[i], info.dli_sname, offset,
info.dli_fname];
} else
frame = [OFString stringWithFormat:
|