ATLAS Offline Software
Loading...
Searching...
No Matches
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_NOT_THREAD_SAFE
 Standard GAUDI constructor.
virtual ~PageAccessControlSvc ()
 Destructor.
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.
virtual bool stopMonitoring ()
virtual bool accessed (const void *address) const
 has this pointer been accessed (read/written)
virtual void report () const
 In baseline implementation, controlled via PageAccessControlSvc.OutputLevel.
virtual bool controlPage (const void *address)

Gaudi implementation

struct sigaction m_saveSEGVaction
 the default action for SIGSEGV
PageAccessControl m_accessControl
PtrAccessSEGVHandler m_SEGVHandler
BooleanProperty m_autoMonitor
 start on init, stop on finalize
virtual StatusCode initialize ()
virtual StatusCode finalize ()

Detailed Description

Service to monitor access to memory pages.

Author
Paolo Calafiura

This service uses

Definition at line 49 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 base_class(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}
struct sigaction m_saveSEGVaction
the default action for SIGSEGV
BooleanProperty m_autoMonitor
start on init, stop on finalize
PageAccessControl m_accessControl
PtrAccessSEGVHandler m_SEGVHandler

◆ ~PageAccessControlSvc()

virtual PageAccessControlSvc::~PageAccessControlSvc ( )
inlinevirtual

Destructor.

Definition at line 56 of file PageAccessControlSvc.h.

56{}

Member Function Documentation

◆ accessed()

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

has this pointer been accessed (read/written)

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

Definition at line 70 of file PageAccessControlSvc.h.

70 {
71 return m_accessControl.forbidPage(address);
72 }

◆ 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}
static Double_t sc
virtual void report() const
In baseline implementation, controlled via PageAccessControlSvc.OutputLevel.
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ 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}
#define endmsg
MsgStream & msg
Definition testRead.cxx:32

◆ report()

void PageAccessControlSvc::report ( ) const
virtual

In baseline implementation, controlled via PageAccessControlSvc.OutputLevel.

Definition at line 56 of file PageAccessControlSvc.cxx.

56 {
57 msg(MSG::INFO) << "Access monitoring report" << endmsg;
59 e(m_SEGVHandler.endAccessedPtrs());
60 while (i != e) {
61 msg(MSG::DEBUG) << "accessed pointer at @" << std::hex << *i++ << endmsg;
62 }
64 ea(m_accessControl.endProtectedPtrs());
65 while (ia != ea) {
66 msg(MSG::DEBUG) << "protected page at @" << std::hex << ia->addr
67 << " accessed "<< ia->restored << " times" << endmsg;
68 ++ia;
69 }
70}
protected_t::const_iterator const_iterator
accessed_t::const_iterator const_iterator

◆ 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.

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}
static Double_t rc

◆ stopMonitoring()

bool PageAccessControlSvc::stopMonitoring ( )
virtual

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 86 of file PageAccessControlSvc.h.

◆ m_autoMonitor

BooleanProperty PageAccessControlSvc::m_autoMonitor
private

start on init, stop on finalize

Definition at line 88 of file PageAccessControlSvc.h.

◆ m_saveSEGVaction

struct sigaction PageAccessControlSvc::m_saveSEGVaction
private

the default action for SIGSEGV

Definition at line 85 of file PageAccessControlSvc.h.

◆ m_SEGVHandler

PtrAccessSEGVHandler PageAccessControlSvc::m_SEGVHandler
private

Definition at line 87 of file PageAccessControlSvc.h.


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