mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 07:15:35 +08:00
refs #935, added cmdline args for crashpad server
This commit is contained in:
committed by
Mathew Sutcliffe
parent
6c76e0fea6
commit
864fa88c65
@@ -63,6 +63,7 @@
|
||||
#include "crashpad/client/crashpad_client.h"
|
||||
#include "crashpad/client/crash_report_database.h"
|
||||
#include "crashpad/client/settings.h"
|
||||
#include "crashpad/client/simulate_crash.h"
|
||||
#endif
|
||||
|
||||
using namespace BlackConfig;
|
||||
@@ -311,7 +312,7 @@ namespace BlackCore
|
||||
do
|
||||
{
|
||||
// clear cache?
|
||||
if (this->isSetOrTrue(this->m_cmdClearCache))
|
||||
if (this->isSet(this->m_cmdClearCache))
|
||||
{
|
||||
const QStringList files(CApplication::clearCaches());
|
||||
msgs.push_back(
|
||||
@@ -319,6 +320,20 @@ namespace BlackCore
|
||||
);
|
||||
}
|
||||
|
||||
// crashpad dump
|
||||
if (this->isSet(this->m_cmdTestCrashpad))
|
||||
{
|
||||
QTimer::singleShot(10 * 1000, [ = ]
|
||||
{
|
||||
#ifdef BLACK_USE_CRASHPAD
|
||||
CRASHPAD_SIMULATE_CRASH();
|
||||
#else
|
||||
CLogMessage(this).warning("This compiler or platform does not support crashpad. Cannot simulate crash dump!");
|
||||
#endif
|
||||
});
|
||||
}
|
||||
|
||||
// load setup
|
||||
if (this->m_startSetupReader && !this->m_setupReader->isSetupAvailable())
|
||||
{
|
||||
msgs = this->requestReloadOfSetupAndVersion();
|
||||
@@ -459,11 +474,8 @@ namespace BlackCore
|
||||
{
|
||||
if (!CBuildConfig::canRunInDeveloperEnvironment()) { return false; }
|
||||
if (this->m_unitTest) { return true; }
|
||||
if (this->m_parser.isSet(this->m_cmdDevelopment))
|
||||
{
|
||||
return this->isSetOrTrue(this->m_cmdDevelopment);
|
||||
}
|
||||
else if (this->isSetupAvailable())
|
||||
if (this->isSet(this->m_cmdDevelopment)) { return true; }
|
||||
if (this->isSetupAvailable())
|
||||
{
|
||||
// assume value from setup
|
||||
return this->getGlobalSetup().isDevelopment();
|
||||
@@ -722,11 +734,10 @@ namespace BlackCore
|
||||
|
||||
// dev. system
|
||||
this->m_cmdDevelopment = QCommandLineOption({ "dev", "development" },
|
||||
QCoreApplication::translate("application", "Dev. system features?"),
|
||||
"development");
|
||||
QCoreApplication::translate("application", "Dev. system features?"));
|
||||
this->addParserOption(this->m_cmdDevelopment);
|
||||
|
||||
// can read a local bootsrap file
|
||||
// can read a local bootstrap file
|
||||
this->m_cmdSharedDir = QCommandLineOption({ "shared", "shareddir" },
|
||||
QCoreApplication::translate("application", "Local shared directory."),
|
||||
"shared");
|
||||
@@ -734,20 +745,18 @@ namespace BlackCore
|
||||
|
||||
// reset caches upfront
|
||||
this->m_cmdClearCache = QCommandLineOption({ "ccache", "clearcache" },
|
||||
QCoreApplication::translate("application", "Clear (reset) the caches."),
|
||||
"clearcache");
|
||||
QCoreApplication::translate("application", "Clear (reset) the caches."));
|
||||
this->addParserOption(this->m_cmdClearCache);
|
||||
|
||||
// test crashpad upload
|
||||
this->m_cmdTestCrashpad = QCommandLineOption({ "testcp", "testcrashpad" },
|
||||
QCoreApplication::translate("application", "Simulate crashpad situation."));
|
||||
this->addParserOption(this->m_cmdTestCrashpad);
|
||||
}
|
||||
|
||||
bool CApplication::isSetOrTrue(const QCommandLineOption &option) const
|
||||
bool CApplication::isSet(const QCommandLineOption &option) const
|
||||
{
|
||||
if (!this->m_parser.isSet(option)) { return false; }
|
||||
|
||||
// explicit value
|
||||
const QString v(this->m_parser.value(option).trimmed());
|
||||
if (v.isEmpty()) { return true; } // just flag
|
||||
if (v.startsWith("-")) { return true; } // just flag, because value is already next parameter
|
||||
return stringToBool(v);
|
||||
return (this->m_parser.isSet(option));
|
||||
}
|
||||
|
||||
void CApplication::registerMetadata()
|
||||
|
||||
@@ -424,7 +424,7 @@ namespace BlackCore
|
||||
virtual BlackMisc::CStatusMessageList startHookIn() { return BlackMisc::CStatusMessageList(); }
|
||||
|
||||
//! Flag set or explicitly set to true
|
||||
bool isSetOrTrue(const QCommandLineOption &option) const;
|
||||
bool isSet(const QCommandLineOption &option) const;
|
||||
|
||||
//! Severe issue during startup, most likely it does not make sense to continue
|
||||
//! \note call this here if the parsing stage is over and reaction to a runtime issue is needed
|
||||
@@ -445,18 +445,19 @@ namespace BlackCore
|
||||
static void registerMetadata();
|
||||
|
||||
// cmd parsing
|
||||
QCommandLineParser m_parser; //!< cmd parser
|
||||
QCommandLineOption m_cmdHelp {"help"}; //!< help option
|
||||
QCommandLineOption m_cmdVersion {"version"}; //!< version option
|
||||
QCommandLineOption m_cmdDBusAddress {"empty"}; //!< DBus address
|
||||
QCommandLineOption m_cmdDevelopment {"dev"}; //!< Development flag
|
||||
QCommandLineOption m_cmdSharedDir {"shared"}; //!< Shared directory
|
||||
QCommandLineOption m_cmdClearCache {"clearcache"}; //!< Clear cache
|
||||
bool m_parsed = false; //!< Parsing accomplished?
|
||||
bool m_started = false; //!< started with success?
|
||||
bool m_startSetupReader = false; //!< start the setup reader
|
||||
bool m_singleApplication = true; //!< only one instance of that application
|
||||
bool m_alreadyRunning = false; //!< Application already running
|
||||
QCommandLineParser m_parser; //!< cmd parser
|
||||
QCommandLineOption m_cmdHelp {"help"}; //!< help option
|
||||
QCommandLineOption m_cmdVersion {"version"}; //!< version option
|
||||
QCommandLineOption m_cmdDBusAddress {"empty"}; //!< DBus address
|
||||
QCommandLineOption m_cmdDevelopment {"dev"}; //!< Development flag
|
||||
QCommandLineOption m_cmdSharedDir {"shared"}; //!< Shared directory
|
||||
QCommandLineOption m_cmdClearCache {"clearcache"}; //!< Clear cache
|
||||
QCommandLineOption m_cmdTestCrashpad {"testcrashpad"}; //!< Test a crasphpad upload
|
||||
bool m_parsed = false; //!< Parsing accomplished?
|
||||
bool m_started = false; //!< started with success?
|
||||
bool m_startSetupReader = false; //!< start the setup reader
|
||||
bool m_singleApplication = true; //!< only one instance of that application
|
||||
bool m_alreadyRunning = false; //!< Application already running
|
||||
|
||||
private:
|
||||
//! init logging system
|
||||
|
||||
Reference in New Issue
Block a user