1.2.2 Breakpoints (break, tbreak, clear, delete, disable, ignore)

A breakpoint makes your program stop at that point. You can add conditions for each breakpoint. You can set breakpoints with the break command and its variants. You can specify the place where your program should stop by file and line number or by function name.

The debugger assigns a number to each breakpoint when you create it; these numbers are successive integers starting with 1. In many of the commands for controlling various features of breakpoints you use this number. Each breakpoint may be enabled or disabled; if disabled, it has no effect on your program until you enable it again.

The debugger allows you to set any number of breakpoints at the same place in your program. There is nothing unusual about this because different breakpoints can have different conditions associated with them.

b(reak) [[filename:]lineno|function[, condition]]

With a lineno argument, set a break at that line number in the current file. With a function argument, set a break at the first executable statement within that function. The line number may be prefixed with a filename and a colon to specify a breakpoint in another file (probably one that hasn't been loaded yet). The file is searched on sys.path. Note that each breakpoint is assigned a number to which all the other breakpoint commands refer.

If a second argument is present, it is an expression which must evaluate to true before the breakpoint is honored.

Without an argument, list all breaks, including for each breakpoint: the number of times that breakpoint has been hit, the current ignore count, and the associated condition if any.

tbreak [[filename:]lineno|function[, condition]]

Temporary breakpoint, which is removed automatically when it is first hit. The arguments are the same as those for break.

cl(ear) [[filename:]lineno|function]

Clear breakpoint at specified line or function. Argument may be line number, function name, or `*' and an address. If a line number is specified, all breakpoints in that line are cleared. If a function is specified, the breakpoints at the beginning of the function are cleared. If an address is specified, breakpoints at that address are cleared.

With no argument, clears all breakpoints in the line where the selected frame is executing.

See also the delete command below which clears breakpoints by number.

delete [bpnumber [bpnumber ...]]

With a space-separated list of breakpoint numbers, clear those breakpoints. Without argument, clear all breaks (but first ask confirmation).

disable [bpnumber [bpnumber ...]]

Disable the breakpoints given as a space-separated list of breakpoint numbers. Disabling a breakpoint means it cannot cause the program to stop execution, but unlike clearing a breakpoint, it remains in the list of breakpoints and can be (re-)enabled.

enable [bpnumber [bpnumber ...]]

Enable the breakpoints specified.

ignore bpnumber [count]

Set the ignore count for the given breakpoint number. If count is omitted, the ignore count is set to 0. A breakpoint becomes active when the ignore count is zero. When non-zero, the count is decremented each time the breakpoint is reached, the breakpoint is not disabled, and any associated condition evaluates to true.

condition bpnumber [condition]

Condition is an expression which must evaluate to true before the breakpoint is honored. If condition is absent, any existing condition is removed; i.e., the breakpoint is made unconditional.

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