14.3.1 Control of Breakpoints

As we saw earlier, the first thing you probably want to do in a debugging session is to get your breakpoints set up, because your program will otherwise just run as if it was not under the debugger. The commands for controlling breakpoints are:

break [[filename:]n | function] ["expression"]
b [[filename:]n | function] ["expression"]

Without any argument, set a breakpoint at the next instruction to be executed in the selected stack frame. Arguments can be one of the following:

n

Set a breakpoint at line number n in the current source file.

filename:n

Set a breakpoint at line number n in source file filename.

function

Set a breakpoint at entry to (the first instruction of) function function.

Each breakpoint is assigned a number that can be used to delete it from the breakpoint list using the delete command.

With a breakpoint, you may also supply a condition. This is an awk expression (enclosed in double quotes) that the debugger evaluates whenever the breakpoint is reached. If the condition is true, then the debugger stops execution and prompts for a command. Otherwise, it continues executing the program.

clear [[filename:]n | function]

Without any argument, delete any breakpoint at the next instruction to be executed in the selected stack frame. If the program stops at a breakpoint, this deletes that breakpoint so that the program does not stop at that location again. Arguments can be one of the following:

n

Delete breakpoint(s) set at line number n in the current source file.

filename:n

Delete breakpoint(s) set at line number n in source file filename.

function

Delete breakpoint(s) set at entry to function function.

condition n "expression"

Add a condition to existing breakpoint or watchpoint n. The condition is an awk expression enclosed in double quotes that the debugger evaluates whenever the breakpoint or watchpoint is reached. If the condition is true, then the debugger stops execution and prompts for a command. Otherwise, the debugger continues executing the program. If the condition expression is not specified, any existing condition is removed (i.e., the breakpoint or watchpoint is made unconditional).

delete [n1 n2 …] [nm]
d [n1 n2 …] [nm]

Delete specified breakpoints or a range of breakpoints. Delete all defined breakpoints if no argument is supplied.

disable [n1 n2 … | nm]

Disable specified breakpoints or a range of breakpoints. Without any argument, disable all breakpoints.

enable [del | once] [n1 n2 …] [nm]
e [del | once] [n1 n2 …] [nm]

Enable specified breakpoints or a range of breakpoints. Without any argument, enable all breakpoints. Optionally, you can specify how to enable the breakpoints:

del

Enable the breakpoints temporarily, then delete each one when the program stops at it.

once

Enable the breakpoints temporarily, then disable each one when the program stops at it.

ignore n count

Ignore breakpoint number n the next count times it is hit.

tbreak [[filename:]n | function]
t [[filename:]n | function]

Set a temporary breakpoint (enabled for only one stop). The arguments are the same as for break.