简体   繁体   中英

_Unwind_RaiseException example

I'm investigating the LLVM's libunwind library. I'd like to write or to look at a simple example which directly calls the

_Unwind_Reason _Unwind_RaiseException( struct _Unwind_Exception *exception_object );

function. Does any one know whether there are any examples that use this function or can write a simple example oneself?

A bit late, but I'd guess you would have appreciated a link to https://monoinfinito.wordpress.com/series/exception-handling-in-c/ that also includes an implementation of __cxa_throw() using said function, quoted here verbatim:

void __cxa_throw(void* thrown_exception, struct type_info *tinfo, void (*dest)(void*))
{
    printf("__cxa_throw called\n");

    __cxa_exception *header = ((__cxa_exception *) thrown_exception - 1);
    _Unwind_RaiseException(&header->unwindHeader);

    // __cxa_throw never returns
    printf("no one handled __cxa_throw, terminate!\n");
    exit(0);
}

The function itself is AFAICT independent of the compiler/C++ runtime library since it is specified in the language standard.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM