1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

main: Remove backtrace handler

This commit is contained in:
David Rosca 2019-04-22 09:46:39 +02:00
parent b9fb89a31c
commit 66d6e81e23
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8

View File

@ -17,84 +17,9 @@
* ============================================================ */
#include "mainapplication.h"
#include "proxystyle.h"
#include "datapaths.h"
#include <QMessageBox> // For QT_REQUIRE_VERSION
#include <iostream>
#if defined(Q_OS_LINUX) || defined(__GLIBC__) || defined(__FreeBSD__) || defined(__HAIKU__)
#include <signal.h>
#include <execinfo.h>
#include <QDir>
#include <QDateTime>
#include <QTextStream>
#include <QWebEnginePage>
void falkon_signal_handler(int s)
{
if (s != SIGSEGV) {
return;
}
static bool sigSegvServed = false;
if (sigSegvServed) {
abort();
}
sigSegvServed = true;
std::cout << "Falkon: Crashed :( Saving backtrace in " << qPrintable(DataPaths::path(DataPaths::Config)) << "/crashlog ..." << std::endl;
void* array[100];
int size = backtrace(array, 100);
char** strings = backtrace_symbols(array, size);
if (size < 0 || !strings) {
std::cout << "Cannot get backtrace!" << std::endl;
abort();
}
QDir dir(DataPaths::path(DataPaths::Config));
if (!dir.exists()) {
std::cout << qPrintable(DataPaths::path(DataPaths::Config)) << " does not exist" << std::endl;
abort();
}
if (!dir.cd("crashlog")) {
if (!dir.mkdir("crashlog")) {
std::cout << "Cannot create " << qPrintable(DataPaths::path(DataPaths::Config)) << "crashlog directory!" << std::endl;
abort();
}
dir.cd("crashlog");
}
const QDateTime currentDateTime = QDateTime::currentDateTime();
QFile file(dir.absoluteFilePath("Crash-" + currentDateTime.toString(Qt::ISODate) + ".txt"));
if (!file.open(QFile::WriteOnly | QFile::Truncate)) {
std::cout << "Cannot open file " << qPrintable(file.fileName()) << " for writing!" << std::endl;
abort();
}
QTextStream stream(&file);
stream << "Time: " << currentDateTime.toString() << endl;
stream << "Qt version: " << qVersion() << " (compiled with " << QT_VERSION_STR << ")" << endl;
stream << "Falkon version: " << Qz::VERSION << endl;
stream << "Rendering engine: QtWebEngine" << endl;
stream << endl;
stream << "============== BACKTRACE ==============" << endl;
for (int i = 0; i < size; ++i) {
stream << "#" << i << ": " << strings[i] << endl;
}
file.close();
std::cout << "Backtrace successfully saved in " << qPrintable(dir.absoluteFilePath(file.fileName())) << std::endl;
}
#endif // defined(Q_OS_LINUX) || defined(__GLIBC__) || defined(__FreeBSD__)
#ifndef Q_OS_WIN
void msgHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
@ -123,16 +48,10 @@ void msgHandler(QtMsgType type, const QMessageLogContext &context, const QString
int main(int argc, char* argv[])
{
QT_REQUIRE_VERSION(argc, argv, "5.8.0");
#ifndef Q_OS_WIN
qInstallMessageHandler(&msgHandler);
#endif
#if defined(Q_OS_LINUX) || defined(__GLIBC__) || defined(__FreeBSD__)
signal(SIGSEGV, falkon_signal_handler);
#endif
// Hack to fix QT_STYLE_OVERRIDE with QProxyStyle
const QByteArray style = qgetenv("QT_STYLE_OVERRIDE");
if (!style.isEmpty()) {