https://github.com/asmaloney/asmcrashreport

🐞 Installs signal handlers to capture stack traces for MinGW 32 and macOS builds.

https://github.com/asmaloney/asmcrashreport

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • β—‹
    CITATION.cff file
  • βœ“
    codemeta.json file
    Found codemeta.json file
  • β—‹
    .zenodo.json file
  • β—‹
    DOI references
  • β—‹
    Academic publication links
  • β—‹
    Committers with academic emails
  • β—‹
    Institutional organization owner
  • β—‹
    JOSS paper metadata
  • β—‹
    Scientific vocabulary similarity
    Low similarity (12.5%) to scientific vocabulary

Keywords

addr2line cpp crash-dump crash-reporting hacktoberfest mingw qt stacktrace

Keywords from Contributors

degoogle
Last synced: 5 months ago · JSON representation

Repository

🐞 Installs signal handlers to capture stack traces for MinGW 32 and macOS builds.

Basic Info
  • Host: GitHub
  • Owner: asmaloney
  • License: mit
  • Language: C++
  • Default Branch: master
  • Homepage:
  • Size: 28.3 KB
Statistics
  • Stars: 54
  • Watchers: 7
  • Forks: 28
  • Open Issues: 8
  • Releases: 0
Topics
addr2line cpp crash-dump crash-reporting hacktoberfest mingw qt stacktrace
Created over 8 years ago · Last pushed almost 2 years ago
Metadata Files
Readme Funding License

README.md

GitHub

asmCrashReport

Provides a simple way to get stack trace information from crashes when using the MinGW 32-bit or macOS clang compilers for Qt-based applications.

This was made to fit my purposes, but I think it is general enough to be useful to others.

Usage

There is a complete example included in this repo.

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

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

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

In your main.cpp, include the header:

```cpp

ifdef ASMCRASHREPORT

include "asmCrashReport.h"

endif

```

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

```cpp QApplication app( argc, argv );

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

ifdef ASMCRASHREPORT

asmCrashReport::setSignalHandler( QString(), { // do something with results - I show a QMessageBox (see example) });

endif

```

asmCrashReport::setSignalHandler has the following prototype:

cpp // inCrashReportDirPath is the path to directory to write our crash report to. If this is not set, it will use Desktop/<App Name> Crash Logs/ // inLogWrittenCallback is a callback that will be called after the log file is written void setSignalHandler( const QString &inCrashReportDirPath = QString(), logWrittenCallback inLogWrittenCallback = nullptr );

The callback can be used to show a message to the user about where to find the log file. It's signature must be this:

cpp // inLogFileName is the full path to the log file which was written // inSuccess returns whether the file was successfully written or not typedef void (*logWrittenCallback)( const QString &inLogFileName, bool inSuccess );

Windows

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

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

cygwin

I use addr2line from Cygwin.

When sending your build to a user, you will need to include some DLLs alongside the exe to make it work.

The tools directory (or whatever you change it to) should contain:

-rwxrwx---+ 1 Administrators None 934931 Nov 21 2015 addr2line.exe -rwxrwx---+ 1 Administrators None 1033235 Feb 20 2015 cygiconv-2.dll -rwxrwx---+ 1 Administrators None 42515 Oct 23 2016 cygintl-8.dll -rwxrwx---+ 1 Administrators None 3319090 Jul 12 05:00 cygwin1.dll -rwxrwx---+ 1 Administrators None 85011 Mar 3 16:45 cygz.dll

These DLLs may be found in your Cygwin install's bin directory.

MinGW

The prebuilt MinGW Qt installers include addr2line in the bin directory. It may require other DLLs in order to work on the target machine. (As mentioned above, I use cygwin, so I'm not sure what is required here.)

Example Logs

macOS (clang):

``` asmCrashReportExample v1.0.0 07 Aug 2017 @ 09:42:38

Caught SIGFPE: (integer divide by zero)

2 libsystem_platform.dylib 0x00007fffacc42b3a _sigtramp + 26 3 ??? 0x0000000000000000 0x0 + 0 4 asmCrashReportExample 0x0000000100008bd4 crashTest::function2(int) (in asmCrashReportExample) (main.cpp:26) 5 asmCrashReportExample 0x0000000100008baa crashTest::function1() (in asmCrashReportExample) (main.cpp:31) 6 asmCrashReportExample 0x00000001000085d5 crashTest::crashMe() (in asmCrashReportExample) (main.cpp:13) 7 asmCrashReportExample 0x00000001000083de main + 206 8 libdyld.dylib 0x00007fffaca33235 start + 1 ```

Windows (MinGW32):

``` asmCrashReportExample v1.0.0 07 Aug 2017 @ 13:48:22

EXCEPTIONINTDIVIDEBYZERO

[0] 0x00000000004056ea crashTest::divideByZero(int) at C:\dev\asmCrashReport\build-example-Qt591MinGW32bit/../example/main.cpp:18 [1] 0x0000000000405749 crashTest::function2(int) at C:\dev\asmCrashReport\build-example-Qt591MinGW32bit/../example/main.cpp:25 [2] 0x0000000000405726 crashTest::function1() at C:\dev\asmCrashReport\build-example-Qt591MinGW32bit/../example/main.cpp:30 [3] 0x0000000000405707 crashTest::crashMe() at C:\dev\asmCrashReport\build-example-Qt591MinGW32bit/../example/main.cpp:13 [4] 0x0000000000403388 qMain(int, char**) at C:\dev\asmCrashReport\build-example-Qt591MinGW32bit/../example/main.cpp:61 [5] 0x0000000000404592 ?? at qtmainwin.cpp:? ```

Pull Requests

Issues and pull requests welcome!

Notes

If anyone knows why the macOS version doesn't get the first frame correct in the example I'd love to hear from you!

This code might work on Linux too since the code path for macOS should be POSIX compliant, though I haven't tried it. It could also be extended to handle MSVC compiles (or maybe it already does!), but I don't use that compiler so I can't test it.

More Information

See the post Crash Reporting For MinGW 32 (Windows) and Clang (macOS) With Qt for details.

07 August 2017 Andy Maloney https://asmaloney.com

Owner

  • Name: Andy Maloney
  • Login: asmaloney
  • Kind: user
  • Location: Canada, Earth, Sol, Oort Cloud

Software guy & independent researcher. Writer of code & hater of pseudo-"AI".

GitHub Events

Total
  • Watch event: 6
Last Year
  • Watch event: 6

Committers

Last synced: 10 months ago

All Time
  • Total Commits: 26
  • Total Committers: 3
  • Avg Commits per committer: 8.667
  • Development Distribution Score (DDS): 0.231
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Andy Maloney a****y@g****m 20
allcontributors[bot] 4****] 3
HΓΌseyin Kozan p****a@h****r 3
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 12
  • Total pull requests: 12
  • Average time to close issues: 26 days
  • Average time to close pull requests: 7 days
  • Total issue authors: 8
  • Total pull request authors: 4
  • Average comments per issue: 3.33
  • Average comments per pull request: 0.83
  • Merged pull requests: 8
  • Bot issues: 0
  • Bot pull requests: 3
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • asmaloney (2)
  • huseyinkozan (2)
  • overlapped (1)
  • charles-huet-ixxi (1)
  • AphaseDev (1)
  • pedjaman (1)
  • vinayAtWork (1)
  • Duolabs (1)
Pull Request Authors
  • huseyinkozan (4)
  • allcontributors[bot] (3)
  • PSlava (1)
  • Riflio (1)
Top Labels
Issue Labels
enhancement (2) question (1)
Pull Request Labels