diff --git a/Control/AthenaServices/src/CoreDumpSvc.cxx b/Control/AthenaServices/src/CoreDumpSvc.cxx index 6385819814510640f6832323a9934aac52ce741e..1c34b6744337a721ddb76fbcaffe4cfe8ff8e50b 100644 --- a/Control/AthenaServices/src/CoreDumpSvc.cxx +++ b/Control/AthenaServices/src/CoreDumpSvc.cxx @@ -28,6 +28,9 @@ #include "CoreDumpSvc.h" #include "SetFatalHandler.h" +// ROOT includes +#include "TSystem.h" + // Gaudi includes #include "GaudiKernel/Property.h" #include "GaudiKernel/IAlgorithm.h" @@ -59,9 +62,10 @@ namespace CoreDumpSvcHandler { typedef std::map<int, struct sigaction> SigHandler_t; - SigHandler_t oldSigHandler; ///< old signal handlers - bool callOldHandler(true); ///< forward calls to old handlers? - CoreDumpSvc* coreDumpSvc(nullptr); ///< pointer to CoreDumpSvc + SigHandler_t oldSigHandler; ///< old signal handlers + bool callOldHandler(true); ///< forward calls to old handlers? + bool stackTrace(false); ///< produce stack trace? + CoreDumpSvc* coreDumpSvc(nullptr); ///< pointer to CoreDumpSvc /** * Signal handler for the CoreDumpSvc @@ -93,6 +97,11 @@ namespace CoreDumpSvcHandler coreDumpSvc->print(); } + if (gSystem && stackTrace) { + std::cout << "Producing stack trace..." << std::endl; + gSystem->StackTrace(); + } + if (callOldHandler) { // Call previous signal handler // Need to distinguish between the two different types @@ -130,6 +139,7 @@ CoreDumpSvc::CoreDumpSvc( const std::string& name, ISvcLocator* pSvcLocator ) : CoreDumpSvcHandler::coreDumpSvc = this; m_callOldHandler.declareUpdateHandler(&CoreDumpSvc::propertyHandler, this); + m_stackTrace.declareUpdateHandler(&CoreDumpSvc::propertyHandler, this); m_coreDumpStream.declareUpdateHandler(&CoreDumpSvc::propertyHandler, this); m_fatalHandlerFlags.declareUpdateHandler(&CoreDumpSvc::propertyHandler, this); @@ -146,6 +156,7 @@ CoreDumpSvc::~CoreDumpSvc() void CoreDumpSvc::propertyHandler(Property& p) { CoreDumpSvcHandler::callOldHandler = m_callOldHandler; + CoreDumpSvcHandler::stackTrace = m_stackTrace; if ( p.name()==m_coreDumpStream.name() ) { const std::string val = p.toString(); diff --git a/Control/AthenaServices/src/CoreDumpSvc.h b/Control/AthenaServices/src/CoreDumpSvc.h index 6c5484c7809e6cb5ea030f997ff7792b9990e1b0..d57e1030466350498a6f1f11cfb1b9284da85554 100644 --- a/Control/AthenaServices/src/CoreDumpSvc.h +++ b/Control/AthenaServices/src/CoreDumpSvc.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef ATHENASERVICES_COREDUMPSVC_H @@ -102,9 +102,12 @@ private: Gaudi::Property<std::vector<int>> m_signals{this, "Signals", {SIGSEGV,SIGBUS,SIGILL,SIGFPE}, "List of signals to catch"}; - Gaudi::Property<bool> m_callOldHandler{this, "CallOldHandler", true, + Gaudi::Property<bool> m_callOldHandler{this, "CallOldHandler", true, "Call previous signal handler"}; + Gaudi::Property<bool> m_stackTrace{this, "StackTrace", false, + "Produce stack trace on crash. Useful if no other signal handler is used"}; + Gaudi::Property<std::string> m_coreDumpStream{this, "CoreDumpStream", "stdout", "Stream to use for core dump [stdout,stderr,MsgStream]"};