summaryrefslogtreecommitdiff
path: root/sim/builder.cc
diff options
context:
space:
mode:
authorNathan Binkert <binkertn@umich.edu>2004-01-29 00:38:18 -0500
committerNathan Binkert <binkertn@umich.edu>2004-01-29 00:38:18 -0500
commit2db1b6ea1b61665908138d7004001d494c168d85 (patch)
treee57ab8297cc47a1bfc93bd63e84577f4ad59303f /sim/builder.cc
parentf994cf4b5edb0eea23b695e1ee4f3a9d7b811b82 (diff)
downloadgem5-2db1b6ea1b61665908138d7004001d494c168d85.tar.xz
provide an output stream for simulator output. (This takes place of the
statStream catchall that we had before) Also provide an optional output directory that multiple simulator output files can be written to. Make most output files use the output directory base/misc.cc: send warnings to the outputStream as well base/trace.cc: dprintf_stream defaults to cerr dev/console.cc: use the output directory for the console output if it exists dev/etherdump.cc: dump to the output directory if it exists sim/builder.cc: sim/builder.hh: move constructor and destructor to .cc file use a function to get the stream that the builder dumps its output to, and create a separate file in the output directory if able sim/main.cc: statStream -> outputStream sim/serialize.cc: dump checkpoints to the output directory if specified sim/universe.cc: provide an output stream for simulator output. (This takes place of the statStream catchall that we had before) Also provide an optional output directory that multiple simulator output files can be written to. --HG-- extra : convert_revision : 03abce20edbbf7ec19c9ddd8d69ec8485c383532
Diffstat (limited to 'sim/builder.cc')
-rw-r--r--sim/builder.cc45
1 files changed, 40 insertions, 5 deletions
diff --git a/sim/builder.cc b/sim/builder.cc
index fa435d322..e2345556e 100644
--- a/sim/builder.cc
+++ b/sim/builder.cc
@@ -34,10 +34,45 @@
#include "sim/configfile.hh"
#include "sim/host.hh"
#include "sim/sim_object.hh"
-#include "sim/sim_stats.hh"
+#include "sim/universe.hh"
using namespace std;
+
+ostream &
+builderStream()
+{
+ static ofstream file;
+ static ostream *stream = NULL;
+
+ if (!stream) {
+ if (!outputDirectory.empty()) {
+ string filename = outputDirectory + "builder.txt";
+ file.open(filename.c_str());
+ stream = &file;
+ } else {
+ stream = outputStream;
+ }
+ }
+
+ return *stream;
+}
+
+SimObjectBuilder::SimObjectBuilder(const string &_configClass,
+ const string &_instanceName,
+ ConfigNode *_configNode,
+ const string &_simObjClassName)
+ : ParamContext(_configClass, true),
+ instanceName(_instanceName),
+ configNode(_configNode),
+ simObjClassName(_simObjClassName)
+{
+}
+
+SimObjectBuilder::~SimObjectBuilder()
+{
+}
+
///////////////////////////////////////////
//
// SimObjectBuilder member definitions
@@ -151,10 +186,10 @@ SimObjectClass::createObject(IniFile &configDB,
// echo object parameters to stats file (for documenting the
// config used to generate the associated stats)
- *statStream << "[" << object->name() << "]" << endl;
- *statStream << "type=" << simObjClassName << endl;
- objectBuilder->showParams(*statStream);
- *statStream << endl;
+ builderStream() << "[" << object->name() << "]" << endl;
+ builderStream() << "type=" << simObjClassName << endl;
+ objectBuilder->showParams(builderStream());
+ builderStream() << endl;
// done with the SimObjectBuilder now
delete objectBuilder;