From d7ad8dc608dd6de4ff9c930de79edcdc3bdf8d40 Mon Sep 17 00:00:00 2001 From: Andreas Hansson Date: Mon, 15 Oct 2012 08:12:29 -0400 Subject: Checkpoint: Make system serialize call children This patch changes how the serialization of the system works. The base class had a non-virtual serialize and unserialize, that was hidden by a function with the same name for a number of subclasses (most likely not intentional as the base class should have been virtual). A few of the derived systems had no specialization at all (e.g. Power and x86 that simply called the System::serialize), but MIPS and Alpha adds additional symbol table entries to the checkpoint. Instead of overriding the virtual function, the additional entries are now printed through a virtual function (un)serializeSymtab. The reason for not calling System::serialize from the two related systems is that a follow up patch will require the system to also serialize the PhysicalMemory, and if this is done in the base class if ends up being between the general parts and the specialized symbol table. With this patch, the checkpoint is not modified, as the order of the segments is unchanged. --- src/sim/system.cc | 2 ++ src/sim/system.hh | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) (limited to 'src/sim') diff --git a/src/sim/system.cc b/src/sim/system.cc index 4871ac824..65eb0e3eb 100644 --- a/src/sim/system.cc +++ b/src/sim/system.cc @@ -341,6 +341,7 @@ System::serialize(ostream &os) kernelSymtab->serialize("kernel_symtab", os); SERIALIZE_SCALAR(pagePtr); SERIALIZE_SCALAR(nextPID); + serializeSymtab(os); } @@ -351,6 +352,7 @@ System::unserialize(Checkpoint *cp, const string §ion) kernelSymtab->unserialize("kernel_symtab", cp, section); UNSERIALIZE_SCALAR(pagePtr); UNSERIALIZE_SCALAR(nextPID); + unserializeSymtab(cp, section); } void diff --git a/src/sim/system.hh b/src/sim/system.hh index 4348ecaca..2393c83f2 100644 --- a/src/sim/system.hh +++ b/src/sim/system.hh @@ -403,6 +403,26 @@ class System : public MemObject // For futex system call std::map * > futexMap; + protected: + + /** + * If needed, serialize additional symbol table entries for a + * specific subclass of this sytem. Currently this is used by + * Alpha and MIPS. + * + * @param os stream to serialize to + */ + virtual void serializeSymtab(std::ostream &os) {} + + /** + * If needed, unserialize additional symbol table entries for a + * specific subclass of this system. + * + * @param cp checkpoint to unserialize from + * @param section relevant section in the checkpoint + */ + virtual void unserializeSymtab(Checkpoint *cp, + const std::string §ion) {} }; -- cgit v1.2.3