Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse java breakpoints - What is the purpose?

I'm working with the Android tutorial and I just got to the debugging section and I'm wondering what the purpose of a Breakpoint is. I can't tell just yet... is it actually stopping the app so I can be sure it runs up until that point, or can I set multiple breakpoints and use them as markers to "stop and go" from breakpoint to breakpoint checking my code?

like image 942
Webnet Avatar asked Jun 14 '26 14:06

Webnet


2 Answers

A breakpoint is a place where the execution stops, and you can start inspecting the current situation in your debugger. This includes:

  • the point has actually been reached
  • the current values of all variables
  • the ability to change manually all variables
  • the current stacktrace - i.e. which methods were executed before the current one
  • the ability to add and execute arbitrary code
  • the ability to inspect the results of a method invocation, while not actually proceeding with the execution

In addition to that, you can manually step forward, line by line in your application. There are three options:

  • step into - enters a method which is invoked in the current line
  • step over - goes to the next line
  • step return - returns from the current method (to the method that invoked it)

You can set multiple breakpoints if you have multiple places where you want to do any of the above.

Generally speaking, a debugger is a very upgraded version of using System.out.println(..) or log.debug(..) all over the place in order to make sure certain conditions are present. (thanks to BalusC for this point)

like image 191
Bozho Avatar answered Jun 17 '26 03:06

Bozho


You can definitely set multiple breakpoints. The questions answered by the breakpoint (alongside all of Eclipse's other debug tooling) include not only "did it get here" but also "how did it get here" (the stack trace) and "with what values" (you can observe the variables while the code is paused).

like image 38
Carl Manaster Avatar answered Jun 17 '26 03:06

Carl Manaster



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!