This page refers to the changes made in the 3.0.13 release of M-sim.
The EIO code has been modified to support the retention of file descriptors.
All EIO files that support this are marked as file version 4. This is internally referred to as "EIO_FILE_VERSION_NEW" (this name will change after testing).
Version 3 EIO files are still supported if they do not require the file descriptors to be repaired. Note that syscall traces were never really well supported in M-sim and were usually ignored (or not ignored by crashing).
The file descriptors are stored in the EIO file as follows (refer to file_table.c):
(<Number of entries>, <entry0>, <entry1>, <entry2>, ..., <entryN>)
<Number of entries> is the number of file descriptors that a context has access to (file_table_t::entries.size())
<entryX> refers to the Xth entry in file_table_t::entries (which is a vector of type file_entry_t)
All contexts have a minimum of 3 entries (stdin, stdout, stderr):
(3, <entry0>, <entry1>, <entry2>)
file_entry_t represents an open file descriptor with the following members:
md_gpr_t simulated_fd; //The file descriptor as seen by the simulated program md_gpr_t real_fd; //The file descriptor as seen by the simulator (the "real" file descriptor) std::string filename; //A string containing the name of the file that file descriptor represents int flags; //The flags used to open the file (if applicable, used by open) int mode; //The mode used to open the file (if applicable, used by open) std::string open_string; //The string used to open the file (if applicable, used by fopen) unsigned long long reserved; //This is a bit field that provides additional information about the file descriptor #define FE_FILE 0x00000 //This is a normal file #define FE_STANDARD_IO 0x00001 //This is stdin/stdout/stderr #define FE_FILE_ATTACHED 0x10000 //Not used during simulation. Indicates that the file should be extracted from the eio file rather than expected to be found.
file_table.c and file_table.h replace "translation_table" and "name_table" objects that were part of a context. file_table_t is the object that replaces this.
Redirection replacement now comes from file_table_t rather than the context.
EIO file descriptor handling in syscall.c is no longer needed.
- now returns an int (the version number of the eio file) instead of void.
- now checks for version 3 or version 4
- now generates files using version 4 - uses version number 4 and writes the translation table to the checkpoint file
- now takes version number as a parameter - this will likely be changed in the future (merged into eio_open)
- reads translation table if the version is 4
- eio_open changed to return an int
- eio_read_chkpt changed to take a version (as an int) as a parameter.
- call to eio_open now retains return value, this is used to pass into eio_read_chkpt (ld_load_prog)
- Instead of std::map<md_gpr_t, md_gpr_t> translation_table, std::vector<std::pair<md_gpr_t,std::string> > name_table and bool replace_with_redirect(md_gpr_t & source), class context now contains "file_table_t file_table;"