ATLAS Offline Software
Loading...
Searching...
No Matches
CoreDumpSvc.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef ATHENASERVICES_COREDUMPSVC_H
6#define ATHENASERVICES_COREDUMPSVC_H 1
7
8// System includes
9#include <signal.h>
10#include <string>
11#include <atomic>
12#include <tbb/concurrent_unordered_map.h>
13
14// Package includes
16
17// FrameWork includes
20#include "GaudiKernel/IIncidentListener.h"
21#include "EventInfo/EventID.h"
22
23
24namespace CoreDumpSvcHandler {
25 void action ATLAS_NOT_THREAD_SAFE ( int sig, siginfo_t *info, void* extra );
26}
27
40
41class CoreDumpSvc : public extends<AthService,
42 ICoreDumpSvc,
43 IIncidentListener> {
44
45protected:
46 friend void CoreDumpSvcHandler::action( int sig, siginfo_t *info, void* extra );
47
50
51public:
52
54 CoreDumpSvc( const std::string& name, ISvcLocator* pSvcLocator ) ATLAS_CTORDTOR_NOT_THREAD_SAFE;
55
58
60
61
62 virtual void setCoreDumpInfo( const std::string& name, const std::string& value ) override;
63
65 virtual void setCoreDumpInfo( const EventContext& ctx, const std::string& name, const std::string& value ) override;
66
68 virtual std::string dump() const override;
70
71
73
74 virtual StatusCode initialize ATLAS_NOT_THREAD_SAFE () override;
75 virtual StatusCode start() override;
76 virtual StatusCode finalize ATLAS_NOT_THREAD_SAFE () override;
77
79 virtual void handle( const Incident& incident ) override;
81
82
84 struct sysDumpRec{
85 std::string LastInc;
86 std::string EvId;
87 };
88 typedef tbb::concurrent_unordered_map<std::string,std::string > UserCore_t;
89 std::vector<UserCore_t> m_usrCoreDumps;
90 std::vector<sysDumpRec> m_sysCoreDumps;
91 siginfo_t* m_siginfo{nullptr};
92 std::atomic<EventID::event_number_t> m_eventCounter{0};
93
94 thread_local static std::vector<uint8_t> s_stack;
95
97
98 Gaudi::Property<std::vector<int>> m_signals{this, "Signals", {SIGSEGV,SIGBUS,SIGILL,SIGABRT,SIGFPE,SIGALRM},
99 "List of signals to catch"};
100
101 Gaudi::Property<bool> m_callOldHandler{this, "CallOldHandler", true,
102 "Call previous signal handler"};
103
104 Gaudi::Property<bool> m_dumpCoreFile{this, "DumpCoreFile", false,
105 "Produce a core dump file if resource limits (ulimit -c) allow"};
106
107 Gaudi::Property<bool> m_stackTrace{this, "StackTrace", false,
108 "Produce (gdb) stack trace on crash. Useful if no other signal handler is used"};
109
110 Gaudi::Property<bool> m_fastStackTrace{this, "FastStackTrace", false,
111 "Produce fast stack trace of current thread"};
112
113 Gaudi::Property<std::string> m_coreDumpStream{this, "CoreDumpStream", "stdout",
114 "Stream to use for core dump [stdout,stderr]"};
115
116 Gaudi::Property<int> m_fatalHandlerFlags{this, "FatalHandler", 0,
117 "Flags given to the fatal handler this service installs\n"
118 "if the flag is zero, no additional fatal handler is installed."};
119
120 Gaudi::Property<double> m_timeout{this, "TimeOut", 30.0*60*1e9,
121 "Terminate job after it this reaches the time out in Wallclock time, "
122 "usually due to hanging during stack unwinding. Timeout given in nanoseconds despite seconds precision"};
123
124 Gaudi::Property<bool> m_killOnSigInt{this, "KillOnSigInt",true, "Terminate job on SIGINT (aka Ctrl-C)"};
125
126
128
130 void propertyHandler ATLAS_NOT_THREAD_SAFE (Gaudi::Details::PropertyBase& p);
131
134
136 void setSigInfo(siginfo_t* info) { m_siginfo = info; }
137
139 StatusCode installSignalHandler ATLAS_NOT_THREAD_SAFE ();
140
142 StatusCode uninstallSignalHandler ATLAS_NOT_THREAD_SAFE ();
143
145 void setAltStack();
146};
147
148
149#endif
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Interface of a core dump service.
void print(char *figname, TCanvas *c1)
Define macros for attributes used to control the static checker.
#define ATLAS_CTORDTOR_NOT_THREAD_SAFE
StatusCode uninstallSignalHandler ATLAS_NOT_THREAD_SAFE()
Uninstall signal handlers.
siginfo_t * m_siginfo
Pointer to siginfo_t struct (set by signal handler)
Definition CoreDumpSvc.h:91
void setAltStack()
Set up an alternate stack for the current thread.
friend void CoreDumpSvcHandler::action(int sig, siginfo_t *info, void *extra)
virtual StatusCode start() override
Gaudi::Property< int > m_fatalHandlerFlags
std::vector< UserCore_t > m_usrCoreDumps
User defined core dump info.
Definition CoreDumpSvc.h:89
static thread_local std::vector< uint8_t > s_stack
Definition CoreDumpSvc.h:94
Gaudi::Property< bool > m_callOldHandler
Gaudi::Property< std::vector< int > > m_signals
Alternate stack for signal handler.
Definition CoreDumpSvc.h:98
void print ATLAS_NOT_THREAD_SAFE()
Print core dump records to configured stream.
Gaudi::Property< bool > m_stackTrace
void propertyHandler ATLAS_NOT_THREAD_SAFE(Gaudi::Details::PropertyBase &p)
Property handler.
StatusCode installSignalHandler ATLAS_NOT_THREAD_SAFE()
Install signal handlers.
void setSigInfo(siginfo_t *info)
Set pointer to siginfo_t struct.
virtual void handle(const Incident &incident) override
Incident listener.
virtual ~CoreDumpSvc() ATLAS_CTORDTOR_NOT_THREAD_SAFE
Destructor.
tbb::concurrent_unordered_map< std::string, std::string > UserCore_t
Definition CoreDumpSvc.h:88
virtual void setCoreDumpInfo(const std::string &name, const std::string &value) override
Set a name/value pair in the core dump record.
Gaudi::Property< bool > m_dumpCoreFile
Gaudi::Property< bool > m_killOnSigInt
CoreDumpSvc()
Default constructor (do not use)
virtual StatusCode initialize ATLAS_NOT_THREAD_SAFE() override
Gaudi::Property< double > m_timeout
Gaudi::Property< std::string > m_coreDumpStream
std::vector< sysDumpRec > m_sysCoreDumps
Core dump info collected by this service.
Definition CoreDumpSvc.h:90
std::atomic< EventID::event_number_t > m_eventCounter
Event counter.
Definition CoreDumpSvc.h:92
Gaudi::Property< bool > m_fastStackTrace
Signal handler for CoreDumpSvc.
std::ostream &log ATLAS_NOT_THREAD_SAFE()
convenience method for logging
-event-from-file
STL namespace.
void initialize()
#define private