mem: Fill the new packet ID fields with master IDs when tracing packets.
authorGabe Black <gabeblack@google.com>
Fri, 22 Sep 2017 00:48:33 +0000 (17:48 -0700)
committerGabe Black <gabeblack@google.com>
Mon, 25 Sep 2017 21:14:21 +0000 (21:14 +0000)
This will let somebody consuming the memory packet trace make sense out of
the master IDs passed along with individual accesses.

Change-Id: I621d915f218728066ce95e6fc81f36d14ae7e597
Reviewed-on: https://gem5-review.googlesource.com/4800
Reviewed-by: Rahul Thakur <rjthakur@google.com>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>

src/mem/probes/MemTraceProbe.py
src/mem/probes/mem_trace.cc
src/mem/probes/mem_trace.hh

index c51ec92824cf7f71a08bb6259cd4630dacb1818a..8daf94dbd5eedd23233272a4c4b05c876e672321 100644 (file)
@@ -52,3 +52,5 @@ class MemTraceProbe(BaseMemProbe):
     # packet trace output file, disabled by default
     trace_file = Param.String("", "Packet trace output file")
 
+    # System object to look up the name associated with a master ID
+    system = Param.System(Parent.any, "System the probe belongs to")
index 465c10004fc59c0955375777e155628d554b956d..6e55c48a11ed7f595ebfcae88e507ab10a80ea26 100644 (file)
 #include "base/output.hh"
 #include "params/MemTraceProbe.hh"
 #include "proto/packet.pb.h"
+#include "sim/system.hh"
 
 MemTraceProbe::MemTraceProbe(MemTraceProbeParams *p)
     : BaseMemProbe(p),
       traceStream(nullptr),
+      system(p->system),
       withPC(p->with_pc)
 {
     std::string filename;
@@ -72,18 +74,29 @@ MemTraceProbe::MemTraceProbe(MemTraceProbeParams *p)
 
     traceStream = new ProtoOutputStream(filename);
 
+    // Register a callback to compensate for the destructor not
+    // being called. The callback forces the stream to flush and
+    // closes the output file.
+    registerExitCallback(
+        new MakeCallback<MemTraceProbe, &MemTraceProbe::closeStreams>(this));
+}
+
+void
+MemTraceProbe::startup()
+{
     // Create a protobuf message for the header and write it to
     // the stream
     ProtoMessage::PacketHeader header_msg;
     header_msg.set_obj_id(name());
     header_msg.set_tick_freq(SimClock::Frequency);
-    traceStream->write(header_msg);
 
-    // Register a callback to compensate for the destructor not
-    // being called. The callback forces the stream to flush and
-    // closes the output file.
-    registerExitCallback(
-        new MakeCallback<MemTraceProbe, &MemTraceProbe::closeStreams>(this));
+    for (int i = 0; i < system->maxMasters(); i++) {
+        auto id_string = header_msg.add_id_strings();
+        id_string->set_key(i);
+        id_string->set_value(system->getMasterName(i));
+    }
+
+    traceStream->write(header_msg);
 }
 
 void
index 158c5aacb63466844f9bc2c2869d1be5f6e365fb..51abebcf349b92ca47fb312c76f38102de3a6f6e 100644 (file)
@@ -45,6 +45,7 @@
 #include "proto/protoio.hh"
 
 struct MemTraceProbeParams;
+class System;
 
 class MemTraceProbe : public BaseMemProbe
 {
@@ -60,11 +61,15 @@ class MemTraceProbe : public BaseMemProbe
      */
     void closeStreams();
 
+    void startup() override;
+
   protected:
 
     /** Trace output stream */
     ProtoOutputStream *traceStream;
 
+    System *system;
+
   private:
 
     /** Include the Program Counter in the memory trace */