tracing: panic() if people try to use tracing, but TRACING_ON is not set.
Also clean things up so that help strings can more easily be added. Move the help function into trace.py
This commit is contained in:
parent
f15f252d4e
commit
0876c822dd
4 changed files with 57 additions and 45 deletions
|
@ -175,30 +175,25 @@ Export('UnitTest')
|
||||||
#
|
#
|
||||||
# Trace Flags
|
# Trace Flags
|
||||||
#
|
#
|
||||||
all_flags = {}
|
trace_flags = {}
|
||||||
trace_flags = []
|
def TraceFlag(name, desc=None):
|
||||||
def TraceFlag(name, desc=''):
|
if name in trace_flags:
|
||||||
if name in all_flags:
|
|
||||||
raise AttributeError, "Flag %s already specified" % name
|
raise AttributeError, "Flag %s already specified" % name
|
||||||
flag = (name, (), desc)
|
trace_flags[name] = (name, (), desc)
|
||||||
trace_flags.append(flag)
|
|
||||||
all_flags[name] = ()
|
|
||||||
|
|
||||||
def CompoundFlag(name, flags, desc=''):
|
def CompoundFlag(name, flags, desc=None):
|
||||||
if name in all_flags:
|
if name in trace_flags:
|
||||||
raise AttributeError, "Flag %s already specified" % name
|
raise AttributeError, "Flag %s already specified" % name
|
||||||
|
|
||||||
compound = tuple(flags)
|
compound = tuple(flags)
|
||||||
for flag in compound:
|
for flag in compound:
|
||||||
if flag not in all_flags:
|
if flag not in trace_flags:
|
||||||
raise AttributeError, "Trace flag %s not found" % flag
|
raise AttributeError, "Trace flag %s not found" % flag
|
||||||
if all_flags[flag]:
|
if trace_flags[flag][1]:
|
||||||
raise AttributeError, \
|
raise AttributeError, \
|
||||||
"Compound flag can't point to another compound flag"
|
"Compound flag can't point to another compound flag"
|
||||||
|
|
||||||
flag = (name, compound, desc)
|
trace_flags[name] = (name, compound, desc)
|
||||||
trace_flags.append(flag)
|
|
||||||
all_flags[name] = compound
|
|
||||||
|
|
||||||
Export('TraceFlag')
|
Export('TraceFlag')
|
||||||
Export('CompoundFlag')
|
Export('CompoundFlag')
|
||||||
|
@ -666,14 +661,16 @@ def traceFlagsPy(target, source, env):
|
||||||
val = eval(s.get_contents())
|
val = eval(s.get_contents())
|
||||||
allFlags.append(val)
|
allFlags.append(val)
|
||||||
|
|
||||||
print >>f, 'baseFlags = ['
|
allFlags.sort()
|
||||||
|
|
||||||
|
print >>f, 'basic = ['
|
||||||
for flag, compound, desc in allFlags:
|
for flag, compound, desc in allFlags:
|
||||||
if not compound:
|
if not compound:
|
||||||
print >>f, " '%s'," % flag
|
print >>f, " '%s'," % flag
|
||||||
print >>f, " ]"
|
print >>f, " ]"
|
||||||
print >>f
|
print >>f
|
||||||
|
|
||||||
print >>f, 'compoundFlags = ['
|
print >>f, 'compound = ['
|
||||||
print >>f, " 'All',"
|
print >>f, " 'All',"
|
||||||
for flag, compound, desc in allFlags:
|
for flag, compound, desc in allFlags:
|
||||||
if compound:
|
if compound:
|
||||||
|
@ -681,10 +678,10 @@ def traceFlagsPy(target, source, env):
|
||||||
print >>f, " ]"
|
print >>f, " ]"
|
||||||
print >>f
|
print >>f
|
||||||
|
|
||||||
print >>f, "allFlags = frozenset(baseFlags + compoundFlags)"
|
print >>f, "all = frozenset(basic + compound)"
|
||||||
print >>f
|
print >>f
|
||||||
|
|
||||||
print >>f, 'compoundFlagMap = {'
|
print >>f, 'compoundMap = {'
|
||||||
all = tuple([flag for flag,compound,desc in allFlags if not compound])
|
all = tuple([flag for flag,compound,desc in allFlags if not compound])
|
||||||
print >>f, " 'All' : %s," % (all, )
|
print >>f, " 'All' : %s," % (all, )
|
||||||
for flag, compound, desc in allFlags:
|
for flag, compound, desc in allFlags:
|
||||||
|
@ -693,7 +690,7 @@ def traceFlagsPy(target, source, env):
|
||||||
print >>f, " }"
|
print >>f, " }"
|
||||||
print >>f
|
print >>f
|
||||||
|
|
||||||
print >>f, 'flagDescriptions = {'
|
print >>f, 'descriptions = {'
|
||||||
print >>f, " 'All' : 'All flags',"
|
print >>f, " 'All' : 'All flags',"
|
||||||
for flag, compound, desc in allFlags:
|
for flag, compound, desc in allFlags:
|
||||||
print >>f, " '%s' : '%s'," % (flag, desc)
|
print >>f, " '%s' : '%s'," % (flag, desc)
|
||||||
|
@ -847,7 +844,7 @@ extern const Flags *compoundFlags[];
|
||||||
|
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
flags = [ Value(f) for f in trace_flags ]
|
flags = [ Value(f) for f in trace_flags.values() ]
|
||||||
env.Command('base/traceflags.py', flags, traceFlagsPy)
|
env.Command('base/traceflags.py', flags, traceFlagsPy)
|
||||||
PySource('m5', 'base/traceflags.py')
|
PySource('m5', 'base/traceflags.py')
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ PySource('m5', 'm5/simulate.py')
|
||||||
PySource('m5', 'm5/smartdict.py')
|
PySource('m5', 'm5/smartdict.py')
|
||||||
PySource('m5', 'm5/stats.py')
|
PySource('m5', 'm5/stats.py')
|
||||||
PySource('m5', 'm5/ticks.py')
|
PySource('m5', 'm5/ticks.py')
|
||||||
|
PySource('m5', 'm5/trace.py')
|
||||||
PySource('m5.util', 'm5/util/__init__.py')
|
PySource('m5.util', 'm5/util/__init__.py')
|
||||||
PySource('m5.util', 'm5/util/attrdict.py')
|
PySource('m5.util', 'm5/util/attrdict.py')
|
||||||
PySource('m5.util', 'm5/util/jobfile.py')
|
PySource('m5.util', 'm5/util/jobfile.py')
|
||||||
|
|
|
@ -138,6 +138,13 @@ def main():
|
||||||
import event
|
import event
|
||||||
import info
|
import info
|
||||||
import internal
|
import internal
|
||||||
|
import trace
|
||||||
|
|
||||||
|
def check_tracing():
|
||||||
|
if defines.TRACING_ON:
|
||||||
|
return
|
||||||
|
|
||||||
|
panic("Tracing is not enabled. Compile with TRACING_ON")
|
||||||
|
|
||||||
# load the options.py config file to allow people to set their own
|
# load the options.py config file to allow people to set their own
|
||||||
# default options
|
# default options
|
||||||
|
@ -221,21 +228,9 @@ def main():
|
||||||
print
|
print
|
||||||
|
|
||||||
if options.trace_help:
|
if options.trace_help:
|
||||||
import traceflags
|
|
||||||
|
|
||||||
done = True
|
done = True
|
||||||
print "Base Flags:"
|
check_tracing()
|
||||||
traceflags.baseFlags.sort()
|
trace.help()
|
||||||
print_list(traceflags.baseFlags, indent=4)
|
|
||||||
print
|
|
||||||
print "Compound Flags:"
|
|
||||||
traceflags.compoundFlags.sort()
|
|
||||||
for flag in traceflags.compoundFlags:
|
|
||||||
if flag == 'All':
|
|
||||||
continue
|
|
||||||
print " %s:" % flag
|
|
||||||
print_list(traceflags.compoundFlagMap[flag], indent=8)
|
|
||||||
print
|
|
||||||
|
|
||||||
if options.list_sim_objects:
|
if options.list_sim_objects:
|
||||||
import SimObject
|
import SimObject
|
||||||
|
@ -306,7 +301,7 @@ def main():
|
||||||
internal.debug.schedBreakCycle(int(when))
|
internal.debug.schedBreakCycle(int(when))
|
||||||
|
|
||||||
if options.trace_flags:
|
if options.trace_flags:
|
||||||
import traceflags
|
check_tracing()
|
||||||
|
|
||||||
on_flags = []
|
on_flags = []
|
||||||
off_flags = []
|
off_flags = []
|
||||||
|
@ -315,7 +310,7 @@ def main():
|
||||||
if flag.startswith('-'):
|
if flag.startswith('-'):
|
||||||
flag = flag[1:]
|
flag = flag[1:]
|
||||||
off = True
|
off = True
|
||||||
if flag not in traceflags.allFlags and flag != "All":
|
if flag not in trace.flags.all and flag != "All":
|
||||||
print >>sys.stderr, "invalid trace flag '%s'" % flag
|
print >>sys.stderr, "invalid trace flag '%s'" % flag
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
@ -325,24 +320,23 @@ def main():
|
||||||
on_flags.append(flag)
|
on_flags.append(flag)
|
||||||
|
|
||||||
for flag in on_flags:
|
for flag in on_flags:
|
||||||
internal.trace.set(flag)
|
trace.set(flag)
|
||||||
|
|
||||||
for flag in off_flags:
|
for flag in off_flags:
|
||||||
internal.trace.clear(flag)
|
trace.clear(flag)
|
||||||
|
|
||||||
if options.trace_start:
|
if options.trace_start:
|
||||||
def enable_trace():
|
check_tracing()
|
||||||
internal.trace.cvar.enabled = True
|
e = event.create(trace.enable)
|
||||||
|
|
||||||
e = event.create(enable_trace)
|
|
||||||
event.mainq.schedule(e, options.trace_start)
|
event.mainq.schedule(e, options.trace_start)
|
||||||
else:
|
else:
|
||||||
internal.trace.cvar.enabled = True
|
trace.enable()
|
||||||
|
|
||||||
internal.trace.output(options.trace_file)
|
trace.output(options.trace_file)
|
||||||
|
|
||||||
for ignore in options.trace_ignore:
|
for ignore in options.trace_ignore:
|
||||||
internal.trace.ignore(ignore)
|
check_tracing()
|
||||||
|
trace.ignore(ignore)
|
||||||
|
|
||||||
sys.argv = arguments
|
sys.argv = arguments
|
||||||
sys.path = [ os.path.dirname(sys.argv[0]) ] + sys.path
|
sys.path = [ os.path.dirname(sys.argv[0]) ] + sys.path
|
||||||
|
|
20
src/python/m5/trace.py
Normal file
20
src/python/m5/trace.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
import internal
|
||||||
|
import traceflags as flags
|
||||||
|
|
||||||
|
from internal.trace import clear, output, set, ignore
|
||||||
|
|
||||||
|
def enable():
|
||||||
|
internal.trace.cvar.enabled = True
|
||||||
|
|
||||||
|
def help():
|
||||||
|
print "Base Flags:"
|
||||||
|
for flag in trace.flags.basic:
|
||||||
|
print " %s: %s" % (flag, trace.flags.descriptions[flag])
|
||||||
|
print
|
||||||
|
print "Compound Flags:"
|
||||||
|
for flag in trace.flags.compound:
|
||||||
|
if flag == 'All':
|
||||||
|
continue
|
||||||
|
print " %s: %s" % (flag, trace.flags.descriptions[flag])
|
||||||
|
print_list(trace.flags.compoundMap[flag], indent=8)
|
||||||
|
print
|
Loading…
Reference in a new issue