ATLAS Offline Software
Loading...
Searching...
No Matches
procmaps Class Reference

On stopMonitoring/finalize the handler is uninstalled. 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
const procmaps_tpmaps () const
 access underlying entries
const_iterator begin () const
const_iterator end () const
void loadMaps (bool dump=false)
 load/refresh info from /proc/self/map

Private Attributes

procmaps_t m_pmaps

Detailed Description

On stopMonitoring/finalize the handler is uninstalled.

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

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}
void loadMaps(bool dump=false)
load/refresh info from /proc/self/map
Definition procmaps.cxx:47
procmaps_t m_pmaps
Definition procmaps.h:53
double entries
Definition listroot.cxx:49

Member Function Documentation

◆ begin()

const_iterator procmaps::begin ( ) const
inline

Definition at line 46 of file procmaps.h.

46{ return pmaps().begin(); }
const procmaps_t & pmaps() const
access underlying entries
Definition procmaps.h:45

◆ 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}
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
const_iterator begin() const
Definition procmaps.h:46
const_iterator end() const
Definition procmaps.h:47

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