How to create minidump for my process when it crashes?
Asked Answered
T

6

33

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

Tamatamable answered 10/10, 2009 at 6:31 Comment(1)
You can always combine try-catch and fstream to make your own minidump.Caviar
P
31

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).

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 do help, 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.

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.

Psoas answered 10/10, 2009 at 6:57 Comment(1)
FFWD to 2022. Use Visual Studio and make debug builds. Using SEH and MiniDumpWriteDump you dutifully have studied and used. If and when a minidump is created open it with Visual Studio 2022. Your new life begins :)Koss
T
16

I found an excellent article on debugInfo.com This is worth to read:

effective minidumps, now staled, so see archived version on Wayback Machine.

Tamatamable answered 10/10, 2009 at 8:1 Comment(0)
S
6

I realise this is an old question, but in terms of system settings (first dot point of the OP), you can enable a setting to use Windows Error Reporting's built-in auto-crash dump generation. This is documented here: https://learn.microsoft.com/en-us/windows/win32/wer/collecting-user-mode-dumps. As this requires elevation, this is best set either manually (provided you're an admin) or at your application's install time. I don't recommend setting it at runtime if your app otherwise does not require elevation.

Essentially, you create create a new key under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\<app_name.exe> and customise the options there. The nice thing about this is that the crash dumps are automatically generated, and you can can control where they're stored, the type and what info is included, and how many dumps are retained.

This is probably the easiest method of generating and managing user mode crash dumps on Windows.

Sugary answered 12/10, 2021 at 1:2 Comment(0)
D
5

We use Google Breakpad in Firefox, although that requires at least Visual C++ 2003. The nice side benefit is that it also supports OS X and Linux.

Deodar answered 24/3, 2010 at 17:53 Comment(0)
A
2

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.

Arda answered 21/12, 2012 at 12:50 Comment(0)
R
1

If you have a few bucks to spare AQtrace may be worth a look at. This has many of the advantages of the crash occurring inside the debugger, while running on a remote end user machine.

Reek answered 10/10, 2009 at 7:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.