// See LICENSE for license details. #ifndef _MEMTRACER_H #define _MEMTRACER_H #include #include #include enum access_type { LOAD, STORE, FETCH, }; class memtracer_t { public: memtracer_t() {} virtual ~memtracer_t() {} virtual bool interested_in_range(uint64_t begin, uint64_t end, access_type type) = 0; virtual void trace(uint64_t addr, size_t bytes, access_type type) = 0; }; class memtracer_list_t : public memtracer_t { public: bool empty() { return list.empty(); } bool interested_in_range(uint64_t begin, uint64_t end, access_type type) { for (std::vector::iterator it = list.begin(); it != list.end(); ++it) if ((*it)->interested_in_range(begin, end, type)) return true; return false; } void trace(uint64_t addr, size_t bytes, access_type type) { for (std::vector::iterator it = list.begin(); it != list.end(); ++it) (*it)->trace(addr, bytes, type); } void hook(memtracer_t* h) { list.push_back(h); } private: std::vector list; }; #endif