main.py (4046:ef34b290091e) main.py (4053:ee914b22709e)
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
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
32
33__all__ = [ 'options', 'arguments', 'main' ]
34
35usage="%prog [m5 options] script.py [script options]"
36version="%prog 2.0"
37brief_copyright='''
38Copyright (c) 2001-2006
39The Regents of The University of Michigan
40All Rights Reserved
41'''
42
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
43# there's only one option parsing done, so make it global and add some
44# helper functions to make it work well.
45parser = optparse.OptionParser(usage=usage, version=version,
46 description=brief_copyright,
47 formatter=optparse.TitledHelpFormatter())
48parser.disable_interspersed_args()
49
50# current option group

--- 79 unchanged lines hidden (view full) ---

130
131# Debugging options
132set_group("Debugging Options")
133add_option("--debug-break", metavar="TIME[,TIME]", action='append', split=',',
134 help="Cycle to create a breakpoint")
135
136# Tracing options
137set_group("Trace Options")
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")
138add_option("--trace-flags", metavar="FLAG[,FLAG]", action='append', split=',',
154add_option("--trace-flags", metavar="FLAG[,FLAG]", action='append', split=',',
139 help="Sets the flags for tracing")
155 help="Sets the flags for tracing (-FLAG disables a flag)")
140add_option("--trace-start", metavar="TIME", type='int',
141 help="Start tracing at TIME (must be in ticks)")
142add_option("--trace-file", metavar="FILE", default="cout",
143 help="Sets the output file for tracing [Default: %default]")
144add_option("--trace-ignore", metavar="EXPR", action='append', split=':',
145 help="Ignore EXPR sim objects")
146
147# Execution Trace options

--- 78 unchanged lines hidden (view full) ---

226
227 if options.release_notes:
228 done = True
229 print 'Release Notes:'
230 print
231 print info.RELEASE_NOTES
232 print
233
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
234 if done:
235 sys.exit(0)
236
237 if options.verbose >= 0:
238 print "M5 Simulator System"
239 print brief_copyright
240 print
241 print "M5 compiled %s" % internal.main.cvar.compileDate;
242 print "M5 started %s" % datetime.now().ctime()
243 print "M5 executing on %s" % socket.gethostname()
244 print "command line:",
245 for argv in sys.argv:
246 print argv,
247 print
248
249 # check to make sure we can find the listed script
250 if not arguments or not os.path.isfile(arguments[0]):
251 if arguments and not os.path.isfile(arguments[0]):
252 print "Script %s not found" % arguments[0]
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
253 usage(2)
254
255 # tell C++ about output directory
256 internal.main.setOutputDir(options.outdir)
257
258 # update the system path with elements from the -p option
259 sys.path[0:0] = options.path
260
261 import objects
262
263 # set stats options
264 objects.Statistics.text_file = options.stats_file
265
266 # set debugging options
267 for when in options.debug_break:
268 internal.debug.schedBreakCycle(int(when))
269
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 = []
270 for flag in options.trace_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:
271 internal.trace.set(flag)
272
317 internal.trace.set(flag)
318
319 for flag in off_flags:
320 internal.trace.clear(flag)
321
273 if options.trace_start is not None:
274 internal.trace.enabled = False
275 def enable_trace():
276 internal.event.enabled = True
277 internal.event.create(enable_trace, options.trace_start)
278
279 internal.trace.output(options.trace_file)
280

--- 52 unchanged lines hidden ---
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 ---