1.2.12 Interfacing to the debugger (alias, complete, help, quit, kill, save, source, unalias)

alias [name [command]]

Create an alias called name that executes command. The command must not be enclosed in quotes. Replaceable parameters can be indicated by "%1", "%2", and so on, while "%*" is replaced by all the parameters. If no command is given, the current alias for name is shown. If no arguments are given, all aliases are listed.

Aliases may be nested and can contain anything that can be legally typed at the pydb prompt. Note that internal pydb commands can be overridden by aliases. Such a command is then hidden until the alias is removed. Aliasing is recursively applied to the first word of the command line; all other words in the line are left alone.

As an example, here are two useful aliases (especially when placed in the .pydbrc file):

(Pydb) list
 23  	    
 24  	def gcd(a,b):
 25  	    """ GCD. We assume positive numbers"""
 26  	
 27  	    # Make: a <= b
 28  ->	    if a > b:
 29  	       (a, b) = (b, a)
 30  	       
 31  	    if a <= 0:
 32  	        return None
(Pydb) p a
3
(Pydb) a=5; print a
5
(Pydb) p a
3
So inside the command the value of a is changed. After the command finishes the value reverts back to its old value.

complete command-prefix

If readline or one of readline-compatible interfaces such as pyreadline are available on your OS, the complete command will print a list of command names that start with command-prefix.

complete will also work on info, set, and show sub-command.

In addition the command-completion key (usually the tab key) can be used to complete command names, or info, set, and show subcommands.

h(elp) [command [subcommand]|expression]

Without argument, print the list of available debugger commands.

When an argument is given, it is first checked to see if it is command name; "help exec" gives help on the "!" command.

With the argument is an expression or object name, you get the same help that you would get inside a Python shell running the built-in help() command.

If the environment variable PAGER is defined, the file is piped through that command. You'll notice this only for long help output.

Without argument, print the list of available commands. With command as argument, print help about that command. "help pydb" displays the full documentation file; if the environment variable PAGER is defined, the file is piped through that command. Since the command argument must be an identifier, "help exec" must be entered to get help on the "!" command.

Some commands, info, set, and show can accept an additional subcommand to give help just about that particular subcommand. For example help info line give help about the info line command.

See also 1.2.7 and 1.2.7.

q(uit)

Quit the debugger. The program being executed is aborted.

kill [unconditional]

A non-maskable or ``hard'' kill. Basically, the program sends itself kill -9. This may be needed to get out of the debugger when doing thread debugging.

Since this is drastic, normally we prompt in interactive sessions whether this is really what you want to do. If however ``unconditional'' is added, no questions are asked.

save [all | break | settings] [filename]

Save the breakpoint settings to a file which can be read back in another session using source. If filename is given the commands are saved that file. Otherwise they are saved to ~/pydb-restart.txt.

source [-v] filename

Read debugger commands from a file named filename. Note that the file .pydbrc is read automatically this way when pydb is started.

`-v', for verbose mode, is given then pydb displays each command as it is executed. The option must be given before filename, and is interpreted as part of the filename anywhere else.

An error in any command terminates execution of the command and control is returned to the console.

For tracking down problems with command files, see the "set trace-commands on" debugger command. See 1.2.3.

A command file for pydb is a text file made of lines that are pydb commands. Comments (lines starting with # may also be included. An empty line in a command file does nothing; it does not mean to repeat the last command, as it would from the terminal.

unalias name

Delete the specified alias.

See About this document... for information on suggesting changes.