mem-cache: Add print function to ReplaceableEntry
authorDaniel R. Carvalho <odanrc@yahoo.com.br>
Thu, 12 Dec 2019 10:05:25 +0000 (11:05 +0100)
committerDaniel Carvalho <odanrc@yahoo.com.br>
Fri, 17 Jan 2020 20:41:50 +0000 (20:41 +0000)
Add a basic print function to acquire and display information about
replaceable entries.

Change-Id: I9640113d305fbe086c5bfaf8928a911bfcac50bb
Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/23567
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>

src/mem/cache/cache_blk.hh
src/mem/cache/replacement_policies/replaceable_entry.hh

index dce0ce434570ad9f5cfc1c8b54736e4cf7433204..42b8ebd2513b4d6ec48cb0b14afe67e75f5768c5 100644 (file)
@@ -345,7 +345,8 @@ class CacheBlk : public ReplaceableEntry
      *
      * @return string with basic state information
      */
-    virtual std::string print() const
+    std::string
+    print() const override
     {
         /**
          *  state       M   O   E   S   I
@@ -382,9 +383,9 @@ class CacheBlk : public ReplaceableEntry
           default:    s = 'T'; break; // @TODO add other types
         }
         return csprintf("state: %x (%c) valid: %d writable: %d readable: %d "
-                        "dirty: %d | tag: %#x set: %#x way: %#x", status, s,
+                        "dirty: %d | tag: %#x %s", status, s,
                         isValid(), isWritable(), isReadable(), isDirty(), tag,
-                        getSet(), getWay());
+                        ReplaceableEntry::print());
     }
 
     /**
index 2b08749e452d00981a667ee7103615704e53f299..9a59b1f2e70ab78cb01191abad22f7fb940dc00b 100644 (file)
@@ -34,6 +34,8 @@
 #include <cstdint>
 #include <memory>
 
+#include "base/cprintf.hh"
+
 /**
  * The replacement data needed by replacement policies. Each replacement policy
  * should have its own implementation of replacement data.
@@ -99,6 +101,17 @@ class ReplaceableEntry
      * @return The way to which this entry belongs.
      */
     uint32_t getWay() const { return _way; }
+
+    /**
+     * Prints relevant information about this entry.
+     *
+     * @return A string containg the contents of this entry.
+     */
+    virtual std::string
+    print() const
+    {
+        return csprintf("set: %#x way: %#x", getSet(), getWay());
+    }
 };
 
 #endif // __MEM_CACHE_REPLACEMENT_POLICIES_REPLACEABLE_ENTRY_HH_