changeset 013bba88efab in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=013bba88efab
description:
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:
src/cpu/testers/traffic_gen/traffic_gen.cc | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diffs (30 lines):
diff -r 00b4e2a1235c -r 013bba88efab src/cpu/testers/traffic_gen/traffic_gen.cc
--- a/src/cpu/testers/traffic_gen/traffic_gen.cc Sun Mar 23 11:11:37
2014 -0400
+++ b/src/cpu/testers/traffic_gen/traffic_gen.cc Sun Mar 23 11:11:39
2014 -0400
@@ -221,6 +221,8 @@
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 @@
// 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++) {
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev