1# Copyright (c) 2016 ARM Limited 2# All rights reserved. 3# 4# The license below extends only to copyright in the software and shall 5# not be construed as granting a license to any other intellectual 6# property including but not limited to intellectual property relating 7# to a hardware implementation of the functionality of the software 8# licensed hereunder. You may use the software subject to the license 9# terms below provided that you ensure that this notice is replicated 10# unmodified and in its entirety in all distributions of the software, 11# modified or unmodified, in source code or in binary form. 12# 13# Copyright (c) 2005 The Regents of The University of Michigan 14# All rights reserved. 15# 16# Redistribution and use in source and binary forms, with or without 17# modification, are permitted provided that the following conditions are 18# met: redistributions of source code must retain the above copyright 19# notice, this list of conditions and the following disclaimer; 20# redistributions in binary form must reproduce the above copyright 21# notice, this list of conditions and the following disclaimer in the 22# documentation and/or other materials provided with the distribution; 23# neither the name of the copyright holders nor the names of its 24# contributors may be used to endorse or promote products derived from 25# this software without specific prior written permission. 26# 27# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 30# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 31# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 32# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 33# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 34# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 35# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 36# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 37# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38# 39# Authors: Nathan Binkert 40 41from __future__ import print_function 42 43import code 44import datetime 45import os 46import socket 47import sys 48 49__all__ = [ 'options', 'arguments', 'main' ] 50 51usage="%prog [gem5 options] script.py [script options]" 52version="%prog 2.0" 53brief_copyright=\ 54 "gem5 is copyrighted software; use the --copyright option for details." 55 56def parse_options(): 57 import config 58 from options import OptionParser 59 60 options = OptionParser(usage=usage, version=version, 61 description=brief_copyright) 62 option = options.add_option 63 group = options.set_group 64 65 listener_modes = ( "on", "off", "auto" ) 66 67 # Help options 68 option('-B', "--build-info", action="store_true", default=False, 69 help="Show build information") 70 option('-C', "--copyright", action="store_true", default=False, 71 help="Show full copyright information") 72 option('-R', "--readme", action="store_true", default=False, 73 help="Show the readme") 74 75 # Options for configuring the base simulator 76 option('-d', "--outdir", metavar="DIR", default="m5out", 77 help="Set the output directory to DIR [Default: %default]") 78 option('-r', "--redirect-stdout", action="store_true", default=False, 79 help="Redirect stdout (& stderr, without -e) to file") 80 option('-e', "--redirect-stderr", action="store_true", default=False, 81 help="Redirect stderr to file") 82 option("--stdout-file", metavar="FILE", default="simout", 83 help="Filename for -r redirection [Default: %default]") 84 option("--stderr-file", metavar="FILE", default="simerr", 85 help="Filename for -e redirection [Default: %default]") 86 option("--listener-mode", metavar="{on,off,auto}", 87 choices=listener_modes, default="auto", 88 help="Port (e.g., gdb) listener mode (auto: Enable if running " \ 89 "interactively) [Default: %default]") 90 option("--listener-loopback-only", action="store_true", default=False, 91 help="Port listeners will only accept connections over the " \ 92 "loopback device") 93 option('-i', "--interactive", action="store_true", default=False, 94 help="Invoke the interactive interpreter after running the script") 95 option("--pdb", action="store_true", default=False, 96 help="Invoke the python debugger before running the script") 97 option('-p', "--path", metavar="PATH[:PATH]", action='append', split=':', 98 help="Prepend PATH to the system path when invoking the script") 99 option('-q', "--quiet", action="count", default=0, 100 help="Reduce verbosity") 101 option('-v', "--verbose", action="count", default=0, 102 help="Increase verbosity") 103 104 # Statistics options 105 group("Statistics Options") 106 option("--stats-file", metavar="FILE", default="stats.txt", 107 help="Sets the output file for statistics [Default: %default]") 108 109 # Configuration Options 110 group("Configuration Options") 111 option("--dump-config", metavar="FILE", default="config.ini", 112 help="Dump configuration output file [Default: %default]") 113 option("--json-config", metavar="FILE", default="config.json", 114 help="Create JSON output of the configuration [Default: %default]") 115 option("--dot-config", metavar="FILE", default="config.dot", 116 help="Create DOT & pdf outputs of the configuration [Default: %default]") 117 option("--dot-dvfs-config", metavar="FILE", default=None, 118 help="Create DOT & pdf outputs of the DVFS configuration" + \ 119 " [Default: %default]") 120 121 # Debugging options 122 group("Debugging Options") 123 option("--debug-break", metavar="TICK[,TICK]", action='append', split=',', 124 help="Create breakpoint(s) at TICK(s) " \ 125 "(kills process if no debugger attached)") 126 option("--debug-help", action='store_true', 127 help="Print help on debug flags") 128 option("--debug-flags", metavar="FLAG[,FLAG]", action='append', split=',', 129 help="Sets the flags for debug output (-FLAG disables a flag)") 130 option("--debug-start", metavar="TICK", type='int', 131 help="Start debug output at TICK") 132 option("--debug-end", metavar="TICK", type='int', 133 help="End debug output at TICK") 134 option("--debug-file", metavar="FILE", default="cout", 135 help="Sets the output file for debug [Default: %default]") 136 option("--debug-ignore", metavar="EXPR", action='append', split=':', 137 help="Ignore EXPR sim objects") 138 option("--remote-gdb-port", type='int', default=7000, 139 help="Remote gdb base port (set to 0 to disable listening)") 140 141 # Help options 142 group("Help Options") 143 option("--list-sim-objects", action='store_true', default=False, 144 help="List all built-in SimObjects, their params and default values") 145 146 # load the options.py config file to allow people to set their own 147 # default options 148 options_file = config.get('options.py') 149 if options_file: 150 scope = { 'options' : options }
|