Source

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

#include 'template.wml'

<p>
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.
</p>

<p>
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.
</p>

<p>
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:
</p>

<quadpres_code_block>
shlomi:~/bin# perl -d add_cr.pl test.txt
Default die handler restored.

Loading DB routines from perl5db.pl version 1.07
Editor support available.

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

main::(add_cr.pl:5):	my ($contents);
  DB&lt;1&gt; b 11
  DB&lt;2&gt; c
main::(add_cr.pl:11):	    open my $in, "&lt;", $file;
  DB&lt;2&gt; 
</quadpres_code_block>

<p>
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.
</p>

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