diff options
author | Nathan Binkert <nate@binkert.org> | 2007-08-02 14:19:40 -0700 |
---|---|---|
committer | Nathan Binkert <nate@binkert.org> | 2007-08-02 14:19:40 -0700 |
commit | 4041e1ddd98ce0d3e21714b5830ac5f3e66c3765 (patch) | |
tree | 5ef0ed60e47e6e622307416b0cd7b2ff1a26f237 /src | |
parent | b3674749168dd4823795644b1bb820ce2876a615 (diff) | |
parent | 31a9114a3d449c41a796bc26cce5dce86a4d1b15 (diff) | |
download | gem5-4041e1ddd98ce0d3e21714b5830ac5f3e66c3765.tar.xz |
merge: no manual changes
--HG--
extra : convert_revision : fe31a334a6db4e4ac8489738429093c90ea94925
Diffstat (limited to 'src')
-rw-r--r-- | src/arch/alpha/linux/threadinfo.hh | 2 | ||||
-rw-r--r-- | src/base/output.cc | 5 | ||||
-rw-r--r-- | src/base/output.hh | 2 | ||||
-rw-r--r-- | src/sim/serialize.cc | 71 | ||||
-rw-r--r-- | src/sim/serialize.hh | 9 | ||||
-rw-r--r-- | src/sim/system.cc | 3 |
6 files changed, 85 insertions, 7 deletions
diff --git a/src/arch/alpha/linux/threadinfo.hh b/src/arch/alpha/linux/threadinfo.hh index caeb69f15..b9ffe02ae 100644 --- a/src/arch/alpha/linux/threadinfo.hh +++ b/src/arch/alpha/linux/threadinfo.hh @@ -57,7 +57,7 @@ class ThreadInfo * thread_info struct. So we can get the address by masking off * the lower 14 bits. */ - current = tc->readIntReg(TheISA::StackPointerReg) & ~0x3fff; + current = tc->readIntReg(TheISA::StackPointerReg) & ~ULL(0x3fff); return VPtr<thread_info>(tc, current); } diff --git a/src/base/output.cc b/src/base/output.cc index afcac03a5..9d02a4a71 100644 --- a/src/base/output.cc +++ b/src/base/output.cc @@ -87,7 +87,7 @@ OutputDirectory::resolve(const string &name) } ostream * -OutputDirectory::create(const string &name) +OutputDirectory::create(const string &name, bool binary) { if (name == "cerr" || name == "stderr") return &cerr; @@ -95,7 +95,8 @@ OutputDirectory::create(const string &name) if (name == "cout" || name == "stdout") return &cout; - ofstream *file = new ofstream(resolve(name).c_str(), ios::trunc); + ofstream *file = new ofstream(resolve(name).c_str(), + ios::trunc | binary ? ios::binary : (ios::openmode)0); if (!file->is_open()) panic("Cannot open file %s", name); diff --git a/src/base/output.hh b/src/base/output.hh index 0aae4ae81..5de0c4005 100644 --- a/src/base/output.hh +++ b/src/base/output.hh @@ -51,7 +51,7 @@ class OutputDirectory const std::string &directory(); std::string resolve(const std::string &name); - std::ostream *create(const std::string &name); + std::ostream *create(const std::string &name, bool binary = false); std::ostream *find(const std::string &name); static bool isFile(const std::ostream *os); diff --git a/src/sim/serialize.cc b/src/sim/serialize.cc index a01e053b9..a7f81d5fb 100644 --- a/src/sim/serialize.cc +++ b/src/sim/serialize.cc @@ -40,6 +40,7 @@ #include <string> #include <vector> +#include "base/annotate.hh" #include "base/inifile.hh" #include "base/misc.hh" #include "base/output.hh" @@ -178,6 +179,22 @@ paramOut(ostream &os, const std::string &name, const T ¶m) os << "\n"; } +template <class T> +void +arrayParamOut(ostream &os, const std::string &name, + const std::vector<T> ¶m) +{ + int size = param.size(); + os << name << "="; + if (size > 0) + showParam(os, param[0]); + for (int i = 1; i < size; ++i) { + os << " "; + showParam(os, param[i]); + } + os << "\n"; +} + template <class T> void @@ -251,6 +268,49 @@ arrayParamIn(Checkpoint *cp, const std::string §ion, } } +template <class T> +void +arrayParamIn(Checkpoint *cp, const std::string §ion, + const std::string &name, std::vector<T> ¶m) +{ + std::string str; + if (!cp->find(section, name, str)) { + fatal("Can't unserialize '%s:%s'\n", section, name); + } + + // code below stolen from VectorParam<T>::parse(). + // it would be nice to unify these somehow... + + vector<string> tokens; + + tokenize(tokens, str, ' '); + + // Need this if we were doing a vector + // value.resize(tokens.size()); + + param.resize(tokens.size()); + + for (int i = 0; i < tokens.size(); i++) { + // need to parse into local variable to handle vector<bool>, + // for which operator[] returns a special reference class + // that's not the same as 'bool&', (since it's a packed + // vector) + T scalar_value; + if (!parseParam(tokens[i], scalar_value)) { + string err("could not parse \""); + + err += str; + err += "\""; + + fatal(err); + } + + // assign parsed value to vector + param[i] = scalar_value; + } +} + + void objParamIn(Checkpoint *cp, const std::string §ion, @@ -273,7 +333,13 @@ arrayParamOut(ostream &os, const std::string &name, \ type const *param, int size); \ template void \ arrayParamIn(Checkpoint *cp, const std::string §ion, \ - const std::string &name, type *param, int size); + const std::string &name, type *param, int size); \ +template void \ +arrayParamOut(ostream &os, const std::string &name, \ + const std::vector<type> ¶m); \ +template void \ +arrayParamIn(Checkpoint *cp, const std::string §ion, \ + const std::string &name, std::vector<type> ¶m); INSTANTIATE_PARAM_TEMPLATES(signed char) INSTANTIATE_PARAM_TEMPLATES(unsigned char) @@ -343,6 +409,7 @@ Serializable::serializeAll(const std::string &cpt_dir) outstream << "// checkpoint generated: " << ctime(&t); globals.serialize(outstream); + Annotate::annotations.serialize(outstream); SimObject::serializeAll(outstream); } @@ -358,7 +425,7 @@ Serializable::unserializeAll(const std::string &cpt_dir) dir); Checkpoint *cp = new Checkpoint(dir, section); unserializeGlobals(cp); - + Annotate::annotations.unserialize(cp); SimObject::unserializeAll(cp); } diff --git a/src/sim/serialize.hh b/src/sim/serialize.hh index 43cd4ecf4..e72eedb30 100644 --- a/src/sim/serialize.hh +++ b/src/sim/serialize.hh @@ -39,6 +39,7 @@ #include <list> +#include <vector> #include <iostream> #include <map> @@ -61,9 +62,17 @@ void arrayParamOut(std::ostream &os, const std::string &name, const T *param, int size); template <class T> +void arrayParamOut(std::ostream &os, const std::string &name, + const std::vector<T> ¶m); + +template <class T> void arrayParamIn(Checkpoint *cp, const std::string §ion, const std::string &name, T *param, int size); +template <class T> +void arrayParamIn(Checkpoint *cp, const std::string §ion, + const std::string &name, std::vector<T> ¶m); + void objParamIn(Checkpoint *cp, const std::string §ion, const std::string &name, SimObject * ¶m); diff --git a/src/sim/system.cc b/src/sim/system.cc index 3c4746e93..eb0655aa5 100644 --- a/src/sim/system.cc +++ b/src/sim/system.cc @@ -72,7 +72,8 @@ System::System(Params *p) #if FULL_SYSTEM kernelSymtab = new SymbolTable; - debugSymbolTable = new SymbolTable; + if (!debugSymbolTable) + debugSymbolTable = new SymbolTable; /** |