changeset dcd0f0091854 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=dcd0f0091854
description:
        cpu: Fix TrafficGen trace playback

        This patch addresses an issue with trace playback in the TrafficGen
        where the trace was reset but the header was not read from the trace
        when a captured trace was played back for a second time. This resulted
        in parsing errors as the expected message was not found in the trace
        file.

        The header check is moved to an init funtion which is called by the
        constructor and when the trace is reset. This ensures that the trace
        header is read each time when the trace is replayed.

        This patch also addresses a small formatting issue in a panic.

diffstat:

 src/cpu/testers/traffic_gen/generators.cc |  11 +++++++++--
 src/cpu/testers/traffic_gen/generators.hh |   6 ++++++
 2 files changed, 15 insertions(+), 2 deletions(-)

diffs (49 lines):

diff -r f3facce3d2b4 -r dcd0f0091854 src/cpu/testers/traffic_gen/generators.cc
--- a/src/cpu/testers/traffic_gen/generators.cc Mon Aug 19 03:52:32 2013 -0400
+++ b/src/cpu/testers/traffic_gen/generators.cc Mon Aug 19 03:52:32 2013 -0400
@@ -205,13 +205,19 @@
 TraceGen::InputStream::InputStream(const std::string& filename)
     : trace(filename)
 {
+    init();
+}
+
+void
+TraceGen::InputStream::init()
+{
     // Create a protobuf message for the header and read it from the stream
     Message::PacketHeader header_msg;
     if (!trace.read(header_msg)) {
-        panic("Failed to read packet header from %s\n", filename);
+        panic("Failed to read packet header from trace\n");
 
         if (header_msg.tick_freq() != SimClock::Frequency) {
-            panic("Trace %s was recorded with a different tick frequency %d\n",
+            panic("Trace was recorded with a different tick frequency %d\n",
                   header_msg.tick_freq());
         }
     }
@@ -221,6 +227,7 @@
 TraceGen::InputStream::reset()
 {
     trace.reset();
+    init();
 }
 
 bool
diff -r f3facce3d2b4 -r dcd0f0091854 src/cpu/testers/traffic_gen/generators.hh
--- a/src/cpu/testers/traffic_gen/generators.hh Mon Aug 19 03:52:32 2013 -0400
+++ b/src/cpu/testers/traffic_gen/generators.hh Mon Aug 19 03:52:32 2013 -0400
@@ -380,6 +380,12 @@
         void reset();
 
         /**
+         * Check the trace header to make sure that it is of the right
+         * format.
+         */
+        void init();
+
+        /**
          * Attempt to read a trace element from the stream,
          * and also notify the caller if the end of the file
          * was reached.
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to