[英]_Unwind_RaiseException example
我正在研究 LLVM 的 libunwind 库。 我想写或看一个简单的例子,它直接调用
_Unwind_Reason _Unwind_RaiseException( struct _Unwind_Exception *exception_object );
功能。 有谁知道有没有使用这个函数的例子或者可以自己写一个简单的例子吗?
有点晚了,但我想你会喜欢https://monoinfinito.wordpress.com/series/exception-handling-in-c/的链接,其中还包括使用上述函数的__cxa_throw()
实现,引用这里逐字逐句:
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);
}
该函数本身是 AFAICT 独立于编译器/C++ 运行时库的,因为它是在语言标准中指定的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.