Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/4800

Change subject: mem: Fill the new packet ID fields with master IDs when tracing packets.
......................................................................

mem: Fill the new packet ID fields with master IDs when tracing packets.

This will let somebody consuming the memory packet trace make sense out of
the master IDs passed along with individual accesses.

Change-Id: I621d915f218728066ce95e6fc81f36d14ae7e597
---
M src/mem/probes/MemTraceProbe.py
M src/mem/probes/mem_trace.cc
M src/mem/probes/mem_trace.hh
3 files changed, 27 insertions(+), 7 deletions(-)



diff --git a/src/mem/probes/MemTraceProbe.py b/src/mem/probes/MemTraceProbe.py
index c51ec92..8daf94d 100644
--- a/src/mem/probes/MemTraceProbe.py
+++ b/src/mem/probes/MemTraceProbe.py
@@ -52,3 +52,5 @@
     # 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")
diff --git a/src/mem/probes/mem_trace.cc b/src/mem/probes/mem_trace.cc
index 465c100..6e55c48 100644
--- a/src/mem/probes/mem_trace.cc
+++ b/src/mem/probes/mem_trace.cc
@@ -44,10 +44,12 @@
 #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,13 +74,6 @@

     traceStream = new ProtoOutputStream(filename);

-    // 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.
@@ -87,6 +82,24 @@
 }

 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);
+
+    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
 MemTraceProbe::closeStreams()
 {
     if (traceStream != NULL)
diff --git a/src/mem/probes/mem_trace.hh b/src/mem/probes/mem_trace.hh
index 158c5aa..51abebc 100644
--- a/src/mem/probes/mem_trace.hh
+++ b/src/mem/probes/mem_trace.hh
@@ -45,6 +45,7 @@
 #include "proto/protoio.hh"

 struct MemTraceProbeParams;
+class System;

 class MemTraceProbe : public BaseMemProbe
 {
@@ -60,11 +61,15 @@
      */
     void closeStreams();

+    void startup() override;
+
   protected:

     /** Trace output stream */
     ProtoOutputStream *traceStream;

+    System *system;
+
   private:

     /** Include the Program Counter in the memory trace */

--
To view, visit https://gem5-review.googlesource.com/4800
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I621d915f218728066ce95e6fc81f36d14ae7e597
Gerrit-Change-Number: 4800
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to