| OLD | NEW |
| 1 #ifndef MAPS_H__ | 1 #ifndef MAPS_H__ |
| 2 #define MAPS_H__ | 2 #define MAPS_H__ |
| 3 | 3 |
| 4 #include <elf.h> | 4 #include <elf.h> |
| 5 #include <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #if defined(__x86_64__) | 8 #if defined(__x86_64__) |
| 9 typedef Elf64_Addr Elf_Addr; | 9 typedef Elf64_Addr Elf_Addr; |
| 10 #elif defined(__i386__) | 10 #elif defined(__i386__) |
| 11 typedef Elf32_Addr Elf_Addr; | 11 typedef Elf32_Addr Elf_Addr; |
| 12 #else | 12 #else |
| 13 #error Undefined target platform | 13 #error Undefined target platform |
| 14 #endif | 14 #endif |
| 15 | 15 |
| 16 namespace playground { | 16 namespace playground { |
| 17 | 17 |
| 18 class Library; | 18 class Library; |
| 19 class Maps { | 19 class Maps { |
| 20 friend class Library; | 20 friend class Library; |
| 21 public: | 21 public: |
| 22 Maps(const std::string& maps_file); | 22 Maps(int proc_self_maps); |
| 23 ~Maps() { } | 23 ~Maps() { } |
| 24 | 24 |
| 25 protected: | 25 protected: |
| 26 // A map with all the libraries currently loaded into the application. | 26 // A map with all the libraries currently loaded into the application. |
| 27 // The key is a unique combination of device number, inode number, and | 27 // The key is a unique combination of device number, inode number, and |
| 28 // file name. It should be treated as opaque. | 28 // file name. It should be treated as opaque. |
| 29 typedef std::map<std::string, Library> LibraryMap; | 29 typedef std::map<std::string, Library> LibraryMap; |
| 30 friend class Iterator; | 30 friend class Iterator; |
| 31 class Iterator { | 31 class Iterator { |
| 32 friend class Maps; | 32 friend class Maps; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 62 | 62 |
| 63 const_iterator end() { | 63 const_iterator end() { |
| 64 return end_iter_; | 64 return end_iter_; |
| 65 } | 65 } |
| 66 | 66 |
| 67 char* allocNearAddr(char *addr, size_t size, int prot) const; | 67 char* allocNearAddr(char *addr, size_t size, int prot) const; |
| 68 | 68 |
| 69 char* vsyscall() const { return vsyscall_; } | 69 char* vsyscall() const { return vsyscall_; } |
| 70 | 70 |
| 71 protected: | 71 protected: |
| 72 const std::string maps_file_; | 72 const int proc_self_maps_; |
| 73 const Iterator begin_iter_; | 73 const Iterator begin_iter_; |
| 74 const Iterator end_iter_; | 74 const Iterator end_iter_; |
| 75 | 75 |
| 76 LibraryMap libs_; | 76 LibraryMap libs_; |
| 77 char* vsyscall_; | 77 char* vsyscall_; |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 } // namespace | 80 } // namespace |
| 81 | 81 |
| 82 #endif // MAPS_H__ | 82 #endif // MAPS_H__ |
| OLD | NEW |