ATLAS Offline Software
Loading...
Searching...
No Matches
ValgrindSvc Class Reference

#include <ValgrindSvc.h>

Inheritance diagram for ValgrindSvc:
Collaboration diagram for ValgrindSvc:

Public Member Functions

 ValgrindSvc (const std::string &name, ISvcLocator *pSvcLocator)
 Constructor with parameters:
virtual ~ValgrindSvc ()
 Destructor:
virtual StatusCode initialize () override
 Gaudi Service Implementation.
virtual StatusCode finalize () override
virtual void handle (const Incident &incident) override
 incident service handle for Begin/EndEvent
virtual void callgrindStartInstrumentation () override
 Start callgrind instrumentation.
virtual void callgrindStopInstrumentation () override
 Stop callgrind instrumentation.
virtual void callgrindDumpStats (std::ostream &out) override
 Dump callgrind profiling stats.
virtual void callgrindToggleCollect () override
 Toggle callgrind event collection.
virtual void valgrindDoLeakCheck () override
 Do a leak check now.
virtual unsigned int profileCount () override
 Number of created callgrind profiles.

Private Attributes

std::vector< std::string > m_algs
 List of algorithms to profile If list is empty, profile between begin/end event.
std::vector< std::string > m_intervals
 List of auditor intervals to profile Syntax: "MessageSvc.initialize:MessageSvc.finalize".
bool m_dumpAfterEachEvent
 Dump separate profile after each event.
bool m_dumpAfterEachInterval
 Dump separate profile after each interval.
unsigned int m_ignoreFirstNEvents
 Don't profile on the first N events.
std::vector< std::string > m_dumpAfterIncident
 List of incidents on which to create a profile dump.
unsigned int m_eventCounter
 Internal event counter for BeginEvent incident.
unsigned int m_profileCounter
 Counter of created profiles.

Detailed Description

Definition at line 29 of file ValgrindSvc.h.

Constructor & Destructor Documentation

◆ ValgrindSvc()

ValgrindSvc::ValgrindSvc ( const std::string & name,
ISvcLocator * pSvcLocator )

Constructor with parameters:

Definition at line 35 of file ValgrindSvc.cxx.

36 :
37 base_class(name, pSvcLocator),
40{
41 //
42 // Property declaration
43 //
44 declareProperty( "ProfiledAlgs", m_algs,
45 "List of profiled algorithms" );
46
47 declareProperty( "ProfiledIntervals", m_intervals,
48 "Intervals to profile (e.g. 'MyAlg.initialize:MyAlg.finalize'" );
49
50 declareProperty( "DumpAfterEachEvent", m_dumpAfterEachEvent = false,
51 "Dump separate profile after each event" );
52
53 declareProperty( "DumpAfterEachInterval", m_dumpAfterEachInterval = true,
54 "Dump separate profile after each interval in ProfiledIntervals" );
55
56 declareProperty( "DumpAfterIncident", m_dumpAfterIncident,
57 "List of incidents on which to dump a profile");
58
59 declareProperty( "IgnoreFirstNEvents", m_ignoreFirstNEvents = 0,
60 "Do not profile the first N events");
61}
std::vector< std::string > m_intervals
List of auditor intervals to profile Syntax: "MessageSvc.initialize:MessageSvc.finalize".
Definition ValgrindSvc.h:83
bool m_dumpAfterEachInterval
Dump separate profile after each interval.
Definition ValgrindSvc.h:89
std::vector< std::string > m_dumpAfterIncident
List of incidents on which to create a profile dump.
Definition ValgrindSvc.h:95
bool m_dumpAfterEachEvent
Dump separate profile after each event.
Definition ValgrindSvc.h:86
unsigned int m_eventCounter
Internal event counter for BeginEvent incident.
Definition ValgrindSvc.h:98
std::vector< std::string > m_algs
List of algorithms to profile If list is empty, profile between begin/end event.
Definition ValgrindSvc.h:79
unsigned int m_ignoreFirstNEvents
Don't profile on the first N events.
Definition ValgrindSvc.h:92
unsigned int m_profileCounter
Counter of created profiles.

◆ ~ValgrindSvc()

ValgrindSvc::~ValgrindSvc ( )
virtual

Destructor:

Definition at line 65 of file ValgrindSvc.cxx.

66{}

Member Function Documentation

◆ callgrindDumpStats()

void ValgrindSvc::callgrindDumpStats ( std::ostream & out)
overridevirtual

Dump callgrind profiling stats.

Definition at line 183 of file ValgrindSvc.cxx.

184{
185 CALLGRIND_DUMP_STATS;
187}

◆ callgrindStartInstrumentation()

void ValgrindSvc::callgrindStartInstrumentation ( )
overridevirtual

Start callgrind instrumentation.

Definition at line 168 of file ValgrindSvc.cxx.

169{
170 CALLGRIND_START_INSTRUMENTATION;
171}

◆ callgrindStopInstrumentation()

void ValgrindSvc::callgrindStopInstrumentation ( )
overridevirtual

Stop callgrind instrumentation.

Definition at line 173 of file ValgrindSvc.cxx.

174{
175 CALLGRIND_STOP_INSTRUMENTATION;
176}

◆ callgrindToggleCollect()

void ValgrindSvc::callgrindToggleCollect ( )
overridevirtual

Toggle callgrind event collection.

Definition at line 178 of file ValgrindSvc.cxx.

179{
180 CALLGRIND_TOGGLE_COLLECT;
181}

◆ finalize()

StatusCode ValgrindSvc::finalize ( )
overridevirtual

Definition at line 103 of file ValgrindSvc.cxx.

