shlomi-fish-homepage / lib / presentations / qp / perl-for-newbies / 2 / src / debugger / breakpoints.html.wml

#include 'template.wml'

When the user places a breakpoint on a certain line in a program, they
insruct the debugger to stop the execution of the program when this line is 
reached. Then, one can cause the program to run freely using the continue
command, and have it stop only at this line.

Breakpoints generally save a lot of stepping. To set a breakpoint type 
<tt>b $line_number</tt> or <tt>b $function_name</tt> where $line_number is the
line number and $function_name is the function name. A breakpoint on a function
will stop the execution of the program as soon as the function is entered.

To continue the execution of the program until a breakpoint is reached (or 
until the program terminates) type <tt>c</tt>. Here is an example session with 
the same program:

shlomi:~/bin# perl -d test.txt
Default die handler restored.

Loading DB routines from version 1.07
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(	my ($contents);
  DB&lt;1&gt; b 11
  DB&lt;2&gt; c
main::(	    open my $in, "&lt;", $file;

One can set a conditional breakpoint by typing 
<tt>b [line] [perl expression]</tt>. A conditional expression is one
that stops the execution of the program only if the perl expression 
evaluates to true. The perl expression can be as complex as you like
and may include whitespace.

To delete a breakpoint type <tt>d [line]</tt>. After a breakpoint is deleted
it will no longer affect the execution of your program.