merged new crashpad implementation

This commit is contained in:
itsmattkc
2021-04-05 13:33:21 +10:00
parent 644d180e89
commit 748f45b7b8
6 changed files with 41 additions and 65 deletions
+8 -1
View File
@@ -343,10 +343,17 @@ jobs:
shell: bash shell: bash
run: | run: |
mv app/$BUNDLE_NAME . mv app/$BUNDLE_NAME .
$DEP_LOCATION/bin/macdeployqt $BUNDLE_NAME $DEP_LOCATION/bin/macdeployqt $BUNDLE_NAME -executable=$BUNDLE_NAME/Contents/MacOS/olive-crashhandler
$DOWNLOAD_TOOL https://github.com/arl/macdeployqtfix/raw/master/macdeployqtfix.py $DOWNLOAD_TOOL https://github.com/arl/macdeployqtfix/raw/master/macdeployqtfix.py
python2 macdeployqtfix.py $BUNDLE_NAME/Contents/MacOS/Olive $DEP_LOCATION python2 macdeployqtfix.py $BUNDLE_NAME/Contents/MacOS/Olive $DEP_LOCATION
# Crashpad symbols
$DEP_LOCATION/bin/dump_syms $BUNDLE_NAME/Contents/MacOS/Olive > Olive.sym
SYM_HEADER=($(head -n 1 Olive.sym)) # Read first line of symbol file
SYM_DIR=$BUNDLE_NAME/Contents/Resources/symbols/Olive/${SYM_HEADER[3]}
mkdir -p "$SYM_DIR"
mv Olive.sym "$SYM_DIR"
# Manual fixes # Manual fixes
cp $DEP_LOCATION/lib/libopentimelineio.dylib $BUNDLE_NAME/Contents/Frameworks cp $DEP_LOCATION/lib/libopentimelineio.dylib $BUNDLE_NAME/Contents/Frameworks
cp $DEP_LOCATION/lib/libopentime.dylib $BUNDLE_NAME/Contents/Frameworks cp $DEP_LOCATION/lib/libopentime.dylib $BUNDLE_NAME/Contents/Frameworks
+4 -40
View File
@@ -38,39 +38,10 @@
crashpad::CrashpadClient *client; crashpad::CrashpadClient *client;
QString GenerateReportPath()
{
return QDir(olive::FileFunctions::GetTempFilePath()).filePath(QStringLiteral("reports"));
}
base::FilePath GenerateReportPathForCrashpad()
{
return base::FilePath(QSTRING_TO_BASE_STRING(GenerateReportPath()));
}
#if defined(OS_WIN)
LONG WINAPI Win32ExceptionHandler(_EXCEPTION_POINTERS *ExceptionInfo)
{
QString crash_handler_exe = QDir(qApp->applicationDirPath()).filePath(QStringLiteral("olive-crashhandler"));
QProcess::startDetached(crash_handler_exe, {GenerateReportPath(), QString::number(QDateTime::currentSecsSinceEpoch())});
client->DumpAndCrash(ExceptionInfo);
return EXCEPTION_CONTINUE_SEARCH;
}
#elif defined(OS_LINUX)
bool LinuxExceptionHandler(int, siginfo_t*, ucontext_t*)
{
QString crash_handler_exe = QDir(qApp->applicationDirPath()).filePath(QStringLiteral("olive-crashhandler"));
QProcess::startDetached(crash_handler_exe, {GenerateReportPath(), QString::number(QDateTime::currentSecsSinceEpoch())});
// Returning false signals to Crashpad to proceed with its own exception handling
return false;
}
#endif
bool InitializeCrashpad() bool InitializeCrashpad()
{ {
QString report_path = QDir(olive::FileFunctions::GetTempFilePath()).filePath(QStringLiteral("reports"));
QString handler_fn = olive::FileFunctions::GetFormattedExecutableForPlatform(QStringLiteral("crashpad_handler")); QString handler_fn = olive::FileFunctions::GetFormattedExecutableForPlatform(QStringLiteral("crashpad_handler"));
// Generate absolute path // Generate absolute path
@@ -81,7 +52,7 @@ bool InitializeCrashpad()
if (QFileInfo::exists(handler_abs_path)) { if (QFileInfo::exists(handler_abs_path)) {
base::FilePath handler(QSTRING_TO_BASE_STRING(handler_abs_path)); base::FilePath handler(QSTRING_TO_BASE_STRING(handler_abs_path));
base::FilePath reports_dir = GenerateReportPathForCrashpad(); base::FilePath reports_dir(QSTRING_TO_BASE_STRING(report_path));
base::FilePath metrics_dir(QSTRING_TO_BASE_STRING(QDir(olive::FileFunctions::GetTempFilePath()).filePath(QStringLiteral("metrics")))); base::FilePath metrics_dir(QSTRING_TO_BASE_STRING(QDir(olive::FileFunctions::GetTempFilePath()).filePath(QStringLiteral("metrics"))));
@@ -109,15 +80,8 @@ bool InitializeCrashpad()
annotations, arguments, true, true); annotations, arguments, true, true);
} }
// Override Crashpad exception filter with our own // Override Crashpad exception filter with our own
if (status) { if (!status) {
#if defined(OS_WIN)
SetUnhandledExceptionFilter(Win32ExceptionHandler);
#elif defined(OS_LINUX)
crashpad::CrashpadClient::SetFirstChanceExceptionHandler(LinuxExceptionHandler);
#endif
} else {
qWarning() << "Failed to start Crashpad, automatic crash reporting will be disabled"; qWarning() << "Failed to start Crashpad, automatic crash reporting will be disabled";
} }
+3 -17
View File
@@ -41,13 +41,12 @@
namespace olive { namespace olive {
CrashHandlerDialog::CrashHandlerDialog(const char *report_dir, const char* crash_time) CrashHandlerDialog::CrashHandlerDialog(const QString& report_path)
{ {
setWindowTitle(tr("Olive")); setWindowTitle(tr("Olive"));
setWindowFlags(Qt::WindowStaysOnTopHint); setWindowFlags(Qt::WindowStaysOnTopHint);
crash_time_ = QString(crash_time).toULongLong(); report_filename_ = report_path;
report_dir_ = report_dir;
waiting_for_upload_ = false; waiting_for_upload_ = false;
QVBoxLayout* layout = new QVBoxLayout(this); QVBoxLayout* layout = new QVBoxLayout(this);
@@ -97,7 +96,7 @@ CrashHandlerDialog::CrashHandlerDialog(const char *report_dir, const char* crash
crash_report_->setText(tr("Waiting for crash report to be generated...")); crash_report_->setText(tr("Waiting for crash report to be generated..."));
AttemptToFindReport(); GenerateReport();
} }
void CrashHandlerDialog::SetGUIObjectsEnabled(bool e) void CrashHandlerDialog::SetGUIObjectsEnabled(bool e)
@@ -158,19 +157,6 @@ void CrashHandlerDialog::ReplyFinished(QNetworkReply* reply)
void CrashHandlerDialog::AttemptToFindReport() void CrashHandlerDialog::AttemptToFindReport()
{ {
// Retrieve reports from Crashpad database
std::unique_ptr<crashpad::CrashReportDatabase> database = crashpad::CrashReportDatabase::Initialize(base::FilePath(QSTRING_TO_BASE_STRING(QString(report_dir_))));
std::vector<crashpad::CrashReportDatabase::Report> reports;
database->GetCompletedReports(&reports);
// Find report that was made after the crash time
foreach (const crashpad::CrashReportDatabase::Report& report, reports) {
if (report.creation_time >= crash_time_) {
report_filename_ = BASE_STRING_TO_QSTRING(report.file_path.value());
break;
}
}
// If we found it, use it, otherwise wait a second and try again // If we found it, use it, otherwise wait a second and try again
if (report_filename_.isEmpty()) { if (report_filename_.isEmpty()) {
// Couldn't find report, try again in one second // Couldn't find report, try again in one second
+1 -5
View File
@@ -36,7 +36,7 @@ class CrashHandlerDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
CrashHandlerDialog(const char* report_dir, const char* crash_time); CrashHandlerDialog(const QString& report_path);
private: private:
void SetGUIObjectsEnabled(bool e); void SetGUIObjectsEnabled(bool e);
@@ -55,10 +55,6 @@ private:
QString report_filename_; QString report_filename_;
time_t crash_time_;
QString report_dir_;
QByteArray report_data_; QByteArray report_data_;
bool waiting_for_upload_; bool waiting_for_upload_;
+18 -2
View File
@@ -24,13 +24,29 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
if (argc < 3) { QString report;
#ifdef Q_OS_WINDOWS
int num_args;
LPWSTR *args = CommandLineToArgvW(GetCommandLineW(), &num_args);
if (num_args < 2) {
LocalFree(args);
return 1; return 1;
} }
report = QString::fromWCharArray(args[1]);
LocalFree(args);
#else
if (argc < 2) {
return 1;
}
report = argv[1];
#endif
QApplication a(argc, argv); QApplication a(argc, argv);
olive::CrashHandlerDialog chd(argv[1], argv[2]); olive::CrashHandlerDialog chd(report);
chd.open(); chd.open();
return a.exec(); return a.exec();
+7
View File
@@ -108,6 +108,7 @@ foreach (COMPONENT ${_crashpad_components})
${SHORT_COMPONENT} ${SHORT_COMPONENT}
HINTS HINTS
"${CRASHPAD_LIBRARY_DIRS}/obj/${COMPONENT}" "${CRASHPAD_LIBRARY_DIRS}/obj/${COMPONENT}"
NO_DEFAULT_PATH
) )
list(APPEND CRASHPAD_LIBRARIES ${CRASHPAD_${UPPER_COMPONENT}_LIB}) list(APPEND CRASHPAD_LIBRARIES ${CRASHPAD_${UPPER_COMPONENT}_LIB})
@@ -177,3 +178,9 @@ if (UNIX AND NOT APPLE)
Threads::Threads # Link against libpthread.so (-lpthread) Threads::Threads # Link against libpthread.so (-lpthread)
) )
endif() endif()
if (WIN32)
list(APPEND CRASHPAD_LIBRARIES
shlwapi.lib # Only necessary for our fork of Crashpad
)
endif()