Commit b7737780 authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

CoreDumpSvc: Add StackTrace property

Add a boolean `StackTrace` property (default: `False`) that will create
a stack trace using ROOT's stack trace generator (usually invoking
`gdb`). This is useful for cases where there is no default signal handler
doing this, or if for some reason the signal handler is not usable
(ATR-20918). For a regular athena job this should not be necessary. If
used anyway, one should set `CallOlderHanlder = False` to avoid multiple
stack trace generations.
parent dd08934d
......@@ -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();
......
/*
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]"};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment