Differences From Artifact [9ee77747e2]:
- File
src/runtime/exception.m
— part of check-in
[b919654740]
at
2016-06-08 23:22:23
on branch trunk
— exception.m: More consistency in #ifdef order
No functional change. (user: js, size: 16040) [annotate] [blame] [check-ins using]
To Artifact [30cec995ef]:
- File
src/runtime/exception.m
— part of check-in
[85a52c4717]
at
2016-07-10 16:23:48
on branch trunk
— runtime/exception.m: abort() -> OBJC_ERROR()
Use OBJC_ERROR() to print an error message instead of silently aborting. (user: js, size: 16342) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #include <string.h> #ifdef HAVE_SEH_EXCEPTIONS # include <windows.h> #endif #import "runtime.h" #import "macros.h" #if defined(HAVE_DWARF_EXCEPTIONS) # define PERSONALITY __gnu_objc_personality_v0 #elif defined(HAVE_SJLJ_EXCEPTIONS) # define PERSONALITY __gnu_objc_personality_sj0 | > | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #include <string.h> #ifdef HAVE_SEH_EXCEPTIONS # include <windows.h> #endif #import "runtime.h" #import "runtime-private.h" #import "macros.h" #if defined(HAVE_DWARF_EXCEPTIONS) # define PERSONALITY __gnu_objc_personality_v0 #elif defined(HAVE_SJLJ_EXCEPTIONS) # define PERSONALITY __gnu_objc_personality_sj0 |
︙ | ︙ | |||
249 250 251 252 253 254 255 | return _Unwind_GetRegionStart(ctx); case DW_EH_PE_datarel: return _Unwind_GetDataRelBase(ctx); case DW_EH_PE_textrel: return _Unwind_GetTextRelBase(ctx); } | | | | < | 250 251 252 253 254 255 256 257 258 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 | return _Unwind_GetRegionStart(ctx); case DW_EH_PE_datarel: return _Unwind_GetDataRelBase(ctx); case DW_EH_PE_textrel: return _Unwind_GetTextRelBase(ctx); } OBJC_ERROR("Unknown encoding!") } static size_t size_for_encoding(uint8_t enc) { if (enc == DW_EH_PE_omit) return 0; switch (enc & 0x07) { case DW_EH_PE_absptr: return sizeof(void*); case DW_EH_PE_udata2: return 2; case DW_EH_PE_udata4: return 4; case DW_EH_PE_udata8: return 8; } OBJC_ERROR("Unknown encoding!") } static uint64_t read_value(uint8_t enc, const uint8_t **ptr) { uint64_t value; if (enc == DW_EH_PE_aligned) OBJC_ERROR("DW_EH_PE_aligned is not implemented!") #define READ(type) \ { \ value = *(type*)(void*)*ptr; \ *ptr += size_for_encoding(enc); \ break; \ } |
︙ | ︙ | |||
309 310 311 312 313 314 315 | case DW_EH_PE_sdata2: READ(int16_t) case DW_EH_PE_sdata4: READ(int32_t) case DW_EH_PE_sdata8: READ(int64_t) default: | | | 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | case DW_EH_PE_sdata2: READ(int16_t) case DW_EH_PE_sdata4: READ(int32_t) case DW_EH_PE_sdata8: READ(int64_t) default: OBJC_ERROR("Unknown encoding!") } #undef READ return value; } #ifndef HAVE_ARM_EHABI_EXCEPTIONS |
︙ | ︙ | |||
497 498 499 500 501 502 503 | if (class_matches(class, e->object)) { *filtervalue = filter; return HANDLER_FOUND; } } else if (filter == 0) return CLEANUP_FOUND; | | | | 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 | if (class_matches(class, e->object)) { *filtervalue = filter; return HANDLER_FOUND; } } else if (filter == 0) return CLEANUP_FOUND; else if (filter < 0) OBJC_ERROR("Invalid filter!") } while (displacement != 0); return 0; } #ifndef HAVE_ARM_EHABI_EXCEPTIONS # ifdef HAVE_SEH_EXCEPTIONS |
︙ | ︙ | |||
620 621 622 623 624 625 626 | (uintptr_t)ex); _Unwind_SetGR(ctx, __builtin_eh_return_data_regno(1), filter); _Unwind_SetIP(ctx, landingpad); return _URC_INSTALL_CONTEXT; } | | | | | 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 | (uintptr_t)ex); _Unwind_SetGR(ctx, __builtin_eh_return_data_regno(1), filter); _Unwind_SetIP(ctx, landingpad); return _URC_INSTALL_CONTEXT; } OBJC_ERROR("Neither _UA_SEARCH_PHASE nor _UA_CLEANUP_PHASE in actions!") } static void cleanup(_Unwind_Reason_Code reason, struct _Unwind_Exception *ex) { free(ex); } void objc_exception_throw(id object) { struct objc_exception *e; if ((e = malloc(sizeof(*e))) == NULL) OBJC_ERROR("Not enough memory to allocate exception!") memset(e, 0, sizeof(*e)); e->exception.class = objc_exception_class; e->exception.cleanup = cleanup; e->object = object; if (_Unwind_RaiseException(&e->exception) == _URC_END_OF_STACK && uncaught_exception_handler != NULL) uncaught_exception_handler(object); OBJC_ERROR("_Unwind_RaiseException() returned!") } objc_uncaught_exception_handler objc_setUncaughtExceptionHandler(objc_uncaught_exception_handler handler) { objc_uncaught_exception_handler old = uncaught_exception_handler; uncaught_exception_handler = handler; |
︙ | ︙ |