{"id":20296861,"url":"https://github.com/asmaloney/asmcrashreport","last_synced_at":"2025-04-11T12:09:43.590Z","repository":{"id":146510545,"uuid":"99694413","full_name":"asmaloney/asmCrashReport","owner":"asmaloney","description":"🐞 Installs signal handlers to capture stack traces for MinGW 32 and macOS builds.","archived":false,"fork":false,"pushed_at":"2024-03-29T18:43:55.000Z","size":29,"stargazers_count":52,"open_issues_count":8,"forks_count":28,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-25T08:23:55.002Z","etag":null,"topics":["addr2line","cpp","crash-dump","crash-reporting","hacktoberfest","mingw","qt","stacktrace"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/asmaloney.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["asmaloney"]}},"created_at":"2017-08-08T13:13:43.000Z","updated_at":"2025-02-01T15:29:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"5e06b7bd-9ba8-4321-92a7-8d3ff0dd48c5","html_url":"https://github.com/asmaloney/asmCrashReport","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asmaloney%2FasmCrashReport","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asmaloney%2FasmCrashReport/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asmaloney%2FasmCrashReport/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asmaloney%2FasmCrashReport/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asmaloney","download_url":"https://codeload.github.com/asmaloney/asmCrashReport/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248397726,"owners_count":21097166,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["addr2line","cpp","crash-dump","crash-reporting","hacktoberfest","mingw","qt","stacktrace"],"created_at":"2024-11-14T15:41:34.613Z","updated_at":"2025-04-11T12:09:43.567Z","avatar_url":"https://github.com/asmaloney.png","language":"C++","funding_links":["https://github.com/sponsors/asmaloney"],"categories":[],"sub_categories":[],"readme":"[![GitHub](https://img.shields.io/github/license/asmaloney/asmCrashReport)](LICENSE)\n\n# asmCrashReport\n\nProvides a simple way to get stack trace information from crashes when using the [MinGW](https://en.wikipedia.org/wiki/MinGW) 32-bit or macOS clang compilers for [Qt](https://www.qt.io/)-based applications.\n\nThis was made to fit my [purposes](https://asmaloney.com/2017/08/code/qt-crash-reporting-for-mingw-32-windows-and-clang-macos), but I think it is general enough to be useful to others.\n\n## Usage\n\nThere is a complete example included in this repo.\n\nIn your .pro file, you need to include the asmCrashreport.pri file. e.g.:\n\n```\nif ( !include( ../asmCrashReport.pri ) ) {\n    error( Could not find the asmCrashReport.pri file. )\n}\n```\n\nThis will define **ASM_CRASH_REPORT** for the preprocessor and modify the C/CXX and linker flags to include the debug symbols properly.\n\nIn your main.cpp, include the header:\n\n```cpp\n#ifdef ASM_CRASH_REPORT\n#include \"asmCrashReport.h\"\n#endif\n```\n\nIn your _main()_ function, set your signal handler _after_ you have declared your **QApplication** and set the application name and version number:\n\n```cpp\nQApplication  app( argc, argv );\n\napp.setApplicationName( QStringLiteral( \"asmCrashReportExample\" ) );\napp.setApplicationVersion( QStringLiteral( \"1.0.0\" ) );\n\n#ifdef ASM_CRASH_REPORT\n  asmCrashReport::setSignalHandler( QString(), [] (const QString \u0026inFileName, bool inSuccess) {\n     // do something with results - I show a QMessageBox (see example)\n  });\n#endif\n```\n\n**asmCrashReport::setSignalHandler** has the following prototype:\n\n```cpp\n// inCrashReportDirPath is the path to directory to write our crash report to. If this is not set, it will use Desktop/\u003cApp Name\u003e Crash Logs/\n// inLogWrittenCallback is a callback that will be called after the log file is written\nvoid  setSignalHandler( const QString \u0026inCrashReportDirPath = QString(), logWrittenCallback inLogWrittenCallback = nullptr );\n```\n\nThe callback can be used to show a message to the user about where to find the log file. It's signature must be this:\n\n```cpp\n// inLogFileName is the full path to the log file which was written\n// inSuccess returns whether the file was successfully written or not\ntypedef void (*logWrittenCallback)( const QString \u0026inLogFileName, bool inSuccess );\n```\n\n## Windows\n\nWindows needs to be able to find the **addr2line** command line tool.\n\nCurrently, asmCrashReporter will look for this in a tools directory next to the executable (see _asmCrashReport.cpp_'s **\\_addr2line()** function).\n\n### cygwin\n\nI use **addr2line** from [Cygwin](https://www.cygwin.com/).\n\nWhen sending your build to a user, you will need to include some DLLs alongside the exe to make it work.\n\nThe _tools_ directory (or whatever you change it to) should contain:\n\n```\n-rwxrwx---+ 1 Administrators None  934931 Nov 21  2015 addr2line.exe\n-rwxrwx---+ 1 Administrators None 1033235 Feb 20  2015 cygiconv-2.dll\n-rwxrwx---+ 1 Administrators None   42515 Oct 23  2016 cygintl-8.dll\n-rwxrwx---+ 1 Administrators None 3319090 Jul 12 05:00 cygwin1.dll\n-rwxrwx---+ 1 Administrators None   85011 Mar  3 16:45 cygz.dll\n```\n\nThese DLLs may be found in your Cygwin install's _bin_ directory.\n\n### MinGW\n\nThe 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.)\n\n## Example Logs\n\nmacOS (clang):\n\n```\nasmCrashReportExample v1.0.0\n07 Aug 2017 @ 09:42:38\n\nCaught SIGFPE: (integer divide by zero)\n\n2   libsystem_platform.dylib            0x00007fffacc42b3a _sigtramp + 26\n3   ???                                 0x0000000000000000 0x0 + 0\n4   asmCrashReportExample               0x0000000100008bd4 crashTest::function2(int) (in asmCrashReportExample) (main.cpp:26)\n5   asmCrashReportExample               0x0000000100008baa crashTest::function1() (in asmCrashReportExample) (main.cpp:31)\n6   asmCrashReportExample               0x00000001000085d5 crashTest::crashMe() (in asmCrashReportExample) (main.cpp:13)\n7   asmCrashReportExample               0x00000001000083de main + 206\n8   libdyld.dylib                       0x00007fffaca33235 start + 1\n```\n\nWindows (MinGW32):\n\n```\nasmCrashReportExample v1.0.0\n07 Aug 2017 @ 13:48:22\n\nEXCEPTION_INT_DIVIDE_BY_ZERO\n\n[0] 0x00000000004056ea crashTest::divideByZero(int) at C:\\dev\\asmCrashReport\\build-example-Qt_5_9_1_MinGW_32bit/../example/main.cpp:18\n[1] 0x0000000000405749 crashTest::function2(int) at C:\\dev\\asmCrashReport\\build-example-Qt_5_9_1_MinGW_32bit/../example/main.cpp:25\n[2] 0x0000000000405726 crashTest::function1() at C:\\dev\\asmCrashReport\\build-example-Qt_5_9_1_MinGW_32bit/../example/main.cpp:30\n[3] 0x0000000000405707 crashTest::crashMe() at C:\\dev\\asmCrashReport\\build-example-Qt_5_9_1_MinGW_32bit/../example/main.cpp:13\n[4] 0x0000000000403388 qMain(int, char**) at C:\\dev\\asmCrashReport\\build-example-Qt_5_9_1_MinGW_32bit/../example/main.cpp:61\n[5] 0x0000000000404592 ?? at qtmain_win.cpp:?\n```\n\n## Pull Requests\n\nIssues and pull requests welcome!\n\n## Notes\n\nIf anyone knows why the macOS version doesn't get the first frame correct in the example I'd love to hear from you!\n\nThis 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.\n\n## More Information\n\nSee the post [Crash Reporting For MinGW 32 (Windows) and Clang (macOS) With Qt](https://asmaloney.com/2017/08/code/crash-reporting-for-mingw-32-windows-and-clang-macos-with-qt/) for details.\n\n07 August 2017\nAndy Maloney\nhttps://asmaloney.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasmaloney%2Fasmcrashreport","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasmaloney%2Fasmcrashreport","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasmaloney%2Fasmcrashreport/lists"}