Merge pull request #117 from riscv/multicore_debug
[riscv-isa-sim.git] / riscv / memtracer.h
index 82c02b6c87e6b40859ee351eaab7f9957c4aafc9..6952e2f870b22db2f6d7e47ecf0ff73751e1a70f 100644 (file)
@@ -1,34 +1,43 @@
+// See LICENSE for license details.
+
 #ifndef _MEMTRACER_H
 #define _MEMTRACER_H
 
-#include <stdint.h>
+#include <cstdint>
 #include <string.h>
 #include <vector>
 
+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, bool store, bool fetch) = 0;
-  virtual void trace(uint64_t addr, size_t bytes, bool store, bool fetch) = 0;
+  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 interested_in_range(uint64_t begin, uint64_t end, bool store, bool fetch)
+  bool empty() { return list.empty(); }
+  bool interested_in_range(uint64_t begin, uint64_t end, access_type type)
   {
     for (std::vector<memtracer_t*>::iterator it = list.begin(); it != list.end(); ++it)
-      if ((*it)->interested_in_range(begin, end, store, fetch))
+      if ((*it)->interested_in_range(begin, end, type))
         return true;
     return false;
   }
-  void trace(uint64_t addr, size_t bytes, bool store, bool fetch)
+  void trace(uint64_t addr, size_t bytes, access_type type)
   {
     for (std::vector<memtracer_t*>::iterator it = list.begin(); it != list.end(); ++it)
-      (*it)->trace(addr, bytes, store, fetch);
+      (*it)->trace(addr, bytes, type);
   }
   void hook(memtracer_t* h)
   {