#
# Trace Flags
#
-all_flags = {}
-trace_flags = []
-def TraceFlag(name, desc=''):
- if name in all_flags:
+trace_flags = {}
+def TraceFlag(name, desc=None):
+ if name in trace_flags:
raise AttributeError, "Flag %s already specified" % name
- flag = (name, (), desc)
- trace_flags.append(flag)
- all_flags[name] = ()
+ trace_flags[name] = (name, (), desc)
-def CompoundFlag(name, flags, desc=''):
- if name in all_flags:
+def CompoundFlag(name, flags, desc=None):
+ if name in trace_flags:
raise AttributeError, "Flag %s already specified" % name
compound = tuple(flags)
for flag in compound:
- if flag not in all_flags:
+ if flag not in trace_flags:
raise AttributeError, "Trace flag %s not found" % flag
- if all_flags[flag]:
+ if trace_flags[flag][1]:
raise AttributeError, \
"Compound flag can't point to another compound flag"
- flag = (name, compound, desc)
- trace_flags.append(flag)
- all_flags[name] = compound
+ trace_flags[name] = (name, compound, desc)
Export('TraceFlag')
Export('CompoundFlag')
val = eval(s.get_contents())
allFlags.append(val)
- print >>f, 'baseFlags = ['
+ allFlags.sort()
+
+ print >>f, 'basic = ['
for flag, compound, desc in allFlags:
if not compound:
print >>f, " '%s'," % flag
print >>f, " ]"
print >>f
- print >>f, 'compoundFlags = ['
+ print >>f, 'compound = ['
print >>f, " 'All',"
for flag, compound, desc in allFlags:
if compound:
print >>f, " ]"
print >>f
- print >>f, "allFlags = frozenset(baseFlags + compoundFlags)"
+ print >>f, "all = frozenset(basic + compound)"
print >>f
- print >>f, 'compoundFlagMap = {'
+ print >>f, 'compoundMap = {'
all = tuple([flag for flag,compound,desc in allFlags if not compound])
print >>f, " 'All' : %s," % (all, )
for flag, compound, desc in allFlags:
print >>f, " }"
print >>f
- print >>f, 'flagDescriptions = {'
+ print >>f, 'descriptions = {'
print >>f, " 'All' : 'All flags',"
for flag, compound, desc in allFlags:
print >>f, " '%s' : '%s'," % (flag, desc)
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)
PySource('m5', 'base/traceflags.py')
import event
import info
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
# default options
print
if options.trace_help:
- import traceflags
-
done = True
- print "Base Flags:"
- traceflags.baseFlags.sort()
- 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
+ check_tracing()
+ trace.help()
if options.list_sim_objects:
import SimObject
internal.debug.schedBreakCycle(int(when))
if options.trace_flags:
- import traceflags
+ check_tracing()
on_flags = []
off_flags = []
if flag.startswith('-'):
flag = flag[1:]
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
sys.exit(1)
on_flags.append(flag)
for flag in on_flags:
- internal.trace.set(flag)
+ trace.set(flag)
for flag in off_flags:
- internal.trace.clear(flag)
+ trace.clear(flag)
if options.trace_start:
- def enable_trace():
- internal.trace.cvar.enabled = True
-
- e = event.create(enable_trace)
+ check_tracing()
+ e = event.create(trace.enable)
event.mainq.schedule(e, options.trace_start)
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:
- internal.trace.ignore(ignore)
+ check_tracing()
+ trace.ignore(ignore)
sys.argv = arguments
sys.path = [ os.path.dirname(sys.argv[0]) ] + sys.path
--- /dev/null
+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