如何从崩溃中提取调试信息 [英] How to extract debugging information from a crash

查看:119
本文介绍了如何从崩溃中提取调试信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的C ++应用程序在Windows上崩溃,我想向我们的服务器发送有用的调试信息。

If my C++ app crashes on Windows I want to send useful debugging information to our server.

在Linux上,我将使用GNU backtrace ()函数 - 是否有等价的Windows?

On Linux I would use the GNU backtrace() function - is there an equivalent for Windows?

程序崩溃后,有没有办法提取有用的调试信息?

Is there a way to extract useful debugging information after a program has crashed? Or only from within the process?

(测试你的应用程序,所以它不会崩溃的建议是没有帮助的 - 所有非平凡的程序将会有bug)

(Advice along the lines of "test you app so it doesn't crash" is not helpful! - all non-trivial programs will have bugs)

推荐答案

函数 Stackwalk64 可用于在Windows上捕获堆栈跟踪。

The function Stackwalk64 can be used to snap a stack trace on Windows.

如果您打算使用此函数,你应该确保在禁用FPO的情况下编译代码 - 没有符号,StackWalk64将无法正确移动FPO'd框架。

If you intend to use this function, you should be sure to compile your code with FPO disabled - without symbols, StackWalk64 won't be able to properly walk FPO'd frames.

你可以得到一些代码运行在崩溃时通过调用SetUnhandledExceptionFilter通过顶层 __ try / __ except 阻塞的过程。这是有点不可靠,因为它需要你有代码运行在崩溃的进程。
或者,您可以只是内置的Windows错误报告收集崩溃数据。这是更可靠的,因为它不需要你添加在受损,崩溃的进程中运行的代码。唯一的代价是获取代码签名证书,因为您必须向服务提交签名的二进制文件。 https://sysdev.microsoft.com/en-US/Hardware/signup/有更多细节。

You can get some code running in process at the time of the crash via a top-level __try/__except block by calling SetUnhandledExceptionFilter. This is a bit unreliable since it requires you to have code running inside a crashed process. Alternatively, you can just the built-in Windows Error Reporting to collect crash data. This is more reliable, since it doesn't require you to add code running inside the compromised, crashed process. The only cost is to get a code-signing certificate, since you must submit a signed binary to the service. https://sysdev.microsoft.com/en-US/Hardware/signup/ has more details.

这篇关于如何从崩溃中提取调试信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