0

I have a windows application that I've built with cmake/ninja/mingw32 in an msys2 environment. My user experienced a crash and I'm having trouble figuring out how to analyse the crash so I can identify and solve the problem.

The binary was built with cmake .. -GNinja -DCMAKE_BUILD_TYPE=Debug && ninja and so it has debugging symbols built into the resulting executable.

So currently I have:

  1. An exact copy of the binary that crashed, with debugging symbols embedded.
  2. A dump file (DMP) created immediately after the crash by windows (By right clicking on the process in the Windows Task Manager).
  3. Source code which produced the binary.

Searching around, I see lots of explanations which require a pdb file (MSVC-specific) but I don't have one of those. I'm not against generating a pdb file (or the Mingw equivalent), but everyone just says to use -g. That doesn't create a pdb file, it just embeds symbols into the executable and I've already got that.

The compile/definitions generated by ninja look like this:

C:\msys64\mingw32\bin\c++.exe  
  -D<Defines>
  -I<Includes>
  -isystem C:/msys64/mingw32/include 
  -g -MD -MT <object>.obj 
  -MF <object>.obj.d 
  -o <object>.obj 
  -c <object>.cpp

C:\msys64\mingw32\bin\c++.exe 
  -g  <object1>.obj <object2>.obj <objectN>.obj 
  -o <Application>.exe 
  -Wl,--major-image-version,0,--minor-image-version,0  
  <library1>.dll.a <library2>.dll.a 
  -l<systemlib1> -l<systemlib2>

I've tried loading the *.DMP file with windbg, but without specifying a symbol file, it really doesn't give any information. I've tried loading the exectuable itself as my symbol file, but windbg doesn't seem to respond.

I've tried loading the *.DMP with gdb, but I get this error:

.DMP" is not a core dump: File format not recognized

Any advice on how to debug a crash like this is appreciated, but I guess my specific questions are:

  1. What kind of symbol files exist with mingw/gcc and how do you generate them?
  2. How can you load a windows DMP file with gdb?
  3. How can you produce a core dump in Windows that can be read by gdb?

Answering any one of the questions above should give me enough to go on.

This seems like analyzing a crash and using a debugging should be trivial, but somehow all I find online (and in my workplace) are lots of very confused and uncomfortable people who have no idea how to do it. I can debug stuff just fine from within an IDE (using QtCreator configured via the CMakeLists.txt file in the msys environment), but that doesn't help analyze a dump.

I found a great blog which articulates the issue very well here but it recommends using cv2pdb, an application which does not come pre-compiled and requires Visual Studio and nmake.

Stewart
  • 4,356
  • 2
  • 27
  • 59
  • 1
    a precompiled possibly old version of cv2pdb is available for download https://archive.is/o/IFMh0/www.dsource.org/projects/cv2pdb/browser/downloads/cv2pdb_0.25.zip?format=raw check if it works – blabb Sep 19 '17 at 12:51
  • Unfortunately, it didn't work. It gave error "cannot load PDB helper DLL". It appears to use VisualStudio libraries to encode the PDB. – Stewart Sep 19 '17 at 13:06
  • Creating a dump file *after* the crash with task manager will not give good results. – Thomas Weller Sep 19 '17 at 13:07
  • I think I have a solution. [drmingw](https://github.com/jrfonseca/drmingw) seems to work. I just need to reproduce the problem on the remote machine with drmingw installed, then I can select "Debug" when the crash prompt appears to see symbols. – Stewart Sep 19 '17 at 13:08
  • 1
    What does WinDbg say in `lm` what kind of symbols it has? – Thomas Weller Sep 19 '17 at 13:09
  • using the lm command shows some wow64, ntdll and image0000 symbols. It doesn't describe a type. They are all "deferred" – Stewart Sep 19 '17 at 13:12
  • 1
    @Stewart: please do a `ld` on your EXE and then a `lm` for your EXE. Since you [see the WOW64, analyzing the crash will be even harder](https://stackoverflow.com/questions/24874027/how-do-i-take-a-good-crash-dump-for-net). – Thomas Weller Sep 19 '17 at 14:10
  • I'll mark this as resolved. Even though I haven't solved my crash, I think we've explored enough methods (and that's what this post was about). – Stewart Sep 20 '17 at 06:54
  • 3
    If you still have any need for it, you could try my [gdb-with-minidump-support](https://github.com/ssbssa/gdb/releases). It handles minidump files on windows the same as core files on linux. – ssbssa Feb 15 '19 at 15:54

0 Answers0