1 <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Adding a Breakpoint</title><meta name="generator" content="DocBook XSL Stylesheets V1.71.0"><link rel="start" href="index.html" title="Debugging in PHP Eclipse"><link rel="up" href="ar03.html" title="Debugging a Project Locally Using PHPEclipse and XDebug"><link rel="prev" href="ar03s03.html" title="Setting up the Debugger"><link rel="next" href="ar03s05.html" title="Watching our Script Run"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Adding a Breakpoint</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ar03s03.html">Prev</a> </td><th width="60%" align="center">Debugging a Project Locally Using PHPEclipse and XDebug</th><td width="20%" align="right"> <a accesskey="n" href="ar03s05.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="phpeclipse.debugginglocal.addingbreakpoint"></a>Adding a Breakpoint</h2></div></div></div><p>Simply being apply to execute our script and view the output isn't
2 too helpful - we can do that from the command line, or via the web
3 browser. The real power in debugging comes from the ability to set
4 breakpoints and step through scripts. A breakpoint is just that - a point
5 in your script at which you would like to break. What will happen is that
6 the PHP Interpreter will continue as normal until it reaches the specified
7 line in your program. When it reaches that line, it will stop and wait for
8 your instructions as to how to proceed.</p><p>To set a breakpoint, move the mouse over the gray bar at the far
9 left of the margin. Right click beside the line at which you want to
10 break, and select the option 'Toggle Breakpoint'. Ensure you select
11 'Toggle Breakpoint' and not 'Toggle PHP Breakpoint' - the latter will not
12 work. After you toggle the breakpoint, a blue ball should appear in the
13 gray margin beside the line you specified.</p><div class="figure"><a name="phpeclipse.debugginglocal.debugbreakpoint"></a><p class="title"><b>Figure 3. Debug Breakpoint</b></p><div class="figure-contents"><div class="screenshot"><div class="mediaobject"><img src="debugbreakpoint.png" alt="Debug Breakpoint"></div></div></div></div><p><br class="figure-break">After you have added your breakpoint, select Debug
14 History-myFirstProject (or whatever name you gave your configuration) from
15 the Run menu.</p><p>Now, to view our debug information, we need to change to our Debug
16 Perspective. To do this, select the Window drop down menu and select Open
17 Perspective-Debug.</p><p>There are a number of things you will notice on the Debug
18 perspective. The top left has a list of scripts that are currently
19 running. There are button in this pane that can control the execution of
20 the script. The first button labelled in the diagram is the Resume button.
21 Clicking on this button will cause execution of your script to resume
22 until it reaches the next breakpoint. The second button that is labelled
23 is the Terminate button. This button will cause execution of your script
24 to terminate. The third button and fourth buttons are the Step Into and
25 Step Over buttons. These will both cause one line of your script to run.
26 The difference between the two is that the Step Into button will expand
27 any function calls on the line, and the step over button will treat
28 function calls as one line. So, if you are not worried about the functions
29 that are being called on a given line, you should use Step Over. If you
30 want to see exactly what the functions are doing, you should use Step
31 Into.</p><p>To the right of the Debug pane you will see a pane with a Variables
32 tab and a Breakpoints tab. In the variables tab, you will see a list of
33 variables that are in the current scope. Our script uses two variables -
34 $i and $output. You will notice that a number of environment variables are
35 also listed. Along with the list of variables, you can see the values of
36 those variables. This is useful if you want to track what happens to a
37 variable over the course of execution of your script. Clicking on the
38 Breakpoints tab will allow you to see a list of breakpoints that have been
39 set for your script. From this tab, you can turn breakpoints on and off by
40 checking or unchecking the checkboxes that are beside them. There are also
41 buttons to remove selected breakpoints and to remove all breakpoints for
42 your script.</p><p>Underneath, you will see an editor containing the current source
43 file that is being executed. A blue arrow generally follows execution of
44 your script. At the very bottom is a window that displays the Console
45 where you can see the output of your script.</p><div class="figure"><a name="phpeclipse.debugginglocal.debugperspective"></a><p class="title"><b>Figure 4. The Debug Perspective</b></p><div class="figure-contents"><div class="screenshot"><div class="mediaobject"><img src="debugperspective.png" alt="The Debug Perspective"></div></div></div></div><p><br class="figure-break"></p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ar03s03.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ar03.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ar03s05.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Setting up the Debugger </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Watching our Script Run</td></tr></table></div></body></html>