summaryrefslogtreecommitdiff
path: root/src/cpu/testers/traffic_gen/generators.cc
diff options
context:
space:
mode:
authorSascha Bischoff <sascha.bischoff@arm.com>2013-08-19 03:52:32 -0400
committerSascha Bischoff <sascha.bischoff@arm.com>2013-08-19 03:52:32 -0400
commite553844efc4247f5be870fad5ea919af85858a55 (patch)
tree461a2180159436396941ace89f04a25e48bcd7fa /src/cpu/testers/traffic_gen/generators.cc
parent6279eaf1f7d28b370ede16d52475a7da372d2dde (diff)
downloadgem5-e553844efc4247f5be870fad5ea919af85858a55.tar.xz
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 (limited to 'src/cpu/testers/traffic_gen/generators.cc')
-rw-r--r--src/cpu/testers/traffic_gen/generators.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/cpu/testers/traffic_gen/generators.cc b/src/cpu/testers/traffic_gen/generators.cc
index 8a03e21d0..9d0c7e02c 100644
--- a/src/cpu/testers/traffic_gen/generators.cc
+++ b/src/cpu/testers/traffic_gen/generators.cc
@@ -205,13 +205,19 @@ RandomGen::nextPacketTick(bool elastic, Tick delay) const
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 @@ void
TraceGen::InputStream::reset()
{
trace.reset();
+ init();
}
bool