summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStan Czerniawski <stan.czerniawski@arm.com>2014-03-23 11:11:39 -0400
committerStan Czerniawski <stan.czerniawski@arm.com>2014-03-23 11:11:39 -0400
commite18d0e04a2d44316bc9c9e09b74bcda5562e64cc (patch)
treecb788f094a70aecc6982708d2f5543bff45beeeb /src
parent0c001e729a2d63ee205b384848a7e95ffae492f7 (diff)
downloadgem5-e18d0e04a2d44316bc9c9e09b74bcda5562e64cc.tar.xz
cpu: Add basic check to TrafficGen initial state
Prevent incomplete configuration of TrafficGen class from causing segmentation faults. If an 'INIT' line is not present in the configuration file then the currState variable will remain uninitialized which may result in a crash.
Diffstat (limited to 'src')
-rw-r--r--src/cpu/testers/traffic_gen/traffic_gen.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/cpu/testers/traffic_gen/traffic_gen.cc b/src/cpu/testers/traffic_gen/traffic_gen.cc
index b7f1ecd4e..4b2259bd9 100644
--- a/src/cpu/testers/traffic_gen/traffic_gen.cc
+++ b/src/cpu/testers/traffic_gen/traffic_gen.cc
@@ -221,6 +221,8 @@ TrafficGen::parseConfig()
name(), configFile);
}
+ bool init_state_set = false;
+
// read line by line and determine the action based on the first
// keyword
string keyword;
@@ -316,11 +318,17 @@ TrafficGen::parseConfig()
// set the initial state as the active state
is >> currState;
+ init_state_set = true;
+
DPRINTF(TrafficGen, "Initial state: %d\n", currState);
}
}
}
+ if (!init_state_set)
+ fatal("%s: initial state not specified (add 'INIT <id>' line "
+ "to the config file)\n", name());
+
// resize and populate state transition matrix
transitionMatrix.resize(states.size());
for (size_t i = 0; i < states.size(); i++) {