Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multi-platform crash reporting system for Qt applications

I am creating a multi-platform Qt application for which I would want a crash reporting system to generate a crash report whenever there's a crash on the user's computer. At a later point, I should be able to view the stack trace with all the debug info from the crash report. I have looked at google-breakpad.

But to use that it seems I need to shift to MSVC for windows. Right now I am using MinGW on windows and it would take me significant time & effort to get all the different libraries compiled with MSVC. Is there any way I can use MinGW and still be able to use google-breakpad? Or is there some other alternative which can work multiplatform and support mingw on windows?

like image 751
Soumya Das Avatar asked Nov 04 '22 05:11

Soumya Das


2 Answers

I don't know any open multi-platform crash report system except google-breakpad. Even google-breakpad doesn't support MinGW, it is what i know, you still can get backtrace from your application. Project Dr. Mingw provide great dlls: mgwhelp.dll and exchndl.dll. For using you need:

  • compile with debug information. See Dr. Mingw FAQ.
  • include mgwhelp.dll and exchndl.dll with your application binaries
  • and load exchndl.dll when your application starts by explicitly calling LoadLibrary("exchndl.dll")

For example like this:

QFile drmingw("exchndl.dll");
if(drmingw.exists())
{// If don't want create reports just delete exchndl.dll from installer
    LoadLibrary(L"exchndl.dll");
}

After crash you will find file binary_name.RPT with backtrace at the same directory where binary is.

What else i do?

  • In release mode strip debug symbols.
win32:!win32-msvc*{
    # Strip debug symbols.
    QMAKE_POST_LINK += objcopy --only-keep-debug bin/${TARGET} bin/${TARGET}.dbg &&
    QMAKE_POST_LINK += objcopy --strip-debug bin/${TARGET} &&
    QMAKE_POST_LINK += objcopy --add-gnu-debuglink="bin/${TARGET}.dbg" bin/${TARGET}
}
  • Each run check if .RPT file exist and send or save in report directory. For example i use gist for collecting reports.
like image 181
dismine Avatar answered Nov 08 '22 06:11

dismine


libcrashreporter-qt "is supposed to provide an easy integration of Google Breakpad crash reporting into a Qt application".

It contains patches to breakpad to make it buildable with the MinGW toolchain.

like image 32
jturney Avatar answered Nov 08 '22 07:11

jturney