Merge zizzer.eecs.umich.edu:/bk/m5

into ziff.eecs.umich.edu:/z/binkertn/research/m5/latest

--HG--
extra : convert_revision : bff2fb78e205f327ce8d04f3ae1b2352857ab824
This commit is contained in:
Nathan Binkert
2004-01-11 21:22:33 -05:00
8 changed files with 76 additions and 60 deletions

View File

@@ -127,7 +127,7 @@ namespace AlphaPseudo
Tick when = curTick + NS2Ticks(delay);
Tick repeat = NS2Ticks(period);
SetupCheckpoint(when, repeat);
Checkpoint::setup(when, repeat);
}
class Context : public ParamContext

View File

@@ -45,8 +45,6 @@ ArgList::dump(const string &format)
stream->fill(' ');
stream->flags((ios::fmtflags)0);
Format fmt;
while (*p) {
switch (*p) {
case '%': {
@@ -56,12 +54,7 @@ ArgList::dump(const string &format)
continue;
}
if (objects.empty())
format_invalid(*stream);
Base *data = objects.front();
fmt.clear();
Format fmt;
bool done = false;
bool end_number = false;
bool have_precision = false;
@@ -205,18 +198,26 @@ ArgList::dump(const string &format)
}
}
ios::fmtflags saved_flags = stream->flags();
char old_fill = stream->fill();
int old_precision = stream->precision();
if (!objects.empty())
{
Base *data = objects.front();
objects.pop_front();
data->process(*stream, fmt);
ios::fmtflags saved_flags = stream->flags();
char old_fill = stream->fill();
int old_precision = stream->precision();
stream->flags(saved_flags);
stream->fill(old_fill);
stream->precision(old_precision);
data->process(*stream, fmt);
stream->flags(saved_flags);
stream->fill(old_fill);
stream->precision(old_precision);
delete data;
} else {
*stream << "<missing arg for format>";
}
delete data;
objects.pop_front();
++p;
}
break;
@@ -241,10 +242,10 @@ ArgList::dump(const string &format)
}
while (!objects.empty()) {
*stream << "<extra arg>";
Base *data = objects.front();
data->process(*stream, fmt);
delete data;
objects.pop_front();
delete data;
}
}

View File

@@ -75,7 +75,7 @@ class ArgList
break;
default:
format_invalid(out);
out << "<bad format>";
break;
}
}

View File

@@ -43,8 +43,10 @@ struct Format
int precision;
int width;
Format() { }
void clear() {
Format() { clear(); }
void clear()
{
alternate_form = false;
flush_left = false;
print_sign = false;
@@ -58,15 +60,6 @@ struct Format
}
};
inline void
format_invalid(std::ostream &out)
{
using namespace std;
out << "format invalid!!!" << endl;
}
template <typename T>
inline void
_format_char(std::ostream &out, const T& data, Format &fmt)
@@ -233,7 +226,7 @@ _format_string(std::ostream &out, const T& data, Format &fmt)
template <typename T>
inline void
format_char(std::ostream &out, const T& data, Format &fmt)
{ format_invalid(out); }
{ out << "<bad arg type for char format>"; }
inline void
format_char(std::ostream &out, char data, Format &fmt)
@@ -329,7 +322,7 @@ format_integer(std::ostream &out, unsigned long long data, Format &fmt)
template <typename T>
inline void
format_float(std::ostream &out, const T& data, Format &fmt)
{ format_invalid(out); }
{ out << "<bad arg type for float format>"; }
inline void
format_float(std::ostream &out, float data, Format &fmt)

View File

@@ -29,8 +29,13 @@
#ifndef __ELF_OBJECT_HH__
#define __ELF_OBJECT_HH__
#include <libelf/gelf.h>
/* Because of the -Wundef flag we have to do this */
#define __LIBELF_INTERNAL__ 0
#define __LIBELF64_LINUX 1
#define __LIBELF_NEED_LINK_H 0
#include <libelf/libelf.h>
#include <libelf/gelf.h>
#include "base/loader/object_file.hh"
class ElfObject : public ObjectFile

View File

@@ -405,7 +405,7 @@ CowDiskImage::write(const uint8_t *data, off_t offset)
void
CowDiskImage::serialize(ostream &os)
{
string cowFilename = CheckpointDir() + name() + ".cow";
string cowFilename = Checkpoint::dir() + name() + ".cow";
SERIALIZE_SCALAR(cowFilename);
save(cowFilename);
}

