1a2,13
> * Copyright (c) 2015 ARM Limited
> * All rights reserved
> *
> * The license below extends only to copyright in the software and shall
> * not be construed as granting a license to any other intellectual
> * property including but not limited to intellectual property relating
> * to a hardware implementation of the functionality of the software
> * licensed hereunder. You may use the software subject to the license
> * terms below provided that you ensure that this notice is replicated
> * unmodified and in its entirety in all distributions of the software,
> * modified or unmodified, in source code or in binary form.
> *
32a45
> * Andreas Sandberg
49a63
> #include "debug/Checkpoint.hh"
74c88
< showParam(ostream &os, const T &value)
---
> showParam(CheckpointOut &os, const T &value)
90c104
< showParam(ostream &os, const char &value)
---
> showParam(CheckpointOut &os, const char &value)
98c112
< showParam(ostream &os, const signed char &value)
---
> showParam(CheckpointOut &os, const signed char &value)
106c120
< showParam(ostream &os, const unsigned char &value)
---
> showParam(CheckpointOut &os, const unsigned char &value)
136c150
< showParam(ostream &os, const bool &value)
---
> showParam(CheckpointOut &os, const bool &value)
153a168
> std::stack<std::string> Serializable::path;
155,166d169
< void
< Serializable::nameOut(ostream &os)
< {
< os << "\n[" << name() << "]\n";
< }
<
< void
< Serializable::nameOut(ostream &os, const string &_name)
< {
< os << "\n[" << _name << "]\n";
< }
<
169c172
< paramOut(ostream &os, const string &name, const T &param)
---
> paramOut(CheckpointOut &os, const string &name, const T &param)
178c181
< arrayParamOut(ostream &os, const string &name, const vector<T> &param)
---
> arrayParamOut(CheckpointOut &os, const string &name, const vector<T> &param)
193c196
< arrayParamOut(ostream &os, const string &name, const list<T> &param)
---
> arrayParamOut(CheckpointOut &os, const string &name, const list<T> &param)
211c214
< paramIn(Checkpoint *cp, const string &section, const string &name, T &param)
---
> paramIn(CheckpointIn &cp, const string &name, T &param)
212a216
> const string &section(Serializable::currentSection());
214c218
< if (!cp->find(section, name, str) || !parseParam(str, param)) {
---
> if (!cp.find(section, name, str) || !parseParam(str, param)) {
221c225
< optParamIn(Checkpoint *cp, const string &section, const string &name, T &param)
---
> optParamIn(CheckpointIn &cp, const string &name, T &param)
222a227
> const string &section(Serializable::currentSection());
224c229
< if (!cp->find(section, name, str) || !parseParam(str, param)) {
---
> if (!cp.find(section, name, str) || !parseParam(str, param)) {
234c239,240
< arrayParamOut(ostream &os, const string &name, const T *param, unsigned size)
---
> arrayParamOut(CheckpointOut &os, const string &name,
> const T *param, unsigned size)
249,250c255
< arrayParamIn(Checkpoint *cp, const string &section, const string &name,
< T *param, unsigned size)
---
> arrayParamIn(CheckpointIn &cp, const string &name, T *param, unsigned size)
251a257
> const string &section(Serializable::currentSection());
253c259
< if (!cp->find(section, name, str)) {
---
> if (!cp.find(section, name, str)) {
276c282
< T scalar_value = 0;
---
> T scalar_value;
293,294c299
< arrayParamIn(Checkpoint *cp, const string &section,
< const string &name, vector<T> &param)
---
> arrayParamIn(CheckpointIn &cp, const string &name, vector<T> &param)
295a301
> const string &section(Serializable::currentSection());
297c303
< if (!cp->find(section, name, str)) {
---
> if (!cp.find(section, name, str)) {
318c324
< T scalar_value = 0;
---
> T scalar_value;
335,336c341
< arrayParamIn(Checkpoint *cp, const string &section,
< const string &name, list<T> &param)
---
> arrayParamIn(CheckpointIn &cp, const string &name, list<T> &param)
337a343
> const string &section(Serializable::currentSection());
339c345
< if (!cp->find(section, name, str)) {
---
> if (!cp.find(section, name, str)) {
348c354
< T scalar_value = 0;
---
> T scalar_value;
365,366c371
< objParamIn(Checkpoint *cp, const string &section,
< const string &name, SimObject * &param)
---
> objParamIn(CheckpointIn &cp, const string &name, SimObject * &param)
368c373,374
< if (!cp->findObj(section, name, param)) {
---
> const string &section(Serializable::currentSection());
> if (!cp.findObj(section, name, param)) {
375,400c381,404
< template void \
< paramOut(ostream &os, const string &name, type const &param); \
< template void \
< paramIn(Checkpoint *cp, const string &section, \
< const string &name, type & param); \
< template bool \
< optParamIn(Checkpoint *cp, const string &section, \
< const string &name, type & param); \
< template void \
< arrayParamOut(ostream &os, const string &name, \
< type const *param, unsigned size); \
< template void \
< arrayParamIn(Checkpoint *cp, const string &section, \
< const string &name, type *param, unsigned size); \
< template void \
< arrayParamOut(ostream &os, const string &name, \
< const vector<type> &param); \
< template void \
< arrayParamIn(Checkpoint *cp, const string &section, \
< const string &name, vector<type> &param); \
< template void \
< arrayParamOut(ostream &os, const string &name, \
< const list<type> &param); \
< template void \
< arrayParamIn(Checkpoint *cp, const string &section, \
< const string &name, list<type> &param);
---
> template void \
> paramOut(CheckpointOut &os, const string &name, type const &param); \
> template void \
> paramIn(CheckpointIn &cp, const string &name, type & param); \
> template bool \
> optParamIn(CheckpointIn &cp, const string &name, type & param); \
> template void \
> arrayParamOut(CheckpointOut &os, const string &name, \
> type const *param, unsigned size); \
> template void \
> arrayParamIn(CheckpointIn &cp, const string &name, \
> type *param, unsigned size); \
> template void \
> arrayParamOut(CheckpointOut &os, const string &name, \
> const vector<type> &param); \
> template void \
> arrayParamIn(CheckpointIn &cp, const string &name, \
> vector<type> &param); \
> template void \
> arrayParamOut(CheckpointOut &os, const string &name, \
> const list<type> &param); \
> template void \
> arrayParamIn(CheckpointIn &cp, const string &name, \
> list<type> &param);
426,428c430,436
< const string name() const;
< void serialize(ostream &os);
< void unserialize(Checkpoint *cp, const std::string &section);
---
> Globals()
> : unserializedCurTick(0) {}
>
> void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
> void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
>
> Tick unserializedCurTick;
434,439d441
< const string
< Globals::name() const
< {
< return "Globals";
< }
<
441c443
< Globals::serialize(ostream &os)
---
> Globals::serialize(CheckpointOut &cp) const
443,444c445,446
< nameOut(os);
< paramOut(os, "curTick", curTick());
---
> paramOut(cp, "curTick", curTick());
> paramOut(cp, "numMainEventQueues", numMainEventQueues);
446,451d447
< paramOut(os, "numMainEventQueues", numMainEventQueues);
<
< for (uint32_t i = 0; i < numMainEventQueues; ++i) {
< nameOut(os, "MainEventQueue");
< mainEventQueue[i]->serialize(os);
< }
455c451
< Globals::unserialize(Checkpoint *cp, const std::string &section)
---
> Globals::unserialize(CheckpointIn &cp)
457,464c453,454
< Tick tick;
< paramIn(cp, section, "curTick", tick);
< paramIn(cp, section, "numMainEventQueues", numMainEventQueues);
<
< for (uint32_t i = 0; i < numMainEventQueues; ++i) {
< mainEventQueue[i]->setCurTick(tick);
< mainEventQueue[i]->unserialize(cp, "MainEventQueue");
< }
---
> paramIn(cp, "curTick", unserializedCurTick);
> paramIn(cp, "numMainEventQueues", numMainEventQueues);
476c466
< Serializable::serialize(ostream &os)
---
> Serializable::serializeSection(CheckpointOut &cp, const char *name) const
477a468,469
> Serializable::ScopedCheckpointSection sec(cp, name);
> serialize(cp);
481c473
< Serializable::unserialize(Checkpoint *cp, const string &section)
---
> Serializable::serializeSectionOld(CheckpointOut &cp, const char *name)
482a475,476
> Serializable::ScopedCheckpointSection sec(cp, name);
> serializeOld(cp);
485a480,486
> Serializable::unserializeSection(CheckpointIn &cp, const char *name)
> {
> Serializable::ScopedCheckpointSection sec(cp, name);
> unserialize(cp);
> }
>
> void
488c489
< string dir = Checkpoint::setDir(cpt_dir);
---
> string dir = CheckpointIn::setDir(cpt_dir);
492c493
< string cpt_file = dir + Checkpoint::baseFilename;
---
> string cpt_file = dir + CheckpointIn::baseFilename;
499c500,503
< globals.serialize(outstream);
---
> globals.serializeSection(outstream, "Globals");
> for (uint32_t i = 0; i < numMainEventQueues; ++i)
> mainEventQueue[i]->serializeSection(outstream, "MainEventQueue");
>
504c508
< Serializable::unserializeGlobals(Checkpoint *cp)
---
> Serializable::unserializeGlobals(CheckpointIn &cp)
506c510,515
< globals.unserialize(cp, globals.name());
---
> globals.unserializeSection(cp, "Globals");
>
> for (uint32_t i = 0; i < numMainEventQueues; ++i) {
> mainEventQueue[i]->setCurTick(globals.unserializedCurTick);
> mainEventQueue[i]->unserializeSection(cp, "MainEventQueue");
> }
508a518,524
> Serializable::ScopedCheckpointSection::~ScopedCheckpointSection()
> {
> assert(!path.empty());
> DPRINTF(Checkpoint, "Popping: %s\n", path.top());
> path.pop();
> }
>
509a526,544
> Serializable::ScopedCheckpointSection::pushName(const char *obj_name)
> {
> if (path.empty()) {
> path.push(obj_name);
> } else {
> path.push(csprintf("%s.%s", path.top(), obj_name));
> }
> DPRINTF(Checkpoint, "ScopedCheckpointSection::pushName: %s\n", obj_name);
> }
>
> void
> Serializable::ScopedCheckpointSection::nameOut(CheckpointOut &cp)
> {
> DPRINTF(Checkpoint, "ScopedCheckpointSection::nameOut: %s\n",
> Serializable::currentSection());
> cp << "\n[" << Serializable::currentSection() << "]\n";
> }
>
> void
545c580
< SerializableClass::createObject(Checkpoint *cp, const string &section)
---
> SerializableClass::createObject(CheckpointIn &cp, const string &section)
549c584
< if (!cp->find(section, "type", className)) {
---
> if (!cp.find(section, "type", className)) {
567a603,606
> const std::string &
> Serializable::currentSection()
> {
> assert(!path.empty());
568a608,610
> return path.top();
> }
>
570c612
< Serializable::create(Checkpoint *cp, const string &section)
---
> Serializable::create(CheckpointIn &cp, const string &section)
573c615
< object->unserialize(cp, section);
---
> object->unserializeSection(cp, section);
578c620
< const char *Checkpoint::baseFilename = "m5.cpt";
---
> const char *CheckpointIn::baseFilename = "m5.cpt";
580c622
< string Checkpoint::currentDirectory;
---
> string CheckpointIn::currentDirectory;
583c625
< Checkpoint::setDir(const string &name)
---
> CheckpointIn::setDir(const string &name)
595c637
< Checkpoint::dir()
---
> CheckpointIn::dir()
601c643
< Checkpoint::Checkpoint(const string &cpt_dir, SimObjectResolver &resolver)
---
> CheckpointIn::CheckpointIn(const string &cpt_dir, SimObjectResolver &resolver)
604c646
< string filename = cptDir + "/" + Checkpoint::baseFilename;
---
> string filename = cptDir + "/" + CheckpointIn::baseFilename;
610c652
< Checkpoint::~Checkpoint()
---
> CheckpointIn::~CheckpointIn()
616c658
< Checkpoint::find(const string &section, const string &entry, string &value)
---
> CheckpointIn::find(const string &section, const string &entry, string &value)
623c665
< Checkpoint::findObj(const string &section, const string &entry,
---
> CheckpointIn::findObj(const string &section, const string &entry,
637c679
< Checkpoint::sectionExists(const string &section)
---
> CheckpointIn::sectionExists(const string &section)