base: Add support for changing output directories

This changeset adds support for changing the simulator output
directory. This can be useful when the simulation goes through several
stages (e.g., a warming phase, a simulation phase, and a verification
phase) since it allows the output from each stage to be located in a
different directory. Relocation is done by calling core.setOutputDir()
from Python or simout.setOutputDirectory() from C++.

This change affects several parts of the design of the gem5's output
subsystem. First, files returned by an OutputDirectory instance (e.g.,
simout) are of the type OutputStream instead of a std::ostream. This
allows us to do some more book keeping and control re-opening of files
when the output directory is changed. Second, new subdirectories are
OutputDirectory instances, which should be used to create files in
that sub-directory.

Signed-off-by: Andreas Sandberg <andreas@sandberg.pp.se>
[sascha.bischoff@arm.com: Rebased patches onto a newer gem5 version]
Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
This commit is contained in:
Andreas Sandberg
2015-11-27 14:41:59 +00:00
parent fed0ea55c4
commit 5383e1ada4
21 changed files with 361 additions and 170 deletions

View File

@@ -544,8 +544,8 @@ HDLcd::pxlFrameDone()
}
assert(pic);
pic->seekp(0);
bmp.write(*pic);
pic->stream()->seekp(0);
bmp.write(*pic->stream());
}
}

View File

@@ -81,6 +81,7 @@
#include "base/bitmap.hh"
#include "base/framebuffer.hh"
#include "base/output.hh"
#include "dev/arm/amba_device.hh"
#include "dev/pixelpump.hh"
#include "sim/serialize.hh"
@@ -347,7 +348,7 @@ class HDLcd: public AmbaDmaDevice
Bitmap bmp;
/** Picture of what the current frame buffer looks like */
std::ostream *pic;
OutputStream *pic;
/** Cached pixel converter, set when the converter is enabled. */
PixelConverter conv;

View File

@@ -523,11 +523,12 @@ Pl111::dmaDone()
DPRINTF(PL111, "-- write out frame buffer into bmp\n");
if (!pic)
pic = simout.create(csprintf("%s.framebuffer.bmp", sys->name()), true);
pic = simout.create(csprintf("%s.framebuffer.bmp", sys->name()),
true);
assert(pic);
pic->seekp(0);
bmp.write(*pic);
pic->stream()->seekp(0);
bmp.write(*pic->stream());
}
// schedule the next read based on when the last frame started

View File

@@ -51,6 +51,7 @@
#include "base/bitmap.hh"
#include "base/framebuffer.hh"
#include "base/output.hh"
#include "dev/arm/amba_device.hh"
#include "params/Pl111.hh"
#include "sim/serialize.hh"
@@ -268,7 +269,7 @@ class Pl111: public AmbaDmaDevice
Bitmap bmp;
/** Picture of what the current frame buffer looks like */
std::ostream *pic;
OutputStream *pic;
/** Frame buffer width - pixels per line */
uint16_t width;

View File

@@ -45,7 +45,7 @@
using std::string;
EtherDump::EtherDump(const Params *p)
: SimObject(p), stream(simout.create(p->file, true)),
: SimObject(p), stream(simout.create(p->file, true)->stream()),
maxlen(p->maxlen)
{
}

View File

@@ -108,18 +108,14 @@ Terminal::DataEvent::process(int revent)
*/
Terminal::Terminal(const Params *p)
: SimObject(p), termDataAvail(NULL), listenEvent(NULL), dataEvent(NULL),
number(p->number), data_fd(-1), txbuf(16384), rxbuf(16384), outfile(NULL)
number(p->number), data_fd(-1), txbuf(16384), rxbuf(16384),
outfile(p->output ? simout.findOrCreate(p->name) : NULL)
#if TRACING_ON == 1
, linebuf(16384)
#endif
{
if (p->output) {
outfile = simout.find(p->name);
if (!outfile)
outfile = simout.create(p->name);
outfile->setf(ios::unitbuf);
}
if (outfile)
outfile->stream()->setf(ios::unitbuf);
if (p->port)
listen(p->port);
@@ -347,7 +343,7 @@ Terminal::out(char c)
write(c);
if (outfile)
outfile->write(&c, 1);
outfile->stream()->write(&c, 1);
DPRINTF(TerminalVerbose, "out: \'%c\' %#02x\n",
isprint(c) ? c : ' ', (int)c);

View File

@@ -46,6 +46,7 @@
#include "params/Terminal.hh"
#include "sim/sim_object.hh"
class OutputStream;
class TerminalListener;
class Terminal : public SimObject
@@ -111,7 +112,7 @@ class Terminal : public SimObject
protected:
CircleBuf<char> txbuf;
CircleBuf<char> rxbuf;
std::ostream *outfile;
OutputStream *outfile;
#if TRACING_ON == 1
CircleBuf<char> linebuf;
#endif