-- cgit v1.2.3 -- cgit v1.2.3 From c9f2aa8c1888aef0f383bdda0ce6d7d7b5a0c7fc Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Thu, 15 Jan 2004 16:33:58 -0500 Subject: Make each stat take up one full line. This allows us to use grep to find and remove stats from the files so we can put less burden on the python interpreter. base/statistics.cc: Manually insert newlines into the python code so that we now have one stat per line. (Make it so we can use grep -v to remove stats) test/stattest.cc: update to reflect changes in how python is accessed --HG-- extra : convert_revision : 554edcf9c795b33d00d3d15554447c8accebebfa --- base/statistics.cc | 58 ++++++++++++++++++++++++++++++++---------------------- test/stattest.cc | 6 ++---- 2 files changed, 37 insertions(+), 27 deletions(-) diff --git a/base/statistics.cc b/base/statistics.cc index 5c9a2bc65..298cc9a36 100644 --- a/base/statistics.cc +++ b/base/statistics.cc @@ -116,7 +116,7 @@ Data::~Data() { if (stream) { delete py; - ccprintf(*stream, "if __name__ == '__main__':\n"); + ccprintf(*stream, "\n\nif __name__ == '__main__':\n"); ccprintf(*stream, " program_display()\n"); stream->close(); delete stream; @@ -209,30 +209,42 @@ Data::python_dump(const string &name, const string &subname) ++i; } } - py->next(); +// py->next(); } void Data::python(const string &name, const string &subname, const string &bin) { - py->start("collections.append"); - py->start("Collection"); + py->name("collections.append"); + py->newline(); + py->name("Collection"); + py->newline(); py->qarg(name); + py->newline(); py->qarg(subname); + py->newline(); py->qarg(bin); + py->newline(); py->qarg(hostname()); + py->newline(); py->qarg(Time::start.date()); - py->startList(); + py->newline(); + py->list(); list_t::iterator i = allStats.begin(); list_t::iterator end = allStats.end(); while (i != end) { StatData *stat = *i; + py->newline(); stat->python(*py); ++i; } - py->endList(); - py->end(); - py->end(); + py->newline(); + py->listEnd(); + py->newline(); + py->nameEnd(); + py->newline(); + py->nameEnd(); + py->newline(); } StatData * @@ -996,7 +1008,7 @@ VectorDistDataBase::display(ostream &stream, DisplayMode mode) const void ScalarDataBase::python(Python &py) const { - py.start("Scalar"); + py.name("Scalar"); py.qarg(name); py.qqqarg(desc); py.kwarg("binned", binned()); @@ -1005,7 +1017,7 @@ ScalarDataBase::python(Python &py) const if (prereq) py.qkwarg("prereq", prereq->name); py.kwarg("value", val()); - py.end(); + py.nameEnd(); } void @@ -1013,7 +1025,7 @@ VectorDataBase::python(Python &py) const { const_cast(this)->update(); - py.start("Vector"); + py.name("Vector"); py.qarg(name); py.qqqarg(desc); py.kwarg("binned", binned()); @@ -1026,7 +1038,7 @@ VectorDataBase::python(Python &py) const py.qkwarg("subnames", subnames); if (!subdescs.empty()) py.qkwarg("subdescs", subdescs); - py.end(); + py.nameEnd(); } void @@ -1039,7 +1051,7 @@ DistDataData::python(Python &py, const string &name) const else s += "FullDist"; - py.start(s); + py.name(s); py.arg(sum); py.arg(squares); py.arg(samples); @@ -1054,7 +1066,7 @@ DistDataData::python(Python &py, const string &name) const py.arg(bucket_size); py.arg(size); } - py.end(); + py.nameEnd(); } void @@ -1062,7 +1074,7 @@ FormulaDataBase::python(Python &py) const { const_cast(this)->update(); - py.start("Formula"); + py.name("Formula"); py.qarg(name); py.qqqarg(desc); py.kwarg("binned", binned()); @@ -1075,7 +1087,7 @@ FormulaDataBase::python(Python &py) const py.qkwarg("subnames", subnames); if (!subdescs.empty()) py.qkwarg("subdescs", subdescs); - py.end(); + py.nameEnd(); } void @@ -1083,7 +1095,7 @@ DistDataBase::python(Python &py) const { const_cast(this)->update(); - py.start("Dist"); + py.name("Dist"); py.qarg(name); py.qqqarg(desc); py.kwarg("binned", binned()); @@ -1092,7 +1104,7 @@ DistDataBase::python(Python &py) const if (prereq) py.qkwarg("prereq", prereq->name); data.python(py, "dist"); - py.end(); + py.nameEnd(); } void @@ -1100,7 +1112,7 @@ VectorDistDataBase::python(Python &py) const { const_cast(this)->update(); - py.start("VectorDist"); + py.name("VectorDist"); py.qarg(name); py.qqqarg(desc); py.kwarg("binned", binned()); @@ -1121,8 +1133,8 @@ VectorDistDataBase::python(Python &py) const i->python(py, ""); ++i; } - py.endTuple(); - py.end(); + py.tupleEnd(); + py.nameEnd(); } void @@ -1130,7 +1142,7 @@ Vector2dDataBase::python(Python &py) const { const_cast(this)->update(); - py.start("Vector2d"); + py.name("Vector2d"); py.qarg(name); py.qqqarg(desc); py.kwarg("binned", binned()); @@ -1149,7 +1161,7 @@ Vector2dDataBase::python(Python &py) const py.kwarg("x", x); py.kwarg("y", y); - py.end(); + py.nameEnd(); } void diff --git a/test/stattest.cc b/test/stattest.cc index d4ae5d1fd..8dd8eeb8e 100644 --- a/test/stattest.cc +++ b/test/stattest.cc @@ -510,10 +510,8 @@ main(int argc, char *argv[]) s12.sample(100); // dump(cout, mode_simplescalar); - ofstream file("/tmp/stats.py"); - dump(file, "stattest", mode_python); - file.close(); - + python_start("/tmp/stats.py"); + python_dump("stattest", "all"); return 0; } -- cgit v1.2.3 From 946b481831e813126de94d3c2c2001c2d51ccdee Mon Sep 17 00:00:00 2001 From: Steve Reinhardt Date: Tue, 20 Jan 2004 13:53:18 -0500 Subject: Set LIBELF_LINUX to 0 to build on zax. Builds but did not test... however the only thing this affects in libelf is the header, so I don't expect any functional problems. base/loader/elf_object.cc: Set LIBELF_LINUX to 0 to build on zax. --HG-- extra : convert_revision : d024b33deff6fc8ea6f1d465f76dc8d9d63254ab --- base/loader/elf_object.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/base/loader/elf_object.cc b/base/loader/elf_object.cc index 93313fac6..f2a67f22e 100644 --- a/base/loader/elf_object.cc +++ b/base/loader/elf_object.cc @@ -30,7 +30,11 @@ // Because of the -Wundef flag we have to do this #define __LIBELF_INTERNAL__ 0 -#define __LIBELF64_LINUX 1 +// counterintuitive, but the flag below causes libelf to define +// 64-bit elf types that apparently didn't exist in some older +// versions of Linux. They seem to be there in 2.4.x, so don't +// set this now (it causes things to break on 64-bit platforms). +#define __LIBELF64_LINUX 0 #define __LIBELF_NEED_LINK_H 0 #include -- cgit v1.2.3 -- cgit v1.2.3 From 01059eadedebfdc0b567edc844b46c5b02bd3991 Mon Sep 17 00:00:00 2001 From: Erik Hallnor Date: Sun, 25 Jan 2004 05:01:00 -0500 Subject: Change the way the hierarchy is separated. Now all virtual functions are in the interfaces. This allows new bus models to be used without major hassle. And I thought it was time to change it all again anyways. cpu/simple_cpu/simple_cpu.cc: Switch doEvents to doEvents() --HG-- extra : convert_revision : 14b9517017e76c7b941247004393bf260f397d9a --- cpu/simple_cpu/simple_cpu.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cpu/simple_cpu/simple_cpu.cc b/cpu/simple_cpu/simple_cpu.cc index adbd17a35..0d5fc4077 100644 --- a/cpu/simple_cpu/simple_cpu.cc +++ b/cpu/simple_cpu/simple_cpu.cc @@ -349,7 +349,7 @@ SimpleCPU::read(Addr addr, T& data, unsigned flags) // Ugly hack to get an event scheduled *only* if the access is // a miss. We really should add first-class support for this // at some point. - if (result != MA_HIT && dcacheInterface->doEvents) { + if (result != MA_HIT && dcacheInterface->doEvents()) { memReq->completionEvent = &cacheCompletionEvent; lastDcacheStall = curTick; unscheduleTickEvent(); @@ -432,7 +432,7 @@ SimpleCPU::write(T data, Addr addr, unsigned flags, uint64_t *res) // Ugly hack to get an event scheduled *only* if the access is // a miss. We really should add first-class support for this // at some point. - if (result != MA_HIT && dcacheInterface->doEvents) { + if (result != MA_HIT && dcacheInterface->doEvents()) { memReq->completionEvent = &cacheCompletionEvent; lastDcacheStall = curTick; unscheduleTickEvent(); @@ -635,7 +635,7 @@ SimpleCPU::tick() // Ugly hack to get an event scheduled *only* if the access is // a miss. We really should add first-class support for this // at some point. - if (result != MA_HIT && icacheInterface->doEvents) { + if (result != MA_HIT && icacheInterface->doEvents()) { memReq->completionEvent = &cacheCompletionEvent; lastIcacheStall = curTick; unscheduleTickEvent(); -- cgit v1.2.3 -- cgit v1.2.3 -- cgit v1.2.3 -- cgit v1.2.3 -- cgit v1.2.3 From 801c46d25049bbf1fea4c3b0f115b095b58e6323 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Tue, 27 Jan 2004 17:56:23 -0500 Subject: a bunch of warning fixes arch/alpha/isa_desc: don't say warn: Warning: base/misc.cc: avoid printing two newlines in a row sim/main.cc: print out a message just before we enter the event queue --HG-- extra : convert_revision : 2a824d4b67661903fc739a0fb0759aa91d72382c --- arch/alpha/isa_desc | 6 +++--- base/misc.cc | 38 +++++++++++++++++++++++++++++++++----- sim/main.cc | 1 + 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/arch/alpha/isa_desc b/arch/alpha/isa_desc index f0a4699f4..3533da09f 100644 --- a/arch/alpha/isa_desc +++ b/arch/alpha/isa_desc @@ -538,7 +538,7 @@ declare {{ trappingMode((enum TrappingMode)FP_TRAPMODE) { if (trappingMode != Imprecise) { - warn("Warning: precise FP traps unimplemented\n"); + warn("precise FP traps unimplemented\n"); } } @@ -1609,7 +1609,7 @@ declare {{ Trace::InstRecord *traceData) { if (!warned) { - warn("Warning: instruction '%s' unimplemented\n", mnemonic); + warn("instruction '%s' unimplemented\n", mnemonic); warned = true; } @@ -1620,7 +1620,7 @@ declare {{ Trace::InstRecord *traceData) { if (!xc->spec_mode && !warned) { - warn("Warning: instruction '%s' unimplemented\n", mnemonic); + warn("instruction '%s' unimplemented\n", mnemonic); warned = true; } diff --git a/base/misc.cc b/base/misc.cc index 8190caddd..80968bd44 100644 --- a/base/misc.cc +++ b/base/misc.cc @@ -42,7 +42,17 @@ void __panic(const string &format, cp::ArgList &args, const char *func, const char *file, int line) { - string fmt = "panic: " + format + " @ cycle %d\n[%s:%s, line %d]\n"; + string fmt = "panic: " + format; + switch (fmt[fmt.size() - 1]) { + case '\n': + case '\r': + break; + default: + fmt += "\n"; + } + + fmt += " @ cycle %d\n[%s:%s, line %d]\n"; + args.append(curTick); args.append(func); args.append(file); @@ -63,8 +73,18 @@ void __fatal(const string &format, cp::ArgList &args, const char *func, const char *file, int line) { - string fmt = "fatal: " + format + " @ cycle %d\n[%s:%s, line %d]\n" - "Memory Usage: %ld KBytes\n"; + string fmt = "fatal: " + format; + + switch (fmt[fmt.size() - 1]) { + case '\n': + case '\r': + break; + default: + fmt += "\n"; + } + + fmt += " @ cycle %d\n[%s:%s, line %d]\n"; + fmt += "Memory Usage: %ld KBytes\n"; args.append(curTick); args.append(func); @@ -83,15 +103,23 @@ __warn(const string &format, cp::ArgList &args, const char *func, const char *file, int line) { string fmt = "warn: " + format; + + switch (fmt[fmt.size() - 1]) { + case '\n': + case '\r': + break; + default: + fmt += "\n"; + } + #ifdef VERBOSE_WARN fmt += " @ cycle %d\n[%s:%s, line %d]\n"; args.append(curTick); args.append(func); args.append(file); args.append(line); -#else - fmt += "\n"; #endif + args.dump(cerr, fmt); delete &args; diff --git a/sim/main.cc b/sim/main.cc index d0cf23039..d2c56d9f2 100644 --- a/sim/main.cc +++ b/sim/main.cc @@ -400,6 +400,7 @@ main(int argc, char **argv) } SimInit(); + warn("Entering event queue. Starting simulation...\n"); while (!mainEventQueue.empty()) { assert(curTick <= mainEventQueue.nextTick() && -- cgit v1.2.3 -- cgit v1.2.3 -- cgit v1.2.3 -- cgit v1.2.3 From dc70ce3a60a01521ffa42b16a1910369155e4373 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Thu, 29 Jan 2004 00:36:22 -0500 Subject: cleanup on aisle 5 base/statistics.cc: dead code --HG-- extra : convert_revision : 8f3fd638acdf7a704475ea90b607a3225a3c174d --- base/statistics.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/base/statistics.cc b/base/statistics.cc index 298cc9a36..49294ad27 100644 --- a/base/statistics.cc +++ b/base/statistics.cc @@ -209,7 +209,6 @@ Data::python_dump(const string &name, const string &subname) ++i; } } -// py->next(); } void -- cgit v1.2.3 -- cgit v1.2.3 From 2db1b6ea1b61665908138d7004001d494c168d85 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Thu, 29 Jan 2004 00:38:18 -0500 Subject: 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 --- base/misc.cc | 2 ++ base/trace.cc | 7 ++----- dev/console.cc | 12 ++++++++++-- dev/etherdump.cc | 18 ++++++++++++++++-- sim/builder.cc | 45 ++++++++++++++++++++++++++++++++++++++++----- sim/builder.hh | 19 ++++++++----------- sim/main.cc | 9 +++++---- sim/serialize.cc | 18 ++++++++++++------ sim/universe.cc | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 151 insertions(+), 35 deletions(-) diff --git a/base/misc.cc b/base/misc.cc index 80968bd44..5caf96d40 100644 --- a/base/misc.cc +++ b/base/misc.cc @@ -121,6 +121,8 @@ __warn(const string &format, cp::ArgList &args, const char *func, #endif args.dump(cerr, fmt); + if (outputStream != &cerr && outputStream != &cout) + args.dump(*outputStream, fmt); delete &args; } diff --git a/base/trace.cc b/base/trace.cc index 99e97e7ea..156110376 100644 --- a/base/trace.cc +++ b/base/trace.cc @@ -49,7 +49,7 @@ FlagVec flags(NumFlags, false); // directly; use DebugOut() (see below) to access this stream for // output. // -ostream *dprintf_stream = NULL; +ostream *dprintf_stream = &cerr; int dprintf_ignore_size; vector dprintf_ignore; @@ -267,10 +267,7 @@ RawDataRecord::dump(ostream &os) std::ostream & DebugOut() { - if (Trace::dprintf_stream) - return *Trace::dprintf_stream; - else - return cerr; + return *Trace::dprintf_stream; } ///////////////////////////////////////////// diff --git a/dev/console.cc b/dev/console.cc index f4156207d..3fa51a414 100644 --- a/dev/console.cc +++ b/dev/console.cc @@ -383,8 +383,16 @@ END_INIT_SIM_OBJECT_PARAMS(SimConsole) CREATE_SIM_OBJECT(SimConsole) { string filename = output; - if (!filename.empty() && append_name) - filename += "." + getInstanceName(); + if (filename.empty()) { + if (!outputDirectory.empty()) + filename = outputDirectory + getInstanceName(); + } else { + if (append_name) + filename += "." + getInstanceName(); + if (!outputDirectory.empty()) + filename = outputDirectory + filename; + } + SimConsole *console = new SimConsole(getInstanceName(), filename, number); ((ConsoleListener *)listener)->add(console); ((SimConsole *)console)->initInt(intr_control); diff --git a/dev/etherdump.cc b/dev/etherdump.cc index 60dc1559d..89f1ce382 100644 --- a/dev/etherdump.cc +++ b/dev/etherdump.cc @@ -126,13 +126,27 @@ END_DECLARE_SIM_OBJECT_PARAMS(EtherDump) BEGIN_INIT_SIM_OBJECT_PARAMS(EtherDump) - INIT_PARAM_DFLT(file, "file to dump packets to", "") + INIT_PARAM(file, "file to dump packets to") END_INIT_SIM_OBJECT_PARAMS(EtherDump) CREATE_SIM_OBJECT(EtherDump) { - return new EtherDump(getInstanceName(), file); + string filename; + if (file.isValid()) { + filename = file; + + if (filename[0] != '/' && !outputDirectory.empty()) + filename = outputDirectory + filename; + } else { + if (outputDirectory.empty()) { + filename = "etherdump"; + } else { + filename = outputDirectory + "etherdump"; + } + } + + return new EtherDump(getInstanceName(), filename); } REGISTER_SIM_OBJECT("EtherDump", EtherDump) 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; diff --git a/sim/builder.hh b/sim/builder.hh index 0364276bf..e13a85272 100644 --- a/sim/builder.hh +++ b/sim/builder.hh @@ -29,15 +29,18 @@ #ifndef __BUILDER_HH__ #define __BUILDER_HH__ -#include +#include #include +#include #include -#include #include "sim/param.hh" class SimObject; +std::ostream & +builderStream(); + // // A SimObjectBuilder serves as an evaluation context for a set of // parameters that describe a specific instance of a SimObject. This @@ -69,15 +72,9 @@ class SimObjectBuilder : public ParamContext SimObjectBuilder(const std::string &_configClass, const std::string &_instanceName, ConfigNode *_configNode, - const std::string &_simObjClassName) - : ParamContext(_configClass, true), - instanceName(_instanceName), - configNode(_configNode), - simObjClassName(_simObjClassName) - { - } - - virtual ~SimObjectBuilder() {} + const std::string &_simObjClassName); + + virtual ~SimObjectBuilder(); // call parse() on all params in this context to convert string // representations to parameter values diff --git a/sim/main.cc b/sim/main.cc index d2c56d9f2..48d64d4cd 100644 --- a/sim/main.cc +++ b/sim/main.cc @@ -54,6 +54,7 @@ #include "sim/sim_init.hh" #include "sim/sim_object.hh" #include "sim/sim_stats.hh" +#include "sim/universe.hh" using namespace std; @@ -355,12 +356,12 @@ main(int argc, char **argv) // Print hello message to stats file if it's actually a file. If // it's not (i.e. it's cout or cerr) then we already did it above. - if (statStreamIsFile) - sayHello(*statStream); + if (outputStream != &cout && outputStream != &cerr) + sayHello(*outputStream); // Echo command line and all parameter settings to stats file as well. - echoCommandLine(argc, argv, *statStream); - ParamContext::showAllContexts(*statStream); + echoCommandLine(argc, argv, *outputStream); + ParamContext::showAllContexts(builderStream()); // Now process the configuration hierarchy and create the SimObjects. ConfigHierarchy configHierarchy(simConfigDB); diff --git a/sim/serialize.cc b/sim/serialize.cc index 33956c6e7..281e7cfc8 100644 --- a/sim/serialize.cc +++ b/sim/serialize.cc @@ -305,10 +305,9 @@ class SerializeParamContext : public ParamContext SerializeParamContext serialParams("serialize"); -Param serialize_dir(&serialParams, - "dir", +Param serialize_dir(&serialParams, "dir", "dir to stick checkpoint in " - "(sprintf format with cycle #)", "m5.%012d"); + "(sprintf format with cycle #)"); Param serialize_cycle(&serialParams, "cycle", @@ -333,11 +332,18 @@ SerializeParamContext::~SerializeParamContext() void SerializeParamContext::checkParams() { - checkpointDirBase = serialize_dir; + if (serialize_dir.isValid()) { + checkpointDirBase = serialize_dir; + } else { + if (outputDirectory.empty()) + checkpointDirBase = "m5.%012d"; + else + checkpointDirBase = outputDirectory + "cpt.%012d"; + } + // guarantee that directory ends with a '/' - if (checkpointDirBase[checkpointDirBase.size() - 1] != '/') { + if (checkpointDirBase[checkpointDirBase.size() - 1] != '/') checkpointDirBase += "/"; - } if (serialize_cycle > 0) Checkpoint::setup(serialize_cycle, serialize_period); diff --git a/sim/universe.cc b/sim/universe.cc index b75b1f78a..440c6363f 100644 --- a/sim/universe.cc +++ b/sim/universe.cc @@ -26,10 +26,17 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include +#include + +#include +#include #include #include #include +#include "base/files.hh" +#include "base/misc.hh" #include "sim/universe.hh" #include "sim/host.hh" #include "sim/param.hh" @@ -42,8 +49,14 @@ double __ticksPerMS; double __ticksPerUS; double __ticksPerNS; +string outputDirectory; +ostream *outputStream; + class UniverseParamContext : public ParamContext { + private: + ofstream outputFile; + public: UniverseParamContext(const string &is) : ParamContext(is) {} void checkParams(); @@ -54,6 +67,11 @@ UniverseParamContext universe("Universe"); Param universe_freq(&universe, "frequency", "tick frequency", 200000000); +Param universe_output_dir(&universe, "output_dir", + "directory to output data to"); +Param universe_output_file(&universe, "output_file", + "file to dump simulator output to"); + void UniverseParamContext::checkParams() { @@ -62,4 +80,42 @@ UniverseParamContext::checkParams() __ticksPerMS = freq / 1.0e3; __ticksPerUS = freq / 1.0e6; __ticksPerNS = freq / 1.0e9; + + if (universe_output_dir.isValid()) { + outputDirectory = universe_output_dir; + + // guarantee that directory ends with a '/' + if (outputDirectory[outputDirectory.size() - 1] != '/') + outputDirectory += "/"; + + if (mkdir(outputDirectory.c_str(), 0777) < 0) { + if (errno != EEXIST) { + panic("%s\ncould not make output directory: %s\n", + strerror(errno), outputDirectory); + } + } + } + + string filename; + if (universe_output_file.isValid()) { + string f = universe_output_file; + if (f != "stdout" && f != "cout" && f != "stderr" && f != "cerr") + filename = outputDirectory + f; + else + filename = f; + } else { + if (outputDirectory.empty()) + filename = "stdout"; + else + filename = outputDirectory + "output.txt"; + } + + if (filename == "stdout" || filename == "cout") + outputStream = &cout; + else if (filename == "stderr" || filename == "cerr") + outputStream = &cerr; + else { + outputFile.open(filename.c_str(), ios::trunc); + outputStream = &outputFile; + } } -- cgit v1.2.3 From 639037d127586bb363ed314b2f00f1d371555ae1 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Thu, 29 Jan 2004 10:32:01 -0500 Subject: remove #include of nonexistent file sim/universe.cc: oops. this doesn't exist --HG-- extra : convert_revision : 2cfb3680e4ebe3f27f22a79f853d4d6df445e65a --- sim/universe.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/sim/universe.cc b/sim/universe.cc index 440c6363f..feede514e 100644 --- a/sim/universe.cc +++ b/sim/universe.cc @@ -35,7 +35,6 @@ #include #include -#include "base/files.hh" #include "base/misc.hh" #include "sim/universe.hh" #include "sim/host.hh" -- cgit v1.2.3 From ee4263f72e547d551e26b058ee16a48a5f47e3c4 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Thu, 29 Jan 2004 16:32:03 -0500 Subject: Fix character input by handling the character and the special console values separately. dev/alpha_console.cc: use new console specific input function --HG-- extra : convert_revision : 08997d6115d2aac3a26cac2774b3c3fc0cd76ab0 --- dev/alpha_console.cc | 2 +- dev/console.cc | 47 ++++++++++++++++++++++++++++++++--------------- dev/console.hh | 8 ++++++-- 3 files changed, 39 insertions(+), 18 deletions(-) diff --git a/dev/alpha_console.cc b/dev/alpha_console.cc index ccf6c33fd..8e59db932 100644 --- a/dev/alpha_console.cc +++ b/dev/alpha_console.cc @@ -81,7 +81,7 @@ AlphaConsole::read(MemReqPtr req, uint8_t *data) Addr daddr = req->paddr & addr_mask; switch (daddr) { case offsetof(AlphaAccess, inputChar): - val = console->in(); + val = console->console_in(); break; default: diff --git a/dev/console.cc b/dev/console.cc index 3fa51a414..5e7b0abf6 100644 --- a/dev/console.cc +++ b/dev/console.cc @@ -228,27 +228,44 @@ SimConsole::configTerm() #define RECEIVE_NONE (ULL(2) << 62) #define RECEIVE_ERROR (ULL(3) << 62) -uint64_t -SimConsole::in() +bool +SimConsole::in(uint8_t &c) { - char c = 0; - uint64_t val = 0; - if (rxbuf.empty()) { + bool empty, ret; + + empty = rxbuf.empty(); + ret = !empty; + if (!empty) { + rxbuf.read((char *)&c, 1); + empty = rxbuf.empty(); + } + + if (empty) clearInt(ReceiveInterrupt); - val |= RECEIVE_NONE; - return 0x8; - } else { - uint64_t val; - rxbuf.read(&c, 1); - val |= RECEIVE_SUCCESS | c; + + DPRINTF(ConsoleVerbose, "in: \'%c\' %#02x more: %d, return: %d\n", + isprint(c) ? c : ' ', c, !empty, ret); + + return ret; +} + +uint64_t +SimConsole::console_in() +{ + uint8_t c; + uint64_t value; + + if (in(c)) { + value = RECEIVE_SUCCESS | c; if (!rxbuf.empty()) - val |= MORE_PENDING; + value |= MORE_PENDING; + } else { + value = RECEIVE_NONE; } - DPRINTF(ConsoleVerbose, "in: \'%c\' %#02x retval: %#x\n", - isprint(c) ? c : ' ', c, val); + DPRINTF(ConsoleVerbose, "console_in: return: %#x\n", value); - return val; + return value; } void diff --git a/dev/console.hh b/dev/console.hh index 9913fe379..d2bba4612 100644 --- a/dev/console.hh +++ b/dev/console.hh @@ -109,7 +109,10 @@ class SimConsole : public SimObject // OS interface // Get a character from the console. - // the return value corresponds to the console GETC return value: + bool in(uint8_t &value); + + // get a character from the console in the console specific format + // corresponds to GETC: // retval<63:61> // 000: success: character received // 001: success: character received, more pending @@ -118,8 +121,9 @@ class SimConsole : public SimObject // 111: failure: character received with error, more pending // retval<31:0> // character read from console + // // Interrupts are cleared when the buffer is empty. - uint64_t in(); + uint64_t console_in(); // Send a character to the console void out(char c, bool raise_int = true); -- cgit v1.2.3 -- cgit v1.2.3 From cb35f819c5326b37899695345ad78e032e8d7cdf Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Thu, 29 Jan 2004 17:44:08 -0500 Subject: delete the data in the arglist when the list is destroyed, not while printing out the data. This allows the data to be dumped more than once. base/cprintf.hh: need a destructor --HG-- extra : convert_revision : 235e9fe24488ac4c0ae1b562ef9fa6e0bd1e899c --- base/cprintf.cc | 26 ++++++++++++++++---------- base/cprintf.hh | 1 + 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/base/cprintf.cc b/base/cprintf.cc index 5796a712b..5cbf0c057 100644 --- a/base/cprintf.cc +++ b/base/cprintf.cc @@ -37,9 +37,20 @@ using namespace std; namespace cp { +ArgList::~ArgList() +{ + while (!objects.empty()) { + delete objects.front(); + objects.pop_front(); + } +} + void ArgList::dump(const string &format) { + list_t::iterator iter = objects.begin(); + list_t::iterator end = objects.end(); + const char *p = format.c_str(); stream->fill(' '); @@ -198,22 +209,19 @@ ArgList::dump(const string &format) } } - if (!objects.empty()) + if (iter != end) { - Base *data = objects.front(); - objects.pop_front(); - ios::fmtflags saved_flags = stream->flags(); char old_fill = stream->fill(); int old_precision = stream->precision(); - data->process(*stream, fmt); + (*iter)->process(*stream, fmt); stream->flags(saved_flags); stream->fill(old_fill); stream->precision(old_precision); - delete data; + ++iter; } else { *stream << ""; } @@ -241,11 +249,9 @@ ArgList::dump(const string &format) } } - while (!objects.empty()) { + while (iter != end) { *stream << ""; - Base *data = objects.front(); - objects.pop_front(); - delete data; + ++iter; } } diff --git a/base/cprintf.hh b/base/cprintf.hh index ac34cd252..ca5c08b16 100644 --- a/base/cprintf.hh +++ b/base/cprintf.hh @@ -89,6 +89,7 @@ class ArgList public: ArgList() : stream(&std::cout) {} + ~ArgList(); template void append(const T &data) { -- cgit v1.2.3 From 9374efa7255b5e159b1a4732819126a90ff8eb43 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Thu, 29 Jan 2004 22:30:14 -0500 Subject: wrap debugging stuff with #ifdef DEBUG --HG-- extra : convert_revision : 8205633c1c1b49b04f389aa40f95fbbc03a43fb6 --- kern/tru64/tru64_system.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kern/tru64/tru64_system.cc b/kern/tru64/tru64_system.cc index 99d99afd4..07c655385 100644 --- a/kern/tru64/tru64_system.cc +++ b/kern/tru64/tru64_system.cc @@ -192,8 +192,10 @@ Tru64System::Tru64System(const string _name, const uint64_t _init_param, //INSTRUMENTATION CODEGEN END #endif //FS_MEASURE +#ifdef DEBUG kernelPanicEvent = new BreakPCEvent(&pcEventQueue, "kernel panic"); consolePanicEvent = new BreakPCEvent(&pcEventQueue, "console panic"); +#endif badaddrEvent = new BadAddrEvent(&pcEventQueue, "badaddr"); skipPowerStateEvent = new SkipFuncEvent(&pcEventQueue, "tl_v48_capture_power_state"); @@ -262,6 +264,7 @@ Tru64System::Tru64System(const string _name, const uint64_t _init_param, strcpy(osflags, boot_osflags.c_str()); } +#ifdef DEBUG if (kernelSymtab->findAddress("panic", addr)) kernelPanicEvent->schedule(addr); else @@ -269,6 +272,7 @@ Tru64System::Tru64System(const string _name, const uint64_t _init_param, if (consoleSymtab->findAddress("panic", addr)) consolePanicEvent->schedule(addr); +#endif if (kernelSymtab->findAddress("badaddr", addr)) badaddrEvent->schedule(addr); @@ -511,8 +515,10 @@ Tru64System::~Tru64System() delete kernelSymtab; delete consoleSymtab; +#ifdef DEBUG delete kernelPanicEvent; delete consolePanicEvent; +#endif delete badaddrEvent; delete skipPowerStateEvent; delete skipScavengeBootEvent; -- cgit v1.2.3 -- cgit v1.2.3 -- cgit v1.2.3 -- cgit v1.2.3