From 413ba1fdaf666118c9a340d0c23c466f4b7d7fee Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Thu, 10 May 2012 18:04:26 -0500 Subject: stats: track if the stats have been enabled and prevent requesting master id Track the point in the initialization where statistics have been registered. After this point registering new masterIds can no longer work as some SimObjects may have sized stats vectors based on the previous value. If someone tries to register a masterId after this point the simulator executes fatal(). --- src/sim/system.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/sim/system.cc') diff --git a/src/sim/system.cc b/src/sim/system.cc index 40f5ea0ce..815a4cf1c 100644 --- a/src/sim/system.cc +++ b/src/sim/system.cc @@ -410,10 +410,11 @@ System::getMasterId(std::string master_name) } } - // todo: Check if stats are enabled yet - // I just don't know a good way to do it + // Verify that the statistics haven't been enabled yet + // Otherwise objects will have sized their stat buckets and + // they will be too small - if (false) + if (Stats::enabled()) fatal("Can't request a masterId after regStats(). \ You must do so in init().\n"); -- cgit v1.2.3