Merge pull request #16265 from Atlante45/feat/shutdown-annotation

DEV-2223: Add shutdown annotations for crash reporting
This commit is contained in:
Shannon Romano 2019-09-30 16:38:23 -07:00 committed by GitHub
commit 2896cde447
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 66 additions and 2 deletions

View file

@ -22,6 +22,7 @@
#include <AccountManager.h>
#include <AddressManager.h>
#include <Assignment.h>
#include <CrashAnnotations.h>
#include <LogHandler.h>
#include <LogUtils.h>
#include <LimitedNodeList.h>
@ -144,6 +145,7 @@ AssignmentClient::~AssignmentClient() {
}
void AssignmentClient::aboutToQuit() {
crash::annotations::setShutdownState(true);
stopAssignmentClient();
}
@ -173,6 +175,7 @@ void AssignmentClient::sendStatusPacketToACM() {
void AssignmentClient::sendAssignmentRequest() {
if (!_currentAssignment && !_isAssigned) {
crash::annotations::setShutdownState(false);
auto nodeList = DependencyManager::get<NodeList>();
@ -289,6 +292,8 @@ void AssignmentClient::handleAuthenticationRequest() {
}
void AssignmentClient::assignmentCompleted() {
crash::annotations::setShutdownState(true);
// we expect that to be here the previous assignment has completely cleaned up
assert(_currentAssignment.isNull());

View file

@ -32,6 +32,7 @@
#include <AccountManager.h>
#include <AssetClient.h>
#include <BuildInfo.h>
#include <CrashAnnotations.h>
#include <DependencyManager.h>
#include <HifiConfigVariantMap.h>
#include <HTTPConnection.h>
@ -185,6 +186,7 @@ DomainServer::DomainServer(int argc, char* argv[]) :
qDebug() << "[VERSION] BUILD_GLOBAL_SERVICES:" << BuildInfo::BUILD_GLOBAL_SERVICES;
qDebug() << "[VERSION] We will be using this name to find ICE servers:" << _iceServerAddr;
connect(this, &QCoreApplication::aboutToQuit, this, &DomainServer::aboutToQuit);
// make sure we have a fresh AccountManager instance
// (need this since domain-server can restart itself and maintain static variables)
@ -432,6 +434,10 @@ DomainServer::~DomainServer() {
DependencyManager::destroy<LimitedNodeList>();
}
void DomainServer::aboutToQuit() {
crash::annotations::setShutdownState(true);
}
void DomainServer::queuedQuit(QString quitMessage, int exitCode) {
if (!quitMessage.isEmpty()) {
qWarning() << qPrintable(quitMessage);

View file

@ -136,6 +136,8 @@ private slots:
void tokenGrantFinished();
void profileRequestFinished();
void aboutToQuit();
signals:
void iceServerChanged();
void userConnected();

View file

@ -15,9 +15,10 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include <BuildInfo.h>
#include <CrashAnnotations.h>
#include <LogHandler.h>
#include <SharedUtil.h>
#include <BuildInfo.h>
#include "DomainServer.h"
@ -32,6 +33,7 @@ int main(int argc, char* argv[]) {
// use a do-while to handle domain-server restart
do {
crash::annotations::setShutdownState(false);
DomainServer domainServer(argc, argv);
currentExitCode = domainServer.exec();
} while (currentExitCode == DomainServer::EXIT_CODE_REBOOT);
@ -39,4 +41,3 @@ int main(int argc, char* argv[]) {
qInfo() << "Quitting.";
return currentExitCode;
}

View file

@ -0,0 +1,27 @@
//
// CrashAnnotations.cpp
// libraries/shared/src
//
// Created by Clement Brisset on 9/26/19.
// Copyright 2019 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "SharedUtil.h"
// Global variables specifically tuned to work with ptrace module for crash collection
// Do not move/rename unless you update the ptrace module with it.
bool crash_annotation_isShuttingDown = false;
namespace crash {
namespace annotations {
void setShutdownState(bool isShuttingDown) {
crash_annotation_isShuttingDown = isShuttingDown;
}
};
};

View file

@ -0,0 +1,23 @@
//
// CrashAnnotations.h
// libraries/shared/src
//
// Created by Clement Brisset on 9/26/19.
// Copyright 2019 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hifi_CrashAnnotations_h
#define hifi_CrashAnnotations_h
namespace crash {
namespace annotations {
void setShutdownState(bool isShuttingDown);
};
};
#endif // hifi_CrashAnnotations_h