ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthenaServices
src
PageAccessControlSvc.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
CxxUtils/cPtrAccessSEGVHandler.h
"
6
7
#include "
PageAccessControlSvc.h
"
8
PageAccessControlSvc::PageAccessControlSvc
(
const
std::string& name,
9
ISvcLocator* pSvcLocator ) :
10
base_class(name, pSvcLocator),
m_saveSEGVaction
(),
11
m_accessControl
(),
m_SEGVHandler
(
m_accessControl
)
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
}
18
19
bool
PageAccessControlSvc::startMonitoring
() {
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
}
30
31
bool
PageAccessControlSvc::stopMonitoring
() {
32
return
(0 == sigaction(SIGSEGV,&
m_saveSEGVaction
,
nullptr
));
33
}
34
36
bool
PageAccessControlSvc::accessed
(
const
void
* address)
const
{
37
return
m_accessControl
.accessed(address);
38
}
39
40
StatusCode
PageAccessControlSvc::initialize
() {
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
}
46
47
StatusCode
PageAccessControlSvc::finalize
() {
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
}
55
56
void
PageAccessControlSvc::report
()
const
{
57
msg
(MSG::INFO) <<
"Access monitoring report"
<<
endmsg
;
58
PtrAccessSEGVHandler::const_iterator
i(
m_SEGVHandler
.beginAccessedPtrs()),
59
e(
m_SEGVHandler
.endAccessedPtrs());
60
while
(i != e) {
61
msg
(MSG::DEBUG) <<
"accessed pointer at @"
<< std::hex << *i++ <<
endmsg
;
62
}
63
PageAccessControl::const_iterator
ia(
m_accessControl
.beginProtectedPtrs()),
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
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
rc
static Double_t rc
Definition
LArPhysWaveHECTool.cxx:37
PageAccessControlSvc.h
A service that monitors access to memory pages.
cPtrAccessSEGVHandler.h
a C wrapper providing access to PtrAccessSEGVHandler::handle the way sigaction wants it Example: PtrA...
PageAccessControlSvc::PageAccessControlSvc
PageAccessControlSvc(const std::string &name, ISvcLocator *pSvcLocator) ATLAS_NOT_THREAD_SAFE
Standard GAUDI constructor.
Definition
PageAccessControlSvc.cxx:8
PageAccessControlSvc::m_saveSEGVaction
struct sigaction m_saveSEGVaction
the default action for SIGSEGV
Definition
PageAccessControlSvc.h:85
PageAccessControlSvc::m_autoMonitor
BooleanProperty m_autoMonitor
start on init, stop on finalize
Definition
PageAccessControlSvc.h:88
PageAccessControlSvc::stopMonitoring
virtual bool stopMonitoring()
Definition
PageAccessControlSvc.cxx:31
PageAccessControlSvc::initialize
virtual StatusCode initialize()
Definition
PageAccessControlSvc.cxx:40
PageAccessControlSvc::report
virtual void report() const
In baseline implementation, controlled via PageAccessControlSvc.OutputLevel.
Definition
PageAccessControlSvc.cxx:56
PageAccessControlSvc::finalize
virtual StatusCode finalize()
Definition
PageAccessControlSvc.cxx:47
PageAccessControlSvc::accessed
virtual bool accessed(const void *address) const
has this pointer been accessed (read/written)
Definition
PageAccessControlSvc.cxx:36
PageAccessControlSvc::startMonitoring
virtual bool startMonitoring()
In baseline implementation, protect pages and install a SEGV handler that counts the number of access...
Definition
PageAccessControlSvc.cxx:19
PageAccessControlSvc::m_accessControl
PageAccessControl m_accessControl
Definition
PageAccessControlSvc.h:86
PageAccessControlSvc::m_SEGVHandler
PtrAccessSEGVHandler m_SEGVHandler
Definition
PageAccessControlSvc.h:87
PageAccessControl::const_iterator
protected_t::const_iterator const_iterator
Definition
PageAccessControl.h:92
PtrAccessSEGVHandler::const_iterator
accessed_t::const_iterator const_iterator
Definition
PtrAccessSEGVHandler.h:32
msg
MsgStream & msg
Definition
testRead.cxx:32
Generated on
for ATLAS Offline Software by
1.17.0