ATLAS Offline Software
ValgrindAuditor.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef VALKYRIE_VALGRINDAUDITOR_H
6 #define VALKYRIE_VALGRINDAUDITOR_H
7 
8 // STL/Boost includes
9 #include <string>
10 #include <vector>
11 #include <utility>
12 #include <boost/regex.hpp>
13 
14 // FrameWork includes
15 #include "GaudiKernel/Auditor.h"
16 #include "GaudiKernel/ServiceHandle.h"
17 #include "GaudiKernel/IIncidentListener.h"
18 #include "GAUDI_VERSION.h"
19 
20 // Forward declaration
21 class INamedInterface;
22 class IValgrindSvc;
23 
34 
35 class ValgrindAuditor : public Auditor,
36  virtual public IIncidentListener
37 {
38 public:
39  ValgrindAuditor(const std::string& name, ISvcLocator* pSvcLocator);
40  virtual ~ValgrindAuditor();
41 
42  virtual StatusCode initialize();
43 
45  virtual void handle( const Incident& incident );
46 
47 
49 
50  virtual void before (StandardEventType evt, const std::string& name);
51 
52  virtual void before (StandardEventType evt, INamedInterface* alg)
53  { if (alg) before(evt, alg->name()); }
54 
55  virtual void before (CustomEventTypeRef evt, INamedInterface* alg)
56  { if (alg) before(evt, alg->name()); }
57 
58  virtual void before (CustomEventTypeRef evt, const std::string& name)
59  { do_before(name, evt); }
61 
63 
64  virtual void after (StandardEventType evt, const std::string& name, const StatusCode& sc);
65 
66  virtual void after (StandardEventType evt, INamedInterface* alg, const StatusCode& sc)
67  { if (alg) after(evt, alg->name(), sc); }
68 
69  virtual void after (CustomEventTypeRef evt, INamedInterface* alg, const StatusCode& sc)
70  { if (alg) after(evt, alg->name(), sc); }
71 
72  virtual void after (CustomEventTypeRef evt, const std::string& name, const StatusCode&)
73  { do_after(name, evt); }
74 
76 
78  virtual void do_beforeExecute(const std::string& name);
79 
81  virtual void do_afterExecute(const std::string& name);
82 
83 public:
85  typedef std::pair<boost::regex,std::string> NameEvt;
86 
87 
88 private:
91 
93  std::vector<std::string> m_algs;
94 
96  std::vector<std::string> m_intervals;
97 
99  unsigned int m_ignoreFirstNEvents;
100 
103 
105  unsigned int m_eventCounter;
106 
108  std::vector<boost::regex> m_algsRegEx;
109 
111  std::vector< std::pair<NameEvt,NameEvt> > m_hooks;
112 
113  void do_before(const std::string& name, const std::string& hook);
114  void do_after(const std::string& name, const std::string& hook);
116 
117  bool algMatch(const std::string& name);
118 };
119 
120 #endif
ValgrindAuditor::decodeIntervals
StatusCode decodeIntervals()
Definition: ValgrindAuditor.cxx:287
ValgrindAuditor::after
virtual void after(CustomEventTypeRef evt, INamedInterface *alg, const StatusCode &sc)
Definition: ValgrindAuditor.h:69
SGout2dot.alg
alg
Definition: SGout2dot.py:243
ValgrindAuditor::before
virtual void before(StandardEventType evt, INamedInterface *alg)
Definition: ValgrindAuditor.h:52
ValgrindAuditor::after
virtual void after(StandardEventType evt, const std::string &name, const StatusCode &sc)
Definition: ValgrindAuditor.cxx:175
ValgrindAuditor::before
virtual void before(CustomEventTypeRef evt, const std::string &name)
Definition: ValgrindAuditor.h:58
ValgrindAuditor::m_algs
std::vector< std::string > m_algs
List of algorithms to profile.
Definition: ValgrindAuditor.h:93
ValgrindAuditor::after
virtual void after(StandardEventType evt, INamedInterface *alg, const StatusCode &sc)
Definition: ValgrindAuditor.h:66
ValgrindAuditor::handle
virtual void handle(const Incident &incident)
Incident handler.
Definition: ValgrindAuditor.cxx:146
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
ValgrindAuditor::m_algsRegEx
std::vector< boost::regex > m_algsRegEx
Regular expressions for algorithm name matching.
Definition: ValgrindAuditor.h:108
ValgrindAuditor::m_valSvc
ServiceHandle< IValgrindSvc > m_valSvc
Handle to ValgrindSvc.
Definition: ValgrindAuditor.h:90
ValgrindAuditor::m_ignoreFirstNEvents
unsigned int m_ignoreFirstNEvents
Don't profile on the first N events.
Definition: ValgrindAuditor.h:99
ValgrindAuditor::ValgrindAuditor
ValgrindAuditor(const std::string &name, ISvcLocator *pSvcLocator)
Definition: ValgrindAuditor.cxx:26
ValgrindAuditor::m_hooks
std::vector< std::pair< NameEvt, NameEvt > > m_hooks
Internal storage of intervals.
Definition: ValgrindAuditor.h:111
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
ValgrindAuditor::m_dumpAfterEachInterval
bool m_dumpAfterEachInterval
Dump profile after each interval.
Definition: ValgrindAuditor.h:102
ValgrindAuditor::NameEvt
std::pair< boost::regex, std::string > NameEvt
Typedef for algorithm/event pair, e.g. ("MyAlg","initialize")
Definition: ValgrindAuditor.h:85
ValgrindAuditor::m_eventCounter
unsigned int m_eventCounter
Internal event counter for BeginEvent incident.
Definition: ValgrindAuditor.h:105
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
IValgrindSvc
Abstract interface for ValgrindSvc.
Definition: IValgrindSvc.h:23
ValgrindAuditor::algMatch
bool algMatch(const std::string &name)
Definition: ValgrindAuditor.cxx:322
ValgrindAuditor::do_after
void do_after(const std::string &name, const std::string &hook)
Definition: ValgrindAuditor.cxx:240
ValgrindAuditor::do_before
void do_before(const std::string &name, const std::string &hook)
Definition: ValgrindAuditor.cxx:222
ValgrindAuditor
Valgrind auditor.
Definition: ValgrindAuditor.h:37
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
ValgrindAuditor::before
virtual void before(StandardEventType evt, const std::string &name)
Definition: ValgrindAuditor.cxx:165
ValgrindAuditor::m_intervals
std::vector< std::string > m_intervals
List of auditor intervals to profile.
Definition: ValgrindAuditor.h:96
ValgrindAuditor::before
virtual void before(CustomEventTypeRef evt, INamedInterface *alg)
Definition: ValgrindAuditor.h:55
ValgrindAuditor::after
virtual void after(CustomEventTypeRef evt, const std::string &name, const StatusCode &)
Definition: ValgrindAuditor.h:72
ValgrindAuditor::do_beforeExecute
virtual void do_beforeExecute(const std::string &name)
Start callgrind instrumentation.
Definition: ValgrindAuditor.cxx:189
ValgrindAuditor::initialize
virtual StatusCode initialize()
Definition: ValgrindAuditor.cxx:51
ValgrindAuditor::~ValgrindAuditor
virtual ~ValgrindAuditor()
Definition: ValgrindAuditor.cxx:46
ValgrindAuditor::do_afterExecute
virtual void do_afterExecute(const std::string &name)
Stop callgrind instrumentation.
Definition: ValgrindAuditor.cxx:206
ServiceHandle< IValgrindSvc >