52 #include <sys/types.h> 63 #include "debug/Checkpoint.hh" 87 : unserializedCurTick(0) {}
112 paramIn(cp,
"curTick", unserializedCurTick);
116 if (!cp.
find(section,
"version_tags", str)) {
117 warn(
"**********************************************************\n");
118 warn(
"!!!! Checkpoint uses an old versioning scheme. !!!!\n");
119 warn(
"Run the checkpoint upgrader (util/cpt_upgrader.py) on your " 121 warn(
"**********************************************************\n");
125 std::set<std::string> cpt_tags;
130 if (cpt_tags.find(
t) == cpt_tags.end()) {
133 warn(
"*****************************************************\n");
134 warn(
"!!!! Checkpoint is missing the following version tags:\n");
141 warn(
"You might experience some issues when restoring and should run " 142 "the checkpoint upgrader (util/cpt_upgrader.py) on your " 144 warn(
"**********************************************************\n");
148 for (
const auto&
t : cpt_tags) {
149 if (version_tags.find(
t) == version_tags.end()) {
152 warn(
"*****************************************************\n");
153 warn(
"!!!! gem5 is missing the following version tags:\n");
160 warn(
"Running a checkpoint with incompatible version tags is not " 161 "supported. While it might work, you may experience incorrect " 162 "behavior or crashes.\n");
163 warn(
"**********************************************************\n");
193 if (mkdir(dir.c_str(), 0775) == -1 && errno != EEXIST)
194 fatal(
"couldn't mkdir %s\n", dir);
197 ofstream outstream(cpt_file.c_str());
198 time_t
t = time(NULL);
199 if (!outstream.is_open())
200 fatal(
"Unable to open file %s for writing\n", cpt_file.c_str());
201 outstream <<
"## checkpoint generated: " << ctime(&t);
219 assert(!path.empty());
220 DPRINTF(Checkpoint,
"Popping: %s\n", path.top());
230 path.push(
csprintf(
"%s.%s", path.top(), obj_name));
232 DPRINTF(Checkpoint,
"ScopedCheckpointSection::pushName: %s\n", obj_name);
238 DPRINTF(Checkpoint,
"ScopedCheckpointSection::nameOut: %s\n",
246 assert(!path.empty());
260 currentDirectory = (name.find(
"%") != string::npos) ?
262 if (currentDirectory[currentDirectory.size() - 1] !=
'/')
263 currentDirectory +=
"/";
264 return currentDirectory;
270 return currentDirectory;
274 : db(new
IniFile), objNameResolver(resolver), cptDir(setDir(cpt_dir))
277 if (!
db->
load(filename)) {
278 fatal(
"Can't load checkpoint file '%s'\n", filename);
296 return db->
find(section, entry, value);
305 if (!
db->
find(section, entry, path))
322 if (!cp.
findObj(section, name, param)) {
323 fatal(
"Can't unserialize '%s:%s'\n", section, name);
void unserialize(CheckpointIn &cp) override
Unserialize an object.
static void unserializeGlobals(CheckpointIn &cp)
#define fatal(...)
This implements a cprintf based fatal() function.
void pushName(const char *name)
const std::string & name()
void serializeSection(CheckpointOut &cp, const char *name) const
Serialize an object into a new section.
bool find(const std::string §ion, const std::string &entry, std::string &value) const
Find value corresponding to given section and entry names.
static std::stack< std::string > path
SimObjectResolver & objNameResolver
std::set< std::string > version_tags
The version tags for this build of the simulator, to be stored in the Globals section during serializ...
void unserializeSection(CheckpointIn &cp, const char *name)
Unserialize an a child object.
static std::string currentDirectory
static void serializeAll(CheckpointOut &cp)
Serialize all SimObjects in the system.
void debug_serialize(const string &cpt_dir)
vector< EventQueue * > mainEventQueue
Array for main event queues.
Overload hash function for BasicBlockRange type.
Globals globals
The one and only instance of the Globals class.
Container for serializing global variables (not associated with any serialized object).
Base class to wrap object resolving functionality.
virtual SimObject * resolveSimObject(const std::string &name)=0
#define SERIALIZE_CONTAINER(member)
Tick curTick()
The current simulated tick.
std::string csprintf(const char *format, const Args &...args)
bool find(const std::string §ion, const std::string &entry, std::string &value)
bool entryExists(const std::string §ion, const std::string &entry) const
Determine whether the entry exists within named section exists in the .ini file.
uint64_t Tick
Tick count type.
void paramOut(CheckpointOut &cp, const string &name, ExtMachInst const &machInst)
void serialize(const ThreadContext &tc, CheckpointOut &cp)
Thread context serialization helpers.
bool load(std::istream &f)
Load parameter settings from given istream.
~ScopedCheckpointSection()
Declaration of IniFile object.
void nameOut(CheckpointOut &cp)
Basic support for object serialization.
void serialize(CheckpointOut &cp) const override
Serialize an object.
std::ostream CheckpointOut
uint32_t numMainEventQueues
Current number of allocated main event queues.
bool sectionExists(const std::string §ion)
static const std::string & currentSection()
Get the fully-qualified name of the active section.
void paramIn(CheckpointIn &cp, const string &name, ExtMachInst &machInst)
bool entryExists(const std::string §ion, const std::string &entry)
void unserialize(ThreadContext &tc, CheckpointIn &cp)
void arrayParamIn(CheckpointIn &cp, const std::string &name, CircleBuf< T > ¶m)
bool findObj(const std::string §ion, const std::string &entry, SimObject *&value)
bool sectionExists(const std::string §ion) const
Determine whether the named section exists in the .ini file.
Scoped checkpoint section helper class.
Abstract superclass for simulation objects.
This class represents the contents of a ".ini" file.
static const char * baseFilename
void objParamIn(CheckpointIn &cp, const string &name, SimObject *¶m)
CheckpointIn(const std::string &cpt_dir, SimObjectResolver &resolver)
static std::string setDir(const std::string &base_name)
static void serializeAll(const std::string &cpt_dir)