View File

@@ -222,11 +222,11 @@ Globals::unserialize(Checkpoint *cp)
void
Serializable::serializeAll()
{
string dir = CheckpointDir();
string dir = Checkpoint::dir();
if (mkdir(dir.c_str(), 0775) == -1 && errno != EEXIST)
warn("could mkdir %s\n", dir);
fatal("couldn't mkdir %s\n", dir);
string cpt_file = dir + "m5.cpt";
string cpt_file = dir + Checkpoint::baseFilename;
ofstream outstream(cpt_file.c_str());
time_t t = time(NULL);
outstream << "// checkpoint generated: " << ctime(&t);
@@ -273,19 +273,21 @@ SerializeEvent::process()
schedule(curTick + repeat);
}
string __CheckpointDirBase;
const char *Checkpoint::baseFilename = "m5.cpt";
static string checkpointDirBase;
string
CheckpointDir()
Checkpoint::dir()
{
if (__CheckpointDirBase.empty())
return __CheckpointDirBase;
return csprintf("%s/m5.%012d/", __CheckpointDirBase, curTick);
// use csprintf to insert curTick into directory name if it
// appears to have a format placeholder in it.
return (checkpointDirBase.find("%") != string::npos) ?
csprintf(checkpointDirBase, curTick) : checkpointDirBase;
}
void
SetupCheckpoint(Tick when, Tick period)
Checkpoint::setup(Tick when, Tick period)
{
new SerializeEvent(when, period);
}
@@ -304,8 +306,9 @@ class SerializeParamContext : public ParamContext
SerializeParamContext serialParams("serialize");
Param<string> serialize_dir(&serialParams,
"dir",
"dir to stick checkpoint in", ".");
"dir",
"dir to stick checkpoint in "
"(sprintf format with cycle #)", "m5.%012d");
Param<Counter> serialize_cycle(&serialParams,
"cycle",
@@ -330,9 +333,14 @@ SerializeParamContext::~SerializeParamContext()
void
SerializeParamContext::checkParams()
{
__CheckpointDirBase = serialize_dir;
checkpointDirBase = serialize_dir;
// guarantee that directory ends with a '/'
if (checkpointDirBase[checkpointDirBase.size() - 1] != '/') {
checkpointDirBase += "/";
}
if (serialize_cycle > 0)
SetupCheckpoint(serialize_cycle, serialize_period);
Checkpoint::setup(serialize_cycle, serialize_period);
}
void
@@ -415,10 +423,11 @@ Serializable::create(Checkpoint *cp, const std::string &section)
}
Checkpoint::Checkpoint(const std::string &filename, const std::string &path,
Checkpoint::Checkpoint(const std::string &cpt_dir, const std::string &path,
const ConfigNode *_configNode)
: db(new IniFile), basePath(path), configNode(_configNode)
{
string filename = cpt_dir + "/" + Checkpoint::baseFilename;
if (!db->load(filename)) {
fatal("Can't load checkpoint file '%s'\n", filename);
}

View File

@@ -207,7 +207,7 @@ class Checkpoint
std::map<std::string, Serializable*> objMap;
public:
Checkpoint(const std::string &filename, const std::string &path,
Checkpoint(const std::string &cpt_dir, const std::string &path,
const ConfigNode *_configNode);
bool find(const std::string &section, const std::string &entry,
@@ -217,14 +217,22 @@ class Checkpoint
Serializable *&value);
bool sectionExists(const std::string &section);
// The following static functions have to do with checkpoint
// creation rather than restoration. This class makes a handy
// namespace for them though.
// Export current checkpoint directory name so other objects can
// derive filenames from it (e.g., memory). The return value is
// guaranteed to end in '/' so filenames can be directly appended.
// This function is only valid while a checkpoint is being created.
static std::string dir();
// Filename for base checkpoint file within directory.
static const char *baseFilename;
// Set up a checkpoint creation event or series of events.
static void setup(Tick when, Tick period = 0);
};
//
// Export checkpoint filename param so other objects can derive
// filenames from it (e.g., memory).
//
std::string CheckpointDir();
void SetupCheckpoint(Tick when, Tick period = 0);
#endif // __SERIALIZE_HH__