Go to the documentation of this file.
47 #include <sys/types.h>
58 #include "debug/Checkpoint.hh"
82 : unserializedCurTick(0) {}
107 paramIn(
cp,
"curTick", unserializedCurTick);
111 if (!
cp.find(section,
"version_tags", str)) {
112 warn(
"**********************************************************\n");
113 warn(
"!!!! Checkpoint uses an old versioning scheme. !!!!\n");
114 warn(
"Run the checkpoint upgrader (util/cpt_upgrader.py) on your "
116 warn(
"**********************************************************\n");
120 std::set<std::string> cpt_tags;
125 if (cpt_tags.find(
t) == cpt_tags.end()) {
128 warn(
"*****************************************************\n");
129 warn(
"!!!! Checkpoint is missing the following version tags:\n");
136 warn(
"You might experience some issues when restoring and should run "
137 "the checkpoint upgrader (util/cpt_upgrader.py) on your "
139 warn(
"**********************************************************\n");
143 for (
const auto&
t : cpt_tags) {
147 warn(
"*****************************************************\n");
148 warn(
"!!!! gem5 is missing the following version tags:\n");
155 warn(
"Running a checkpoint with incompatible version tags is not "
156 "supported. While it might work, you may experience incorrect "
157 "behavior or crashes.\n");
158 warn(
"**********************************************************\n");
188 if (mkdir(dir.c_str(), 0775) == -1 && errno != EEXIST)
189 fatal(
"couldn't mkdir %s\n", dir);
192 ofstream outstream(cpt_file.c_str());
193 time_t
t = time(NULL);
194 if (!outstream.is_open())
195 fatal(
"Unable to open file %s for writing\n", cpt_file.c_str());
196 outstream <<
"## checkpoint generated: " << ctime(&
t);
214 assert(!path.empty());
215 DPRINTF(Checkpoint,
"Popping: %s\n", path.top());
225 path.push(
csprintf(
"%s.%s", path.top(), obj_name));
227 DPRINTF(Checkpoint,
"ScopedCheckpointSection::pushName: %s\n", obj_name);
233 DPRINTF(Checkpoint,
"ScopedCheckpointSection::nameOut: %s\n",
241 assert(!path.empty());
255 currentDirectory = (
name.find(
"%") != string::npos) ?
257 if (currentDirectory[currentDirectory.size() - 1] !=
'/')
258 currentDirectory +=
"/";
259 return currentDirectory;
265 return currentDirectory;
269 : db(new
IniFile), objNameResolver(resolver), _cptDir(setDir(cpt_dir))
272 if (!
db->
load(filename)) {
273 fatal(
"Can't load checkpoint file '%s'\n", filename);
308 return db->
find(section, entry, value);
326 if (!
db->
find(section, entry, path))
343 if (!
cp.findObj(section,
name, param)) {
344 fatal(
"Can't unserialize '%s:%s'\n", section,
name);
void nameOut(CheckpointOut &cp)
#define fatal(...)
This implements a cprintf based fatal() function.
Base class to wrap object resolving functionality.
void serialize(CheckpointOut &cp) const override
Serialize an object.
void unserializeSection(CheckpointIn &cp, const char *name)
Unserialize an a child object.
SimObjectResolver & objNameResolver
CheckpointIn(const std::string &cpt_dir, SimObjectResolver &resolver)
~ScopedCheckpointSection()
Globals globals
The one and only instance of the Globals class.
static void serializeAll(CheckpointOut &cp)
Serialize all SimObjects in the system.
Basic support for object serialization.
bool sectionExists(const std::string §ion)
virtual SimObject * resolveSimObject(const std::string &name)=0
Find a SimObject given a full path name.
bool find(const std::string §ion, const std::string &entry, std::string &value) const
Find value corresponding to given section and entry names.
uint64_t Tick
Tick count type.
This class represents the contents of a ".ini" file.
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 serialize(const ThreadContext &tc, CheckpointOut &cp)
Thread context serialization helpers.
bool findObj(const std::string §ion, const std::string &entry, SimObject *&value)
static std::string setDir(const std::string &base_name)
Set the current directory.
bool find(const std::string §ion, const std::string &entry, std::string &value)
void serializeSection(CheckpointOut &cp, const char *name) const
Serialize an object into a new section.
bool entryExists(const std::string §ion, const std::string &entry) const
Determine whether the entry exists within named section exists in the .ini file.
void paramOut(CheckpointOut &cp, const string &name, ExtMachInst const &machInst)
void unserialize(ThreadContext &tc, CheckpointIn &cp)
void debug_serialize(const string &cpt_dir)
vector< EventQueue * > mainEventQueue
Array for main event queues.
Container for serializing global variables (not associated with any serialized object).
void pushName(const char *name)
static const char * baseFilename
static void unserializeGlobals(CheckpointIn &cp)
const std::string & name()
void unserialize(CheckpointIn &cp) override
Unserialize an object.
void objParamIn(CheckpointIn &cp, const string &name, SimObject *¶m)
static std::string dir()
Get the current checkout directory name.
const std::string getCptDir()
bool entryExists(const std::string §ion, const std::string &entry)
Overload hash function for BasicBlockRange type.
#define SERIALIZE_CONTAINER(member)
void paramIn(CheckpointIn &cp, const string &name, ExtMachInst &machInst)
static void serializeAll(const std::string &cpt_dir)
Serializes all the SimObjects.
std::ostream CheckpointOut
void arrayParamIn(CheckpointIn &cp, const std::string &name, CircleBuf< T > ¶m)
static const std::string & currentSection()
Gets the fully-qualified name of the active section.
bool load(std::istream &f)
Load parameter settings from given istream.
uint32_t numMainEventQueues
Current number of allocated main event queues.
bool sectionExists(const std::string §ion) const
Determine whether the named section exists in the .ini file.
std::string csprintf(const char *format, const Args &...args)
static std::string currentDirectory
static std::stack< std::string > path
Tick curTick()
The current simulated tick.
Abstract superclass for simulation objects.
Generated on Wed Sep 30 2020 14:02:14 for gem5 by doxygen 1.8.17