P
P
Profi_GMan2018-01-31 15:18:45
Qt
Profi_GMan, 2018-01-31 15:18:45

What are the libraries for catching exceptions and throwing them?

Good day!
I've already searched for the answer, but I couldn't find it.
I am using qt.
I need to make sure that all program crashes, i.e. exceptions were caught and an error message was displayed.
I did this: I catch ordinary exceptions using catch (). I catch exceptions like sigsegv with
SetUnhandledExceptionFilter() on Windows and sigaction() on Linux. I also added std::set_terminate(). After that, backtrace is displayed, if it is Windows, a mini-dump is created and an error with a description is displayed on the screen.
But there are several problems:
1. If an error occurs in another thread (and they only happen there for me), then the program, firstly, does not wait for the "ok" button in the error message to be pressed and closes, and secondly, after closing, the thread remains to work, and even QProcess::startDetached("taskkill ...") does not help
2. Now the most important thing. How to get the location where the error occurred? With the help of a minidump, you can only get it if the program is compiled in debug mode and if the error occurred directly in the program code, but if I passed the wrong pointer to the qt function, then I will get the place in this function, and not the place where it was called .
3. To get a normal backtrace and error location, I need to compile the program into debug, but then it, together with all the dlls, will weigh 500 mb.
4. std::set_terminate() is set for only one thread. How to install for everyone?
How to implement all this? I googled crashrpt, but I have mingw and it is not cross-platform. I also found Google breakpad and its adaptation for qt ( https://github.com/dschmidt/libcrashreporter-qt), but it doesn't say how to implement it in your project. What libraries can be used for this?
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Profi_GMan, 2018-02-02
@Profi_GMan

In general, the library is google breakpad.
You need to collect it first. And here's how I did it:
First you need to put this (lss library) into the folder folder_with_brickpad\src\third_party https://yadi.sk/d/BmWlgUmx3SHqka
On Linux I just downloaded it completely , after which I did it in the root folder./ configure && make. After that, the .a file will be in folder_c_breakpad\src\client\linux\libbreakpad_client.a
On Windows, I created this .pro file in the breakpad root folder and compiled it:

spoiler
TEMPLATE = lib
CONFIG += staticlib
INCLUDEPATH += $$PWD
INCLUDEPATH += $$PWD/src
# Windows
win32:HEADERS += $$PWD/src/common/windows/string_utils-inl.h
win32:HEADERS += $$PWD/src/common/windows/guid_string.h
win32:HEADERS += $$PWD/src/client/windows/handler/exception_handler.h
win32:HEADERS += $$PWD/src/client/windows/common/ipc_protocol.h
win32:HEADERS += $$PWD/src/google_breakpad/common/minidump_format.h
win32:HEADERS += $$PWD/src/google_breakpad/common/breakpad_types.h
win32:HEADERS += $$PWD/src/client/windows/crash_generation/crash_generation_client.h
win32:HEADERS += $$PWD/src/common/scoped_ptr.h
win32:SOURCES += $$PWD/src/client/windows/handler/exception_handler.cc
win32:SOURCES += $$PWD/src/common/windows/string_utils.cc
win32:SOURCES += $$PWD/src/common/windows/guid_string.cc
win32:SOURCES += $$PWD/src/client/windows/crash_generation/crash_generation_client.cc
after that, an .a file will appear in the root folder.
Now you need to connect it (.a file) (in qt it is LIBS += path\name.a in the pro file) and then you need to connect only the client/windows/sender/crash_report_sender header file. h for Windows and client/linux/sender/crash_report_sender.h and that's it. You can read about what to do next here:
https://maxsavenkov.livejournal.com/189460.html for Windows
https://gist.github.com/byronwind/94c94ee00dc442c71638 for linux

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question