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:
- An exact copy of the binary that crashed, with debugging symbols embedded.
- A dump file (DMP) created immediately after the crash by windows (By right clicking on the process in the Windows Task Manager).
- 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:
- What kind of symbol files exist with mingw/gcc and how do you generate them?
- How can you load a windows DMP file with gdb?
- 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.