dev: Enable Terminal output's dump to stdout

While the default option is to dump the Terminal content in a file (e.g.
m5out/system.terminal), with this patch it will be possible to choose to
dump it to standard output.

Change-Id: If51c2fd671fa3eb0867a855b5f7d3b0df9cad025
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/20639
Maintainer: Jason Lowe-Power <jason@lowepower.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
This commit is contained in:
Giacomo Travaglini
2019-04-16 11:39:30 +01:00
parent e7c75d2c11
commit 1c72e90e4e
3 changed files with 58 additions and 2 deletions

View File

@@ -1,3 +1,15 @@
# Copyright (c) 2019 ARM Limited
# All rights reserved.
#
# The license below extends only to copyright in the software and shall
# not be construed as granting a license to any other intellectual
# property including but not limited to intellectual property relating
# to a hardware implementation of the functionality of the software
# licensed hereunder. You may use the software subject to the license
# terms below provided that you ensure that this notice is replicated
# unmodified and in its entirety in all distributions of the software,
# modified or unmodified, in source code or in binary form.
#
# Copyright (c) 2005-2007 The Regents of The University of Michigan # Copyright (c) 2005-2007 The Regents of The University of Michigan
# All rights reserved. # All rights reserved.
# #
@@ -32,9 +44,12 @@ from m5.proxy import *
from m5.objects.Serial import SerialDevice from m5.objects.Serial import SerialDevice
class TerminalDump(Enum): vals = ["none", "stdout", "stderr", "file"]
class Terminal(SerialDevice): class Terminal(SerialDevice):
type = 'Terminal' type = 'Terminal'
cxx_header = "dev/serial/terminal.hh" cxx_header = "dev/serial/terminal.hh"
port = Param.TcpPort(3456, "listen port") port = Param.TcpPort(3456, "listen port")
number = Param.Int(0, "terminal number") number = Param.Int(0, "terminal number")
output = Param.Bool(True, "Enable output dump to file") outfile = Param.TerminalDump("file",
"Selects if and where the terminal is dumping its output")

View File

@@ -1,4 +1,16 @@
/* /*
* Copyright (c) 2019 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
* not be construed as granting a license to any other intellectual
* property including but not limited to intellectual property relating
* to a hardware implementation of the functionality of the software
* licensed hereunder. You may use the software subject to the license
* terms below provided that you ensure that this notice is replicated
* unmodified and in its entirety in all distributions of the software,
* modified or unmodified, in source code or in binary form.
*
* Copyright (c) 2001-2005 The Regents of The University of Michigan * Copyright (c) 2001-2005 The Regents of The University of Michigan
* All rights reserved. * All rights reserved.
* *
@@ -109,7 +121,7 @@ Terminal::DataEvent::process(int revent)
Terminal::Terminal(const Params *p) Terminal::Terminal(const Params *p)
: SerialDevice(p), listenEvent(NULL), dataEvent(NULL), : SerialDevice(p), listenEvent(NULL), dataEvent(NULL),
number(p->number), data_fd(-1), txbuf(16384), rxbuf(16384), number(p->number), data_fd(-1), txbuf(16384), rxbuf(16384),
outfile(p->output ? simout.findOrCreate(p->name) : NULL) outfile(terminalDump(p))
#if TRACING_ON == 1 #if TRACING_ON == 1
, linebuf(16384) , linebuf(16384)
#endif #endif
@@ -133,6 +145,22 @@ Terminal::~Terminal()
delete dataEvent; delete dataEvent;
} }
OutputStream *
Terminal::terminalDump(const TerminalParams* p)
{
switch (p->outfile) {
case Enums::TerminalDump::none:
return nullptr;
case Enums::TerminalDump::stdout:
return simout.findOrCreate("stdout");
case Enums::TerminalDump::stderr:
return simout.findOrCreate("stderr");
case Enums::TerminalDump::file:
return simout.findOrCreate(p->name);
default:
panic("Invalid option\n");
}
}
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
// socket creation and terminal attach // socket creation and terminal attach

View File

@@ -1,4 +1,16 @@
/* /*
* Copyright (c) 2019 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
* not be construed as granting a license to any other intellectual
* property including but not limited to intellectual property relating
* to a hardware implementation of the functionality of the software
* licensed hereunder. You may use the software subject to the license
* terms below provided that you ensure that this notice is replicated
* unmodified and in its entirety in all distributions of the software,
* modified or unmodified, in source code or in binary form.
*
* Copyright (c) 2001-2005 The Regents of The University of Michigan * Copyright (c) 2001-2005 The Regents of The University of Michigan
* All rights reserved. * All rights reserved.
* *
@@ -86,6 +98,7 @@ class Terminal : public SerialDevice
typedef TerminalParams Params; typedef TerminalParams Params;
Terminal(const Params *p); Terminal(const Params *p);
~Terminal(); ~Terminal();
OutputStream * terminalDump(const TerminalParams* p);
protected: protected:
ListenSocket listener; ListenSocket listener;