ATLAS Offline Software
Public Member Functions | Static Public Member Functions | List of all members
PageAccessControlSvc Class Reference

Service to monitor access to memory pages. More...

#include <PageAccessControlSvc.h>

Inheritance diagram for PageAccessControlSvc:
Collaboration diagram for PageAccessControlSvc:

Public Member Functions

 PageAccessControlSvc (const std::string &name, ISvcLocator *pSvcLocator) ATLAS_CTORDTOR_NOT_THREAD_SAFE
 Standard GAUDI constructor. More...
 
virtual ~PageAccessControlSvc ()
 Destructor. More...
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 
IPageAccessControlSvc implementation
virtual bool startMonitoring ()
 In baseline implementation, protect pages and install a SEGV handler that counts the number of accesses to a protected address. More...
 
virtual bool stopMonitoring ()
 
virtual bool accessed (const void *address) const
 has this pointer been accessed (read/written) More...
 
virtual void report () const
 In baseline implementation, controlled via PageAccessControlSvc.OutputLevel
More...
 
virtual bool controlPage (const void *address)
 control access to the page containing address More...
 

Static Public Member Functions

static const InterfaceID & interfaceID ()
 Retrieve interface ID. More...
 

Gaudi implementation

struct sigaction m_saveSEGVaction
 the default action for SIGSEGV More...
 
PageAccessControl m_accessControl
 
PtrAccessSEGVHandler m_SEGVHandler
 
BooleanProperty m_autoMonitor
 start on init, stop on finalize More...
 
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface)
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 

Detailed Description

Service to monitor access to memory pages.

Author
Paolo Calafiura

This service uses

Definition at line 51 of file PageAccessControlSvc.h.

Constructor & Destructor Documentation

◆ PageAccessControlSvc()

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

Standard GAUDI constructor.

Definition at line 8 of file PageAccessControlSvc.cxx.

9  :
10  AthService(name, pSvcLocator), m_saveSEGVaction(),
12 {
13  //pass m_SEGVHandler pointer to cPtrAccessSEGVHandler
14  setPtrAccessSEGVHandler(&m_SEGVHandler);
15  declareProperty("AutoMonitoring", m_autoMonitor=true,
16  "start monitoring on initialize, stop on finalize");
17 }

◆ ~PageAccessControlSvc()

virtual PageAccessControlSvc::~PageAccessControlSvc ( )
inlinevirtual

Destructor.

Definition at line 59 of file PageAccessControlSvc.h.

59 {}

Member Function Documentation

◆ accessed()

bool PageAccessControlSvc::accessed ( const void *  address) const
virtual

has this pointer been accessed (read/written)

Implements IPageAccessControlSvc.

Definition at line 36 of file PageAccessControlSvc.cxx.

36  {
37  return m_accessControl.accessed(address);
38 }

◆ controlPage()

virtual bool PageAccessControlSvc::controlPage ( const void *  address)
inlinevirtual

control access to the page containing address

Implements IPageAccessControlSvc.

Definition at line 73 of file PageAccessControlSvc.h.

73  {
74  return m_accessControl.forbidPage(address);
75  }

◆ finalize()

StatusCode PageAccessControlSvc::finalize ( )
virtual

Definition at line 47 of file PageAccessControlSvc.cxx.

47  {
48  StatusCode sc(StatusCode::SUCCESS);
49  if (m_autoMonitor.value()) {
50  if (this->stopMonitoring()) this->report();
51  else sc = StatusCode::FAILURE;
52  }
53  return sc;
54 }

◆ initialize()

StatusCode PageAccessControlSvc::initialize ( )
virtual

Definition at line 40 of file PageAccessControlSvc.cxx.

40  {
41  StatusCode sc(StatusCode::SUCCESS);
42  msg(MSG::INFO) << "Initializing " << name() << endmsg ;
43  if (m_autoMonitor.value() && !this->startMonitoring()) sc = StatusCode::FAILURE;
44  return sc;
45 }

◆ interfaceID()

const InterfaceID & IPageAccessControlSvc::interfaceID ( )
inlinestaticinherited

Retrieve interface ID.

Definition at line 56 of file IPageAccessControlSvc.h.

57 {
58  static const InterfaceID IID_IPageAccessControlSvc("IPageAccessControlSvc", 1, 0);
59  return IID_IPageAccessControlSvc;
60 }

◆ msg() [1/2]

MsgStream& AthCommonMsg< Service >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24  {
25  return this->msgStream();
26  }

◆ msg() [2/2]

MsgStream& AthCommonMsg< Service >::msg ( const MSG::Level  lvl) const
inlineinherited

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ msgLvl()

bool AthCommonMsg< Service >::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30  {
31  return this->msgLevel(lvl);
32  }

◆ queryInterface()

StatusCode PageAccessControlSvc::queryInterface ( const InterfaceID &  riid,
void **  ppvInterface 
)
virtual

Definition at line 61 of file PageAccessControlSvc.cxx.

