summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/sim/process.cc36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/sim/process.cc b/src/sim/process.cc
index 0ba215511..ef3ab9ecd 100644
--- a/src/sim/process.cc
+++ b/src/sim/process.cc
@@ -336,6 +336,18 @@ Process::fixFileOffsets()
// Search through the input options and set fd if match is found;
// otherwise, open an input file and seek to location.
FDEntry *fde_stdin = getFDEntry(STDIN_FILENO);
+
+ // Check if user has specified a different input file, and if so, use it
+ // instead of the file specified in the checkpoint. This also resets the
+ // file offset from the checkpointed value
+ string new_in = ((ProcessParams*)params())->input;
+ if (new_in != fde_stdin->filename) {
+ warn("Using new input file (%s) rather than checkpointed (%s)\n",
+ new_in, fde_stdin->filename);
+ fde_stdin->filename = new_in;
+ fde_stdin->fileOffset = 0;
+ }
+
if ((it = imap.find(fde_stdin->filename)) != imap.end()) {
fde_stdin->fd = it->second;
} else {
@@ -346,6 +358,18 @@ Process::fixFileOffsets()
// Search through the output/error options and set fd if match is found;
// otherwise, open an output file and seek to location.
FDEntry *fde_stdout = getFDEntry(STDOUT_FILENO);
+
+ // Check if user has specified a different output file, and if so, use it
+ // instead of the file specified in the checkpoint. This also resets the
+ // file offset from the checkpointed value
+ string new_out = ((ProcessParams*)params())->output;
+ if (new_out != fde_stdout->filename) {
+ warn("Using new output file (%s) rather than checkpointed (%s)\n",
+ new_out, fde_stdout->filename);
+ fde_stdout->filename = new_out;
+ fde_stdout->fileOffset = 0;
+ }
+
if ((it = oemap.find(fde_stdout->filename)) != oemap.end()) {
fde_stdout->fd = it->second;
} else {
@@ -354,6 +378,18 @@ Process::fixFileOffsets()
}
FDEntry *fde_stderr = getFDEntry(STDERR_FILENO);
+
+ // Check if user has specified a different error file, and if so, use it
+ // instead of the file specified in the checkpoint. This also resets the
+ // file offset from the checkpointed value
+ string new_err = ((ProcessParams*)params())->errout;
+ if (new_err != fde_stderr->filename) {
+ warn("Using new error file (%s) rather than checkpointed (%s)\n",
+ new_err, fde_stderr->filename);
+ fde_stderr->filename = new_err;
+ fde_stderr->fileOffset = 0;
+ }
+
if (fde_stdout->filename == fde_stderr->filename) {
// Reuse the same file descriptor if these match.
fde_stderr->fd = fde_stdout->fd;