From 276bb86fca388416428613dec981e4e5eb927081 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Sat, 21 Aug 2021 18:48:52 +0200 Subject: Improved crash reporting setup and removed old stubs Also added ability to exercise crash reporting from command line --- zenserver/config.cpp | 7 +++++++ zenserver/config.h | 1 + zenserver/diag/crashreport.cpp | 12 ------------ zenserver/diag/crashreport.h | 9 --------- zenserver/zenserver.cpp | 25 ++++++++++++++++++------- zenserver/zenserver.vcxproj | 2 -- zenserver/zenserver.vcxproj.filters | 2 -- 7 files changed, 26 insertions(+), 32 deletions(-) delete mode 100644 zenserver/diag/crashreport.cpp delete mode 100644 zenserver/diag/crashreport.h diff --git a/zenserver/config.cpp b/zenserver/config.cpp index 79433f20c..6d725e55b 100644 --- a/zenserver/config.cpp +++ b/zenserver/config.cpp @@ -88,6 +88,13 @@ ParseGlobalCliOptions(int argc, char* argv[], ZenServerOptions& GlobalOptions, Z cxxopts::value(ServiceConfig.MeshEnabled)->default_value("true"), ""); + options.add_option("diagnostics", + "", + "crash", + "Simulate a crash", + cxxopts::value(ServiceConfig.ShouldCrash)->default_value("false"), + ""); + try { auto result = options.parse(argc, argv); diff --git a/zenserver/config.h b/zenserver/config.h index e33b27962..53538314d 100644 --- a/zenserver/config.h +++ b/zenserver/config.h @@ -20,6 +20,7 @@ struct ZenServiceConfig { bool LegacyCacheEnabled = false; bool StructuredCacheEnabled = true; + bool ShouldCrash = false; // Option for testing crash handling bool MeshEnabled = false; // Experimental p2p mesh discovery std::string FlockId; // Id for grouping test instances into sets }; diff --git a/zenserver/diag/crashreport.cpp b/zenserver/diag/crashreport.cpp deleted file mode 100644 index b9b8b5020..000000000 --- a/zenserver/diag/crashreport.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright Epic Games, Inc. All Rights Reserved. - -#include "crashreport.h" - -#include -#include - -void -InitializeCrashReporting(const std::filesystem::path&) -{ - // TODO: properly implement crash reporting -} diff --git a/zenserver/diag/crashreport.h b/zenserver/diag/crashreport.h deleted file mode 100644 index 6369d1cf5..000000000 --- a/zenserver/diag/crashreport.h +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright Epic Games, Inc. All Rights Reserved. - -#pragma once - -namespace std::filesystem { -class path; -} - -void InitializeCrashReporting(const std::filesystem::path& DumpPath); diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp index 1d1711dfe..d9f72ed12 100644 --- a/zenserver/zenserver.cpp +++ b/zenserver/zenserver.cpp @@ -38,7 +38,6 @@ #include "casstore.h" #include "config.h" -#include "diag/crashreport.h" #include "diag/logging.h" #define SENTRY_BUILD_STATIC 1 @@ -74,6 +73,8 @@ public: using namespace fmt::literals; spdlog::info(ZEN_APP_NAME " initializing"); + m_DebugOptionForcedCrash = ServiceConfig.ShouldCrash; + if (ParentPid) { m_Process.Initialize(ParentPid); @@ -195,6 +196,13 @@ public: spdlog::info(ZEN_APP_NAME " now running"); + sentry_clear_modulecache(); + + if (m_DebugOptionForcedCrash) + { + __debugbreak(); + } + m_Http.Run(m_TestMode); spdlog::info(ZEN_APP_NAME " exiting"); @@ -288,6 +296,8 @@ private: HttpAdminService m_AdminService; HttpHealthService m_HealthService; zen::Mesh m_ZenMesh{m_IoContext}; + + bool m_DebugOptionForcedCrash = false; }; int @@ -295,18 +305,19 @@ main(int argc, char* argv[]) { mi_version(); + ZenServerOptions GlobalOptions; + ZenServiceConfig ServiceConfig; + ParseGlobalCliOptions(argc, argv, GlobalOptions, ServiceConfig); + InitializeLogging(GlobalOptions); + + // Initialize sentry.io client + sentry_options_t* SentryOptions = sentry_options_new(); sentry_options_set_dsn(SentryOptions, "https://8ba3441bebc941c1ae24b8cd2fd25d55@o10593.ingest.sentry.io/5919284"); sentry_init(SentryOptions); auto _ = zen::MakeGuard([&] { sentry_close(); }); - ZenServerOptions GlobalOptions; - ZenServiceConfig ServiceConfig; - ParseGlobalCliOptions(argc, argv, GlobalOptions, ServiceConfig); - InitializeCrashReporting(GlobalOptions.DataDir / "crashdumps"); - InitializeLogging(GlobalOptions); - // Prototype config system, let's see how this pans out ParseServiceConfig(GlobalOptions.DataDir, /* out */ ServiceConfig); diff --git a/zenserver/zenserver.vcxproj b/zenserver/zenserver.vcxproj index 89784300b..6c87b4a68 100644 --- a/zenserver/zenserver.vcxproj +++ b/zenserver/zenserver.vcxproj @@ -108,7 +108,6 @@ - @@ -130,7 +129,6 @@ - diff --git a/zenserver/zenserver.vcxproj.filters b/zenserver/zenserver.vcxproj.filters index 95cba466f..79fcfb803 100644 --- a/zenserver/zenserver.vcxproj.filters +++ b/zenserver/zenserver.vcxproj.filters @@ -35,7 +35,6 @@ - @@ -69,7 +68,6 @@ - -- cgit v1.2.3