diff options
author | Andrew Waterman <waterman@cs.berkeley.edu> | 2013-02-13 12:59:53 -0800 |
---|---|---|
committer | Andrew Waterman <waterman@cs.berkeley.edu> | 2013-02-13 12:59:53 -0800 |
commit | b119073ab013f387000435ba5a55a3026fc8a8d9 (patch) | |
tree | 8480090f710b511a9765bde8c59773bb3c0e0b9e /riscv/memtracer.h | |
parent | 55cc5d40ec16ea0639046ff1487636ba618d0e09 (diff) | |
download | spike-b119073ab013f387000435ba5a55a3026fc8a8d9.zip spike-b119073ab013f387000435ba5a55a3026fc8a8d9.tar.gz spike-b119073ab013f387000435ba5a55a3026fc8a8d9.tar.bz2 |
add I$/D$/L2$ simulators
Diffstat (limited to 'riscv/memtracer.h')
-rw-r--r-- | riscv/memtracer.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/riscv/memtracer.h b/riscv/memtracer.h new file mode 100644 index 0000000..ed62be5 --- /dev/null +++ b/riscv/memtracer.h @@ -0,0 +1,46 @@ +#ifndef _MEMTRACER_H +#define _MEMTRACER_H + +#include <stdint.h> +#include <string.h> +#include <vector> + +class memtracer_t +{ + public: + memtracer_t() : link(NULL) {} + virtual ~memtracer_t() {} + + virtual bool interested_in_range(uint64_t begin, uint64_t end, bool store, bool fetch) = 0; + virtual void trace(uint64_t addr, size_t bytes, bool store, bool fetch) = 0; + + protected: + + private: + memtracer_t* link; +}; + +class memtracer_list_t : public memtracer_t +{ + public: + bool interested_in_range(uint64_t begin, uint64_t end, bool store, bool fetch) + { + for (std::vector<memtracer_t*>::iterator it = list.begin(); it != list.end(); ++it) + if ((*it)->interested_in_range(begin, end, store, fetch)) + return true; + return false; + } + void trace(uint64_t addr, size_t bytes, bool store, bool fetch) + { + for (std::vector<memtracer_t*>::iterator it = list.begin(); it != list.end(); ++it) + (*it)->trace(addr, bytes, store, fetch); + } + void hook(memtracer_t* h) + { + list.push_back(h); + } + private: + std::vector<memtracer_t*> list; +}; + +#endif |