104{
105 ATH_MSG_INFO ("Finalizing " << name() << "...");
106 return StatusCode::SUCCESS;
107}
#define ATH_MSG_INFO(x)

◆ handle()

void ValgrindSvc::handle ( const Incident & incident)
overridevirtual

incident service handle for Begin/EndEvent

Definition at line 117 of file ValgrindSvc.cxx.

118{
119 // Only use Begin/EndEvent incident if no profiled algorithm or interval is set
120 bool useEventIncident = m_intervals.empty() && m_algs.empty();
121
122 // BeginEvent
123 if ( inc.type() == IncidentType::BeginEvent ) {
125 if ( useEventIncident && m_eventCounter > m_ignoreFirstNEvents) {
126 ATH_MSG_DEBUG ("[BeginEvent] Callgrind instrumentation ON.");
128 }
129 }
130
131 // EndEvent
132 if ( inc.type() == IncidentType::EndEvent && (m_eventCounter > m_ignoreFirstNEvents) ) {
133 if ( useEventIncident ) {
135 ATH_MSG_DEBUG ("[EndEvent] Callgrind instrumentation OFF.");
136 }
137 if ( !m_algs.empty() && m_dumpAfterEachEvent ) {
139 ATH_MSG_INFO ("Creating callgrind profile #" << profileCount()
140 << " for event #" << m_eventCounter);
141 }
142 }
143
144 // Optional additional dumps for user specified incidents
145 if ( std::find(m_dumpAfterIncident.begin(),
147 inc.type()) != m_dumpAfterIncident.end() ) {
149 ATH_MSG_INFO (" Creating callgrind profile #" << profileCount()
150 << " after incident [" << inc.type() << "].");
151 }
152
153}
#define ATH_MSG_DEBUG(x)
virtual void callgrindDumpStats(std::ostream &out) override
Dump callgrind profiling stats.
virtual void callgrindStopInstrumentation() override
Stop callgrind instrumentation.
virtual void callgrindStartInstrumentation() override
Start callgrind instrumentation.
virtual unsigned int profileCount() override
Number of created callgrind profiles.
Definition ValgrindSvc.h:69
MsgStream & msg
Definition testRead.cxx:32

◆ initialize()

StatusCode ValgrindSvc::initialize ( )
overridevirtual

Gaudi Service Implementation.

Definition at line 70 of file ValgrindSvc.cxx.

71{
72 ATH_MSG_DEBUG ("Initializing " << name());
73
74 ATH_MSG_INFO ("My process ID is [" << System::procID() << "]");
75
76 const bool insideValgrind = static_cast<bool>(RUNNING_ON_VALGRIND);
77 if ( insideValgrind ) {
78 ATH_MSG_INFO ("=== Running from inside Valgrind ! Hi there! ===");
79 }
80 else {
81 ATH_MSG_WARNING ("=== Valgrind is not running! ===");
82 }
83
84 // Use incidents in case there is no auditor configured
85 if (!m_algs.empty() || !m_intervals.empty()) {
86 ATH_CHECK( auditorSvc()->addAuditor("ValgrindAuditor") );
87 }
88
89 // Register incidents
90 ServiceHandle<IIncidentSvc> incSvc("IncidentSvc", this->name());
91 ATH_CHECK(incSvc.retrieve());
92 incSvc->addListener( this, IncidentType::BeginEvent );
93 incSvc->addListener( this, IncidentType::EndEvent );
94
95 for(const std::string& incident : m_dumpAfterIncident) {
96 incSvc->addListener( this, incident );
97 }
98
99 return StatusCode::SUCCESS;
100
101}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)

◆ profileCount()

virtual unsigned int ValgrindSvc::profileCount ( )
inlineoverridevirtual

Number of created callgrind profiles.

Definition at line 69 of file ValgrindSvc.h.

69{ return m_profileCounter; }

◆ valgrindDoLeakCheck()

void ValgrindSvc::valgrindDoLeakCheck ( )
overridevirtual

Do a leak check now.

Definition at line 189 of file ValgrindSvc.cxx.

190{
191 VALGRIND_DO_LEAK_CHECK;
192}

Member Data Documentation

◆ m_algs

std::vector<std::string> ValgrindSvc::m_algs
private

List of algorithms to profile If list is empty, profile between begin/end event.

Definition at line 79 of file ValgrindSvc.h.

◆ m_dumpAfterEachEvent

bool ValgrindSvc::m_dumpAfterEachEvent
private

Dump separate profile after each event.

Definition at line 86 of file ValgrindSvc.h.

◆ m_dumpAfterEachInterval

bool ValgrindSvc::m_dumpAfterEachInterval
private

Dump separate profile after each interval.

Definition at line 89 of file ValgrindSvc.h.

◆ m_dumpAfterIncident

std::vector<std::string> ValgrindSvc::m_dumpAfterIncident
private

List of incidents on which to create a profile dump.

Definition at line 95 of file ValgrindSvc.h.

◆ m_eventCounter

unsigned int ValgrindSvc::m_eventCounter
private

Internal event counter for BeginEvent incident.

Definition at line 98 of file ValgrindSvc.h.

◆ m_ignoreFirstNEvents

unsigned int ValgrindSvc::m_ignoreFirstNEvents
private

Don't profile on the first N events.

Definition at line 92 of file ValgrindSvc.h.

◆ m_intervals

std::vector<std::string> ValgrindSvc::m_intervals
private

List of auditor intervals to profile Syntax: "MessageSvc.initialize:MessageSvc.finalize".

Definition at line 83 of file ValgrindSvc.h.

◆ m_profileCounter

unsigned int ValgrindSvc::m_profileCounter
private

Counter of created profiles.

Definition at line 101 of file ValgrindSvc.h.


The documentation for this class was generated from the following files: