changeset 0af61da2b66a in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=0af61da2b66a
description:
        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

diffstat:

4 files changed, 57 insertions(+), 45 deletions(-)
src/SConscript         |   37 +++++++++++++++++--------------------
src/python/SConscript  |    1 +
src/python/m5/main.py  |   44 +++++++++++++++++++-------------------------
src/python/m5/trace.py |   20 ++++++++++++++++++++

diffs (220 lines):

diff -r edbf23127462 -r 0af61da2b66a src/SConscript
--- a/src/SConscript    Mon Jan 19 09:59:13 2009 -0800
+++ b/src/SConscript    Mon Jan 19 09:59:13 2009 -0800
@@ -175,30 +175,25 @@
 #
 # 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')
@@ -666,14 +661,16 @@
         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:
@@ -681,10 +678,10 @@
     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:
@@ -693,7 +690,7 @@
     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)
@@ -847,7 +844,7 @@
 
     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')
 
diff -r edbf23127462 -r 0af61da2b66a src/python/SConscript
--- a/src/python/SConscript     Mon Jan 19 09:59:13 2009 -0800
+++ b/src/python/SConscript     Mon Jan 19 09:59:13 2009 -0800
@@ -48,6 +48,7 @@
 PySource('m5', 'm5/smartdict.py')
 PySource('m5', 'm5/stats.py')
 PySource('m5', 'm5/ticks.py')
+PySource('m5', 'm5/trace.py')
 PySource('m5.util', 'm5/util/__init__.py')
 PySource('m5.util', 'm5/util/attrdict.py')
 PySource('m5.util', 'm5/util/jobfile.py')
diff -r edbf23127462 -r 0af61da2b66a src/python/m5/main.py
--- a/src/python/m5/main.py     Mon Jan 19 09:59:13 2009 -0800
+++ b/src/python/m5/main.py     Mon Jan 19 09:59:13 2009 -0800
@@ -138,6 +138,13 @@
     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
@@ -221,21 +228,9 @@
         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
@@ -306,7 +301,7 @@
         internal.debug.schedBreakCycle(int(when))
 
     if options.trace_flags:
-        import traceflags
+        check_tracing()
 
         on_flags = []
         off_flags = []
@@ -315,7 +310,7 @@
             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)
 
@@ -325,24 +320,23 @@
                 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
diff -r edbf23127462 -r 0af61da2b66a src/python/m5/trace.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/src/python/m5/trace.py    Mon Jan 19 09:59:13 2009 -0800
@@ -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
_______________________________________________
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to