A breakpoint is a signal to the IDE's Integrated Debugger to suspend a program thread that is running the code that contains the breakpoint. When the IDE is running a program and encounters a breakpoint, it suspends the thread (the program temporarily stops running), and the Debugger browser opens so that you can see the run-time stack for the thread.
Breakpoints can be set on any instruction in source code in the workspace. They can be set at any time, including while code is being debugged; that is, you can add a breakpoint to a method in a suspended thread's stack without being dropped to the top of the method.
To set a breakpoint in source code in the IDE:
A breakpoint symbol is placed in
the margin of the Source pane next to the line in which you placed the cursor. If
you try to set a breakpoint at an invalid location (for example, a comment line), the
breakpoing will be set at the closest valid location. If you try to set a breakpoint
in a method in which breakpoints cannot be used, a dialog will inform you that there are
no valid locations in the method to set a breakpoint.
Setting and Clearing Breakpoints by Double-Clicking
Now that you can see where the breakpoint symbol is placed (in the margin of the Source pane next to the code),
you can learn the short-cut to setting and clearing breakpoints.
If you set a breakpoint by using the Breakpoint menu option in the Edit menu, clear it by double-clicking on the symbol. You can likewise set a breakpoint by double-clicking on the margin next to the desired line.
Example: Running the Hanoi Sample with a Breakpoint Set
The Breakpoints Page in the Debugger Browser
The Breakpoints page in the Debugger browser shows a summary of all breakpoints
that have been set in the workspace. To open this page, select Debug >
Breakpoints from the Window menu. The Methods pane lists
all the methods in the workspace that contain breakpoints, and the source pane shows the
source code for the method selected in the Methods pane. From this page, you can set
breakpoints in methods that already have a breakpoint, and you can remove
breakpoints. You can also disable breakpoints (which means that the breakpoints
remain set, but the IDE ignores them when running programs).
Other Types of Breakpoints
Breakpoints can be modified so that they only suspend the thread under certain
circumstances; these are called conditional breakpoints. You can
configure the breakpoint to perform an action or evaluation, which, if results in a true
value, will suspend the thread. Also, you can set breakpoints on methods in
external classes (classes that reside on the file system and that are called by programs
running in the IDE that have the external classes in their class path). See the
related tasks below for information on setting these breakpoints.
Debugging During the Development Cycle
Configuring and Setting Conditions on Breakpoints
Setting Breakpoints in External Classes
Clearing and Disabling Breakpoints