Nils Asmussen has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/28727 )
Change subject: base,sim: allow m5writeFile with stdout/stderr.
......................................................................
base,sim: allow m5writeFile with stdout/stderr.
If m5writeFile opens stdout/stderr, no file is registered in
OutputDirectory and thus we don't want to search for it on close.
In order to write multiple times to stdout/stderr in a reasonable way,
we also want to prevent seeking. Thus, don't seek if the offset is 0, in
which case this would be a noop anyway (we just opened the file without
append).
Finally, it is helpful for debugging if the stream is flushed on every
write.
Change-Id: I102f82dcd2c63420b6f3fe55d67f03c62349e69d
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/28727
Reviewed-by: Jason Lowe-Power <power...@gmail.com>
Maintainer: Jason Lowe-Power <power...@gmail.com>
Tested-by: kokoro <noreply+kok...@google.com>
---
M src/base/output.cc
M src/sim/pseudo_inst.cc
2 files changed, 11 insertions(+), 2 deletions(-)
Approvals:
Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved
kokoro: Regressions pass
diff --git a/src/base/output.cc b/src/base/output.cc
index ec94a13..47b8aa7 100644
--- a/src/base/output.cc
+++ b/src/base/output.cc
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2015 ARM Limited
+ * Copyright (c) 2020 Barkhausen Institut
* All rights reserved
*
* The license below extends only to copyright in the software and shall
@@ -142,6 +143,11 @@
void
OutputDirectory::close(OutputStream *file)
{
+ if (file == &stdout || file == &stderr) {
+ file->stream()->flush();
+ return;
+ }
+
auto i = files.find(file->name());
if (i == files.end())
fatal("Attempted to close an unregistred file stream");
diff --git a/src/sim/pseudo_inst.cc b/src/sim/pseudo_inst.cc
index c65fdc0..b11a5a4 100644
--- a/src/sim/pseudo_inst.cc
+++ b/src/sim/pseudo_inst.cc
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2010-2012, 2015, 2017 ARM Limited
+ * Copyright (c) 2020 Barkhausen Institut
* All rights reserved
*
* The license below extends only to copyright in the software and shall
@@ -425,8 +426,10 @@
if (!os)
panic("could not open file %s\n", filename);
- // seek to offset
- os->seekp(offset);
+ if (offset != 0) {
+ // seek to offset
+ os->seekp(offset);
+ }
// copy out data and write to file
char *buf = new char[len];
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/28727
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: release-staging-v20.0.0.0
Gerrit-Change-Id: I102f82dcd2c63420b6f3fe55d67f03c62349e69d
Gerrit-Change-Number: 28727
Gerrit-PatchSet: 2
Gerrit-Owner: Nils Asmussen <nils.asmus...@barkhauseninstitut.org>
Gerrit-Reviewer: Bobby R. Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: Jason Lowe-Power <power...@gmail.com>
Gerrit-Reviewer: Nils Asmussen <nils.asmus...@barkhauseninstitut.org>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s