summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configs/example/se.py27
-rw-r--r--src/sim/Process.py3
-rw-r--r--src/sim/process.cc35
3 files changed, 52 insertions, 13 deletions
diff --git a/configs/example/se.py b/configs/example/se.py
index fa7959b99..a2172aeb5 100644
--- a/configs/example/se.py
+++ b/configs/example/se.py
@@ -37,6 +37,7 @@ if m5.build_env['FULL_SYSTEM']:
from m5.objects import *
import os, optparse, sys
+from os.path import join as joinpath
m5.AddToPath('../common')
import Simulation
from Caches import *
@@ -51,13 +52,13 @@ parser = optparse.OptionParser()
# Benchmark options
parser.add_option("-c", "--cmd",
- default=os.path.join(m5_root, "tests/test-progs/hello/bin/alpha/linux/hello"),
- help="The binary to run in syscall emulation mode.")
+ default=joinpath(m5_root, "tests/test-progs/hello/bin/alpha/linux/hello"),
+ help="The binary to run in syscall emulation mode.")
parser.add_option("-o", "--options", default="",
- help="The options to pass to the binary, use \" \" around the entire\
- string.")
-parser.add_option("-i", "--input", default="",
- help="A file of input to give to the binary.")
+ help='The options to pass to the binary, use " " around the entire string')
+parser.add_option("-i", "--input", default="", help="Read stdin from a file.")
+parser.add_option("--output", default="", help="Redirect stdout to a file.")
+parser.add_option("--errout", default="", help="Redirect stderr to a file.")
execfile(os.path.join(config_root, "common", "Options.py"))
@@ -85,6 +86,10 @@ else:
if options.input != "":
process.input = options.input
+if options.output != "":
+ process.output = options.output
+if options.errout != "":
+ process.errout = options.errout
if options.detailed:
#check for SMT workload
@@ -93,9 +98,15 @@ if options.detailed:
process = []
smt_idx = 0
inputs = []
+ outputs = []
+ errouts = []
if options.input != "":
inputs = options.input.split(';')
+ if options.output != "":
+ outputs = options.output.split(';')
+ if options.errout != "":
+ errouts = options.errout.split(';')
for wrkld in workloads:
smt_process = LiveProcess()
@@ -103,6 +114,10 @@ if options.detailed:
smt_process.cmd = wrkld + " " + options.options
if inputs and inputs[smt_idx]:
smt_process.input = inputs[smt_idx]
+ if outputs and outputs[smt_idx]:
+ smt_process.output = outputs[smt_idx]
+ if errouts and errouts[smt_idx]:
+ smt_process.errout = errouts[smt_idx]
process += [smt_process, ]
smt_idx += 1
diff --git a/src/sim/Process.py b/src/sim/Process.py
index 37a27bf3b..81108dd70 100644
--- a/src/sim/Process.py
+++ b/src/sim/Process.py
@@ -34,7 +34,8 @@ class Process(SimObject):
type = 'Process'
abstract = True
input = Param.String('cin', "filename for stdin")
- output = Param.String('cout', 'filename for stdout/stderr')
+ output = Param.String('cout', 'filename for stdout')
+ errout = Param.String('cerr', 'filename for stderr')
system = Param.System(Parent.any, "system process will run on")
max_stack_size = Param.MemorySize('64MB', 'maximum size of the stack')
diff --git a/src/sim/process.cc b/src/sim/process.cc
index 046a6bf9b..23e890b06 100644
--- a/src/sim/process.cc
+++ b/src/sim/process.cc
@@ -92,6 +92,7 @@ Process::Process(ProcessParams * params)
{
string in = params->input;
string out = params->output;
+ string err = params->errout;
// initialize file descriptors to default: same as simulator
int stdin_fd, stdout_fd, stderr_fd;
@@ -112,7 +113,16 @@ Process::Process(ProcessParams * params)
else
stdout_fd = Process::openOutputFile(out);
- stderr_fd = (stdout_fd != STDOUT_FILENO) ? stdout_fd : STDERR_FILENO;
+ if (err == "stdout" || err == "cout")
+ stderr_fd = STDOUT_FILENO;
+ else if (err == "stderr" || err == "cerr")
+ stderr_fd = STDERR_FILENO;
+ else if (err == "None")
+ stderr_fd = -1;
+ else if (err == out)
+ stderr_fd = stdout_fd;
+ else
+ stderr_fd = Process::openOutputFile(err);
M5_pid = system->allocatePID();
// initialize first 3 fds (stdin, stdout, stderr)
@@ -132,7 +142,7 @@ Process::Process(ProcessParams * params)
fdo = &fd_map[STDERR_FILENO];
fdo->fd = stderr_fd;
- fdo->filename = "STDERR";
+ fdo->filename = err;
fdo->flags = O_WRONLY;
fdo->mode = -1;
fdo->fileOffset = 0;
@@ -183,7 +193,7 @@ Process::openInputFile(const string &filename)
int
Process::openOutputFile(const string &filename)
{
- int fd = open(filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0774);
+ int fd = open(filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0664);
if (fd == -1) {
perror(NULL);
@@ -355,6 +365,7 @@ Process::fix_file_offsets() {
Process::FdMap *fdo_stderr = &fd_map[STDERR_FILENO];
string in = fdo_stdin->filename;
string out = fdo_stdout->filename;
+ string err = fdo_stderr->filename;
// initialize file descriptors to default: same as simulator
int stdin_fd, stdout_fd, stderr_fd;
@@ -378,11 +389,23 @@ Process::fix_file_offsets() {
stdout_fd = -1;
else{
stdout_fd = Process::openOutputFile(out);
- if (lseek(stdin_fd, fdo_stdout->fileOffset, SEEK_SET) < 0)
- panic("Unable to seek to correct in file: %s", out);
+ if (lseek(stdout_fd, fdo_stdout->fileOffset, SEEK_SET) < 0)
+ panic("Unable to seek to correct location in file: %s", out);
}
- stderr_fd = (stdout_fd != STDOUT_FILENO) ? stdout_fd : STDERR_FILENO;
+ if (err == "stdout" || err == "cout")
+ stderr_fd = STDOUT_FILENO;
+ else if (err == "stderr" || err == "cerr")
+ stderr_fd = STDERR_FILENO;
+ else if (err == "None")
+ stderr_fd = -1;
+ else if (err == out)
+ stderr_fd = stdout_fd;
+ else {
+ stderr_fd = Process::openOutputFile(err);
+ if (lseek(stderr_fd, fdo_stderr->fileOffset, SEEK_SET) < 0)
+ panic("Unable to seek to correct location in file: %s", err);
+ }
fdo_stdin->fd = stdin_fd;
fdo_stdout->fd = stdout_fd;