Differences From Artifact [8fabc728f2]:
- File src/exceptions/OFException.m — part of check-in [d07c56a8bb] at 2017-04-02 01:06:35 on branch trunk — Add OF_CONSTRUCTOR() / OF_DESTRUCTOR() (user: js, size: 6923) [annotate] [blame] [check-ins using]
To Artifact [0b126c90fd]:
- File
src/exceptions/OFException.m
— part of check-in
[4af49a13c3]
at
2017-05-07 20:10:13
on branch trunk
— Small code style change
Casts are now written like types in variable declarations. (user: js, size: 6941) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
73 74 75 76 77 78 79 | struct backtrace_ctx { void **backtrace; uint8_t i; }; extern _Unwind_Reason_Code _Unwind_Backtrace( | | | | > | | 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 *); # ifndef HAVE_ARM_EHABI_EXCEPTIONS extern uintptr_t _Unwind_GetIP(struct _Unwind_Context *); # else 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 * of_strerror(int errNo) { OFString *ret; #ifdef HAVE_STRERROR_R char buffer[256]; #endif |
︙ | ︙ | |||
224 225 226 227 228 229 230 | 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 | | | | 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); # else uintptr_t ip; _Unwind_VRS_Get(ctx, 0, 15, 0, &ip); bt->backtrace[bt->i++] = (void *)(ip & ~1); # endif return _URC_OK; } return _URC_END_OF_STACK; } #endif |
︙ | ︙ | |||
259 260 261 262 263 264 265 | ctx.i = 0; _Unwind_Backtrace(backtrace_callback, &ctx); return self; } #endif | | | | | | 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 { return [OFString stringWithFormat: @"An exception of type %@ occurred!", [self class]]; } - (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; frame = [OFString stringWithFormat: @"%p <%s+%td> at %s", _backtrace[i], info.dli_sname, offset, info.dli_fname]; } else frame = [OFString stringWithFormat: |
︙ | ︙ |