main.py revision 5767
12889Sbinkertn@umich.edu# Copyright (c) 2005 The Regents of The University of Michigan
22889Sbinkertn@umich.edu# All rights reserved.
32889Sbinkertn@umich.edu#
42889Sbinkertn@umich.edu# Redistribution and use in source and binary forms, with or without
52889Sbinkertn@umich.edu# modification, are permitted provided that the following conditions are
62889Sbinkertn@umich.edu# met: redistributions of source code must retain the above copyright
72889Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer;
82889Sbinkertn@umich.edu# redistributions in binary form must reproduce the above copyright
92889Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer in the
102889Sbinkertn@umich.edu# documentation and/or other materials provided with the distribution;
112889Sbinkertn@umich.edu# neither the name of the copyright holders nor the names of its
122889Sbinkertn@umich.edu# contributors may be used to endorse or promote products derived from
132889Sbinkertn@umich.edu# this software without specific prior written permission.
142889Sbinkertn@umich.edu#
152889Sbinkertn@umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
162889Sbinkertn@umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
172889Sbinkertn@umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
182889Sbinkertn@umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
192889Sbinkertn@umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
202889Sbinkertn@umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
212889Sbinkertn@umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
222889Sbinkertn@umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
232889Sbinkertn@umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
242889Sbinkertn@umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
252889Sbinkertn@umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
262889Sbinkertn@umich.edu#
272889Sbinkertn@umich.edu# Authors: Nathan Binkert
282889Sbinkertn@umich.edu
294850Snate@binkert.orgimport code
304850Snate@binkert.orgimport datetime
314850Snate@binkert.orgimport os
324850Snate@binkert.orgimport socket
334850Snate@binkert.orgimport sys
344850Snate@binkert.org
355467Snate@binkert.orgfrom util import attrdict
365471Snate@binkert.orgimport config
375470Snate@binkert.orgfrom options import OptionParser
382889Sbinkertn@umich.edu
392889Sbinkertn@umich.edu__all__ = [ 'options', 'arguments', 'main' ]
402889Sbinkertn@umich.edu
414053Sbinkertn@umich.edudef print_list(items, indent=4):
424053Sbinkertn@umich.edu    line = ' ' * indent
434053Sbinkertn@umich.edu    for i,item in enumerate(items):
444053Sbinkertn@umich.edu        if len(line) + len(item) > 76:
454053Sbinkertn@umich.edu            print line
464053Sbinkertn@umich.edu            line = ' ' * indent
474053Sbinkertn@umich.edu
484053Sbinkertn@umich.edu        if i < len(items) - 1:
494053Sbinkertn@umich.edu            line += '%s, ' % item
504053Sbinkertn@umich.edu        else:
514053Sbinkertn@umich.edu            line += item
524053Sbinkertn@umich.edu            print line
534053Sbinkertn@umich.edu
545470Snate@binkert.orgusage="%prog [m5 options] script.py [script options]"
555470Snate@binkert.orgversion="%prog 2.0"
565470Snate@binkert.orgbrief_copyright='''
575470Snate@binkert.orgCopyright (c) 2001-2008
585470Snate@binkert.orgThe Regents of The University of Michigan
595470Snate@binkert.orgAll Rights Reserved
605470Snate@binkert.org'''
612889Sbinkertn@umich.edu
625470Snate@binkert.orgoptions = OptionParser(usage=usage, version=version,
635470Snate@binkert.org                       description=brief_copyright)
645470Snate@binkert.orgadd_option = options.add_option
655470Snate@binkert.orgset_group = options.set_group
665470Snate@binkert.orgusage = options.usage
672889Sbinkertn@umich.edu
682889Sbinkertn@umich.edu# Help options
692889Sbinkertn@umich.eduadd_option('-A', "--authors", action="store_true", default=False,
702889Sbinkertn@umich.edu    help="Show author information")
714850Snate@binkert.orgadd_option('-B', "--build-info", action="store_true", default=False,
724850Snate@binkert.org    help="Show build information")
732889Sbinkertn@umich.eduadd_option('-C', "--copyright", action="store_true", default=False,
742889Sbinkertn@umich.edu    help="Show full copyright information")
752889Sbinkertn@umich.eduadd_option('-R', "--readme", action="store_true", default=False,
762889Sbinkertn@umich.edu    help="Show the readme")
772889Sbinkertn@umich.eduadd_option('-N', "--release-notes", action="store_true", default=False,
782889Sbinkertn@umich.edu    help="Show the release notes")
792889Sbinkertn@umich.edu
802889Sbinkertn@umich.edu# Options for configuring the base simulator
812889Sbinkertn@umich.eduadd_option('-d', "--outdir", metavar="DIR", default=".",
822889Sbinkertn@umich.edu    help="Set the output directory to DIR [Default: %default]")
835524Sstever@gmail.comadd_option('-r', "--redirect-stdout", action="store_true", default=False,
845524Sstever@gmail.com           help="Redirect stdout (& stderr, without -e) to file")
855524Sstever@gmail.comadd_option('-e', "--redirect-stderr", action="store_true", default=False,
865524Sstever@gmail.com           help="Redirect stderr to file")
875524Sstever@gmail.comadd_option("--stdout-file", metavar="FILE", default="simout",
885524Sstever@gmail.com           help="Filename for -r redirection [Default: %default]")
895524Sstever@gmail.comadd_option("--stderr-file", metavar="FILE", default="simerr",
905524Sstever@gmail.com           help="Filename for -e redirection [Default: %default]")
912889Sbinkertn@umich.eduadd_option('-i', "--interactive", action="store_true", default=False,
922889Sbinkertn@umich.edu    help="Invoke the interactive interpreter after running the script")
932899Sbinkertn@umich.eduadd_option("--pdb", action="store_true", default=False,
942899Sbinkertn@umich.edu    help="Invoke the python debugger before running the script")
952889Sbinkertn@umich.eduadd_option('-p', "--path", metavar="PATH[:PATH]", action='append', split=':',
962889Sbinkertn@umich.edu    help="Prepend PATH to the system path when invoking the script")
972889Sbinkertn@umich.eduadd_option('-q', "--quiet", action="count", default=0,
982889Sbinkertn@umich.edu    help="Reduce verbosity")
992889Sbinkertn@umich.eduadd_option('-v', "--verbose", action="count", default=0,
1002889Sbinkertn@umich.edu    help="Increase verbosity")
1012889Sbinkertn@umich.edu
1022889Sbinkertn@umich.edu# Statistics options
1032889Sbinkertn@umich.eduset_group("Statistics Options")
1042889Sbinkertn@umich.eduadd_option("--stats-file", metavar="FILE", default="m5stats.txt",
1052889Sbinkertn@umich.edu    help="Sets the output file for statistics [Default: %default]")
1062889Sbinkertn@umich.edu
1072889Sbinkertn@umich.edu# Debugging options
1082889Sbinkertn@umich.eduset_group("Debugging Options")
1092889Sbinkertn@umich.eduadd_option("--debug-break", metavar="TIME[,TIME]", action='append', split=',',
1102889Sbinkertn@umich.edu    help="Cycle to create a breakpoint")
1115512SMichael.Adler@intel.comadd_option("--remote-gdb-port", type='int', default=7000,
1125512SMichael.Adler@intel.com    help="Remote gdb base port")
1132889Sbinkertn@umich.edu
1142889Sbinkertn@umich.edu# Tracing options
1152889Sbinkertn@umich.eduset_group("Trace Options")
1164053Sbinkertn@umich.eduadd_option("--trace-help", action='store_true',
1174053Sbinkertn@umich.edu    help="Print help on trace flags")
1182889Sbinkertn@umich.eduadd_option("--trace-flags", metavar="FLAG[,FLAG]", action='append', split=',',
1194053Sbinkertn@umich.edu    help="Sets the flags for tracing (-FLAG disables a flag)")
1204044Sbinkertn@umich.eduadd_option("--trace-start", metavar="TIME", type='int',
1214044Sbinkertn@umich.edu    help="Start tracing at TIME (must be in ticks)")
1222889Sbinkertn@umich.eduadd_option("--trace-file", metavar="FILE", default="cout",
1232889Sbinkertn@umich.edu    help="Sets the output file for tracing [Default: %default]")
1242889Sbinkertn@umich.eduadd_option("--trace-ignore", metavar="EXPR", action='append', split=':',
1252889Sbinkertn@umich.edu    help="Ignore EXPR sim objects")
1262889Sbinkertn@umich.edu
1275473Snate@binkert.org# Help options
1285473Snate@binkert.orgset_group("Help Options")
1295473Snate@binkert.orgadd_option("--list-sim-objects", action='store_true', default=False,
1305473Snate@binkert.org    help="List all built-in SimObjects, their parameters and default values")
1315473Snate@binkert.org
1322889Sbinkertn@umich.edudef main():
1334167Sbinkertn@umich.edu    import event
1344042Sbinkertn@umich.edu    import info
1353624Sbinkertn@umich.edu    import internal
1362889Sbinkertn@umich.edu
1375472Snate@binkert.org    # load the options.py config file to allow people to set their own
1385472Snate@binkert.org    # default options
1395472Snate@binkert.org    options_file = config.get('options.py')
1405472Snate@binkert.org    if options_file:
1415472Snate@binkert.org        scope = { 'options' : options }
1425472Snate@binkert.org        execfile(options_file, scope)
1435472Snate@binkert.org
1445470Snate@binkert.org    arguments = options.parse_args()
1452889Sbinkertn@umich.edu
1465524Sstever@gmail.com    if not os.path.isdir(options.outdir):
1475524Sstever@gmail.com        os.makedirs(options.outdir)
1485524Sstever@gmail.com
1495524Sstever@gmail.com    # These filenames are used only if the redirect_std* options are set
1505524Sstever@gmail.com    stdout_file = os.path.join(options.outdir, options.stdout_file)
1515524Sstever@gmail.com    stderr_file = os.path.join(options.outdir, options.stderr_file)
1525524Sstever@gmail.com
1535524Sstever@gmail.com    # Print redirection notices here before doing any redirection
1545524Sstever@gmail.com    if options.redirect_stdout and not options.redirect_stderr:
1555524Sstever@gmail.com        print "Redirecting stdout and stderr to", stdout_file
1565524Sstever@gmail.com    else:
1575524Sstever@gmail.com        if options.redirect_stdout:
1585524Sstever@gmail.com            print "Redirecting stdout to", stdout_file
1595524Sstever@gmail.com        if options.redirect_stderr:
1605524Sstever@gmail.com            print "Redirecting stderr to", stderr_file
1615524Sstever@gmail.com
1625524Sstever@gmail.com    # Now redirect stdout/stderr as desired
1635524Sstever@gmail.com    if options.redirect_stdout:
1645524Sstever@gmail.com        redir_fd = os.open(stdout_file, os. O_WRONLY | os.O_CREAT | os.O_TRUNC)
1655524Sstever@gmail.com        os.dup2(redir_fd, sys.stdout.fileno())
1665524Sstever@gmail.com        if not options.redirect_stderr:
1675524Sstever@gmail.com            os.dup2(redir_fd, sys.stderr.fileno())
1685524Sstever@gmail.com
1695524Sstever@gmail.com    if options.redirect_stderr:
1705524Sstever@gmail.com        redir_fd = os.open(stderr_file, os. O_WRONLY | os.O_CREAT | os.O_TRUNC)
1715524Sstever@gmail.com        os.dup2(redir_fd, sys.stderr.fileno())
1725524Sstever@gmail.com
1732889Sbinkertn@umich.edu    done = False
1744850Snate@binkert.org
1754850Snate@binkert.org    if options.build_info:
1765586Snate@binkert.org        import defines
1775586Snate@binkert.org
1784850Snate@binkert.org        done = True
1794850Snate@binkert.org        print 'Build information:'
1804850Snate@binkert.org        print
1814850Snate@binkert.org        print 'compiled %s' % internal.core.cvar.compileDate;
1825528Sstever@gmail.com        print "revision %s" % internal.core.cvar.hgRev
1835528Sstever@gmail.com        print "commit date %s" % internal.core.cvar.hgDate
1844850Snate@binkert.org        print 'build options:'
1854850Snate@binkert.org        keys = defines.m5_build_env.keys()
1864850Snate@binkert.org        keys.sort()
1874850Snate@binkert.org        for key in keys:
1884850Snate@binkert.org            val = defines.m5_build_env[key]
1894850Snate@binkert.org            print '    %s = %s' % (key, val)
1904850Snate@binkert.org        print
1914850Snate@binkert.org
1922889Sbinkertn@umich.edu    if options.copyright:
1932889Sbinkertn@umich.edu        done = True
1942889Sbinkertn@umich.edu        print info.LICENSE
1952889Sbinkertn@umich.edu        print
1962889Sbinkertn@umich.edu
1972889Sbinkertn@umich.edu    if options.authors:
1982889Sbinkertn@umich.edu        done = True
1992889Sbinkertn@umich.edu        print 'Author information:'
2002889Sbinkertn@umich.edu        print
2012889Sbinkertn@umich.edu        print info.AUTHORS
2022889Sbinkertn@umich.edu        print
2032889Sbinkertn@umich.edu
2042889Sbinkertn@umich.edu    if options.readme:
2052889Sbinkertn@umich.edu        done = True
2062889Sbinkertn@umich.edu        print 'Readme:'
2072889Sbinkertn@umich.edu        print
2082889Sbinkertn@umich.edu        print info.README
2092889Sbinkertn@umich.edu        print
2102889Sbinkertn@umich.edu
2112889Sbinkertn@umich.edu    if options.release_notes:
2122889Sbinkertn@umich.edu        done = True
2132889Sbinkertn@umich.edu        print 'Release Notes:'
2142889Sbinkertn@umich.edu        print
2152889Sbinkertn@umich.edu        print info.RELEASE_NOTES
2162889Sbinkertn@umich.edu        print
2172889Sbinkertn@umich.edu
2184053Sbinkertn@umich.edu    if options.trace_help:
2195586Snate@binkert.org        import traceflags
2205586Snate@binkert.org
2214053Sbinkertn@umich.edu        done = True
2224053Sbinkertn@umich.edu        print "Base Flags:"
2235752SSteve.Reinhardt@amd.com        traceflags.baseFlags.sort()
2244053Sbinkertn@umich.edu        print_list(traceflags.baseFlags, indent=4)
2254053Sbinkertn@umich.edu        print
2264053Sbinkertn@umich.edu        print "Compound Flags:"
2275752SSteve.Reinhardt@amd.com        traceflags.compoundFlags.sort()
2284053Sbinkertn@umich.edu        for flag in traceflags.compoundFlags:
2294053Sbinkertn@umich.edu            if flag == 'All':
2304053Sbinkertn@umich.edu                continue
2314053Sbinkertn@umich.edu            print "    %s:" % flag
2324053Sbinkertn@umich.edu            print_list(traceflags.compoundFlagMap[flag], indent=8)
2334053Sbinkertn@umich.edu            print
2344053Sbinkertn@umich.edu
2355473Snate@binkert.org    if options.list_sim_objects:
2365473Snate@binkert.org        import SimObject
2375473Snate@binkert.org        done = True
2385473Snate@binkert.org        print "SimObjects:"
2395473Snate@binkert.org        objects = SimObject.allClasses.keys()
2405473Snate@binkert.org        objects.sort()
2415473Snate@binkert.org        for name in objects:
2425473Snate@binkert.org            obj = SimObject.allClasses[name]
2435473Snate@binkert.org            print "    %s" % obj
2445473Snate@binkert.org            params = obj._params.keys()
2455473Snate@binkert.org            params.sort()
2465473Snate@binkert.org            for pname in params:
2475473Snate@binkert.org                param = obj._params[pname]
2485473Snate@binkert.org                default = getattr(param, 'default', '')
2495473Snate@binkert.org                print "        %s" % pname
2505473Snate@binkert.org                if default:
2515473Snate@binkert.org                    print "            default: %s" % default
2525473Snate@binkert.org                print "            desc: %s" % param.desc
2535473Snate@binkert.org                print
2545473Snate@binkert.org            print
2555473Snate@binkert.org
2562889Sbinkertn@umich.edu    if done:
2572889Sbinkertn@umich.edu        sys.exit(0)
2582889Sbinkertn@umich.edu
2595470Snate@binkert.org    # setting verbose and quiet at the same time doesn't make sense
2605470Snate@binkert.org    if options.verbose > 0 and options.quiet > 0:
2615470Snate@binkert.org        options.usage(2)
2625470Snate@binkert.org
2635470Snate@binkert.org    verbose = options.verbose - options.quiet
2642889Sbinkertn@umich.edu    if options.verbose >= 0:
2652889Sbinkertn@umich.edu        print "M5 Simulator System"
2662889Sbinkertn@umich.edu        print brief_copyright
2672889Sbinkertn@umich.edu        print
2684123Sbinkertn@umich.edu        print "M5 compiled %s" % internal.core.cvar.compileDate;
2695456Ssaidi@eecs.umich.edu        print "M5 revision %s" % internal.core.cvar.hgRev
2705456Ssaidi@eecs.umich.edu        print "M5 commit date %s" % internal.core.cvar.hgDate
2715456Ssaidi@eecs.umich.edu
2725528Sstever@gmail.com        print "M5 started %s" % datetime.datetime.now().strftime("%b %e %Y %X")
2735528Sstever@gmail.com        print "M5 executing on %s" % socket.gethostname()
2745528Sstever@gmail.com
2752967Sktlim@umich.edu        print "command line:",
2762967Sktlim@umich.edu        for argv in sys.argv:
2772967Sktlim@umich.edu            print argv,
2782967Sktlim@umich.edu        print
2792889Sbinkertn@umich.edu
2802889Sbinkertn@umich.edu    # check to make sure we can find the listed script
2812889Sbinkertn@umich.edu    if not arguments or not os.path.isfile(arguments[0]):
2822922Sktlim@umich.edu        if arguments and not os.path.isfile(arguments[0]):
2832922Sktlim@umich.edu            print "Script %s not found" % arguments[0]
2844053Sbinkertn@umich.edu
2855470Snate@binkert.org        options.usage(2)
2862889Sbinkertn@umich.edu
2872889Sbinkertn@umich.edu    # tell C++ about output directory
2884123Sbinkertn@umich.edu    internal.core.setOutputDir(options.outdir)
2892889Sbinkertn@umich.edu
2902889Sbinkertn@umich.edu    # update the system path with elements from the -p option
2912889Sbinkertn@umich.edu    sys.path[0:0] = options.path
2922889Sbinkertn@umich.edu
2932889Sbinkertn@umich.edu    import objects
2942889Sbinkertn@umich.edu
2952889Sbinkertn@umich.edu    # set stats options
2964078Sbinkertn@umich.edu    internal.stats.initText(options.stats_file)
2972889Sbinkertn@umich.edu
2982889Sbinkertn@umich.edu    # set debugging options
2995512SMichael.Adler@intel.com    internal.debug.setRemoteGDBPort(options.remote_gdb_port)
3003645Sbinkertn@umich.edu    for when in options.debug_break:
3013645Sbinkertn@umich.edu        internal.debug.schedBreakCycle(int(when))
3022889Sbinkertn@umich.edu
3035586Snate@binkert.org    if options.trace_flags:
3045586Snate@binkert.org        import traceflags
3054053Sbinkertn@umich.edu
3065586Snate@binkert.org        on_flags = []
3075586Snate@binkert.org        off_flags = []
3085586Snate@binkert.org        for flag in options.trace_flags:
3095586Snate@binkert.org            off = False
3105586Snate@binkert.org            if flag.startswith('-'):
3115586Snate@binkert.org                flag = flag[1:]
3125586Snate@binkert.org                off = True
3135767Snate@binkert.org            if flag not in traceflags.allFlags and flag != "All":
3145586Snate@binkert.org                print >>sys.stderr, "invalid trace flag '%s'" % flag
3155586Snate@binkert.org                sys.exit(1)
3164053Sbinkertn@umich.edu
3175586Snate@binkert.org            if off:
3185586Snate@binkert.org                off_flags.append(flag)
3195586Snate@binkert.org            else:
3205586Snate@binkert.org                on_flags.append(flag)
3214042Sbinkertn@umich.edu
3225586Snate@binkert.org        for flag in on_flags:
3235586Snate@binkert.org            internal.trace.set(flag)
3245586Snate@binkert.org
3255586Snate@binkert.org        for flag in off_flags:
3265586Snate@binkert.org            internal.trace.clear(flag)
3274053Sbinkertn@umich.edu
3284074Sbinkertn@umich.edu    if options.trace_start:
3294042Sbinkertn@umich.edu        def enable_trace():
3304074Sbinkertn@umich.edu            internal.trace.cvar.enabled = True
3315606Snate@binkert.org
3325606Snate@binkert.org        e = event.create(enable_trace)
3335606Snate@binkert.org        event.mainq.schedule(e, options.trace_start)
3344074Sbinkertn@umich.edu    else:
3354087Sbinkertn@umich.edu        internal.trace.cvar.enabled = True
3364042Sbinkertn@umich.edu
3374046Sbinkertn@umich.edu    internal.trace.output(options.trace_file)
3384042Sbinkertn@umich.edu
3394042Sbinkertn@umich.edu    for ignore in options.trace_ignore:
3404042Sbinkertn@umich.edu        internal.trace.ignore(ignore)
3412889Sbinkertn@umich.edu
3422889Sbinkertn@umich.edu    sys.argv = arguments
3432889Sbinkertn@umich.edu    sys.path = [ os.path.dirname(sys.argv[0]) ] + sys.path
3442891Sbinkertn@umich.edu
3455604Snate@binkert.org    filename = sys.argv[0]
3465604Snate@binkert.org    filedata = file(filename, 'r').read()
3475604Snate@binkert.org    filecode = compile(filedata, filename, 'exec')
3485604Snate@binkert.org    scope = { '__file__' : filename,
3493887Sbinkertn@umich.edu              '__name__' : '__m5_main__' }
3502899Sbinkertn@umich.edu
3512899Sbinkertn@umich.edu    # we want readline if we're doing anything interactive
3522899Sbinkertn@umich.edu    if options.interactive or options.pdb:
3534042Sbinkertn@umich.edu        exec "import readline" in scope
3542899Sbinkertn@umich.edu
3552899Sbinkertn@umich.edu    # if pdb was requested, execfile the thing under pdb, otherwise,
3562899Sbinkertn@umich.edu    # just do the execfile normally
3572899Sbinkertn@umich.edu    if options.pdb:
3585604Snate@binkert.org        import pdb
3595604Snate@binkert.org        import traceback
3605604Snate@binkert.org
3615604Snate@binkert.org        pdb = pdb.Pdb()
3625604Snate@binkert.org        try:
3635604Snate@binkert.org            pdb.run(filecode, scope)
3645604Snate@binkert.org        except SystemExit:
3655604Snate@binkert.org            print "The program exited via sys.exit(). Exit status: ",
3665604Snate@binkert.org            print sys.exc_info()[1]
3675604Snate@binkert.org        except:
3685604Snate@binkert.org            traceback.print_exc()
3695604Snate@binkert.org            print "Uncaught exception. Entering post mortem debugging"
3705604Snate@binkert.org            t = sys.exc_info()[2]
3715604Snate@binkert.org            while t.tb_next is not None:
3725604Snate@binkert.org                t = t.tb_next
3735604Snate@binkert.org                pdb.interaction(t.tb_frame,t)
3742899Sbinkertn@umich.edu    else:
3755604Snate@binkert.org        exec filecode in scope
3762889Sbinkertn@umich.edu
3772889Sbinkertn@umich.edu    # once the script is done
3782889Sbinkertn@umich.edu    if options.interactive:
3792889Sbinkertn@umich.edu        interact = code.InteractiveConsole(scope)
3802889Sbinkertn@umich.edu        interact.interact("M5 Interactive Console")
3812889Sbinkertn@umich.edu
3822889Sbinkertn@umich.eduif __name__ == '__main__':
3832889Sbinkertn@umich.edu    from pprint import pprint
3842889Sbinkertn@umich.edu
3855586Snate@binkert.org    # load the options.py config file to allow people to set their own
3865586Snate@binkert.org    # default options
3875586Snate@binkert.org    options_file = config.get('options.py')
3885586Snate@binkert.org    if options_file:
3895586Snate@binkert.org        scope = { 'options' : options }
3905586Snate@binkert.org        execfile(options_file, scope)
3915586Snate@binkert.org
3925586Snate@binkert.org    arguments = options.parse_args()
3932889Sbinkertn@umich.edu
3942889Sbinkertn@umich.edu    print 'opts:'
3952889Sbinkertn@umich.edu    pprint(options, indent=4)
3962889Sbinkertn@umich.edu    print
3972889Sbinkertn@umich.edu
3982889Sbinkertn@umich.edu    print 'args:'
3992889Sbinkertn@umich.edu    pprint(arguments, indent=4)
400