How to write a sample code that will crash and produce dump file?

后端 未结 9 1408
礼貌的吻别
礼貌的吻别 2020-12-12 23:15

I started learned windbg and I found this good post How to use WinDbg to analyze the crash dump for VC++ application?

Now I want to follow the instructions and do it

相关标签:
9条回答
  • 2020-12-12 23:34

    This will produce a null pointer dereference exception: *((int*) 0) = 0;

    This will produce integer division by zero: int a = 0; int b = 5 / a;

    EDIT: Post-Mortem Debugging Your Application with Minidumps and Visual Studio .NET contains a lot of sample code and theory on using minidumps.

    0 讨论(0)
  • 2020-12-12 23:41

    Most of the times you will find all apps dump in C:\windows\minidumps.

    To generate a dump file you could use a simple solution:

    1. Open windbg
    2. File->Open Executable
    3. You run the app that will crash
    4. A breakpoint will trigger
    5. Now you can use .dump in windbg to create a dmp file

    or

    1. Run the app and wait to crash
    2. Open windbg and attach to process (File->Attach to process)
    3. run .dump

    This way you will be able to analyze that crash anytime :)

    0 讨论(0)
  • 2020-12-12 23:46

    Auto minidump generation is done by the post-mortem debugger, so you need to start there. Most importantly though, it's done by a debugger. So if you just want to generate a minidump, you can use your typical debugger (probably visual studio or windbg). Even task manager can create dump files.

    The registry setting which specifies the post-mortem debugger is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug

    Look at the Debugger string, and you will be on your way to finding your minidumps.

    0 讨论(0)
提交回复
热议问题