What is a minidump? Now, if the client application was launched from the debugger, then when an error occurs, the debugger would show a stopping place in the code and it would be possible to see variable values at the time of the crash. So minidump snapshot, with which you can do the same, but without running the debugger. The client runs your application, and from crashing minidump, you can determine where is the place of failure.

But the way of creation this minidumps differ in VisualStudio and GCC.

In VS you can use dbghelp.h (dll) to save the *. dmp file. Then run this file through VS or WinDbg and look at the stack and registers in the point of failure.

More information about this you can be read in a series of Alexander Kudinov articles (in russion)

For GCC there is an interesting thing – MiniGW – utils, which includes exchndl.dll. Simply plug this library dynamically in your program and place this file next to the executable program, and after a crash it will create a text *.rpt file with information about the state of the stack and the registers at the time of the crash.

Add library code is very simple:

1
2
3
4
5
6
7
8
9
class ExceptionHandler
{
public:ExceptionHandler()
{
LoadLibrary("exchndl.dll");
}
};

static ExceptionHandler gExceptionHandler;  //  global instance of class

Look report for the GCC would be:

Error occured on Thursday, September 17, 2009 at 21:14:20.
C:\Work\tuning\.code\CarTuning\bin\CarTuning.exe caused an Access Violation at location 00000000 Reading from location 00000000.
Registers:
eax=00000000 ebx=002423bb ecx=00000020 edx=00000000 esi=00380034 edi=00340039
eip=00000000 esp=0022fedc ebp=0022fef8 iopl=0         nv up ei pl zr na po nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010246
Call stack:
00000000
00445109  C:\Work\tuning\.code\CarTuning\bin\CarTuning.exe:00445109  WinMain  C:/Work/tuning/.code/CarTuning/src/main.c:61
00484D94  C:\Work\tuning\.code\CarTuning\bin\CarTuning.exe:00484D94  CConsol::CConsol
0040124B  C:\Work\tuning\.code\CarTuning\bin\CarTuning.exe:0040124B  CConsol::CConsol
004012B8  C:\Work\tuning\.code\CarTuning\bin\CarTuning.exe:004012B8  CConsol::CConsol
7C817077  C:\WINDOWS\system32\kernel32.dll:7C817077  RegisterWaitForInputIdle

Error occured on Thursday, September 17, 2009 at 21:14:20.

C:\Work\tuning\.code\CarTuning\bin\CarTuning.exe caused an Access Violation at location 00000000 Reading from location 00000000.

Registers:

eax=00000000 ebx=002423bb ecx=00000020 edx=00000000 esi=00380034 edi=00340039

eip=00000000 esp=0022fedc ebp=0022fef8 iopl=0         nv up ei pl zr na po nc

cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010246

Call stack:

00000000

00445109  C:\Work\tuning\.code\CarTuning\bin\CarTuning.exe:00445109  WinMain  C:/Work/tuning/.code/CarTuning/src/main.c:61

00484D94  C:\Work\tuning\.code\CarTuning\bin\CarTuning.exe:00484D94  CConsol::CConsol

0040124B  C:\Work\tuning\.code\CarTuning\bin\CarTuning.exe:0040124B  CConsol::CConsol

004012B8  C:\Work\tuning\.code\CarTuning\bin\CarTuning.exe:004012B8  CConsol::CConsol

7C817077  C:\WINDOWS\system32\kernel32.dll:7C817077  RegisterWaitForInputIdle

Successful debugging!

Minidump for VisualStudio and GCC
Tagged on:                             

One thought on “Minidump for VisualStudio and GCC

  • Wednesday September 30th, 2009 at 09:07 PM
    Permalink

    Отличная статья.
    Давно хотел почитать что-то подобное – но руки не доходили! ?ногда такая вещь необходима. )
    Спасибо!

Leave a Reply

Your email address will not be published. Required fields are marked *