crashhandler: updated for linux

This commit is contained in:
itsmattkc
2020-02-28 13:37:02 +11:00
parent c32ed5955c
commit ff69e69be4
3 changed files with 12 additions and 5 deletions
+8 -5
View File
@@ -1,5 +1,6 @@
#include "crashhandler.h"
#include <QApplication>
#include <QDir>
#include <QFile>
#include <QProcess>
@@ -7,15 +8,17 @@
#include <QTextStream>
#include <QtGlobal>
#ifdef Q_OS_WINDOWS
#if defined(Q_OS_WINDOWS)
#include <Windows.h>
#include <DbgHelp.h>
#include <stdio.h>
#include <stdlib.h>
#elif defined(Q_OS_LINUX)
#include <execinfo.h>
#endif
void crash_handler(int sig) {
QString log_path = QDir(QStandardPaths::writableLocation(QStandardPaths::TempLocation)).filePath("olive_crash");
QString log_path = QDir(QStandardPaths::writableLocation(QStandardPaths::TempLocation)).filePath(QStringLiteral("olive_crash"));
QFile output(log_path);
output.open(QFile::WriteOnly);
@@ -105,13 +108,13 @@ void crash_handler(int sig) {
size = backtrace(array, 10);
// print out all the frames to stderr
fprintf(stderr, "Error: signal %d:\n", sig);
backtrace_symbols_fd(array, size, STDERR_FILENO);
backtrace_symbols_fd(array, size, output.handle());
#endif
output.close();
QProcess::startDetached(QStringLiteral("crashhandler"), {log_path});
QString crash_handler_exe = QDir(qApp->applicationDirPath()).filePath(QStringLiteral("crashhandler"));
QProcess::startDetached(crash_handler_exe, {log_path});
exit(1);
}
+3
View File
@@ -28,6 +28,9 @@
AboutDialog::AboutDialog(QWidget *parent) :
QDialog(parent)
{
char* test = nullptr;
test[250] = 69;
setWindowTitle(tr("About %1").arg(QApplication::applicationName()));
QVBoxLayout* layout = new QVBoxLayout(this);
+1
View File
@@ -33,6 +33,7 @@ extern "C" {
#include <QApplication>
#include <QSurfaceFormat>
#include <csignal>
#include "core.h"
#include "common/crashhandler.h"