ATLAS Offline Software
Public Types | Public Member Functions | Private Attributes | List of all members
PtrAccessSEGVHandler Class Reference

#include <PtrAccessSEGVHandler.h>

Collaboration diagram for PtrAccessSEGVHandler:

Public Types

typedef std::vector< void * > accessed_t
 the list of accessed pointers More...
 
typedef accessed_t::const_iterator const_iterator
 

Public Member Functions

const accessed_taccessedPtrs () const
 
const_iterator beginAccessedPtrs () const
 
const_iterator endAccessedPtrs () const
 
void reset ()
 
 PtrAccessSEGVHandler (PageAccessControl &pac, size_t reservedSize=65535)
 
void handle (int signal_number, siginfo_t *sigi, void *unused)
 the actual signal handler More...
 

Private Attributes

PageAccessControlm_pac
 used to restore protection of the page which segfaulted More...
 
accessed_t m_accessed
 the addresses accessed since last reset More...
 

Detailed Description

Definition at line 28 of file PtrAccessSEGVHandler.h.

Member Typedef Documentation

◆ accessed_t

typedef std::vector<void*> PtrAccessSEGVHandler::accessed_t

the list of accessed pointers

Definition at line 31 of file PtrAccessSEGVHandler.h.

◆ const_iterator

typedef accessed_t::const_iterator PtrAccessSEGVHandler::const_iterator

Definition at line 32 of file PtrAccessSEGVHandler.h.

Constructor & Destructor Documentation

◆ PtrAccessSEGVHandler()

PtrAccessSEGVHandler::PtrAccessSEGVHandler ( PageAccessControl pac,
size_t  reservedSize = 65535 
)
inline

Definition at line 38 of file PtrAccessSEGVHandler.h.

38  :
39  m_pac(pac)
40  {
41  //we must reserve enough elements, or we risk vector allocating in a protected page during handle()...
42  m_accessed.reserve(reservedSize);
43  }

Member Function Documentation

◆ accessedPtrs()

const accessed_t& PtrAccessSEGVHandler::accessedPtrs ( ) const
inline

Definition at line 33 of file PtrAccessSEGVHandler.h.

33 { return m_accessed; }

◆ beginAccessedPtrs()

const_iterator PtrAccessSEGVHandler::beginAccessedPtrs ( ) const
inline

Definition at line 34 of file PtrAccessSEGVHandler.h.

34 { return m_accessed.begin(); }

◆ endAccessedPtrs()

const_iterator PtrAccessSEGVHandler::endAccessedPtrs ( ) const
inline

Definition at line 35 of file PtrAccessSEGVHandler.h.

35 { return m_accessed.end(); }

◆ handle()

void PtrAccessSEGVHandler::handle ( int  signal_number,
siginfo_t sigi,
void *  unused 
)

the actual signal handler

Definition at line 13 of file PtrAccessSEGVHandler.cxx.

13  {
14  void *addr=sigi->si_addr;
15 #ifdef DEBUG
16  printf("page fault @address=%p\n",sigi->si_addr);
17 #ifdef __ARCH_SI_TRAPNO
18  printf("page fault trapno=%d\n",sigi->si_trapno);
19 #endif
20  printf("page fault signo=%d\n",sigi->si_signo);
21  printf("page fault errno=%d\n",sigi->si_errno);
22  printf("this page fault failed because ");
23  if (SEGV_MAPERR == sigi->si_code)
24  printf("you tried to access an invalid address\n");
25  else if (SEGV_ACCERR == sigi->si_code) {
26  printf("you tried to access a protected address\n");
27  } else printf(" an unknown reason. Page fault code=%d\n",sigi->si_code);
28 #endif
29  //record the access and restore page protection
30  if (SEGV_ACCERR == sigi->si_code) {
31  m_pac.restorePageProt(addr);
32  m_accessed.push_back(addr);
33  } else abort();
34 }

◆ reset()

void PtrAccessSEGVHandler::reset ( )
inline

Definition at line 36 of file PtrAccessSEGVHandler.h.

36 { m_accessed.clear(); }

Member Data Documentation

◆ m_accessed

accessed_t PtrAccessSEGVHandler::m_accessed
private

the addresses accessed since last reset

Definition at line 52 of file PtrAccessSEGVHandler.h.

◆ m_pac

PageAccessControl& PtrAccessSEGVHandler::m_pac
private

used to restore protection of the page which segfaulted

Definition at line 50 of file PtrAccessSEGVHandler.h.


The documentation for this class was generated from the following files:
PtrAccessSEGVHandler::m_pac
PageAccessControl & m_pac
used to restore protection of the page which segfaulted
Definition: PtrAccessSEGVHandler.h:50
PtrAccessSEGVHandler::m_accessed
accessed_t m_accessed
the addresses accessed since last reset
Definition: PtrAccessSEGVHandler.h:52