Add crash reporting to assignment client

This commit is contained in:
Dale Glass 2023-06-27 00:08:04 +02:00
parent 2cfac3a896
commit e7fb5049ec
3 changed files with 29 additions and 2 deletions

View file

@ -19,10 +19,13 @@ link_hifi_libraries(
audio avatars octree gpu graphics shaders model-serializers hfm entities
networking animation recording shared script-engine embedded-webserver
controllers physics plugins midi image
material-networking model-networking ktx shaders
material-networking model-networking ktx shaders monitoring
)
include_hifi_library_headers(procedural)
add_crashpad()
target_breakpad()
if (BUILD_TOOLS)
add_dependencies(${TARGET_NAME} oven)

View file

@ -24,6 +24,8 @@
#include <SharedUtil.h>
#include <ShutdownEventListener.h>
#include <shared/ScriptInitializerMixin.h>
#include <crash-handler/CrashHandler.h>
#include "Assignment.h"
#include "AssignmentClient.h"
@ -106,6 +108,9 @@ AssignmentClientApp::AssignmentClientApp(int argc, char* argv[]) :
const QCommandLineOption logOption("logOptions", "Logging options, comma separated: color,nocolor,process_id,thread_id,milliseconds,keep_repeats,journald,nojournald", "options");
parser.addOption(logOption);
const QCommandLineOption forceCrashReportingOption("forceCrashReporting", "Force crash reporting to initialize.");
parser.addOption(forceCrashReportingOption);
if (!parser.parse(QCoreApplication::arguments())) {
std::cout << parser.errorText().toStdString() << std::endl; // Avoid Qt log spam
parser.showHelp();
@ -174,6 +179,7 @@ AssignmentClientApp::AssignmentClientApp(int argc, char* argv[]) :
disableDomainPortAutoDiscovery = true;
}
Assignment::Type requestAssignmentType = Assignment::AllTypes;
if (argumentVariantMap.contains(ASSIGNMENT_TYPE_OVERRIDE_OPTION)) {
requestAssignmentType = (Assignment::Type) argumentVariantMap.value(ASSIGNMENT_TYPE_OVERRIDE_OPTION).toInt();
@ -182,6 +188,9 @@ AssignmentClientApp::AssignmentClientApp(int argc, char* argv[]) :
requestAssignmentType = (Assignment::Type) parser.value(clientTypeOption).toInt();
}
auto &ch = CrashHandler::getInstance();
ch.setAnnotation("type", QString::number(requestAssignmentType));
QString assignmentPool;
// check for an assignment pool passed on the command line or in the config
if (argumentVariantMap.contains(ASSIGNMENT_POOL_OPTION)) {
@ -247,6 +256,11 @@ AssignmentClientApp::AssignmentClientApp(int argc, char* argv[]) :
}
}
if (parser.isSet(forceCrashReportingOption)) {
auto &ch = CrashHandler::getInstance();
ch.setEnabled(true);
}
QThread::currentThread()->setObjectName("main thread");
LogHandler::getInstance().moveToThread(thread());

View file

@ -13,12 +13,22 @@
#include <SharedUtil.h>
#include "AssignmentClientApp.h"
#include <crash-handler/CrashHandler.h>
int main(int argc, char* argv[]) {
setupHifiApplication(BuildInfo::ASSIGNMENT_CLIENT_NAME);
auto &ch = CrashHandler::getInstance();
ch.start(argv[0]);
ch.setAnnotation("program", "assignment-client");
AssignmentClientApp app(argc, argv);
ch.startMonitor(&app);
int acReturn = app.exec();
qDebug() << "assignment-client process" << app.applicationPid() << "exiting with status code" << acReturn;