main.py (5586:d27058799d3a) | main.py (5604:7c58fc1ec5dc) |
---|---|
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 --- 324 unchanged lines hidden (view full) --- 333 internal.trace.output(options.trace_file) 334 335 for ignore in options.trace_ignore: 336 internal.trace.ignore(ignore) 337 338 sys.argv = arguments 339 sys.path = [ os.path.dirname(sys.argv[0]) ] + sys.path 340 | 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 --- 324 unchanged lines hidden (view full) --- 333 internal.trace.output(options.trace_file) 334 335 for ignore in options.trace_ignore: 336 internal.trace.ignore(ignore) 337 338 sys.argv = arguments 339 sys.path = [ os.path.dirname(sys.argv[0]) ] + sys.path 340 |
341 scope = { '__file__' : sys.argv[0], | 341 filename = sys.argv[0] 342 filedata = file(filename, 'r').read() 343 filecode = compile(filedata, filename, 'exec') 344 scope = { '__file__' : filename, |
342 '__name__' : '__m5_main__' } 343 344 # we want readline if we're doing anything interactive 345 if options.interactive or options.pdb: 346 exec "import readline" in scope 347 348 # if pdb was requested, execfile the thing under pdb, otherwise, 349 # just do the execfile normally 350 if options.pdb: | 345 '__name__' : '__m5_main__' } 346 347 # we want readline if we're doing anything interactive 348 if options.interactive or options.pdb: 349 exec "import readline" in scope 350 351 # if pdb was requested, execfile the thing under pdb, otherwise, 352 # just do the execfile normally 353 if options.pdb: |
351 from pdb import Pdb 352 debugger = Pdb() 353 debugger.run('execfile("%s")' % sys.argv[0], scope) | 354 import pdb 355 import traceback 356 357 pdb = pdb.Pdb() 358 try: 359 pdb.run(filecode, scope) 360 except SystemExit: 361 print "The program exited via sys.exit(). Exit status: ", 362 print sys.exc_info()[1] 363 except: 364 traceback.print_exc() 365 print "Uncaught exception. Entering post mortem debugging" 366 t = sys.exc_info()[2] 367 while t.tb_next is not None: 368 t = t.tb_next 369 pdb.interaction(t.tb_frame,t) |
354 else: | 370 else: |
355 execfile(sys.argv[0], scope) | 371 exec filecode in scope |
356 357 # once the script is done 358 if options.interactive: 359 interact = code.InteractiveConsole(scope) 360 interact.interact("M5 Interactive Console") 361 362if __name__ == '__main__': 363 from pprint import pprint --- 16 unchanged lines hidden --- | 372 373 # once the script is done 374 if options.interactive: 375 interact = code.InteractiveConsole(scope) 376 interact.interact("M5 Interactive Console") 377 378if __name__ == '__main__': 379 from pprint import pprint --- 16 unchanged lines hidden --- |