Next: Set Watchpoints, Up: Breakpoints [Contents][Index]
Breakpoints are set with the break
command (abbreviated
b
).
break function
Set a breakpoint at entry to function function.
break linenum
Set a breakpoint at line linenum in the current source file. The current source file is the last file whose source text was printed. The breakpoint will stop your script just before it executes any of the code on that line.
break filename:linenum
Set a breakpoint at line linenum in source file filename; filename has to be one of the files previously read in and has to be specified exactly as the name used when read in. For a list of read-in files, use the ‘info files’ command.
break … if cond
Set a breakpoint with condition cond; evaluate the expression
cond each time the breakpoint is reached, and stop only if the
value is nonzero—that is, if cond evaluates as true. The
expression is evaluated via the let
built-in function.
‘…’ stands for one of the possible arguments described
above (or no argument) specifying where to break. The word “if” is
often optional and is necessary only ‘…’ is
omitted. See Break conditions, for more information on
breakpoint conditions.
Examples:
bashdb<0> break fn1 Breakpoint 1 set in file parm.sh, line 3. bashdb<1> break 28 Breakpoint 2 set in file parm.sh, line 28. bashdb<2> break parm.sh:29 Breakpoint 3 set in file parm.sh, line 29. bashdb<3> break 28 if x==5 Breakpoint 4 set in file parm.sh, line 28.
tbreak args
Set a breakpoint enabled only for one stop. args are the
same as for the break
command, and the breakpoint is set in the same
way, but the breakpoint is automatically deleted after the first time your
program stops there. See Disabling breakpoints.
info breakpoints [n]
info break [n]
info watchpoints [n]
Print a table of all breakpoints, watchpoints set and not deleted, with the following columns for each breakpoint:
Enabled breakpoints are marked with ‘1’. ‘0’ marks breakpoints that are disabled (not enabled).
The number of times that breakpoint or watchpoint has been hit.
The filename and line number inside that file where of breakpoint in the script. The file and line are separated with a colon.
A condition (an arithmetic expression) which when true causes the breakpoint to take effect.
If a breakpoint is conditional, info break
shows the condition on
the line following the affected breakpoint; breakpoint commands, if any,
are listed after that.
info break
displays a count of the number of times the breakpoint
has been hit.
info break
with a breakpoint number n as argument lists
only that breakpoint.
Examples:
bashdb<4> info break Breakpoints at following places: Num Type Disp Enb What 1 breakpoint keep y parm.sh:3 2 breakpoint keep y parm.sh:28 3 breakpoint keep y parm.sh:29 4 breakpoint keep y parm.sh:28 No watch expressions have been set. bashdb<5> info break 4 Num Type Disp Enb What 4 breakpoint keep y parm.sh:28 No watch expressions have been set.
the BASH debugger allows you to set any number of breakpoints at the same place in your script. There is nothing silly or meaningless about this. When the breakpoints are conditional, this is even useful (see Break conditions).
Next: Set Watchpoints, Up: Breakpoints [Contents][Index]