5.6. Running Until Encountering a Breakpoint
Problem
You don’t want to single-step through many lines of code while debugging. Rather, you want to step through breakpoints only.
Solution
While paused at a breakpoint, click the Resume button in the Debug view or select Run→ Resume. Execution continues until the next breakpoint is encountered.
Discussion
If you don’t want to keep single-stepping through your code, you have other options. For example, you can simply let your code execute until it reaches a breakpoint. To do that, just click the Resume button in the Debug view (the arrow button to the right of the word Debug in the Debug view), or select Run→ Resume.
In the previous recipe, we stopped at a breakpoint and then
single-stepped to the next line of executable code. Clicking Resume
resumes program execution until the breakpoint is encountered for a
second time, and the index loopIndex
will hold a
value of 2
, as shown in Figure 5-13.

Figure 5-13. Running to a breakpoint
Clicking Resume again takes us to the next iteration, where
loopIndex
holds 1
. Clicking
loopIndex
one more time makes the code execute
until the program terminates, which is unexpected because
we’re waiting for loopIndex
to
equal 0
.
Getting an unexpected result is an indication you’ve
found your bug; the problem is in the line in which
we’ve set up the for
loop
incorrectly:
public class DebugClass { public static void ...
Get Eclipse Cookbook now with O’Reilly online learning.
O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.