Solaris 上的异常处理机制
我正在为 C++ 应用程序构建错误处理机制。现在,我使用 VectoredExceptionHandling 完成了 Windows 部分,我想知道 Solaris 上是否有类似的概念。基本上,每当程序中的任何地方抛出异常时,我都希望调用回调。在Windows下,您可以使用AddVectoredExceptionHandler()
注册回调。对于 Solaris,我该如何执行此操作?
I'm building an error handling mechanism for a C++ application. Right now, I got the windows part done using VectoredExceptionHandling and I wanted to know if there is a similar concept on Solaris. Basically, whenever an exception is thrown from anywhere in the program, I want to have a callback called. Under windows, you can register a callback using AddVectoredExceptionHandler()
. How do I do this for Solaris?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果这可行的话,不是 100%,但您可以尝试模仿 gdb 的捕获点的工作方式:请参阅 http://www.delorie.com/gnu/docs/gdb/gdb_31.html 关键信息是这样的:
“要在调用异常处理程序之前停止,您需要一些在 GNU C++ 的情况下,通过调用名为 __raise_exception 的库函数引发异常,该函数具有以下 ANSI C 接口:
要使调试器在发生任何堆栈展开之前捕获所有异常,请在 __raise_exception 上设置断点”
所以,我的猜测是,例如,您可以通过 LD_PRELOAD 技巧安装自己的 __raise_exception 。
Not 100% if this will work, but you can try to mimic the way gdb's catchpoints work: see http://www.delorie.com/gnu/docs/gdb/gdb_31.html The key piece of info is this:
"To stop just before an exception handler is called, you need some knowledge of the implementation. In the case of GNU C++, exceptions are raised by calling a library function named __raise_exception which has the following ANSI C interface:
To make the debugger catch all exceptions before any stack unwinding takes place, set a breakpoint on __raise_exception"
So, my guess is that you could install your own __raise_exception via LD_PRELOAD trick, for example.