mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-06 14:00:16 +02:00
Telemetry: Save on signal terminate
When a signal handler is not installed and is a terminal failure, make sure to save telemetry before faulting. We know when an application is going down in this case so we can make sure to have the telemetry data saved. Adds a telemetry signal mask data point as well to know which signal took it down.
This commit is contained in:
1 parent
de0f3984e9
commit
45d3b83143
7 files changed
+24
-9
No files matched your search
+1
@@ -23,6 +23,7 @@ namespace FEXCore::Telemetry {
|
||||
"32bit CAS Tear",
|
||||
"64bit CAS Tear",
|
||||
"128bit CAS Tear",
|
||||
"Crash mask",
|
||||
};
|
||||
void Initialize() {
|
||||
auto DataDirectory = Config::GetDataDirectory();
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace FEXCore::Telemetry {
|
||||
TYPE_CAS_32BIT_TEAR,
|
||||
TYPE_CAS_64BIT_TEAR,
|
||||
TYPE_CAS_128BIT_TEAR,
|
||||
TYPE_CRASH_MASK,
|
||||
TYPE_LAST,
|
||||
};
|
||||
|
||||
|
||||
@@ -472,7 +472,7 @@ int main(int argc, char **argv, char **const envp) {
|
||||
// Setup TSO hardware emulation immediately after initializing the context.
|
||||
FEX::TSO::SetupTSOEmulation(CTX.get());
|
||||
|
||||
auto SignalDelegation = FEX::HLE::CreateSignalDelegator(CTX.get());
|
||||
auto SignalDelegation = FEX::HLE::CreateSignalDelegator(CTX.get(), Program.ProgramName);
|
||||
|
||||
auto SyscallHandler = Loader.Is64BitMode() ? FEX::HLE::x64::CreateHandler(CTX.get(), SignalDelegation.get())
|
||||
: FEX::HLE::x32::CreateHandler(CTX.get(), SignalDelegation.get(), std::move(Allocator));
|
||||
|
||||
@@ -187,7 +187,7 @@ int main(int argc, char **argv, char **const envp)
|
||||
auto CTX = FEXCore::Context::Context::CreateNewContext();
|
||||
CTX->InitializeContext();
|
||||
|
||||
auto SignalDelegation = FEX::HLE::CreateSignalDelegator(CTX.get());
|
||||
auto SignalDelegation = FEX::HLE::CreateSignalDelegator(CTX.get(), {});
|
||||
|
||||
CTX->SetSignalDelegator(SignalDelegation.get());
|
||||
CTX->SetSyscallHandler(new DummySyscallHandler());
|
||||
|
||||
@@ -1440,6 +1440,15 @@ namespace FEX::HLE {
|
||||
else if (Handler.OldAction.handler == SIG_DFL &&
|
||||
(Handler.DefaultBehaviour == DEFAULT_COREDUMP ||
|
||||
Handler.DefaultBehaviour == DEFAULT_TERM)) {
|
||||
|
||||
// In the case of signals that cause coredump or terminate, save telemetry early.
|
||||
// FEX is hard crashing at this point and won't hit regular shutdown routines.
|
||||
// Add the signal to the crash mask.
|
||||
CrashMask |= (1ULL << Signal);
|
||||
if (!ApplicationName.empty()) {
|
||||
FEXCore::Telemetry::Shutdown(ApplicationName);
|
||||
}
|
||||
|
||||
// Reassign back to DFL and crash
|
||||
signal(Signal, SIG_DFL);
|
||||
if (SigInfo->si_code != SI_KERNEL) {
|
||||
@@ -1550,8 +1559,9 @@ namespace FEX::HLE {
|
||||
::syscall(SYS_rt_sigaction, Signal, &SignalHandler.OldAction, nullptr, 8);
|
||||
}
|
||||
|
||||
SignalDelegator::SignalDelegator(FEXCore::Context::Context *_CTX)
|
||||
: CTX {_CTX} {
|
||||
SignalDelegator::SignalDelegator(FEXCore::Context::Context *_CTX, const std::string_view ApplicationName)
|
||||
: CTX {_CTX}
|
||||
, ApplicationName {ApplicationName} {
|
||||
// Register this delegate
|
||||
LOGMAN_THROW_AA_FMT(!GlobalDelegator, "Can't register global delegator multiple times!");
|
||||
GlobalDelegator = this;
|
||||
@@ -2020,7 +2030,7 @@ namespace FEX::HLE {
|
||||
return Result == -1 ? -errno : Result;
|
||||
}
|
||||
|
||||
fextl::unique_ptr<FEX::HLE::SignalDelegator> CreateSignalDelegator(FEXCore::Context::Context *CTX) {
|
||||
return fextl::make_unique<FEX::HLE::SignalDelegator>(CTX);
|
||||
fextl::unique_ptr<FEX::HLE::SignalDelegator> CreateSignalDelegator(FEXCore::Context::Context *CTX, const std::string_view ApplicationName) {
|
||||
return fextl::make_unique<FEX::HLE::SignalDelegator>(CTX, ApplicationName);
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ $end_info$
|
||||
#include <mutex>
|
||||
|
||||
#include <FEXCore/Core/SignalDelegator.h>
|
||||
#include <FEXCore/Utils/Telemetry.h>
|
||||
|
||||
namespace FEXCore {
|
||||
namespace Context {
|
||||
@@ -40,7 +41,7 @@ namespace FEX::HLE {
|
||||
public:
|
||||
// Returns true if the host handled the signal
|
||||
// Arguments are the same as sigaction handler
|
||||
SignalDelegator(FEXCore::Context::Context *_CTX);
|
||||
SignalDelegator(FEXCore::Context::Context *_CTX, const std::string_view ApplicationName);
|
||||
~SignalDelegator() override;
|
||||
|
||||
/**
|
||||
@@ -118,6 +119,8 @@ namespace FEX::HLE {
|
||||
private:
|
||||
FEX_CONFIG_OPT(Is64BitMode, IS64BIT_MODE);
|
||||
FEX_CONFIG_OPT(Core, CORE);
|
||||
fextl::string const ApplicationName;
|
||||
FEXCORE_TELEMETRY_INIT(CrashMask, TYPE_CRASH_MASK);
|
||||
|
||||
enum DefaultBehaviour {
|
||||
DEFAULT_TERM,
|
||||
@@ -231,5 +234,5 @@ namespace FEX::HLE {
|
||||
std::mutex GuestDelegatorMutex;
|
||||
};
|
||||
|
||||
fextl::unique_ptr<FEX::HLE::SignalDelegator> CreateSignalDelegator(FEXCore::Context::Context *CTX);
|
||||
fextl::unique_ptr<FEX::HLE::SignalDelegator> CreateSignalDelegator(FEXCore::Context::Context *CTX, const std::string_view ApplicationName);
|
||||
}
|
||||
@@ -256,7 +256,7 @@ int main(int argc, char **argv, char **const envp) {
|
||||
CTX->InitializeContext();
|
||||
|
||||
#ifndef _WIN32
|
||||
auto SignalDelegation = FEX::HLE::CreateSignalDelegator(CTX.get());
|
||||
auto SignalDelegation = FEX::HLE::CreateSignalDelegator(CTX.get(), {});
|
||||
#else
|
||||
// Enable exit on HLT while Wine's longjump is broken.
|
||||
//
|
||||
|
||||
Reference in new issue
Block a user