mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 02:35:38 +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 crashpadHandler(CBuildConfig::isRunningOnWindowsNtPlatform() ? "swift_crashpad_handler.exe" : "swift_crashpad_handler");
|
||||||
static const QString handler = CFileUtils::appendFilePaths(CDirectoryUtils::binDirectory(), crashpadHandler);
|
static const QString handler = CFileUtils::appendFilePaths(CDirectoryUtils::binDirectory(), crashpadHandler);
|
||||||
static const QString crashpadPath = CDirectoryUtils::crashpadDirectory();
|
// const QString crashpadPath = CDirectoryUtils::crashpadDirectory();
|
||||||
static const QString database = CFileUtils::appendFilePaths(crashpadPath, "/database");
|
const QString database = CDirectoryUtils::crashpadDatabaseDirectory();
|
||||||
static const QString metrics = CFileUtils::appendFilePaths(crashpadPath, "/metrics");
|
const QString metrics = CDirectoryUtils::crashpadMetricsDirectory();
|
||||||
|
|
||||||
if (!QFileInfo::exists(handler))
|
if (!QFileInfo::exists(handler))
|
||||||
{
|
{
|
||||||
@@ -1678,6 +1678,12 @@ namespace BlackCore
|
|||||||
const QString crashAttachment = QStringLiteral("--attachment=attachment_%1=%2").arg(crashInfoFileName, crashInfoFilePath);
|
const QString crashAttachment = QStringLiteral("--attachment=attachment_%1=%2").arg(crashInfoFileName, crashInfoFilePath);
|
||||||
arguments.push_back(crashAttachment.toStdString());
|
arguments.push_back(crashAttachment.toStdString());
|
||||||
|
|
||||||
|
// for testing purposes
|
||||||
|
if (CBuildConfig::isLocalDeveloperDebugBuild())
|
||||||
|
{
|
||||||
|
arguments.push_back("--no-rate-limit");
|
||||||
|
}
|
||||||
|
|
||||||
QDir().mkpath(database);
|
QDir().mkpath(database);
|
||||||
m_crashReportDatabase = CrashReportDatabase::Initialize(qstringToFilePath(database));
|
m_crashReportDatabase = CrashReportDatabase::Initialize(qstringToFilePath(database));
|
||||||
this->onCrashDumpUploadEnabledChanged(); // settings for crashpad uploads
|
this->onCrashDumpUploadEnabledChanged(); // settings for crashpad uploads
|
||||||
@@ -1741,6 +1747,9 @@ namespace BlackCore
|
|||||||
void CApplication::simulateCrash()
|
void CApplication::simulateCrash()
|
||||||
{
|
{
|
||||||
#ifdef BLACK_USE_CRASHPAD
|
#ifdef BLACK_USE_CRASHPAD
|
||||||
|
CLogMessage(this).info(u"Simulated crash dump!");
|
||||||
|
m_crashAndLogInfo.appendInfo("Simulated crash dump!");
|
||||||
|
m_crashAndLogInfo.writeToFile();
|
||||||
CRASHPAD_SIMULATE_CRASH();
|
CRASHPAD_SIMULATE_CRASH();
|
||||||
// real crash
|
// real crash
|
||||||
// raise(SIGSEGV); #include <signal.h>
|
// raise(SIGSEGV); #include <signal.h>
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include "blackmisc/math/mathutils.h"
|
#include "blackmisc/math/mathutils.h"
|
||||||
#include "blackmisc/logmessage.h"
|
#include "blackmisc/logmessage.h"
|
||||||
#include "blackmisc/statusmessage.h"
|
#include "blackmisc/statusmessage.h"
|
||||||
|
#include "blackconfig/buildconfig.h"
|
||||||
|
|
||||||
#include "ui_internalscomponent.h"
|
#include "ui_internalscomponent.h"
|
||||||
|
|
||||||
@@ -39,6 +40,7 @@
|
|||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
using namespace BlackConfig;
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
using namespace BlackMisc::Aviation;
|
using namespace BlackMisc::Aviation;
|
||||||
using namespace BlackMisc::Network;
|
using namespace BlackMisc::Network;
|
||||||
@@ -331,7 +333,13 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CInternalsComponent::simulateCrash()
|
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; }
|
if (reply != QMessageBox::Yes) { return; }
|
||||||
sGui->simulateCrash();
|
sGui->simulateCrash();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,10 +77,16 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCrashInfo::triggerWritingFile()
|
void CCrashInfo::triggerWritingFile() const
|
||||||
{
|
{
|
||||||
if (m_logFileAndPath.isEmpty()) { return; }
|
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
|
QString CCrashInfo::summary() const
|
||||||
|
|||||||
@@ -79,8 +79,11 @@ namespace BlackMisc
|
|||||||
//! \copydoc BlackMisc::Mixin::Index::comparePropertyByIndex
|
//! \copydoc BlackMisc::Mixin::Index::comparePropertyByIndex
|
||||||
int comparePropertyByIndex(const CPropertyIndex &index, const CCrashInfo &compareValue) const;
|
int comparePropertyByIndex(const CPropertyIndex &index, const CCrashInfo &compareValue) const;
|
||||||
|
|
||||||
//! Trigger writing this to file
|
//! Trigger writing this to file (in background)
|
||||||
void triggerWritingFile();
|
void triggerWritingFile() const;
|
||||||
|
|
||||||
|
//! Write to file (synchronous)
|
||||||
|
bool writeToFile() const;
|
||||||
|
|
||||||
//! Summary
|
//! Summary
|
||||||
QString summary() const;
|
QString summary() const;
|
||||||
|
|||||||
@@ -378,7 +378,7 @@ namespace BlackMisc
|
|||||||
|
|
||||||
QString getDocumentationDirectoryImpl()
|
QString getDocumentationDirectoryImpl()
|
||||||
{
|
{
|
||||||
QStringList pathes(QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation));
|
const QStringList pathes(QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation));
|
||||||
QString d = pathes.first();
|
QString d = pathes.first();
|
||||||
d = QDir::cleanPath(d + QDir::separator() + "swift");
|
d = QDir::cleanPath(d + QDir::separator() + "swift");
|
||||||
QDir dir(d);
|
QDir dir(d);
|
||||||
@@ -398,6 +398,18 @@ namespace BlackMisc
|
|||||||
return p;
|
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)
|
QString CDirectoryUtils::decodeNormalizedDirectory(const QString &directory)
|
||||||
{
|
{
|
||||||
return QUrl::fromPercentEncoding(directory.toUtf8());
|
return QUrl::fromPercentEncoding(directory.toUtf8());
|
||||||
|
|||||||
@@ -139,6 +139,12 @@ namespace BlackMisc
|
|||||||
//! Directory for crashpad files
|
//! Directory for crashpad files
|
||||||
static const QString &crashpadDirectory();
|
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
|
//! Virtually the inverse operation of CDirectoryUtils::normalizedApplicationDirectory
|
||||||
static QString decodeNormalizedDirectory(const QString &directory);
|
static QString decodeNormalizedDirectory(const QString &directory);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user