从未捕获的异常中获取堆栈跟踪?
我意识到这将是特定于平台的:有没有办法从未捕获的 C++ 异常中获取堆栈跟踪,但从引发异常的点开始?
我有一个 Windows 结构化异常处理程序来捕获访问冲突等并生成小型转储。但当然,如果由于未捕获的 C++ 异常而终止,则不会调用该方法,因此不存在故障转储。
我目前正在寻找 Windows 解决方案(无论多么肮脏!),但如果可能的话,希望了解其他平台。
谢谢。
I realise this will be platform specific: is there any way to get a stack trace from an uncaught C++ exception, but from the point at which the exception is thrown?
I have a Windows Structured Exception Handler to catch access violations, etc. and generate a minidump. But of course that won't get called in the event of termination due to an uncaught C++ exception, and so there is no crash dump.
I'm looking for a Windows solution at the moment (no matter how dirty!), but would like to hear about other platforms if possible.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我们在上一篇文章中使用以下站点中的信息实现了针对未处理异常的 MiniDump:
http://beefchunk .com/documentation/sys-programming/os-win32/debug/www.debuginfo.com/articles/effminidumps.html
要捕获 Windows 上未处理的异常,请查看:
SetUnhandledExceptionFilter (http://msdn.microsoft.com/en-us/library/ms680634 %28VS.85%29.aspx)。
作为一名助手,我们花了很多时间尝试不同级别的小型转储,直到我们确定了一个。事实证明,这在现实世界的崩溃中没有真正的用处,因为我们不知道在实施小型转储时它们会是什么。它是特定于应用程序的,也是特定于崩溃的,所以我的建议是尽早添加小型转储处理程序,它将随着项目和质量检查而增长,并且在某个时候它将成为救星(希望在现实世界中)也)。
We implemented MiniDumps for unhandled exceptions in our last title using the information from this site:
http://beefchunk.com/documentation/sys-programming/os-win32/debug/www.debuginfo.com/articles/effminidumps.html
And to catch the unhandled exceptions on windows have a look at:
SetUnhandledExceptionFilter (http://msdn.microsoft.com/en-us/library/ms680634%28VS.85%29.aspx).
As an aisde, we spent a lot of time experimenting with the different levels of minidump until we settled on one. This proved to be of no real use in real world crashes as we had no idea what they would be at the time the minidumps were implemented. It's very application specific, and also crash specific, so my recommendation is to add the minidump handler as early as possible, it will grow with the project and through QA and it will be a life saver at somepoint (and hopefully out in the real world too).
您可以使用 try- except 语句将 C++ 异常“转换”为结构化异常(然后您可以从中获得不错的堆栈跟踪)。考虑一下:
这有点笨拙,但好处是您可以将 __try { } __ except() { } 部分放入通用
dumpStackTrace()
函数中。然后,您可以根据需要从程序中的任何点生成堆栈跟踪。You can use the try-except Statement to "convert" a C++ exception to a structured exception (out of which you can then get a nice stack trace). Consider this:
This is a little clumsy, but the nice thing is that you can put the __try { } __except() { } part into a general purpose
dumpStackTrace()
function. You can then yield stack traces from any point in your program, as you like.尝试使用 set_terminate 安装终止处理程序。并在其中使用迷你转储函数抓取堆栈跟踪。也许会起作用。
Try using set_terminate to install terminate handler. And in it grab stack trace using mini dump funcitons. Maybe it will work.