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

A simple API to access /proc/self/maps info. More...

#include <procmaps.h>

Collaboration diagram for procmaps:

Classes

struct  Entry
 

Public Types

typedef std::vector< Entryprocmaps_t
 
typedef procmaps_t::const_iterator const_iterator
 

Public Member Functions

 procmaps (size_t entries=1024)
 
const EntrygetEntry (const void *address, bool tryReloadMaps=true)
 main entry point: get info for the page range containing address by default tries to reload /proc/self/maps when address is not found More...
 
const procmaps_tpmaps () const
 access underlying entries More...
 
const_iterator begin () const
 
const_iterator end () const
 
void loadMaps (bool dump=false)
 load/refresh info from /proc/self/map More...
 

Private Attributes

procmaps_t m_pmaps
 

Detailed Description

A simple API to access /proc/self/maps info.

On stopMonitoring/finalize the handler is uninstalled. On finalize a report of the accessed and unaccessed pages and addresses is produced. processing. Additional information can be added via setPageAccessControlInfo().

Properties: AutoMonitor: when true start monitoring on initialize, stop on finalize;

Author
Paolo Calafiura - LBNL, ATLAS Collaboration
Id
procmaps.h,v 1.3 2009-04-01 08:23:32 binet Exp

Definition at line 18 of file procmaps.h.

Member Typedef Documentation

◆ const_iterator

typedef procmaps_t::const_iterator procmaps::const_iterator

Definition at line 38 of file procmaps.h.

◆ procmaps_t

typedef std::vector<Entry> procmaps::procmaps_t

Definition at line 37 of file procmaps.h.

Constructor & Destructor Documentation

◆ procmaps()

procmaps::procmaps ( size_t  entries = 1024)

Definition at line 41 of file procmaps.cxx.

41  {
42  m_pmaps.reserve(entries);
43  loadMaps(false);
44 }

Member Function Documentation

◆ begin()

const_iterator procmaps::begin ( ) const
inline

Definition at line 46 of file procmaps.h.

46 { return pmaps().begin(); }

◆ end()

const_iterator procmaps::end ( ) const
inline

Definition at line 47 of file procmaps.h.

47 { return pmaps().end(); }

◆ getEntry()

const procmaps::Entry * procmaps::getEntry ( const void *  address,
bool  tryReloadMaps = true 
)

main entry point: get info for the page range containing address by default tries to reload /proc/self/maps when address is not found

Definition at line 59 of file procmaps.cxx.

59  {
60  unsigned long toMatch = reinterpret_cast<unsigned long>(address);
61  auto i = std::upper_bound (this->begin(), this->end(),
62  toMatch,
63  [] (unsigned long addr, const Entry& ent)
64  { return addr < ent.begAddress; });
65 
66  if (i > this->begin()) {
67  --i;
68  if (toMatch >= i->begAddress && toMatch < i->endAddress) {
69  return &*i;
70  }
71  }
72 
73  if (refreshMaps) {
74  //if ! found recurse once by calling getEntry with refreshMaps false
75  loadMaps();
76  return getEntry(address,false);
77  }
78 
79  return nullptr;
80 }

◆ loadMaps()

void procmaps::loadMaps ( bool  dump = false)

load/refresh info from /proc/self/map

Definition at line 47 of file procmaps.cxx.

47  {
48  m_pmaps.clear();
49  std::ifstream f("/proc/self/maps");
50  const int LMAX=256;
51  char line[LMAX];
52  while ( f.getline(line,LMAX) ) {
53  if (dump) printf("%s",line);
54  m_pmaps.emplace_back(line);
55  }
56 }

◆ pmaps()

const procmaps_t& procmaps::pmaps ( ) const
inline

access underlying entries

Definition at line 45 of file procmaps.h.

45 { return m_pmaps; }

Member Data Documentation

◆ m_pmaps

procmaps_t procmaps::m_pmaps
private

Definition at line 53 of file procmaps.h.


The documentation for this class was generated from the following files:
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
checkFileSG.line
line
Definition: checkFileSG.py:75
procmaps::end
const_iterator end() const
Definition: procmaps.h:47
procmaps::m_pmaps
procmaps_t m_pmaps
Definition: procmaps.h:53
lumiFormat.i
int i
Definition: lumiFormat.py:92
RTTAlgmain.address
address
Definition: RTTAlgmain.py:55
procmaps::loadMaps
void loadMaps(bool dump=false)
load/refresh info from /proc/self/map
Definition: procmaps.cxx:47
procmaps::pmaps
const procmaps_t & pmaps() const
access underlying entries
Definition: procmaps.h:45
entries
double entries
Definition: listroot.cxx:49
procmaps::getEntry
const Entry * getEntry(const void *address, bool tryReloadMaps=true)
main entry point: get info for the page range containing address by default tries to reload /proc/sel...
Definition: procmaps.cxx:59
procmaps::begin
const_iterator begin() const
Definition: procmaps.h:46
FourMomUtils::dump
std::ostream & dump(std::ostream &out, const I4MomIter iBeg, const I4MomIter iEnd)
Helper to stream out a range of I4Momentum objects.
Definition: P4Dumper.h:24