12755751fSHerbert Dürr /************************************************************** 22755751fSHerbert Dürr * 32755751fSHerbert Dürr * Licensed to the Apache Software Foundation (ASF) under one 42755751fSHerbert Dürr * or more contributor license agreements. See the NOTICE file 52755751fSHerbert Dürr * distributed with this work for additional information 62755751fSHerbert Dürr * regarding copyright ownership. The ASF licenses this file 72755751fSHerbert Dürr * to you under the Apache License, Version 2.0 (the 82755751fSHerbert Dürr * "License"); you may not use this file except in compliance 92755751fSHerbert Dürr * with the License. You may obtain a copy of the License at 102755751fSHerbert Dürr * 112755751fSHerbert Dürr * http://www.apache.org/licenses/LICENSE-2.0 122755751fSHerbert Dürr * 132755751fSHerbert Dürr * Unless required by applicable law or agreed to in writing, 142755751fSHerbert Dürr * software distributed under the License is distributed on an 152755751fSHerbert Dürr * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 162755751fSHerbert Dürr * KIND, either express or implied. See the License for the 172755751fSHerbert Dürr * specific language governing permissions and limitations 182755751fSHerbert Dürr * under the License. 192755751fSHerbert Dürr * 202755751fSHerbert Dürr *************************************************************/ 212755751fSHerbert Dürr 222755751fSHerbert Dürr 232755751fSHerbert Dürr 242755751fSHerbert Dürr #include "uno/mapping.h" 252755751fSHerbert Dürr 262755751fSHerbert Dürr #include <typeinfo> 272755751fSHerbert Dürr #include <exception> 282755751fSHerbert Dürr #include <cstddef> 292755751fSHerbert Dürr 302755751fSHerbert Dürr namespace CPPU_CURRENT_NAMESPACE 312755751fSHerbert Dürr { 322755751fSHerbert Dürr 332755751fSHerbert Dürr void dummy_can_throw_anything( char const * ); 342755751fSHerbert Dürr 35*67a794bcSJim Jagielski typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__))); 36*67a794bcSJim Jagielski 372755751fSHerbert Dürr // ----- the following structure is compatible with the one declared in libunwind's unwind.h 38*67a794bcSJim Jagielski // (use forced types) 392755751fSHerbert Dürr 402755751fSHerbert Dürr struct _Unwind_Exception 412755751fSHerbert Dürr { 42*67a794bcSJim Jagielski uint64_t exception_class; 432755751fSHerbert Dürr void * exception_cleanup; 442755751fSHerbert Dürr uintptr_t private_1; 452755751fSHerbert Dürr uintptr_t private_2; 469310f8ceSHerbert Dürr }; 472755751fSHerbert Dürr 482755751fSHerbert Dürr struct __cxa_exception 49*67a794bcSJim Jagielski { 50*67a794bcSJim Jagielski #if __LP64__ 51*67a794bcSJim Jagielski // From LLVM 10 - Added reserved member at top of struct. Who the hell does that? 52*67a794bcSJim Jagielski // https://reviews.llvm.org/rG674ec1eb16678b8addc02a4b0534ab383d22fa77 53*67a794bcSJim Jagielski // Sure would be nice to be able to test for CCNUMVER >= 1000000000 54*67a794bcSJim Jagielski // and COM == CLANG here. 55*67a794bcSJim Jagielski // void *reserved; 56*67a794bcSJim Jagielski // ----- from libcxxabi/src/cxa_exception.hpp 572755751fSHerbert Dürr // This is a new field to support C++ 0x exception_ptr. 582755751fSHerbert Dürr // For binary compatibility it is at the start of this 592755751fSHerbert Dürr // struct which is prepended to the object thrown in 602755751fSHerbert Dürr // __cxa_allocate_exception. 612755751fSHerbert Dürr size_t referenceCount; 622755751fSHerbert Dürr #endif 632755751fSHerbert Dürr 642755751fSHerbert Dürr ::std::type_info *exceptionType; 652755751fSHerbert Dürr void (*exceptionDestructor)(void *); 662755751fSHerbert Dürr 672755751fSHerbert Dürr ::std::unexpected_handler unexpectedHandler; 682755751fSHerbert Dürr ::std::terminate_handler terminateHandler; 692755751fSHerbert Dürr 702755751fSHerbert Dürr __cxa_exception *nextException; 712755751fSHerbert Dürr 722755751fSHerbert Dürr int handlerCount; 732755751fSHerbert Dürr 742755751fSHerbert Dürr int handlerSwitchValue; 752755751fSHerbert Dürr const unsigned char *actionRecord; 762755751fSHerbert Dürr const unsigned char *languageSpecificData; 772755751fSHerbert Dürr void *catchTemp; 782755751fSHerbert Dürr void *adjustedPtr; 792755751fSHerbert Dürr 802755751fSHerbert Dürr _Unwind_Exception unwindHeader; 812755751fSHerbert Dürr }; 822755751fSHerbert Dürr 832755751fSHerbert Dürr extern "C" void *__cxa_allocate_exception( 842755751fSHerbert Dürr std::size_t thrown_size ) throw(); 852755751fSHerbert Dürr extern "C" void __cxa_throw ( 862755751fSHerbert Dürr void *thrown_exception, std::type_info *tinfo, void (*dest) (void *) ) __attribute__((noreturn)); 872755751fSHerbert Dürr 882755751fSHerbert Dürr struct __cxa_eh_globals 892755751fSHerbert Dürr { 902755751fSHerbert Dürr __cxa_exception *caughtExceptions; 912755751fSHerbert Dürr unsigned int uncaughtExceptions; 922755751fSHerbert Dürr }; 932755751fSHerbert Dürr extern "C" __cxa_eh_globals *__cxa_get_globals () throw(); 942755751fSHerbert Dürr 952755751fSHerbert Dürr // ----- 962755751fSHerbert Dürr 97*67a794bcSJim Jagielski #if 0 9851a1e52eSHerbert Dürr // on OSX 64bit the class_type_info classes are specified 9951a1e52eSHerbert Dürr // in http://refspecs.linuxbase.org/cxxabi-1.86.html#rtti but 10051a1e52eSHerbert Dürr // these details are not generally available in a public header 10151a1e52eSHerbert Dürr // of most development environments. So we define them here. 102*67a794bcSJim Jagielski // NOTE: https://www.hexblog.com/wp-content/uploads/2012/06/Recon-2012-Skochinsky-Compiler-Internals.pdf 10351a1e52eSHerbert Dürr class __class_type_info : public std::type_info 10451a1e52eSHerbert Dürr { 10551a1e52eSHerbert Dürr public: 10651a1e52eSHerbert Dürr explicit __class_type_info( const char* pRttiName) 10751a1e52eSHerbert Dürr : std::type_info( pRttiName) 10851a1e52eSHerbert Dürr {} 10951a1e52eSHerbert Dürr }; 11051a1e52eSHerbert Dürr 11151a1e52eSHerbert Dürr class __si_class_type_info : public __class_type_info 11251a1e52eSHerbert Dürr { 11351a1e52eSHerbert Dürr const __class_type_info* mpBaseType; 11451a1e52eSHerbert Dürr public: 11551a1e52eSHerbert Dürr explicit __si_class_type_info( const char* pRttiName, __class_type_info* pBaseType) 11651a1e52eSHerbert Dürr : __class_type_info( pRttiName), mpBaseType( pBaseType) 11751a1e52eSHerbert Dürr {} 11851a1e52eSHerbert Dürr }; 119fd233926SHerbert Dürr #endif 1202755751fSHerbert Dürr //================================================================================================== 1212755751fSHerbert Dürr void raiseException( 1222755751fSHerbert Dürr uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ); 1232755751fSHerbert Dürr //================================================================================================== 1242755751fSHerbert Dürr void fillUnoException( 1252755751fSHerbert Dürr __cxa_exception * header, uno_Any *, uno_Mapping * pCpp2Uno ); 1262755751fSHerbert Dürr } 1272755751fSHerbert Dürr 128