Crash reporting for MinGW applications

后端 未结 1 1732
醉话见心
醉话见心 2021-01-31 18:33

I have a c++ application compiled with MinGW for which I\'ve been receiving crash complaints from customers. So, besides heavily logging in the parts that might be crashing (bef

相关标签:
1条回答
  • 2021-01-31 18:46

    Actually the problem is not so much getting the crash reports to work. That is rather trivial with the DbgHelp library functions and most prominently there MiniDumpWriteDump. Remember, however, to redistribute the DbgHelp library on older systems and observe the version requirements for the functions you intend to call - newer versions of Windows come with at least some version of this library.

    Your problem with using a non-MS compiler (the problem also exists with the Embarcadero, formerly Borland, products, for example, or Watcom) is that the debug symbols created make no sense to the DbgHelp library - which is the standard facility for debugging on Windows. The PDB format is largely undocumented (for some clues search for the terms: Sven Schreiber PDB) and the libraries used to create them are not "public" in the same sense as the DbgHelp library - the latter can only be used to read/parse the created debug symbols. They are part of the Visual Studio products and usually named something like mspdbXY.dll (where XY are decimal digits).

    So, if you want to create bug reports I strongly suggest that instead of concentrating on the "compiler issues", concentrate on the debugger issues. Here are the general directions in which you can go:

    1. Use a debugger that understands your particular debug format (GDB for DWARF in MinGW, IIRC)
    2. Use a debugger that understands multiple formats (IDA comes to mind and has other advantages, too ;))
    3. Write an extension to something like WinDbg in order to make sense of yourdebug symbols (DWARF) or more generically .map files (I'm aware that such extensions were written some years ago for Borland .map files)
    4. Learn assembly language and use the available tools (WinDbg or more generally the DbgHelp library) without symbols (probably a too steep learning curve unless you know it already)

    As an extension to 4 you can also let GCC create the .S (assembly) files during compilation in order to cross-reference source code and crash dump when working without symbol support.

    Given that I prefer GDB on unixoid platforms, but WinDbg and other debuggers on Windows, I cannot really say whether there is support for the actual crash dump format (created with MiniDumpWriteDump) in GDB on Windows, so I'm not sure what format may be expected by GDB in this case.

    BTW: if you use Windows XP or higher and can rely on that fact, use AddVectoredExceptionHandler instead of SetUnhandledExceptionFilter to prepare writing the crash dump.

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