Giter Site home page Giter Site logo

yapparicrashreport's Introduction

YappariCrashReport

Based on asmCrashReport (excellent work by Andy Maloney).

Provides a dialog to show the user the stack trace information from crashes when using the GNU GCC/G++ compilers including MinGW for Windows or the clang compiler for Qt-based applications.

The user can optionally save the stack trace to a file clicking on the Save report button.

Supports Windows, Linux and macOS.

In Windows the dialog look like this:

Yappari Crash Report Test on Windows

For Linux it would look like this:

Yappari Crash Report Test on Linux

If you run the included test you get to select which type of crash you want to test:

Choosing a crash

Usage

There are two examples included in this repository.

In your .pro file, you need to include the YappariCrashReport.pri file. e.g.:

if ( !include( ../YappariCrashReport.pri ) ) {
    error( Could not find the YappariCrashReport.pri file. )
}

This will define YAPPARI_CRASH_REPORT for the preprocessor and modify the C/CXX and linker flags to include the debug symbols properly.

In your main.cpp, include the header:

#ifdef YAPPARI_CRASH_REPORT
#include "YappariCrashReport.h"
#endif

In your main() function, set your signal handler after you have declared your QApplication and set the application name and version number:

QApplication  app( argc, argv );

app.setApplicationName( QStringLiteral( "YappariCrashReportExample" ) );
app.setApplicationVersion( QStringLiteral( "1.0.0" ) );

#ifdef YAPPARI_CRASH_REPORT
   YappariCrashReport::setSignalHandler( [] (const QString &inStackTrace) {

       const QStringList strList = QStringList(inStackTrace.split("\n"));
       for (const QString &str : strList)
           qCritical() << str;
   });
#endif

YappariCrashReport::setSignalHandler has the following prototype:

   /// inCrashReportCallback: A callback function to call after we've shown the dialog to the user
   void setSignalHandler( crashReportCallback inCrashReportCallback = nullptr );

The callback can be used to send the stack trace to the stderr. Its signature must be this:

   /// inCrashReport: The report including the stack trace as a QString
   void crashReportCallback( const QString &inCrashReport );

Look at the example and test source code for more information on how to do this.

Windows (MingW)

Windows needs to be able to find the addr2line command line tool.

Currently, YappariCrashReport will look for this in a tools directory next to the executable (see YappariCrashReport.cpp's _addr2line() function).

The prebuilt MinGW Qt installers include addr2line in the bin directory. It's statically linked so you only need to copy this file to the tools directory.

You can find it usually at C:\Qt\Tools\mingwxxx_xx\bin.

Linux

You need to have the binutils package installed that includes addr2line.

Main differences with asmCrashReport

asmCrashReport saves the stack trace to a log file in a subfolder of the Desktop (Windows) or the user's home directory (Linux/macOS).

YappariCrashReport shows a nice dialog to the user and give them the option to save the file or not, in a location of their preference.

Also asmCrashReport doesn't work on Linux without some modifications that are included in this project.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.