C++ 崩溃时如何为我的进程创建小型转储?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1547211/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to create minidump for my process when it crashes?
提问by Satbir
I am not able to create minidump form my process by changing system setting. So my Question is :
我无法通过更改系统设置从我的进程中创建小型转储。所以我的问题是:
Will the system create a minidump for a user process when it crashes
If yes, which setting do I need to configure
Or do I have to create minidump programmatically.
How effective are minidumps while investigating a crash
系统崩溃时是否会为用户进程创建一个小型转储
如果是,我需要配置哪些设置
或者我必须以编程方式创建小型转储。
小型转储在调查崩溃时的效果如何
I'm using Windows XP, C++, VC6
我使用的是 Windows XP、C++、VC6
采纳答案by gimpf
You need to programatically create a minidump (with one exception, see next link). CodeProject has a nice article on MiniDumps. Basically, you want to use dbghelp.dll
, and use the function MiniDumpWriteDump()
(see MSDN on MiniDumpWriteDump).
您需要以编程方式创建一个小型转储(有一个例外,请参阅下一个链接)。CodeProject 有一篇关于 MiniDumps的好文章。基本上,您想使用dbghelp.dll
, 并使用该功能MiniDumpWriteDump()
(请参阅MiniDumpWriteDump 上的 MSDN)。
How effective such dumps are depends very much on the application. Sometimes, for optimized binaries, they are practically useless. Also, without experience, heap/stack corruption bugs will lead you astray.
此类转储的有效性在很大程度上取决于应用程序。有时,对于优化的二进制文件,它们实际上是无用的。此外,如果没有经验,堆/堆栈损坏错误会导致您误入歧途。
However, if the optimizer was not too hard on you, there is a large class of errors where the dumps dohelp, namely all the bugs where having a stack-trace + values of the locally used variables is useful, i.e. many pure-virtual-function call things (i.e. wrong destruction order), access violations (uninitialized accessed or missing NULL checks), etc.
但是,如果优化器对您不太苛刻,那么转储确实有帮助的一大类错误,即具有堆栈跟踪 + 本地使用变量的值的所有错误,即许多纯虚拟- 函数调用事物(即错误的销毁顺序)、访问冲突(未初始化的访问或缺少 NULL 检查)等。
BTW, if your maintenance policy somehow allows it, port your application from VC6 to something acceptable, like VC8 or 9. You'll do yourself a big favor.
顺便说一句,如果您的维护政策以某种方式允许,请将您的应用程序从 VC6 移植到可接受的版本,例如 VC8 或 9。您会帮自己一个大忙。
回答by Satbir
Thanks all for viewing and replying special thanks to gimpf, I googled on internet and msdn.
感谢大家查看和回复,特别感谢 gimpf,我在互联网和 msdn 上用谷歌搜索。
I found an excellent article on debugInfo.comThis is worth to read :
我在debugInfo.com上找到了一篇很棒的文章,值得一读:
回答by Ted Mielczarek
We use Google Breakpadin Firefox, although that requires at least Visual C++ 2003. The nice side benefit is that it also supports OS X and Linux.
我们在 Firefox 中使用Google Breakpad,尽管这至少需要 Visual C++ 2003。好的附带好处是它还支持 OS X 和 Linux。
回答by Tosha
I ended up using CrashRpt on Windows (required me to move the whole codebase and toolchain from MinGW to native Microsoft C/C++ compiler), and google-breakpad on Linux.
我最终在 Windows 上使用了 CrashRpt(要求我将整个代码库和工具链从 MinGW 移动到本机 Microsoft C/C++ 编译器),并在 Linux 上使用 google-breakpad。