python: Automatically disable listeners in batch setups
Determine if gem5 is running in a batch environment by checking if STDIN is wired to a TTY or not. If the simulator is running in a batch environment, disable all listeners by default. This behavior can be overridden using the --enable-listeners option. Change-Id: I404c709135339144216bf08a2769c016c543333c Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-by: Sean McGoogan <sean.mcgoogan@arm.com> Reviewed-on: https://gem5-review.googlesource.com/2322 Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
This commit is contained in:
parent
065bb8c655
commit
7110d2313e
2 changed files with 49 additions and 1 deletions
|
@ -1,3 +1,15 @@
|
||||||
|
# Copyright (c) 2016 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 The Regents of The University of Michigan
|
# Copyright (c) 2005 The Regents of The University of Michigan
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
|
@ -48,6 +60,8 @@ def parse_options():
|
||||||
option = options.add_option
|
option = options.add_option
|
||||||
group = options.set_group
|
group = options.set_group
|
||||||
|
|
||||||
|
listener_modes = ( "on", "off", "auto" )
|
||||||
|
|
||||||
# Help options
|
# Help options
|
||||||
option('-B', "--build-info", action="store_true", default=False,
|
option('-B', "--build-info", action="store_true", default=False,
|
||||||
help="Show build information")
|
help="Show build information")
|
||||||
|
@ -67,6 +81,10 @@ def parse_options():
|
||||||
help="Filename for -r redirection [Default: %default]")
|
help="Filename for -r redirection [Default: %default]")
|
||||||
option("--stderr-file", metavar="FILE", default="simerr",
|
option("--stderr-file", metavar="FILE", default="simerr",
|
||||||
help="Filename for -e redirection [Default: %default]")
|
help="Filename for -e redirection [Default: %default]")
|
||||||
|
option("--listener-mode", metavar="{on,off,auto}",
|
||||||
|
choices=listener_modes, default="auto",
|
||||||
|
help="Port (e.g., gdb) listener mode (auto: Enable if running " \
|
||||||
|
"interactively) [Default: %default]")
|
||||||
option('-i', "--interactive", action="store_true", default=False,
|
option('-i', "--interactive", action="store_true", default=False,
|
||||||
help="Invoke the interactive interpreter after running the script")
|
help="Invoke the interactive interpreter after running the script")
|
||||||
option("--pdb", action="store_true", default=False,
|
option("--pdb", action="store_true", default=False,
|
||||||
|
@ -179,7 +197,7 @@ def main(*args):
|
||||||
import stats
|
import stats
|
||||||
import trace
|
import trace
|
||||||
|
|
||||||
from util import fatal
|
from util import inform, fatal, panic, isInteractive
|
||||||
|
|
||||||
if len(args) == 0:
|
if len(args) == 0:
|
||||||
options, arguments = parse_options()
|
options, arguments = parse_options()
|
||||||
|
@ -321,6 +339,19 @@ def main(*args):
|
||||||
# set stats options
|
# set stats options
|
||||||
stats.addStatVisitor(options.stats_file)
|
stats.addStatVisitor(options.stats_file)
|
||||||
|
|
||||||
|
# Disable listeners unless running interactively or explicitly
|
||||||
|
# enabled
|
||||||
|
if options.listener_mode == "off":
|
||||||
|
m5.disableAllListeners()
|
||||||
|
elif options.listener_mode == "auto":
|
||||||
|
if not isInteractive():
|
||||||
|
inform("Standard input is not a terminal, disabling listeners.")
|
||||||
|
m5.disableAllListeners()
|
||||||
|
elif options.listener_mode == "on":
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
panic("Unhandled listener mode: %s" % options.listener_mode)
|
||||||
|
|
||||||
# set debugging options
|
# set debugging options
|
||||||
debug.setRemoteGDBPort(options.remote_gdb_port)
|
debug.setRemoteGDBPort(options.remote_gdb_port)
|
||||||
for when in options.debug_break:
|
for when in options.debug_break:
|
||||||
|
|
|
@ -1,3 +1,15 @@
|
||||||
|
# Copyright (c) 2016 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) 2008-2009 The Hewlett-Packard Development Company
|
# Copyright (c) 2008-2009 The Hewlett-Packard Development Company
|
||||||
# Copyright (c) 2004-2006 The Regents of The University of Michigan
|
# Copyright (c) 2004-2006 The Regents of The University of Michigan
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
|
@ -195,3 +207,8 @@ def makeDir(path):
|
||||||
raise AttributeError, "%s exists but is not directory" % path
|
raise AttributeError, "%s exists but is not directory" % path
|
||||||
else:
|
else:
|
||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
|
|
||||||
|
def isInteractive():
|
||||||
|
"""Check if the simulator is run interactively or in a batch environment"""
|
||||||
|
|
||||||
|
return sys.__stdin__.isatty()
|
||||||
|
|
Loading…
Reference in a new issue