1// -*- C++ -*- The GNU C++ exception personality routine. 2// Copyright (C) 2001, 2002, 2003, 2006, 2008 Free Software Foundation, Inc. 3// 4// This file is part of GCC. 5// 6// GCC is free software; you can redistribute it and/or modify 7// it under the terms of the GNU General Public License as published by 8// the Free Software Foundation; either version 2, or (at your option) 9// any later version. 10// 11// GCC is distributed in the hope that it will be useful, 12// but WITHOUT ANY WARRANTY; without even the implied warranty of 13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14// GNU General Public License for more details. 15// 16// You should have received a copy of the GNU General Public License 17// along with GCC; see the file COPYING. If not, write to 18// the Free Software Foundation, 51 Franklin Street, Fifth Floor, 19// Boston, MA 02110-1301, USA. 20 21// As a special exception, you may use this file as part of a free software 22// library without restriction. Specifically, if other files instantiate 23// templates or use macros or inline functions from this file, or you compile 24// this file and link it with other files to produce an executable, this 25// file does not by itself cause the resulting executable to be covered by 26// the GNU General Public License. This exception does not however 27// invalidate any other reasons why the executable file might be covered by 28// the GNU General Public License. 29 30#include <bits/c++config.h> 31#include <cstdlib> 32#include <exception_defines.h> 33#include "unwind-cxx.h" 34 35using namespace __cxxabiv1; 36 37#ifdef __ARM_EABI_UNWINDER__ 38#define NO_SIZE_OF_ENCODED_VALUE 39#endif 40 41#include "unwind-pe.h" 42 43 44struct lsda_header_info 45{ 46 _Unwind_Ptr Start; 47 _Unwind_Ptr LPStart; 48 _Unwind_Ptr ttype_base; 49 const unsigned char *TType; 50 const unsigned char *action_table; 51 unsigned char ttype_encoding; 52 unsigned char call_site_encoding; 53}; 54 55static const unsigned char * 56parse_lsda_header (_Unwind_Context *context, const unsigned char *p, 57 lsda_header_info *info) 58{ 59 _Unwind_Word tmp; 60 unsigned char lpstart_encoding; 61 62 info->Start = (context ? _Unwind_GetRegionStart (context) : 0); 63 64 // Find @LPStart, the base to which landing pad offsets are relative. 65 lpstart_encoding = *p++; 66 if (lpstart_encoding != DW_EH_PE_omit) 67 p = read_encoded_value (context, lpstart_encoding, p, &info->LPStart); 68 else 69 info->LPStart = info->Start; 70 71 // Find @TType, the base of the handler and exception spec type data. 72 info->ttype_encoding = *p++; 73 if (info->ttype_encoding != DW_EH_PE_omit) 74 { 75 p = read_uleb128 (p, &tmp); 76 info->TType = p + tmp; 77 } 78 else 79 info->TType = 0; 80 81 // The encoding and length of the call-site table; the action table 82 // immediately follows. 83 info->call_site_encoding = *p++; 84 p = read_uleb128 (p, &tmp); 85 info->action_table = p + tmp; 86 87 return p; 88} 89 90#ifdef __ARM_EABI_UNWINDER__ 91 92// Return an element from a type table. 93 94static const std::type_info* 95get_ttype_entry(lsda_header_info* info, _Unwind_Word i) 96{ 97 _Unwind_Ptr ptr; 98 99 ptr = (_Unwind_Ptr) (info->TType - (i * 4)); 100 ptr = _Unwind_decode_target2(ptr); 101 102 return reinterpret_cast<const std::type_info *>(ptr); 103} 104 105// The ABI provides a routine for matching exception object types. 106typedef _Unwind_Control_Block _throw_typet; 107#define get_adjusted_ptr(catch_type, throw_type, thrown_ptr_p) \ 108 (__cxa_type_match (throw_type, catch_type, false, thrown_ptr_p) \ 109 != ctm_failed) 110 111// Return true if THROW_TYPE matches one if the filter types. 112 113static bool 114check_exception_spec(lsda_header_info* info, _throw_typet* throw_type, 115 void* thrown_ptr, _Unwind_Sword filter_value) 116{ 117 const _Unwind_Word* e = ((const _Unwind_Word*) info->TType) 118 - filter_value - 1; 119 120 while (1) 121 { 122 const std::type_info* catch_type; 123 _Unwind_Word tmp; 124 125 tmp = *e; 126 127 // Zero signals the end of the list. If we've not found 128 // a match by now, then we've failed the specification. 129 if (tmp == 0) 130 return false; 131 132 tmp = _Unwind_decode_target2((_Unwind_Word) e); 133 134 // Match a ttype entry. 135 catch_type = reinterpret_cast<const std::type_info*>(tmp); 136 137 // ??? There is currently no way to ask the RTTI code about the 138 // relationship between two types without reference to a specific 139 // object. There should be; then we wouldn't need to mess with 140 // thrown_ptr here. 141 if (get_adjusted_ptr(catch_type, throw_type, &thrown_ptr)) 142 return true; 143 144 // Advance to the next entry. 145 e++; 146 } 147} 148 149 150// Save stage1 handler information in the exception object 151 152static inline void 153save_caught_exception(struct _Unwind_Exception* ue_header, 154 struct _Unwind_Context* context, 155 void* thrown_ptr, 156 int handler_switch_value, 157 const unsigned char* language_specific_data, 158 _Unwind_Ptr landing_pad, 159 const unsigned char* action_record 160 __attribute__((__unused__))) 161{ 162 ue_header->barrier_cache.sp = _Unwind_GetGR(context, 13); 163 ue_header->barrier_cache.bitpattern[0] = (_uw) thrown_ptr; 164 ue_header->barrier_cache.bitpattern[1] 165 = (_uw) handler_switch_value; 166 ue_header->barrier_cache.bitpattern[2] 167 = (_uw) language_specific_data; 168 ue_header->barrier_cache.bitpattern[3] = (_uw) landing_pad; 169} 170 171 172// Restore the catch handler data saved during phase1. 173 174static inline void 175restore_caught_exception(struct _Unwind_Exception* ue_header, 176 int& handler_switch_value, 177 const unsigned char*& language_specific_data, 178 _Unwind_Ptr& landing_pad) 179{ 180 handler_switch_value = (int) ue_header->barrier_cache.bitpattern[1]; 181 language_specific_data = 182 (const unsigned char*) ue_header->barrier_cache.bitpattern[2]; 183 landing_pad = (_Unwind_Ptr) ue_header->barrier_cache.bitpattern[3]; 184} 185 186#define CONTINUE_UNWINDING \ 187 do \ 188 { \ 189 if (__gnu_unwind_frame(ue_header, context) != _URC_OK) \ 190 return _URC_FAILURE; \ 191 return _URC_CONTINUE_UNWIND; \ 192 } \ 193 while (0) 194 195#else 196typedef const std::type_info _throw_typet; 197 198 199// Return an element from a type table. 200 201static const std::type_info * 202get_ttype_entry (lsda_header_info *info, _Unwind_Word i) 203{ 204 _Unwind_Ptr ptr; 205 206 i *= size_of_encoded_value (info->ttype_encoding); 207 read_encoded_value_with_base (info->ttype_encoding, info->ttype_base, 208 info->TType - i, &ptr); 209 210 return reinterpret_cast<const std::type_info *>(ptr); 211} 212 213// Given the thrown type THROW_TYPE, pointer to a variable containing a 214// pointer to the exception object THROWN_PTR_P and a type CATCH_TYPE to 215// compare against, return whether or not there is a match and if so, 216// update *THROWN_PTR_P. 217 218static bool 219get_adjusted_ptr (const std::type_info *catch_type, 220 const std::type_info *throw_type, 221 void **thrown_ptr_p) 222{ 223 void *thrown_ptr = *thrown_ptr_p; 224 225 // Pointer types need to adjust the actual pointer, not 226 // the pointer to pointer that is the exception object. 227 // This also has the effect of passing pointer types 228 // "by value" through the __cxa_begin_catch return value. 229 if (throw_type->__is_pointer_p ()) 230 thrown_ptr = *(void **) thrown_ptr; 231 232 if (catch_type->__do_catch (throw_type, &thrown_ptr, 1)) 233 { 234 *thrown_ptr_p = thrown_ptr; 235 return true; 236 } 237 238 return false; 239} 240 241// Return true if THROW_TYPE matches one if the filter types. 242 243static bool 244check_exception_spec(lsda_header_info* info, _throw_typet* throw_type, 245 void* thrown_ptr, _Unwind_Sword filter_value) 246{ 247 const unsigned char *e = info->TType - filter_value - 1; 248 249 while (1) 250 { 251 const std::type_info *catch_type; 252 _Unwind_Word tmp; 253 254 e = read_uleb128 (e, &tmp); 255 256 // Zero signals the end of the list. If we've not found 257 // a match by now, then we've failed the specification. 258 if (tmp == 0) 259 return false; 260 261 // Match a ttype entry. 262 catch_type = get_ttype_entry (info, tmp); 263 264 // ??? There is currently no way to ask the RTTI code about the 265 // relationship between two types without reference to a specific 266 // object. There should be; then we wouldn't need to mess with 267 // thrown_ptr here. 268 if (get_adjusted_ptr (catch_type, throw_type, &thrown_ptr)) 269 return true; 270 } 271} 272 273 274// Save stage1 handler information in the exception object 275 276static inline void 277save_caught_exception(struct _Unwind_Exception* ue_header, 278 struct _Unwind_Context* context 279 __attribute__((__unused__)), 280 void* thrown_ptr, 281 int handler_switch_value, 282 const unsigned char* language_specific_data, 283 _Unwind_Ptr landing_pad __attribute__((__unused__)), 284 const unsigned char* action_record) 285{ 286 __cxa_exception* xh = __get_exception_header_from_ue(ue_header); 287 288 xh->handlerSwitchValue = handler_switch_value; 289 xh->actionRecord = action_record; 290 xh->languageSpecificData = language_specific_data; 291 xh->adjustedPtr = thrown_ptr; 292 293 // ??? Completely unknown what this field is supposed to be for. 294 // ??? Need to cache TType encoding base for call_unexpected. 295 xh->catchTemp = landing_pad; 296} 297 298 299// Restore the catch handler information saved during phase1. 300 301static inline void 302restore_caught_exception(struct _Unwind_Exception* ue_header, 303 int& handler_switch_value, 304 const unsigned char*& language_specific_data, 305 _Unwind_Ptr& landing_pad) 306{ 307 __cxa_exception* xh = __get_exception_header_from_ue(ue_header); 308 handler_switch_value = xh->handlerSwitchValue; 309 language_specific_data = xh->languageSpecificData; 310 landing_pad = (_Unwind_Ptr) xh->catchTemp; 311} 312 313#define CONTINUE_UNWINDING return _URC_CONTINUE_UNWIND 314 315#endif // !__ARM_EABI_UNWINDER__ 316 317// Return true if the filter spec is empty, ie throw(). 318 319static bool 320empty_exception_spec (lsda_header_info *info, _Unwind_Sword filter_value) 321{ 322 const unsigned char *e = info->TType - filter_value - 1; 323 _Unwind_Word tmp; 324 325 e = read_uleb128 (e, &tmp); 326 return tmp == 0; 327} 328 329namespace __cxxabiv1 330{ 331 332// Using a different personality function name causes link failures 333// when trying to mix code using different exception handling models. 334#ifdef _GLIBCXX_SJLJ_EXCEPTIONS 335#define PERSONALITY_FUNCTION __gxx_personality_sj0 336#define __builtin_eh_return_data_regno(x) x 337#else 338#define PERSONALITY_FUNCTION __gxx_personality_v0 339#endif 340 341extern "C" _Unwind_Reason_Code 342#ifdef __ARM_EABI_UNWINDER__ 343PERSONALITY_FUNCTION (_Unwind_State state, 344 struct _Unwind_Exception* ue_header, 345 struct _Unwind_Context* context) 346#else 347PERSONALITY_FUNCTION (int version, 348 _Unwind_Action actions, 349 _Unwind_Exception_Class exception_class, 350 struct _Unwind_Exception *ue_header, 351 struct _Unwind_Context *context) 352#endif 353{ 354 enum found_handler_type 355 { 356 found_nothing, 357 found_terminate, 358 found_cleanup, 359 found_handler 360 } found_type; 361 362 lsda_header_info info; 363 const unsigned char *language_specific_data; 364 const unsigned char *action_record; 365 const unsigned char *p; 366 _Unwind_Ptr landing_pad, ip; 367 int handler_switch_value; 368 void* thrown_ptr = ue_header + 1; 369 bool foreign_exception; 370 int ip_before_insn = 0; 371 372#ifdef __ARM_EABI_UNWINDER__ 373 _Unwind_Action actions; 374 375 switch (state & _US_ACTION_MASK) 376 { 377 case _US_VIRTUAL_UNWIND_FRAME: 378 actions = _UA_SEARCH_PHASE; 379 break; 380 381 case _US_UNWIND_FRAME_STARTING: 382 actions = _UA_CLEANUP_PHASE; 383 if (!(state & _US_FORCE_UNWIND) 384 && ue_header->barrier_cache.sp == _Unwind_GetGR(context, 13)) 385 actions |= _UA_HANDLER_FRAME; 386 break; 387 388 case _US_UNWIND_FRAME_RESUME: 389 CONTINUE_UNWINDING; 390 break; 391 392 default: 393 std::abort(); 394 } 395 actions |= state & _US_FORCE_UNWIND; 396 397 // We don't know which runtime we're working with, so can't check this. 398 // However the ABI routines hide this from us, and we don't actually need 399 // to know. 400 foreign_exception = false; 401 402 // The dwarf unwinder assumes the context structure holds things like the 403 // function and LSDA pointers. The ARM implementation caches these in 404 // the exception header (UCB). To avoid rewriting everything we make the 405 // virtual IP register point at the UCB. 406 ip = (_Unwind_Ptr) ue_header; 407 _Unwind_SetGR(context, 12, ip); 408#else 409 __cxa_exception* xh = __get_exception_header_from_ue(ue_header); 410 411 // Interface version check. 412 if (version != 1) 413 return _URC_FATAL_PHASE1_ERROR; 414 foreign_exception = !__is_gxx_exception_class(exception_class); 415#endif 416 417 // Shortcut for phase 2 found handler for domestic exception. 418 if (actions == (_UA_CLEANUP_PHASE | _UA_HANDLER_FRAME) 419 && !foreign_exception) 420 { 421 restore_caught_exception(ue_header, handler_switch_value, 422 language_specific_data, landing_pad); 423 found_type = (landing_pad == 0 ? found_terminate : found_handler); 424 goto install_context; 425 } 426 427 language_specific_data = (const unsigned char *) 428 _Unwind_GetLanguageSpecificData (context); 429 430 // If no LSDA, then there are no handlers or cleanups. 431 if (! language_specific_data) 432 CONTINUE_UNWINDING; 433 434 // Parse the LSDA header. 435 p = parse_lsda_header (context, language_specific_data, &info); 436 info.ttype_base = base_of_encoded_value (info.ttype_encoding, context); 437#ifdef _GLIBCXX_HAVE_GETIPINFO 438 ip = _Unwind_GetIPInfo (context, &ip_before_insn); 439#else 440 ip = _Unwind_GetIP (context); 441#endif 442 if (! ip_before_insn) 443 --ip; 444 landing_pad = 0; 445 action_record = 0; 446 handler_switch_value = 0; 447 448#ifdef _GLIBCXX_SJLJ_EXCEPTIONS 449 // The given "IP" is an index into the call-site table, with two 450 // exceptions -- -1 means no-action, and 0 means terminate. But 451 // since we're using uleb128 values, we've not got random access 452 // to the array. 453 if ((int) ip < 0) 454 return _URC_CONTINUE_UNWIND; 455 else if (ip == 0) 456 { 457 // Fall through to set found_terminate. 458 } 459 else 460 { 461 _Unwind_Word cs_lp, cs_action; 462 do 463 { 464 p = read_uleb128 (p, &cs_lp); 465 p = read_uleb128 (p, &cs_action); 466 } 467 while (--ip); 468 469 // Can never have null landing pad for sjlj -- that would have 470 // been indicated by a -1 call site index. 471 landing_pad = cs_lp + 1; 472 if (cs_action) 473 action_record = info.action_table + cs_action - 1; 474 goto found_something; 475 } 476#else 477 // Search the call-site table for the action associated with this IP. 478 while (p < info.action_table) 479 { 480 _Unwind_Ptr cs_start, cs_len, cs_lp; 481 _Unwind_Word cs_action; 482 483 // Note that all call-site encodings are "absolute" displacements. 484 p = read_encoded_value (0, info.call_site_encoding, p, &cs_start); 485 p = read_encoded_value (0, info.call_site_encoding, p, &cs_len); 486 p = read_encoded_value (0, info.call_site_encoding, p, &cs_lp); 487 p = read_uleb128 (p, &cs_action); 488 489 // The table is sorted, so if we've passed the ip, stop. 490 if (ip < info.Start + cs_start) 491 p = info.action_table; 492 else if (ip < info.Start + cs_start + cs_len) 493 { 494 if (cs_lp) 495 landing_pad = info.LPStart + cs_lp; 496 if (cs_action) 497 action_record = info.action_table + cs_action - 1; 498 goto found_something; 499 } 500 } 501#endif // _GLIBCXX_SJLJ_EXCEPTIONS 502 503 // If ip is not present in the table, call terminate. This is for 504 // a destructor inside a cleanup, or a library routine the compiler 505 // was not expecting to throw. 506 found_type = found_terminate; 507 goto do_something; 508 509 found_something: 510 if (landing_pad == 0) 511 { 512 // If ip is present, and has a null landing pad, there are 513 // no cleanups or handlers to be run. 514 found_type = found_nothing; 515 } 516 else if (action_record == 0) 517 { 518 // If ip is present, has a non-null landing pad, and a null 519 // action table offset, then there are only cleanups present. 520 // Cleanups use a zero switch value, as set above. 521 found_type = found_cleanup; 522 } 523 else 524 { 525 // Otherwise we have a catch handler or exception specification. 526 527 _Unwind_Sword ar_filter, ar_disp; 528 const std::type_info* catch_type; 529 _throw_typet* throw_type; 530 bool saw_cleanup = false; 531 bool saw_handler = false; 532 533 // During forced unwinding, we only run cleanups. With a foreign 534 // exception class, there's no exception type. 535 // ??? What to do about GNU Java and GNU Ada exceptions. 536 537 if ((actions & _UA_FORCE_UNWIND) 538 || foreign_exception) 539 throw_type = 0; 540 else 541#ifdef __ARM_EABI_UNWINDER__ 542 throw_type = ue_header; 543#else 544 throw_type = xh->exceptionType; 545#endif 546 547 while (1) 548 { 549 p = action_record; 550 p = read_sleb128 (p, &ar_filter); 551 read_sleb128 (p, &ar_disp); 552 553 if (ar_filter == 0) 554 { 555 // Zero filter values are cleanups. 556 saw_cleanup = true; 557 } 558 else if (ar_filter > 0) 559 { 560 // Positive filter values are handlers. 561 catch_type = get_ttype_entry (&info, ar_filter); 562 563 // Null catch type is a catch-all handler; we can catch foreign 564 // exceptions with this. Otherwise we must match types. 565 if (! catch_type 566 || (throw_type 567 && get_adjusted_ptr (catch_type, throw_type, 568 &thrown_ptr))) 569 { 570 saw_handler = true; 571 break; 572 } 573 } 574 else 575 { 576 // Negative filter values are exception specifications. 577 // ??? How do foreign exceptions fit in? As far as I can 578 // see we can't match because there's no __cxa_exception 579 // object to stuff bits in for __cxa_call_unexpected to use. 580 // Allow them iff the exception spec is non-empty. I.e. 581 // a throw() specification results in __unexpected. 582 if (throw_type 583 ? ! check_exception_spec (&info, throw_type, thrown_ptr, 584 ar_filter) 585 : empty_exception_spec (&info, ar_filter)) 586 { 587 saw_handler = true; 588 break; 589 } 590 } 591 592 if (ar_disp == 0) 593 break; 594 action_record = p + ar_disp; 595 } 596 597 if (saw_handler) 598 { 599 handler_switch_value = ar_filter; 600 found_type = found_handler; 601 } 602 else 603 found_type = (saw_cleanup ? found_cleanup : found_nothing); 604 } 605 606 do_something: 607 if (found_type == found_nothing) 608 CONTINUE_UNWINDING; 609 610 if (actions & _UA_SEARCH_PHASE) 611 { 612 if (found_type == found_cleanup) 613 CONTINUE_UNWINDING; 614 615 // For domestic exceptions, we cache data from phase 1 for phase 2. 616 if (!foreign_exception) 617 { 618 save_caught_exception(ue_header, context, thrown_ptr, 619 handler_switch_value, language_specific_data, 620 landing_pad, action_record); 621 } 622 return _URC_HANDLER_FOUND; 623 } 624 625 install_context: 626 627 // We can't use any of the cxa routines with foreign exceptions, 628 // because they all expect ue_header to be a struct __cxa_exception. 629 // So in that case, call terminate or unexpected directly. 630 if ((actions & _UA_FORCE_UNWIND) 631 || foreign_exception) 632 { 633 if (found_type == found_terminate) 634 std::terminate (); 635 else if (handler_switch_value < 0) 636 { 637 try 638 { std::unexpected (); } 639 catch(...) 640 { std::terminate (); } 641 } 642 } 643 else 644 { 645 if (found_type == found_terminate) 646 __cxa_call_terminate(ue_header); 647 648 // Cache the TType base value for __cxa_call_unexpected, as we won't 649 // have an _Unwind_Context then. 650 if (handler_switch_value < 0) 651 { 652 parse_lsda_header (context, language_specific_data, &info); 653 654#ifdef __ARM_EABI_UNWINDER__ 655 const _Unwind_Word* e; 656 _Unwind_Word n; 657 658 e = ((const _Unwind_Word*) info.TType) - handler_switch_value - 1; 659 // Count the number of rtti objects. 660 n = 0; 661 while (e[n] != 0) 662 n++; 663 664 // Count. 665 ue_header->barrier_cache.bitpattern[1] = n; 666 // Base (obsolete) 667 ue_header->barrier_cache.bitpattern[2] = 0; 668 // Stride. 669 ue_header->barrier_cache.bitpattern[3] = 4; 670 // List head. 671 ue_header->barrier_cache.bitpattern[4] = (_Unwind_Word) e; 672#else 673 xh->catchTemp = base_of_encoded_value (info.ttype_encoding, context); 674#endif 675 } 676 } 677 678 /* For targets with pointers smaller than the word size, we must extend the 679 pointer, and this extension is target dependent. */ 680 _Unwind_SetGR (context, __builtin_eh_return_data_regno (0), 681 __builtin_extend_pointer (ue_header)); 682 _Unwind_SetGR (context, __builtin_eh_return_data_regno (1), 683 handler_switch_value); 684 _Unwind_SetIP (context, landing_pad); 685#ifdef __ARM_EABI_UNWINDER__ 686 if (found_type == found_cleanup) 687 __cxa_begin_cleanup(ue_header); 688#endif 689 return _URC_INSTALL_CONTEXT; 690} 691 692/* The ARM EABI implementation of __cxa_call_unexpected is in a 693 different file so that the personality routine (PR) can be used 694 standalone. The generic routine shared datastructures with the PR 695 so it is most convenient to implement it here. */ 696#ifndef __ARM_EABI_UNWINDER__ 697extern "C" void 698__cxa_call_unexpected (void *exc_obj_in) 699{ 700 _Unwind_Exception *exc_obj 701 = reinterpret_cast <_Unwind_Exception *>(exc_obj_in); 702 703 __cxa_begin_catch (exc_obj); 704 705 // This function is a handler for our exception argument. If we exit 706 // by throwing a different exception, we'll need the original cleaned up. 707 struct end_catch_protect 708 { 709 end_catch_protect() { } 710 ~end_catch_protect() { __cxa_end_catch(); } 711 } end_catch_protect_obj; 712 713 lsda_header_info info; 714 __cxa_exception *xh = __get_exception_header_from_ue (exc_obj); 715 const unsigned char *xh_lsda; 716 _Unwind_Sword xh_switch_value; 717 std::terminate_handler xh_terminate_handler; 718 719 // If the unexpectedHandler rethrows the exception (e.g. to categorize it), 720 // it will clobber data about the current handler. So copy the data out now. 721 xh_lsda = xh->languageSpecificData; 722 xh_switch_value = xh->handlerSwitchValue; 723 xh_terminate_handler = xh->terminateHandler; 724 info.ttype_base = (_Unwind_Ptr) xh->catchTemp; 725 726 try 727 { __unexpected (xh->unexpectedHandler); } 728 catch(...) 729 { 730 // Get the exception thrown from unexpected. 731 732 __cxa_eh_globals *globals = __cxa_get_globals_fast (); 733 __cxa_exception *new_xh = globals->caughtExceptions; 734 void *new_ptr = new_xh + 1; 735 736 // We don't quite have enough stuff cached; re-parse the LSDA. 737 parse_lsda_header (0, xh_lsda, &info); 738 739 // If this new exception meets the exception spec, allow it. 740 if (check_exception_spec (&info, new_xh->exceptionType, 741 new_ptr, xh_switch_value)) 742 __throw_exception_again; 743 744 // If the exception spec allows std::bad_exception, throw that. 745 // We don't have a thrown object to compare against, but since 746 // bad_exception doesn't have virtual bases, that's OK; just pass 0. 747#ifdef __EXCEPTIONS 748 const std::type_info &bad_exc = typeid (std::bad_exception); 749 if (check_exception_spec (&info, &bad_exc, 0, xh_switch_value)) 750 throw std::bad_exception(); 751#endif 752 753 // Otherwise, die. 754 __terminate (xh_terminate_handler); 755 } 756} 757#endif 758 759} // namespace __cxxabiv1 760