62 {
63  if ( IPageAccessControlSvc::interfaceID().versionMatch(riid) ) {
64  *ppvInterface = (IPageAccessControlSvc*)this;
65  }
66  else {
67  // Interface is not directly available: try out a base class
68  return Service::queryInterface(riid, ppvInterface);
69  }
70  this->addRef();
71  return StatusCode::SUCCESS;
72 }

◆ report()

void PageAccessControlSvc::report ( ) const
virtual

In baseline implementation, controlled via PageAccessControlSvc.OutputLevel

Implements IPageAccessControlSvc.

Definition at line 75 of file PageAccessControlSvc.cxx.

75  {
76  msg(MSG::INFO) << "Access monitoring report" << endmsg;
79  while (i != e) {
80  msg(MSG::DEBUG) << "accessed pointer at @" << std::hex << *i++ << endmsg;
81  }
82  PageAccessControl::const_iterator ia(m_accessControl.beginProtectedPtrs()),
83  ea(m_accessControl.endProtectedPtrs());
84  while (ia != ea) {
85  msg(MSG::DEBUG) << "protected page at @" << std::hex << ia->addr
86  << " accessed "<< ia->restored << " times" << endmsg;
87  ++ia;
88  }
89 }

◆ startMonitoring()

bool PageAccessControlSvc::startMonitoring ( )
virtual

In baseline implementation, protect pages and install a SEGV handler that counts the number of accesses to a protected address.

Implements IPageAccessControlSvc.

Definition at line 19 of file PageAccessControlSvc.cxx.

19  {
20  int rc = sigaction(SIGSEGV,nullptr, &m_saveSEGVaction);
21  if (0==rc) {
22  struct sigaction sa(m_saveSEGVaction);
23  sa.sa_sigaction= cPtrAccessSEGVHandler;
24  sa.sa_flags=SA_SIGINFO;
25  //off we go
26  rc=sigaction(SIGSEGV,&sa,nullptr);
27  }
28  return (0==rc);
29 }

◆ stopMonitoring()

bool PageAccessControlSvc::stopMonitoring ( )
virtual

Implements IPageAccessControlSvc.

Definition at line 31 of file PageAccessControlSvc.cxx.

31  {
32  return (0 == sigaction(SIGSEGV,&m_saveSEGVaction, nullptr));
33 }

Member Data Documentation

◆ m_accessControl

PageAccessControl PageAccessControlSvc::m_accessControl
private

Definition at line 90 of file PageAccessControlSvc.h.

◆ m_autoMonitor

BooleanProperty PageAccessControlSvc::m_autoMonitor
private

start on init, stop on finalize

Definition at line 92 of file PageAccessControlSvc.h.

◆ m_saveSEGVaction

struct sigaction PageAccessControlSvc::m_saveSEGVaction
private

the default action for SIGSEGV

Definition at line 83 of file PageAccessControlSvc.h.

◆ m_SEGVHandler

PtrAccessSEGVHandler PageAccessControlSvc::m_SEGVHandler
private

Definition at line 91 of file PageAccessControlSvc.h.


The documentation for this class was generated from the following files:
AthService::AthService
AthService()
PtrAccessSEGVHandler::const_iterator
accessed_t::const_iterator const_iterator
Definition: PtrAccessSEGVHandler.h:32
IPageAccessControlSvc::interfaceID
static const InterfaceID & interfaceID()
Retrieve interface ID.
Definition: IPageAccessControlSvc.h:56
PageAccessControlSvc::m_accessControl
PageAccessControl m_accessControl
Definition: PageAccessControlSvc.h:90
PageAccessControl::const_iterator
protected_t::const_iterator const_iterator
Definition: PageAccessControl.h:92
PageAccessControlSvc::m_saveSEGVaction
struct sigaction m_saveSEGVaction
the default action for SIGSEGV
Definition: PageAccessControlSvc.h:89
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
IPageAccessControlSvc
Interface to a service that monitors memory page accesses.
Definition: IPageAccessControlSvc.h:30
PageAccessControlSvc::stopMonitoring
virtual bool stopMonitoring()
Definition: PageAccessControlSvc.cxx:31
PtrAccessSEGVHandler::endAccessedPtrs
const_iterator endAccessedPtrs() const
Definition: PtrAccessSEGVHandler.h:35
lumiFormat.i
int i
Definition: lumiFormat.py:92
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
RTTAlgmain.address
address
Definition: RTTAlgmain.py:55
PtrAccessSEGVHandler::beginAccessedPtrs
const_iterator beginAccessedPtrs() const
Definition: PtrAccessSEGVHandler.h:34
PageAccessControlSvc::report
virtual void report() const
In baseline implementation, controlled via PageAccessControlSvc.OutputLevel
Definition: PageAccessControlSvc.cxx:75
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
PageAccessControlSvc::m_autoMonitor
BooleanProperty m_autoMonitor
start on init, stop on finalize
Definition: PageAccessControlSvc.h:92
DEBUG
#define DEBUG
Definition: page_access.h:11
AthCommonMsg< Service >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
PageAccessControlSvc::m_SEGVHandler
PtrAccessSEGVHandler m_SEGVHandler
Definition: PageAccessControlSvc.h:91
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
python.trfValidateRootFile.rc
rc
Definition: trfValidateRootFile.py:350