Valgrind auditor.
More...
#include <ValgrindAuditor.h>
|
typedef std::pair< boost::regex, std::string > | NameEvt |
| Typedef for algorithm/event pair, e.g. ("MyAlg","initialize") More...
|
|
ServiceHandle< IValgrindSvc > | m_valSvc |
| Handle to ValgrindSvc. More...
|
|
std::vector< std::string > | m_algs |
| List of algorithms to profile. More...
|
|
std::vector< std::string > | m_intervals |
| List of auditor intervals to profile. More...
|
|
unsigned int | m_ignoreFirstNEvents |
| Don't profile on the first N events. More...
|
|
bool | m_dumpAfterEachInterval |
| Dump profile after each interval. More...
|
|
unsigned int | m_eventCounter |
| Internal event counter for BeginEvent incident. More...
|
|
std::vector< boost::regex > | m_algsRegEx |
| Regular expressions for algorithm name matching. More...
|
|
std::vector< std::pair< NameEvt, NameEvt > > | m_hooks |
| Internal storage of intervals. More...
|
|
virtual void | after (StandardEventType evt, const std::string &name, const StatusCode &sc) |
|
virtual void | after (StandardEventType evt, INamedInterface *alg, const StatusCode &sc) |
|
virtual void | after (CustomEventTypeRef evt, INamedInterface *alg, const StatusCode &sc) |
|
virtual void | after (CustomEventTypeRef evt, const std::string &name, const StatusCode &) |
|
virtual void | do_beforeExecute (const std::string &name) |
| Start callgrind instrumentation. More...
|
|
virtual void | do_afterExecute (const std::string &name) |
| Stop callgrind instrumentation. More...
|
|
void | do_before (const std::string &name, const std::string &hook) |
|
void | do_after (const std::string &name, const std::string &hook) |
|
StatusCode | decodeIntervals () |
|
bool | algMatch (const std::string &name) |
|
Valgrind auditor.
Gaudi auditor to programmatically control valgrind. Currently only callgrind controls are implemented. Turns callgrind instrumentation on/off before/afterExecute.
- Author
- Frank Winklmeier
- Id
- ValgrindAuditor.h,v 1.4 2008-10-14 12:31:40 fwinkl Exp
Definition at line 35 of file ValgrindAuditor.h.
◆ NameEvt
Typedef for algorithm/event pair, e.g. ("MyAlg","initialize")
Definition at line 85 of file ValgrindAuditor.h.
◆ ValgrindAuditor()
ValgrindAuditor::ValgrindAuditor |
( |
const std::string & |
name, |
|
|
ISvcLocator * |
pSvcLocator |
|
) |
| |
Definition at line 26 of file ValgrindAuditor.cxx.
28 : Auditor(
name, pSvcLocator),
32 declareProperty(
"ProfiledAlgs",
m_algs,
33 "List of algorithms to run in valgrind");
36 "Intervals to profile (e.g. 'MyAlg.initialize:MyAlg.finalize'" );
39 "Do not profile the first N events");
42 "Dump separate profile after each interval in ProfiledIntervals" );
◆ ~ValgrindAuditor()
ValgrindAuditor::~ValgrindAuditor |
( |
| ) |
|
|
virtual |
◆ after() [1/4]
virtual void ValgrindAuditor::after |
( |
CustomEventTypeRef |
evt, |
|
|
const std::string & |
name, |
|
|
const StatusCode & |
|
|
) |
| |
|
inlinevirtual |
◆ after() [2/4]
virtual void ValgrindAuditor::after |
( |
CustomEventTypeRef |
evt, |
|
|
INamedInterface * |
alg, |
|
|
const StatusCode & |
sc |
|
) |
| |
|
inlinevirtual |
◆ after() [3/4]
void ValgrindAuditor::after |
( |
StandardEventType |
evt, |
|
|
const std::string & |
name, |
|
|
const StatusCode & |
sc |
|
) |
| |
|
virtual |
◆ after() [4/4]
virtual void ValgrindAuditor::after |
( |
StandardEventType |
evt, |
|
|
INamedInterface * |
alg, |
|
|
const StatusCode & |
sc |
|
) |
| |
|
inlinevirtual |
◆ algMatch()
bool ValgrindAuditor::algMatch |
( |
const std::string & |
name | ) |
|
|
private |
Definition at line 322 of file ValgrindAuditor.cxx.
324 std::vector<boost::regex>::const_iterator iter;
326 if ( boost::regex_match(
name,*iter) )
return true;
◆ before() [1/4]
virtual void ValgrindAuditor::before |
( |
CustomEventTypeRef |
evt, |
|
|
const std::string & |
name |
|
) |
| |
|
inlinevirtual |
◆ before() [2/4]
virtual void ValgrindAuditor::before |
( |
CustomEventTypeRef |
evt, |
|
|
INamedInterface * |
alg |
|
) |
| |
|
inlinevirtual |
◆ before() [3/4]
void ValgrindAuditor::before |
( |
StandardEventType |
evt, |
|
|
const std::string & |
name |
|
) |
| |
|
virtual |
◆ before() [4/4]
virtual void ValgrindAuditor::before |
( |
StandardEventType |
evt, |
|
|
INamedInterface * |
alg |
|
) |
| |
|
inlinevirtual |
◆ decodeIntervals()
StatusCode ValgrindAuditor::decodeIntervals |
( |
| ) |
|
|
private |
Definition at line 287 of file ValgrindAuditor.cxx.
292 std::vector<string>::const_iterator iter =
m_intervals.begin();
294 const string&
spec = *iter;
295 string::size_type loc =
spec.find(
':');
299 if (loc==string::npos)
s1 =
s2 =
spec;
306 if (
s1==
"" ||
s2==
"" ||
307 decodeNameEvt(
s1,ne1).isFailure() || decodeNameEvt(
s2,ne2).isFailure() ) {
308 msgStream() << MSG::ERROR <<
"Invalid profiling interval [" <<
spec <<
"]" <<
endmsg;
309 return StatusCode::FAILURE;
312 std::pair<NameEvt,NameEvt>
p(ne1,ne2);
316 return StatusCode::SUCCESS;
◆ do_after()
void ValgrindAuditor::do_after |
( |
const std::string & |
name, |
|
|
const std::string & |
hook |
|
) |
| |
|
private |
Definition at line 240 of file ValgrindAuditor.cxx.
242 std::vector< std::pair<NameEvt,NameEvt> >::const_iterator iter;
245 if ( boost::regex_match(
name, iter->second.first) &&
246 iter->second.second == hook ) {
247 m_valSvc->callgrindStopInstrumentation();
249 msgStream() <<
MSG::DEBUG <<
"Stopping callgrind after " << hook
254 msgStream() << MSG::INFO <<
"Creating callgrind profile #" <<
m_valSvc->profileCount()
255 <<
" after " << hook <<
" of " <<
name <<
endmsg;
◆ do_afterExecute()
void ValgrindAuditor::do_afterExecute |
( |
const std::string & |
name | ) |
|
|
virtual |
◆ do_before()
void ValgrindAuditor::do_before |
( |
const std::string & |
name, |
|
|
const std::string & |
hook |
|
) |
| |
|
private |
Definition at line 222 of file ValgrindAuditor.cxx.
224 std::vector< std::pair<NameEvt,NameEvt> >::const_iterator iter;
227 if ( boost::regex_match(
name, iter->first.first) &&
228 iter->first.second == hook ) {
229 m_valSvc->callgrindStartInstrumentation();
231 msgStream() <<
MSG::DEBUG <<
"Starting callgrind before " << hook
◆ do_beforeExecute()
void ValgrindAuditor::do_beforeExecute |
( |
const std::string & |
name | ) |
|
|
virtual |
◆ handle()
void ValgrindAuditor::handle |
( |
const Incident & |
incident | ) |
|
|
virtual |
Incident handler.
Definition at line 146 of file ValgrindAuditor.cxx.
149 if ( inc.type() == IncidentType::BeginEvent ) {
154 std::vector< std::pair<NameEvt,NameEvt> >::const_iterator
h;
156 if (
h->first.second==
"incident" )
do_before(inc.type(),
"incident");
157 if (
h->second.second==
"incident" )
do_after(inc.type(),
"incident");
◆ initialize()
StatusCode ValgrindAuditor::initialize |
( |
| ) |
|
|
virtual |
Definition at line 51 of file ValgrindAuditor.cxx.
53 if ( !
m_valSvc.retrieve().isSuccess()) {
54 msgStream() << MSG::ERROR <<
"Could not retrieve the ValgrindSvc" <<
endmsg;
55 return StatusCode::FAILURE;
58 const IProperty* valSvcProp =
dynamic_cast<const IProperty*
>(&(*m_valSvc));
60 msgStream() << MSG::ERROR
61 <<
"Could not retrieve IProperty interface to ValgrindSvc."
63 return StatusCode::FAILURE;
67 ATH_CHECK(setProperty(valSvcProp->getProperty(
"OutputLevel")));
70 <<
"Initializing " <<
name() <<
"..."
77 "DumpAfterEachInterval"};
80 if ( !setProperty(valSvcProp->getProperty(prop)) ) {
81 msgStream() << MSG::ERROR <<
"Cannot set " << prop <<
" property." <<
endmsg;
82 return StatusCode::FAILURE;
90 for(
const std::string&
re :
m_algs ) {
94 catch (
const boost::regex_error& ) {
95 msgStream() << MSG::ERROR <<
"Ignoring invalid regular expression: " <<
re <<
endmsg;
99 if ( msgLevel() <= MSG::INFO ) {
100 std::ostringstream
out;
103 std::ostream_iterator<std::string>(
out,
" " ) );
105 msgStream() << MSG::INFO <<
"Profiled algorithms: " <<
out.str() <<
endmsg;
110 std::ostream_iterator<std::string>(
out,
" " ) );
112 msgStream() << MSG::INFO <<
"Profiled intervals: " <<
out.str() <<
endmsg;
117 msgStream() << MSG::ERROR <<
"Syntax error in ProfiledIntervals" <<
endmsg;
118 return StatusCode::FAILURE;
124 if ( !incSvc.retrieve().isSuccess() ) {
125 msgStream() << MSG::ERROR <<
"Unable to get the IncidentSvc" <<
endmsg;
126 return StatusCode::FAILURE;
131 incSvc->addListener(
this, IncidentType::BeginEvent, prio );
133 for(
const std::pair<NameEvt,NameEvt>&
h :
m_hooks ) {
135 if (
h.first.second==
"incident" ) incSvc->addListener(
this,
h.first.first.str(), prio );
136 if (
h.second.second==
"incident" ) incSvc->addListener(
this,
h.second.first.str(), prio );
139 return StatusCode::SUCCESS;
◆ m_algs
std::vector<std::string> ValgrindAuditor::m_algs |
|
private |
◆ m_algsRegEx
std::vector<boost::regex> ValgrindAuditor::m_algsRegEx |
|
private |
◆ m_dumpAfterEachInterval
bool ValgrindAuditor::m_dumpAfterEachInterval |
|
private |
◆ m_eventCounter
unsigned int ValgrindAuditor::m_eventCounter |
|
private |
◆ m_hooks
◆ m_ignoreFirstNEvents
unsigned int ValgrindAuditor::m_ignoreFirstNEvents |
|
private |
◆ m_intervals
std::vector<std::string> ValgrindAuditor::m_intervals |
|
private |
◆ m_valSvc
The documentation for this class was generated from the following files: