Migrate most of main() and and all option parsing to python
configs/test/fs.py:
configs/test/test.py:
update for the new way that m5 deals with options
src/python/SConscript:
Compile AUTHORS, LICENSE, README, and RELEASE_NOTES into the
python stuff.
src/python/m5/__init__.py:
redo the way options work.
Move them all to main.py
src/sim/main.cc:
Migrate more functionality for main() into python.
Namely option parsing
src/python/m5/attrdict.py:
A dictionary object that overrides attribute access to
do item access.
src/python/m5/main.py:
The new location for M5's option parsing, and the main()
routine to set up the simulation.
--HG--
extra : convert_revision : c86b87a9f508bde1994088e23fd470c7753ee4c1
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
# Authors: Nathan Binkert
|
||||
# Steve Reinhardt
|
||||
|
||||
import sys, os, time, atexit, optparse
|
||||
import atexit, os, sys
|
||||
|
||||
# import the SWIG-wrapped main C++ functions
|
||||
import cc_main
|
||||
@@ -57,111 +57,6 @@ def AddToPath(path):
|
||||
# so place the new dir right after that.
|
||||
sys.path.insert(1, path)
|
||||
|
||||
|
||||
# The m5 module's pointer to the parsed options object
|
||||
options = None
|
||||
|
||||
|
||||
# User should call this function after calling parse_args() to pass
|
||||
# parsed standard option values back into the m5 module for
|
||||
# processing.
|
||||
def setStandardOptions(_options):
|
||||
# Set module global var
|
||||
global options
|
||||
options = _options
|
||||
# tell C++ about output directory
|
||||
cc_main.setOutputDir(options.outdir)
|
||||
|
||||
# Callback to set trace flags. Not necessarily the best way to do
|
||||
# things in the long run (particularly if we change how these global
|
||||
# options are handled).
|
||||
def setTraceFlags(option, opt_str, value, parser):
|
||||
objects.Trace.flags = value
|
||||
|
||||
def setTraceStart(option, opt_str, value, parser):
|
||||
objects.Trace.start = value
|
||||
|
||||
def setTraceFile(option, opt_str, value, parser):
|
||||
objects.Trace.file = value
|
||||
|
||||
def noPCSymbol(option, opt_str, value, parser):
|
||||
objects.ExecutionTrace.pc_symbol = False
|
||||
|
||||
def noPrintCycle(option, opt_str, value, parser):
|
||||
objects.ExecutionTrace.print_cycle = False
|
||||
|
||||
def noPrintOpclass(option, opt_str, value, parser):
|
||||
objects.ExecutionTrace.print_opclass = False
|
||||
|
||||
def noPrintThread(option, opt_str, value, parser):
|
||||
objects.ExecutionTrace.print_thread = False
|
||||
|
||||
def noPrintEA(option, opt_str, value, parser):
|
||||
objects.ExecutionTrace.print_effaddr = False
|
||||
|
||||
def noPrintData(option, opt_str, value, parser):
|
||||
objects.ExecutionTrace.print_data = False
|
||||
|
||||
def printFetchseq(option, opt_str, value, parser):
|
||||
objects.ExecutionTrace.print_fetchseq = True
|
||||
|
||||
def printCpseq(option, opt_str, value, parser):
|
||||
objects.ExecutionTrace.print_cpseq = True
|
||||
|
||||
def dumpOnExit(option, opt_str, value, parser):
|
||||
objects.Trace.dump_on_exit = True
|
||||
|
||||
def debugBreak(option, opt_str, value, parser):
|
||||
objects.Debug.break_cycles = value
|
||||
|
||||
def statsTextFile(option, opt_str, value, parser):
|
||||
objects.Statistics.text_file = value
|
||||
|
||||
# Standard optparse options. Need to be explicitly included by the
|
||||
# user script when it calls optparse.OptionParser().
|
||||
standardOptions = [
|
||||
optparse.make_option("--outdir", type="string", default="."),
|
||||
optparse.make_option("--traceflags", type="string", action="callback",
|
||||
callback=setTraceFlags),
|
||||
optparse.make_option("--tracestart", type="int", action="callback",
|
||||
callback=setTraceStart),
|
||||
optparse.make_option("--tracefile", type="string", action="callback",
|
||||
callback=setTraceFile),
|
||||
optparse.make_option("--nopcsymbol",
|
||||
action="callback", callback=noPCSymbol,
|
||||
help="Disable PC symbols in trace output"),
|
||||
optparse.make_option("--noprintcycle",
|
||||
action="callback", callback=noPrintCycle,
|
||||
help="Don't print cycle numbers in trace output"),
|
||||
optparse.make_option("--noprintopclass",
|
||||
action="callback", callback=noPrintOpclass,
|
||||
help="Don't print op class type in trace output"),
|
||||
optparse.make_option("--noprintthread",
|
||||
action="callback", callback=noPrintThread,
|
||||
help="Don't print thread number in trace output"),
|
||||
optparse.make_option("--noprinteffaddr",
|
||||
action="callback", callback=noPrintEA,
|
||||
help="Don't print effective address in trace output"),
|
||||
optparse.make_option("--noprintdata",
|
||||
action="callback", callback=noPrintData,
|
||||
help="Don't print result data in trace output"),
|
||||
optparse.make_option("--printfetchseq",
|
||||
action="callback", callback=printFetchseq,
|
||||
help="Print fetch sequence numbers in trace output"),
|
||||
optparse.make_option("--printcpseq",
|
||||
action="callback", callback=printCpseq,
|
||||
help="Print correct path sequence numbers in trace output"),
|
||||
optparse.make_option("--dumponexit",
|
||||
action="callback", callback=dumpOnExit,
|
||||
help="Dump trace buffer on exit"),
|
||||
optparse.make_option("--debugbreak", type="int", metavar="CYCLE",
|
||||
action="callback", callback=debugBreak,
|
||||
help="Cycle to create a breakpoint"),
|
||||
optparse.make_option("--statsfile", type="string", action="callback",
|
||||
callback=statsTextFile, metavar="FILE",
|
||||
help="Sets the output file for the statistics")
|
||||
]
|
||||
|
||||
# make a SmartDict out of the build options for our local use
|
||||
import smartdict
|
||||
build_env = smartdict.SmartDict()
|
||||
@@ -171,12 +66,13 @@ build_env.update(defines.m5_build_env)
|
||||
env = smartdict.SmartDict()
|
||||
env.update(os.environ)
|
||||
|
||||
|
||||
# Function to provide to C++ so it can look up instances based on paths
|
||||
def resolveSimObject(name):
|
||||
obj = config.instanceDict[name]
|
||||
return obj.getCCObject()
|
||||
|
||||
from main import options, arguments, main
|
||||
|
||||
# The final hook to generate .ini files. Called from the user script
|
||||
# once the config is built.
|
||||
def instantiate(root):
|
||||
|
||||
Reference in New Issue
Block a user