make some changes to bonnie - now that the simulator uses more memory the old config...
[gem5.git] / dev / simconsole.cc
index a1505740239490b7385cd468b34e8ee4ce33626a..94fd9ec1fc3adfcba93312d2a3d84c6ddeac58d4 100644 (file)
 #include <string>
 
 #include "base/misc.hh"
+#include "base/output.hh"
 #include "base/socket.hh"
 #include "base/trace.hh"
+#include "dev/platform.hh"
 #include "dev/simconsole.hh"
+#include "dev/uart.hh"
 #include "mem/functional_mem/memory_control.hh"
 #include "sim/builder.hh"
-#include "targetarch/ev5.hh"
-#include "dev/uart.hh"
-#include "dev/platform.hh"
 
 using namespace std;
 
@@ -72,27 +72,20 @@ SimConsole::Event::process(int revent)
         cons->detach();
 }
 
-SimConsole::SimConsole(const string &name, const string &file, int num)
+SimConsole::SimConsole(const string &name, ostream *os, int num)
     : SimObject(name), event(NULL), number(num), in_fd(-1), out_fd(-1),
-      listener(NULL), txbuf(16384), rxbuf(16384), outfile(NULL)
+      listener(NULL), txbuf(16384), rxbuf(16384), outfile(os)
 #if TRACING_ON == 1
       , linebuf(16384)
 #endif
 {
-    if (!file.empty())
-        outfile = new ofstream(file.c_str());
-
     if (outfile)
         outfile->setf(ios::unitbuf);
-
 }
 
 SimConsole::~SimConsole()
 {
     close();
-
-    if (outfile)
-        delete outfile;
 }
 
 void
@@ -311,7 +304,7 @@ BEGIN_INIT_SIM_OBJECT_PARAMS(SimConsole)
 
     INIT_PARAM(listener, "console listener"),
     INIT_PARAM(intr_control, "interrupt controller"),
-    INIT_PARAM_DFLT(output, "file to dump output to", ""),
+    INIT_PARAM(output, "file to dump output to"),
     INIT_PARAM_DFLT(append_name, "append name() to filename", true),
     INIT_PARAM_DFLT(number, "console number", 0)
 
@@ -320,17 +313,15 @@ END_INIT_SIM_OBJECT_PARAMS(SimConsole)
 CREATE_SIM_OBJECT(SimConsole)
 {
     string filename = output;
-    if (filename.empty()) {
-        if (!outputDirectory.empty())
-            filename = outputDirectory + getInstanceName();
-    } else {
+    ostream *stream = NULL;
+
+    if (!filename.empty()) {
         if (append_name)
             filename += "." + getInstanceName();
-        if (!outputDirectory.empty())
-            filename = outputDirectory + filename;
+        stream = simout.find(filename);
     }
 
-    SimConsole *console = new SimConsole(getInstanceName(), filename, number);
+    SimConsole *console = new SimConsole(getInstanceName(), stream, number);
     ((ConsoleListener *)listener)->add(console);
 
     return console;