As with subobptions to info
, or set
, show
subcommands can be abbreviated to any prefix that uniquely
specifies them. For example set lis 5
is a valid abbreviation for
info listsize 5
while set li
is not since there is another
subcommand (linetrace
) which also starts with `li'.
|
offWhen showing filenames print only the basename. This option is useful in regression testing where the base file names are the same on different installations even though the directory path may be different. You may want to use this in other situations as well, like showing a debugger session in a manual such as this one.
|
offIn contrast to the stock python debugger, we don't show or stop at `def' (method creation) lines by default, because this makes stepping more cumbersome. However should you want to change this, you can set this off.
|
off
Show lines as they are read from the debugger command file (or
"source" debugger command). This is useful in running
regression tests, but it may be helpful in tracking down a problem in
your .pydbrc
file.
|
offSet whether we allow tracing the debugger. This is used for debugging pydb and getting access to some of its object variables.
When debug-pydb
is ``on'', the most recent side of the stack
frame will be located somewhere in the debugger; you'll need to adjust
the frame ``up'' to get where the program was before entering the
debugger. (In some versions this and some situations frame 6
gets you out of the debugger and into the debugged program.
|
off
If this is set on, every call and return of a function or method will
be indicated with the nesting level. Return show the return type
and/or value if the value is a scalar or string. By default this is
off. Using the command-line option "--fntrace" when invoking
pydb
implicitly sets this on. For information on
"--fntrace", see 1.1.1.
$ pydb --basename --fntrace gcd.py 4 10 --Call level 0 check_args() (gcd.py:13): check_args + 13 def check_args(): --Return from level 0 (<type 'NoneType'>) --Call level 0 gcd(a=4, b=10) (gcd.py:24): gcd + 24 def gcd(a,b): ----Call level 1 gcd(a=6, b=4) (gcd.py:24): gcd + 24 def gcd(a,b): ------Call level 2 gcd(a=2, b=4) (gcd.py:24): gcd + 24 def gcd(a,b): --------Call level 3 gcd(a=2, b=2) (gcd.py:24): gcd + 24 def gcd(a,b): --------Return from level 3 => 2 (<type 'int'>) ------Return from level 2 => 2 (<type 'int'>) ----Return from level 1 => 2 (<type 'int'>) --Return from level 0 => 2 (<type 'int'>) The GCD of 4 and 10 is 2
Adding function tracing output will slow down your program. Unless single stepping through a program, normally the debugger is called only at breakpoints or at the call and return of a function or method. However when line tracing is turned on, the debugger is called on execution of every statement.
Set the filename in which to record the command history.
(the list of previous commands of which a record is kept). The default
file is ~/.pydbhist
.
|
offSet saving of the history record on exit. Use ``on'' to enable the saving, and ``off'' to disable it. Without an argument, saving is enabled.
Set the size of the command history, i.e. the number of previous
commands to keep a record of. This defaults to the value of the environment variable
HISTSIZE
, or to 256 if this variable is not set.
|
off
If this is set on, the position (file and line number) is shown before
executing a statement. By default this is off. Using the command-line
option "--trace" when invoking pydb
implicitly sets this
on. For information on "--trace", see 1.1.1.
$ pydb --basename --trace hanoi.py 2 (hanoi.py:2): <module> + 2 """Towers of Hanoi""" (hanoi.py:3): <module> + 3 import sys (hanoi.py:5): <module> + 5 def hanoi(n,a,b,c): (hanoi.py:12): <module> + 12 if __name__=='__main__': (hanoi.py:13): <module> + 13 i_args=len(sys.argv) (hanoi.py:14): <module> + 14 if i_args != 1 and i_args != 2: (hanoi.py:18): <module> + 18 n=3 (hanoi.py:20): <module> + 20 if i_args > 1: (hanoi.py:21): <module> + 21 try: (hanoi.py:22): <module> + 22 n = int(sys.argv[1]) (hanoi.py:27): <module> + 27 if n < 1 or n > 100: (hanoi.py:31): <module> + 31 hanoi(n, "a", "b", "c") --Call level 0 hanoi(n=2, a='a', b='b', c='c') (hanoi.py:5): hanoi + 5 def hanoi(n,a,b,c): (hanoi.py:6): hanoi + 6 if n-1 > 0: (hanoi.py:7): hanoi + 7 hanoi(n-1, a, c, b) ----Call level 1 hanoi(n=1, a='a', b='c', c='b') (hanoi.py:5): hanoi + 5 def hanoi(n,a,b,c): (hanoi.py:6): hanoi + 6 if n-1 > 0: (hanoi.py:8): hanoi + 8 print "Move disk %s to %s" % (a, b) Move disk a to c (hanoi.py:9): hanoi + 9 if n-1 > 0: ----Return from level 1 (<type 'NoneType'>) (hanoi.py:9): hanoi + 9 if n-1 > 0: (hanoi.py:8): hanoi + 8 print "Move disk %s to %s" % (a, b) Move disk a to b (hanoi.py:9): hanoi + 9 if n-1 > 0: (hanoi.py:10): hanoi + 10 hanoi(n-1, c, b, a) ----Call level 1 hanoi(n=1, a='c', b='b', c='a') (hanoi.py:5): hanoi + 5 def hanoi(n,a,b,c): (hanoi.py:6): hanoi + 6 if n-1 > 0: (hanoi.py:8): hanoi + 8 print "Move disk %s to %s" % (a, b) Move disk c to b (hanoi.py:9): hanoi + 9 if n-1 > 0: ----Return from level 1 (<type 'NoneType'>) (hanoi.py:9): hanoi + 9 if n-1 > 0: --Return from level 0 (<type 'NoneType'>) (hanoi.py:10): hanoi + 10 hanoi(n-1, c, b, a) (hanoi.py:31): <module> + 31 hanoi(n, "a", "b", "c") (<string>:1): <module> +
Adding linetracing output will slow down your program. Unless single stepping through a program, normally the debugger is called only at breakpoints or at the call and return of a function or method. However when line tracing is turned on, the debugger is called on execution of every statement.
That said, execution may still be pretty fast. If you want to slow down execution further, see the following option.
One of the useful things you can do with this debugger if you run it
via a front-end GUI is watch your program as it executes. To do this,
use "set linetrace on" which prints the location before each
Python statement is run. Many front-end GUIs like the one in GNU Emacs
and ddd
will read the location and update the display
accordingly.
There is however one catch--Python runs too fast. So by using this option you can set a delay after each statement is run in order for GNU and your eyes to catch up with Python. Specify a floating point indicating the number of seconds to wait. For example:
set linetrace delay 0.5 # 1/2 a second
In my experience half a second is about right.
Sets how many lines are shown by the list
command. See
1.2.11.
Prints set logging
usage.
|
offEnable or disable logging.
By default, pydb
output will go to both the terminal and the
logfile. Set redirect
if you want output to go only to the log
file.
|
off
By default, pydb
will append to the logfile. Set
overwrite
if you want set logging on
to overwrite the
logfile instead.
|
off
By default, pydb
output will go to both the terminal and the
logfile. Set redirect
if you want output to go only to the log
file.
Set debugger's prompt string. By default it is "(Pydb) " with a trailing space. For information on how the prompt changes, see 1.2.1.
There's currently a bug in the code where specified trailing blanks specified. Furthermore the prompt may change in the future to add a history number. It is generally not advisable to change the prompt.
|
offTurning this on causes the debugger to check after every statement whether a signal handler has changed from one of those that is to be handled by the debugger. Because this may add a bit of overhead to the running of the debugged program, by default it is set off. However if you want to ensure that the debugger takes control when a particular signal is encountered you should set this on.
Set the Python warning options that are in effect when a program is started
or restarted. On the command line, these are the -W
options,
e.g. -Werror
, or -We::Deprecation
. However the list
should not contain the leading -W
and options should be
separated with white space only, e.g. don't use commas.
Examples:
(Pydb) set warn error e::Deprecation Warning options used in running a Python program: -Werror, -We::Deprecation (Pydb) set warnoptions No warning options have been set. (Pydb)
Set number of characters the debugger thinks are in a line.
We also change OS environment variable COLUMNS.
See About this document... for information on suggesting changes.