|
gem5
v19.0.0.0
|
Interface for creating files in a gem5 output directory. More...
#include <output.hh>
Public Member Functions | |
| OutputDirectory () | |
| Constructor. More... | |
| OutputDirectory (const std::string &name) | |
| Constructor. More... | |
| ~OutputDirectory () | |
| Destructor. More... | |
| std::string | resolve (const std::string &name) const |
| Returns relative file names prepended with name of this directory. More... | |
| void | setDirectory (const std::string &dir) |
| Sets name of this directory. More... | |
| const std::string & | directory () const |
| Gets name of this directory. More... | |
| OutputStream * | create (const std::string &name, bool binary=false, bool no_gz=false) |
| Creates a file in this directory (optionally compressed). More... | |
| OutputStream * | open (const std::string &name, std::ios_base::openmode mode, bool recreateable=true, bool no_gz=false) |
| Open a file in this directory (optionally compressed). More... | |
| void | close (OutputStream *file) |
| Closes an output file and free the corresponding OutputFile. More... | |
| OutputStream * | find (const std::string &name) const |
| Finds stream associated with an open file or stdout/stderr. More... | |
| OutputStream * | findOrCreate (const std::string &name, bool binary=false) |
| bool | isFile (const std::string &name) const |
| Determines whether a file name corresponds to a file in this directory. More... | |
| OutputDirectory * | createSubdirectory (const std::string &name) |
| Creates a subdirectory within this directory. More... | |
| void | remove (const std::string &name, bool recursive=false) |
| Removes a specified file or subdirectory. More... | |
Static Public Member Functions | |
| static bool | isAbsolute (const std::string &name) |
| Test if a path is absolute. More... | |
Static Protected Member Functions | |
| static OutputStream * | checkForStdio (const std::string &name) |
| Determines whether given file name corresponds to standard output streams. More... | |
Private Types | |
| typedef std::map< std::string, OutputStream * > | file_map_t |
| File names and associated stream handles. More... | |
| typedef std::map< std::string, OutputDirectory * > | dir_map_t |
| Output subdirectories. More... | |
Private Attributes | |
| file_map_t | files |
| Open file streams within this directory. More... | |
| dir_map_t | dirs |
| Output sub-directories. More... | |
| std::string | dir |
| Name of this directory. More... | |
Static Private Attributes | |
| static const char | PATH_SEPARATOR = '/' |
| System-specific path separator character. More... | |
| static OutputStream | stdout |
| static OutputStream | stderr |
|
private |
|
private |
| OutputDirectory::OutputDirectory | ( | const std::string & | name | ) |
| OutputDirectory::~OutputDirectory | ( | ) |
|
staticprotected |
| void OutputDirectory::close | ( | OutputStream * | file | ) |
Closes an output file and free the corresponding OutputFile.
The output file must have been opened by the same OutputDirectory instance as the one closing it, or sim will fail.
| file | OutputStream instance in this OutputDirectory. |
Definition at line 148 of file output.cc.
References fatal, ArmISA::i, and OutputStream::name().
Referenced by VncInput::captureFrameBuffer(), O3ThreadState< Impl >::dumpFuncProfile(), SimpleThread::dumpFuncProfile(), Linux::DmesgDumpEvent::process(), Linux::KernelPanicEvent::process(), PseudoInst::writefile(), SimPoint::~SimPoint(), and sc_gem5::TraceFile::~TraceFile().
| OutputStream * OutputDirectory::create | ( | const std::string & | name, |
| bool | binary = false, |
||
| bool | no_gz = false |
||
| ) |
Creates a file in this directory (optionally compressed).
Will open a file as a compressed stream if filename ends in .gz, unless explicitly disabled.
Relative output paths will result in the creation of a recreateable (see OutputFile) output file in the current output directory. Files created with an absolute path will not be recreateable.
| name | name of file to create (without this directory's name leading it) |
| binary | true to create a binary file; false otherwise |
| no_gz | true to disable opening the file as a gzip compressed output stream; false otherwise |
Definition at line 206 of file output.cc.
References ArmISA::mode, and OutputFile< StreamType >::recreateable().
Referenced by VncInput::captureFrameBuffer(), Pl111::dmaDone(), O3ThreadState< Impl >::dumpFuncProfile(), SimpleThread::dumpFuncProfile(), X86ISA::GpuTLB::exitCallback(), output(), Linux::DmesgDumpEvent::process(), AnnotateDumpCallback::process(), Linux::KernelPanicEvent::process(), ComputeUnit::CUExitCallback::process(), HDLcd::pxlFrameDone(), SimPoint::SimPoint(), LinuxArmSystem::startup(), and PseudoInst::writefile().
| OutputDirectory * OutputDirectory::createSubdirectory | ( | const std::string & | name | ) |
Creates a subdirectory within this directory.
| name | name of subdirectory |
Definition at line 279 of file output.cc.
References fatal, OutputStream::name(), and OutputFile< StreamType >::OutputDirectory.
Referenced by VncInput::VncInput().
| const string & OutputDirectory::directory | ( | ) | const |
| OutputStream * OutputDirectory::find | ( | const std::string & | name | ) | const |
| OutputStream * OutputDirectory::findOrCreate | ( | const std::string & | name, |
| bool | binary = false |
||
| ) |
Definition at line 258 of file output.cc.
References X86ISA::os.
Referenced by BaseCPU::BaseCPU(), Stats::initText(), and Terminal::terminalDump().
|
inlinestatic |
Test if a path is absolute.
Definition at line 279 of file output.hh.
References OutputStream::name(), and simout.
Referenced by VirtIO9PDiod::startDiod().
| bool OutputDirectory::isFile | ( | const std::string & | name | ) | const |
Determines whether a file name corresponds to a file in this directory.
| name | name of file to evaluate |
Definition at line 268 of file output.cc.
References ArmISA::st.
| OutputStream * OutputDirectory::open | ( | const std::string & | name, |
| std::ios_base::openmode | mode, | ||
| bool | recreateable = true, |
||
| bool | no_gz = false |
||
| ) |
Open a file in this directory (optionally compressed).
Will open a file as a compressed stream if filename ends in .gz, unless explicitly disabled.
| filename | file to open |
| mode | attributes to open file with |
| recreateable | Set to true if the file can be recreated in a new location. |
| no_gz | true to disable opening the file as a gzip compressed output stream; false otherwise |
Definition at line 220 of file output.cc.
References ArmISA::mode, OutputStream::name(), X86ISA::os, and OutputFile< StreamType >::recreateable().
Referenced by PseudoInst::writefile().
| void OutputDirectory::remove | ( | const std::string & | name, |
| bool | recursive = false |
||
| ) |
Removes a specified file or subdirectory.
Will cause sim to fail for most errors. However, it will only warn the user if a directory could not be removed. This is in place to accommodate slow file systems where file deletions within a subdirectory may not be recognized quickly enough thereby causing the subsequent call to remove the directory to fail (seemingly unempty directory).
| name | name of file or subdirectory to remove; name should not be prepended with the name of this directory object |
| recursive | set to true to attempt to recursively delete a subdirectory and its contents |
Definition at line 292 of file output.cc.
References X86ISA::de, fatal, and ArmISA::i.
Referenced by VncInput::VncInput().
| string OutputDirectory::resolve | ( | const std::string & | name | ) | const |
Returns relative file names prepended with name of this directory.
Returns absolute file names unaltered.
| name | file name to prepend with directory name |
Definition at line 200 of file output.cc.
References OutputStream::name().
Referenced by Trace::InstPBTrace::createTraceFile(), ElasticTrace::ElasticTrace(), Stats::initHDF5(), MemTraceProbe::MemTraceProbe(), FDArray::openOutputFile(), OutputFile< StreamType >::OutputFile(), OutputFile< StreamType >::relocate(), and VirtIO9PDiod::startDiod().
| void OutputDirectory::setDirectory | ( | const std::string & | dir | ) |
|
private |
|
private |
|
private |
|
staticprivate |
|
staticprivate |
Definition at line 161 of file output.hh.
Referenced by OutputFile< StreamType >::relocate().
|
staticprivate |
Definition at line 160 of file output.hh.
Referenced by OutputFile< StreamType >::relocate().