4.4.1 Breakpoints, watchpoints (‘break’, ‘tbreak’, ‘watch’, ‘watche’...)

A breakpoint makes your script stop whenever a certain point in the program is reached. For each breakpoint, you can add conditions to control in finer detail whether your script stops.

You specify the place where your script should stop with the break command and its variants (see Setting breakpoints). These commands allow own to specify the location by line number and file name or function name.

A watchpoint is a special breakpoint that stops your script when the value of an expression changes. There is a different command to set watchpoints (see Setting watchpoints).

But aside from that, you can manage a watchpoint like any other breakpoint: you delete enable, and disable both breakpoints and watchpoints using the same commands.

You can arrange to have values from your program displayed automatically whenever BASH stops at a breakpoint. See Automatic display.

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

Watchpoint numbers however are distinguished from breakpoint numbers by virtue of their being suffixed with the either an upper- or lower-case ‘W’. For example, to enable breakpoint entry 0 along with watchpoint entry 1 you would write ‘enable 1 2w’, the “2w” refers to the watchpoint; “2W” would work just as well.