X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=dev%2Fsimconsole.cc;h=94fd9ec1fc3adfcba93312d2a3d84c6ddeac58d4;hb=91601f44948060939527bad44e82b1379168fc6c;hp=a1505740239490b7385cd468b34e8ee4ce33626a;hpb=75ed8090bf34c38123c779a7f040108268d32a1b;p=gem5.git diff --git a/dev/simconsole.cc b/dev/simconsole.cc index a15057402..94fd9ec1f 100644 --- a/dev/simconsole.cc +++ b/dev/simconsole.cc @@ -43,14 +43,14 @@ #include #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;