diff options
author | Nathan Binkert <binkertn@umich.edu> | 2006-07-12 15:21:23 -0400 |
---|---|---|
committer | Nathan Binkert <binkertn@umich.edu> | 2006-07-12 15:21:23 -0400 |
commit | bf4fdbe25a275eeb036cd5e9e05d126c52f90aba (patch) | |
tree | 48943c2860539f86659fe90f33a2e9b72c9bec2c | |
parent | 10a8769d6d0815d41fb852a3ce75e7d9b1c837cc (diff) | |
download | gem5-bf4fdbe25a275eeb036cd5e9e05d126c52f90aba.tar.xz |
Add --pdb
src/python/m5/main.py:
Add a command line option to invoke pdb on your script
--HG--
extra : convert_revision : ef5a2860bd3f6e479fa80eccaae0cb5541a20b50
-rw-r--r-- | src/python/m5/main.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/python/m5/main.py b/src/python/m5/main.py index 80dbcb5aa..54c54c1d5 100644 --- a/src/python/m5/main.py +++ b/src/python/m5/main.py @@ -119,6 +119,8 @@ add_option('-d', "--outdir", metavar="DIR", default=".", help="Set the output directory to DIR [Default: %default]") add_option('-i', "--interactive", action="store_true", default=False, help="Invoke the interactive interpreter after running the script") +add_option("--pdb", action="store_true", default=False, + help="Invoke the python debugger before running the script") add_option('-p', "--path", metavar="PATH[:PATH]", action='append', split=':', help="Prepend PATH to the system path when invoking the script") add_option('-q', "--quiet", action="count", default=0, @@ -287,8 +289,19 @@ def main(): sys.path = [ os.path.dirname(sys.argv[0]) ] + sys.path scope = { '__file__' : sys.argv[0] } - exec("import readline", scope) - execfile(sys.argv[0], scope) + + # we want readline if we're doing anything interactive + if options.interactive or options.pdb: + exec("import readline", scope) + + # if pdb was requested, execfile the thing under pdb, otherwise, + # just do the execfile normally + if options.pdb: + from pdb import Pdb + debugger = Pdb() + debugger.run('execfile("%s")' % sys.argv[0], scope) + else: + execfile(sys.argv[0], scope) # once the script is done if options.interactive: |