00001
00002 #ifndef PROCMAPS_H
00003 #define PROCMAPS_H 1
00004 #include <boost/pool/pool_alloc.hpp>
00005 #include <vector>
00012 class procmaps {
00013 public:
00014 struct Entry {
00015 Entry(const char* line);
00016 unsigned long begAddress;
00017 unsigned long endAddress;
00018 bool readable;
00019 bool writable;
00020 bool executable;
00021 bool isPrivate;
00022 unsigned int offset;
00023 unsigned int dev[2];
00024 unsigned int inode;
00025 char pathname[32];
00026 };
00027
00028 procmaps(size_t entries=1024);
00029
00030
00031 typedef std::vector<Entry, boost::pool_allocator<Entry> > procmaps_t;
00032 typedef procmaps_t::const_iterator const_iterator;
00033
00036 const Entry* getEntry(const void* address, bool tryReloadMaps=true);
00037
00039 static const procmaps_t& pmaps() { return s_pmaps; }
00040 const_iterator begin() const { return pmaps().begin(); }
00041 const_iterator end() const { return pmaps().end(); }
00042
00044 void loadMaps(bool dump=false);
00045
00046 private:
00047 static bool s_pmapsLoaded;
00048 static procmaps_t s_pmaps;
00049 };
00050
00051 inline
00052 bool operator<(procmaps::Entry& lhs, procmaps::Entry& rhs){
00053 return lhs.begAddress < rhs.begAddress;
00054 }
00055 #endif