From 454d10554ac14bed7d059abe1f7a4f26d03c178d Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Thu, 15 Jan 2004 14:29:09 -0500 Subject: [PATCH 01/25] Make dump cycle relative --HG-- extra : convert_revision : 3434f60fa08d1543358c1209be8a5cfbe43a53bf From 81575e74e7a22a244df62cd998ba337ed6cdc2f2 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Thu, 15 Jan 2004 14:29:34 -0500 Subject: [PATCH 02/25] Make the python stats script more robust --HG-- extra : convert_revision : a7680d5cdeac96345e8f521cfb96fccaa3e7a7f6 From c9f2aa8c1888aef0f383bdda0ce6d7d7b5a0c7fc Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Thu, 15 Jan 2004 16:33:58 -0500 Subject: [PATCH 03/25] 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 5c9a2bc654..298cc9a36d 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 d4ae5d1fd8..8dd8eeb8e4 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; } From 946b481831e813126de94d3c2c2001c2d51ccdee Mon Sep 17 00:00:00 2001 From: Steve Reinhardt Date: Tue, 20 Jan 2004 13:53:18 -0500 Subject: [PATCH 04/25] 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 93313fac6e..f2a67f22e3 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 From fde0b7bfaf916cd3b1805f2f30ca01f40dd7570b Mon Sep 17 00:00:00 2001 From: Erik Hallnor Date: Wed, 21 Jan 2004 14:22:55 -0500 Subject: [PATCH 05/25] I hate compiling decoder.cc every time I touch something. --HG-- extra : convert_revision : b79519452947ea7b110922d5a3dae2f3dfc0b916 From 01059eadedebfdc0b567edc844b46c5b02bd3991 Mon Sep 17 00:00:00 2001 From: Erik Hallnor Date: Sun, 25 Jan 2004 05:01:00 -0500 Subject: [PATCH 06/25] 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 adbd17a35f..0d5fc40770 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(); From 04a73312982a49b5b765e1bc2c1785106c8018c2 Mon Sep 17 00:00:00 2001 From: Steve Reinhardt Date: Sun, 25 Jan 2004 21:53:32 -0800 Subject: [PATCH 07/25] Minor cleanup of sb_issue() in full_cpu/issue.cc. --HG-- extra : convert_revision : 4bf69125c37a067a3a06022226a7eb38dcaaf6d1 From 9bbec8808b6b051b526845ed4e9a9b1a4fa67f3a Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Tue, 27 Jan 2004 12:45:12 -0500 Subject: [PATCH 08/25] Add trace flag for the sampling CPU --HG-- extra : convert_revision : 928588d46fa069e869416f4f5df8041849625e9f From f7a8db20fe538c41ae32d2a0b91b3d4f7d951097 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Tue, 27 Jan 2004 13:55:50 -0500 Subject: [PATCH 09/25] Always write out a value for pending so that an m5.fast simulator can generate a checkpoint that an m5.debug simulator can use --HG-- extra : convert_revision : eec2d94013119236a9c65c9b5fb6c2ccb0480f51 From 6e61efbbb5dfb1617869d647275b714cfd40f9cd Mon Sep 17 00:00:00 2001 From: Erik Hallnor Date: Tue, 27 Jan 2004 16:40:04 -0500 Subject: [PATCH 10/25] Remove SS-like code from lru.hh/cc --HG-- extra : convert_revision : 66baf998671a24e6a630d2f35c2f529418cd4d5b From 801c46d25049bbf1fea4c3b0f115b095b58e6323 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Tue, 27 Jan 2004 17:56:23 -0500 Subject: [PATCH 11/25] 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 f0a4699f42..3533da09ff 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 8190caddde..80968bd44d 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 d0cf230398..d2c56d9f28 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() && From b0344b76187378971e81ccbca42f1db8b8dea1fb Mon Sep 17 00:00:00 2001 From: Steve Reinhardt Date: Tue, 27 Jan 2004 22:26:59 -0800 Subject: [PATCH 12/25] Minor optimization of new LRU stack code. --HG-- extra : convert_revision : 953bc2f1ceab1cec9f48d65b94cc075655f6e9ec From f50d1ef1c8721ac982dd82bb964be5f2ec2b614d Mon Sep 17 00:00:00 2001 From: Steve Raasch Date: Wed, 28 Jan 2004 18:06:07 -0500 Subject: [PATCH 13/25] removing the last vestages of the dep-tree stuff (hasn't worked for a LONG time) --HG-- extra : convert_revision : 145d56564ccca3a3c1c3d9115a4b8a5fb52c301d From 2fb876e55db1ad2891295bf6896645893ac721aa Mon Sep 17 00:00:00 2001 From: Andrew Schultz Date: Wed, 28 Jan 2004 23:00:30 -0500 Subject: [PATCH 14/25] Remove references to dep_tree to fix build --HG-- extra : convert_revision : dff311c1a18bd01750c1b5902410c23e0f43b798 From dc70ce3a60a01521ffa42b16a1910369155e4373 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Thu, 29 Jan 2004 00:36:22 -0500 Subject: [PATCH 15/25] 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 298cc9a36d..49294ad275 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 From f994cf4b5edb0eea23b695e1ee4f3a9d7b811b82 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Thu, 29 Jan 2004 00:37:07 -0500 Subject: [PATCH 16/25] use $ENV{PWD} so that the amd paths work ok. Also, compare real paths to ensure that the links point to the right place --HG-- extra : convert_revision : f4127a67f02b714808c6d2181fabf245ed2309c0 From 2db1b6ea1b61665908138d7004001d494c168d85 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Thu, 29 Jan 2004 00:38:18 -0500 Subject: [PATCH 17/25] 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 | 17 ++++++--------- sim/main.cc | 9 ++++---- sim/serialize.cc | 20 +++++++++++------ sim/universe.cc | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 151 insertions(+), 35 deletions(-) diff --git a/base/misc.cc b/base/misc.cc index 80968bd44d..5caf96d407 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 99e97e7eae..1561103761 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 f4156207df..3fa51a4142 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 60dc1559dd..89f1ce382c 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 fa435d3226..e2345556ed 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 0364276bfb..e13a85272f 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) - { - } + const std::string &_simObjClassName); - virtual ~SimObjectBuilder() {} + 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 d2c56d9f28..48d64d4cd5 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 33956c6e7e..281e7cfc89 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,12 +332,19 @@ SerializeParamContext::~SerializeParamContext() void SerializeParamContext::checkParams() { - checkpointDirBase = serialize_dir; - // guarantee that directory ends with a '/' - if (checkpointDirBase[checkpointDirBase.size() - 1] != '/') { - checkpointDirBase += "/"; + 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] != '/') + checkpointDirBase += "/"; + if (serialize_cycle > 0) Checkpoint::setup(serialize_cycle, serialize_period); } diff --git a/sim/universe.cc b/sim/universe.cc index b75b1f78af..440c6363f8 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; + } } From 639037d127586bb363ed314b2f00f1d371555ae1 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Thu, 29 Jan 2004 10:32:01 -0500 Subject: [PATCH 18/25] 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 440c6363f8..feede514e9 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" From ee4263f72e547d551e26b058ee16a48a5f47e3c4 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Thu, 29 Jan 2004 16:32:03 -0500 Subject: [PATCH 19/25] 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 | 51 +++++++++++++++++++++++++++++--------------- dev/console.hh | 8 +++++-- 3 files changed, 41 insertions(+), 20 deletions(-) diff --git a/dev/alpha_console.cc b/dev/alpha_console.cc index ccf6c33fd3..8e59db9326 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 3fa51a4142..5e7b0abf6b 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()) { - clearInt(ReceiveInterrupt); - val |= RECEIVE_NONE; - return 0x8; - } else { - uint64_t val; - rxbuf.read(&c, 1); - val |= RECEIVE_SUCCESS | c; - if (!rxbuf.empty()) - val |= MORE_PENDING; + bool empty, ret; + + empty = rxbuf.empty(); + ret = !empty; + if (!empty) { + rxbuf.read((char *)&c, 1); + empty = rxbuf.empty(); } - DPRINTF(ConsoleVerbose, "in: \'%c\' %#02x retval: %#x\n", - isprint(c) ? c : ' ', c, val); + if (empty) + clearInt(ReceiveInterrupt); - return val; + 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()) + value |= MORE_PENDING; + } else { + value = RECEIVE_NONE; + } + + DPRINTF(ConsoleVerbose, "console_in: return: %#x\n", value); + + return value; } void diff --git a/dev/console.hh b/dev/console.hh index 9913fe379b..d2bba46123 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); From fe4d9f124f6234a1b431dc33433a88ee18d61db9 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Thu, 29 Jan 2004 16:33:03 -0500 Subject: [PATCH 20/25] whack debugging statement --HG-- extra : convert_revision : f623d35a6e5a234e2b203974012c653b91826dbf From cb35f819c5326b37899695345ad78e032e8d7cdf Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Thu, 29 Jan 2004 17:44:08 -0500 Subject: [PATCH 21/25] 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 5796a712bb..5cbf0c057e 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 ac34cd2521..ca5c08b161 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) { From 9374efa7255b5e159b1a4732819126a90ff8eb43 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Thu, 29 Jan 2004 22:30:14 -0500 Subject: [PATCH 22/25] 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 99d99afd43..07c6553852 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; From e7e6717a1ac0c3228b56b7f1b5867aac87067683 Mon Sep 17 00:00:00 2001 From: Steve Reinhardt Date: Fri, 30 Jan 2004 08:18:20 -0800 Subject: [PATCH 23/25] Fix libelf generation so it works on a clean make -j. --HG-- extra : convert_revision : 377633aa2c04695c598ee82a9529d2e40f0ffef7 From 7d64183b44f7865e44c449258e29a5272167dcf9 Mon Sep 17 00:00:00 2001 From: Steve Reinhardt Date: Fri, 30 Jan 2004 09:16:34 -0800 Subject: [PATCH 24/25] Use $(MAKE) instead of 'make' when building libelf (suppresses an error message about -j). Check for, delete, and die on zero-length .d files. --HG-- extra : convert_revision : 71b7f9e639d96fb7ed30952b142d69c34c725774 From 2f4f7aacf77dea16795a4052613da6092f6efc31 Mon Sep 17 00:00:00 2001 From: Steve Raasch Date: Fri, 30 Jan 2004 13:51:09 -0500 Subject: [PATCH 25/25] major rework/rewrite of the breakdown script --HG-- extra : convert_revision : 2e1d186e0f20b6089300b82a3f6dcb1d0b44c09d