mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T401, crash simulation improvements
* sub-directory paths in directory utils * no UI simulated crash in release builds * no upload rate in local developer builds
This commit is contained in:
committed by
Mat Sutcliffe
parent
9745bafd4e
commit
60b3c16120
@@ -1646,9 +1646,9 @@ namespace BlackCore
|
||||
|
||||
static const QString crashpadHandler(CBuildConfig::isRunningOnWindowsNtPlatform() ? "swift_crashpad_handler.exe" : "swift_crashpad_handler");
|
||||
static const QString handler = CFileUtils::appendFilePaths(CDirectoryUtils::binDirectory(), crashpadHandler);
|
||||
static const QString crashpadPath = CDirectoryUtils::crashpadDirectory();
|
||||
static const QString database = CFileUtils::appendFilePaths(crashpadPath, "/database");
|
||||
static const QString metrics = CFileUtils::appendFilePaths(crashpadPath, "/metrics");
|
||||
// const QString crashpadPath = CDirectoryUtils::crashpadDirectory();
|
||||
const QString database = CDirectoryUtils::crashpadDatabaseDirectory();
|
||||
const QString metrics = CDirectoryUtils::crashpadMetricsDirectory();
|
||||
|
||||
if (!QFileInfo::exists(handler))
|
||||
{
|
||||
@@ -1678,6 +1678,12 @@ namespace BlackCore
|
||||
const QString crashAttachment = QStringLiteral("--attachment=attachment_%1=%2").arg(crashInfoFileName, crashInfoFilePath);
|
||||
arguments.push_back(crashAttachment.toStdString());
|
||||
|
||||
// for testing purposes
|
||||
if (CBuildConfig::isLocalDeveloperDebugBuild())
|
||||
{
|
||||
arguments.push_back("--no-rate-limit");
|
||||
}
|
||||
|
||||
QDir().mkpath(database);
|
||||
m_crashReportDatabase = CrashReportDatabase::Initialize(qstringToFilePath(database));
|
||||
this->onCrashDumpUploadEnabledChanged(); // settings for crashpad uploads
|
||||
@@ -1741,6 +1747,9 @@ namespace BlackCore
|
||||
void CApplication::simulateCrash()
|
||||
{
|
||||
#ifdef BLACK_USE_CRASHPAD
|
||||
CLogMessage(this).info(u"Simulated crash dump!");
|
||||
m_crashAndLogInfo.appendInfo("Simulated crash dump!");
|
||||
m_crashAndLogInfo.writeToFile();
|
||||
CRASHPAD_SIMULATE_CRASH();
|
||||
// real crash
|
||||
// raise(SIGSEGV); #include <signal.h>
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "blackmisc/math/mathutils.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
#include "blackconfig/buildconfig.h"
|
||||
|
||||
#include "ui_internalscomponent.h"
|
||||
|
||||
@@ -39,6 +40,7 @@
|
||||
#include <QDateTime>
|
||||
#include <QMessageBox>
|
||||
|
||||
using namespace BlackConfig;
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Network;
|
||||
@@ -331,7 +333,13 @@ namespace BlackGui
|
||||
|
||||
void CInternalsComponent::simulateCrash()
|
||||
{
|
||||
const QMessageBox::StandardButton reply = QMessageBox::question(this, "crash", "Really simulate crash?", QMessageBox::Yes | QMessageBox::No);
|
||||
if (CBuildConfig::isReleaseBuild())
|
||||
{
|
||||
QMessageBox::information(this, "crash simulation", "Not possible in release builds!");
|
||||
return;
|
||||
}
|
||||
|
||||
const QMessageBox::StandardButton reply = QMessageBox::question(this, "crash simulation", "Really simulate crash?", QMessageBox::Yes | QMessageBox::No);
|
||||
if (reply != QMessageBox::Yes) { return; }
|
||||
sGui->simulateCrash();
|
||||
}
|
||||
|
||||
@@ -77,10 +77,16 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
void CCrashInfo::triggerWritingFile()
|
||||
void CCrashInfo::triggerWritingFile() const
|
||||
{
|
||||
if (m_logFileAndPath.isEmpty()) { return; }
|
||||
CFileUtils::writeStringToFileInBackground(summary(), m_logFileAndPath);
|
||||
CFileUtils::writeStringToFileInBackground(this->summary(), m_logFileAndPath);
|
||||
}
|
||||
|
||||
bool CCrashInfo::writeToFile() const
|
||||
{
|
||||
if (m_logFileAndPath.isEmpty()) { return false; }
|
||||
return CFileUtils::writeStringToFile(this->summary(), m_logFileAndPath);
|
||||
}
|
||||
|
||||
QString CCrashInfo::summary() const
|
||||
|
||||
@@ -79,8 +79,11 @@ namespace BlackMisc
|
||||
//! \copydoc BlackMisc::Mixin::Index::comparePropertyByIndex
|
||||
int comparePropertyByIndex(const CPropertyIndex &index, const CCrashInfo &compareValue) const;
|
||||
|
||||
//! Trigger writing this to file
|
||||
void triggerWritingFile();
|
||||
//! Trigger writing this to file (in background)
|
||||
void triggerWritingFile() const;
|
||||
|
||||
//! Write to file (synchronous)
|
||||
bool writeToFile() const;
|
||||
|
||||
//! Summary
|
||||
QString summary() const;
|
||||
|
||||
@@ -378,7 +378,7 @@ namespace BlackMisc
|
||||
|
||||
QString getDocumentationDirectoryImpl()
|
||||
{
|
||||
QStringList pathes(QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation));
|
||||
const QStringList pathes(QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation));
|
||||
QString d = pathes.first();
|
||||
d = QDir::cleanPath(d + QDir::separator() + "swift");
|
||||
QDir dir(d);
|
||||
@@ -398,6 +398,18 @@ namespace BlackMisc
|
||||
return p;
|
||||
}
|
||||
|
||||
const QString &CDirectoryUtils::crashpadDatabaseDirectory()
|
||||
{
|
||||
static const QString p = CFileUtils::appendFilePaths(crashpadDirectory(), "/database");
|
||||
return p;
|
||||
}
|
||||
|
||||
const QString &CDirectoryUtils::crashpadMetricsDirectory()
|
||||
{
|
||||
static const QString p = CFileUtils::appendFilePaths(crashpadDirectory(), "/metrics");
|
||||
return p;
|
||||
}
|
||||
|
||||
QString CDirectoryUtils::decodeNormalizedDirectory(const QString &directory)
|
||||
{
|
||||
return QUrl::fromPercentEncoding(directory.toUtf8());
|
||||
|
||||
@@ -139,6 +139,12 @@ namespace BlackMisc
|
||||
//! Directory for crashpad files
|
||||
static const QString &crashpadDirectory();
|
||||
|
||||
//! Directory for crashpad database files
|
||||
static const QString &crashpadDatabaseDirectory();
|
||||
|
||||
//! Directory for crashpad metrics files
|
||||
static const QString &crashpadMetricsDirectory();
|
||||
|
||||
//! Virtually the inverse operation of CDirectoryUtils::normalizedApplicationDirectory
|
||||
static QString decodeNormalizedDirectory(const QString &directory);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user