1# Copyright (c) 2005 The Regents of The University of Michigan 2# All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions are 6# met: redistributions of source code must retain the above copyright 7# notice, this list of conditions and the following disclaimer; 8# redistributions in binary form must reproduce the above copyright --- 15 unchanged lines hidden (view full) --- 24# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26# 27# Authors: Nathan Binkert 28 29import code, optparse, os, socket, sys 30from datetime import datetime 31from attrdict import attrdict |
32import traceflags |
33 34__all__ = [ 'options', 'arguments', 'main' ] 35 36usage="%prog [m5 options] script.py [script options]" 37version="%prog 2.0" 38brief_copyright=''' 39Copyright (c) 2001-2006 40The Regents of The University of Michigan 41All Rights Reserved 42''' 43 |
44def print_list(items, indent=4): 45 line = ' ' * indent 46 for i,item in enumerate(items): 47 if len(line) + len(item) > 76: 48 print line 49 line = ' ' * indent 50 51 if i < len(items) - 1: 52 line += '%s, ' % item 53 else: 54 line += item 55 print line 56 |
57# there's only one option parsing done, so make it global and add some 58# helper functions to make it work well. 59parser = optparse.OptionParser(usage=usage, version=version, 60 description=brief_copyright, 61 formatter=optparse.TitledHelpFormatter()) 62parser.disable_interspersed_args() 63 64# current option group --- 79 unchanged lines hidden (view full) --- 144 145# Debugging options 146set_group("Debugging Options") 147add_option("--debug-break", metavar="TIME[,TIME]", action='append', split=',', 148 help="Cycle to create a breakpoint") 149 150# Tracing options 151set_group("Trace Options") |
152add_option("--trace-help", action='store_true', 153 help="Print help on trace flags") |
154add_option("--trace-flags", metavar="FLAG[,FLAG]", action='append', split=',', |
155 help="Sets the flags for tracing (-FLAG disables a flag)") |
156add_option("--trace-start", metavar="TIME", type='int', 157 help="Start tracing at TIME (must be in ticks)") 158add_option("--trace-file", metavar="FILE", default="cout", 159 help="Sets the output file for tracing [Default: %default]") 160add_option("--trace-ignore", metavar="EXPR", action='append', split=':', 161 help="Ignore EXPR sim objects") 162 163# Execution Trace options --- 78 unchanged lines hidden (view full) --- 242 243 if options.release_notes: 244 done = True 245 print 'Release Notes:' 246 print 247 print info.RELEASE_NOTES 248 print 249 |
250 if options.trace_help: 251 done = True 252 print "Base Flags:" 253 print_list(traceflags.baseFlags, indent=4) 254 print 255 print "Compound Flags:" 256 for flag in traceflags.compoundFlags: 257 if flag == 'All': 258 continue 259 print " %s:" % flag 260 print_list(traceflags.compoundFlagMap[flag], indent=8) 261 print 262 |
263 if done: 264 sys.exit(0) 265 266 if options.verbose >= 0: 267 print "M5 Simulator System" 268 print brief_copyright 269 print 270 print "M5 compiled %s" % internal.main.cvar.compileDate; 271 print "M5 started %s" % datetime.now().ctime() 272 print "M5 executing on %s" % socket.gethostname() 273 print "command line:", 274 for argv in sys.argv: 275 print argv, 276 print 277 278 # check to make sure we can find the listed script 279 if not arguments or not os.path.isfile(arguments[0]): 280 if arguments and not os.path.isfile(arguments[0]): 281 print "Script %s not found" % arguments[0] |
282 |
283 usage(2) 284 285 # tell C++ about output directory 286 internal.main.setOutputDir(options.outdir) 287 288 # update the system path with elements from the -p option 289 sys.path[0:0] = options.path 290 291 import objects 292 293 # set stats options 294 objects.Statistics.text_file = options.stats_file 295 296 # set debugging options 297 for when in options.debug_break: 298 internal.debug.schedBreakCycle(int(when)) 299 |
300 on_flags = [] 301 off_flags = [] |
302 for flag in options.trace_flags: |
303 off = False 304 if flag.startswith('-'): 305 flag = flag[1:] 306 off = True 307 if flag not in traceflags.allFlags: 308 print >>sys.stderr, "invalid trace flag '%s'" % flag 309 sys.exit(1) 310 311 if off: 312 off_flags.append(flag) 313 else: 314 on_flags.append(flag) 315 316 for flag in on_flags: |
317 internal.trace.set(flag) 318 |
319 for flag in off_flags: 320 internal.trace.clear(flag) 321 |
322 if options.trace_start is not None: 323 internal.trace.enabled = False 324 def enable_trace(): 325 internal.event.enabled = True 326 internal.event.create(enable_trace, options.trace_start) 327 328 internal.trace.output(options.trace_file) 329 --- 52 unchanged lines hidden --- |