Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

data breakpoints in java/eclipse

when developing C++ with VS you have this amazing feature of data breakpoints, which trigger when the data at a certain address in memory changes.

is there a similar feature when developing java in eclipse?

thanks!

edit: about the "suspend when value changes" feature: i have the impression that the execution must still reach the line where the breakpoint is. the thing is i want it to trigger anywhere as soon as the value changes.

like image 774
clamp Avatar asked Nov 03 '10 10:11

clamp


People also ask

How do you set breakpoints in Eclipse?

To define a breakpoint in your source code, right-click in the left margin in the Java editor and select Toggle Breakpoint. Alternatively, you can double-click on this position. The Breakpoints view allows you to delete and deactivate Breakpoints and modify their properties.

How do I get all breakpoints in Eclipse?

As other users have suggested, to view all breakpoints : Window-> Show View -> Breakpoints. To delete them, there are three ways: select the breakpoint & click on the cross button displayed in the same view.

What are data breakpoints?

Data breakpoints allow you to stop execution when a particular variable stored at a specific memory address changes.

How do you use data breakpoints?

To set a breakpoint in source code, click in the far left margin next to a line of code. You can also select the line and press F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert breakpoint. The breakpoint appears as a red dot in the left margin.


6 Answers

You can set a watchpoint on a field: put the cursor at the line where the field is being declared and select the menu Run -> Toggle Watchpoint
or just set a breakpoint by double-clicking at the left margin on that line.

You can change the properties of the watchpoint like suspend on field access or suspend on field modification after adding it. Just right-click on the watchpoint at the left margin and select Breakpoint Properties...

Search the help for watchpoint to get more information:

A watchpoint is a special breakpoint that stops the execution of an application whenever the value of a given expression changes, without specifying where it might occur. ...

like image 197
user85421 Avatar answered Oct 06 '22 02:10

user85421


Using the Variable view:

  • right click the field and select "Toggle Watchpoint", and then
  • right click the same instance again and select "Instance breakpoints..." which allows you to restrict a specific breakpoint to a given instance.

Note that the performance is probably not as good as with a memory hardware breakpoint (like in VC++ for example).

like image 26
Francois Misiak Avatar answered Oct 06 '22 02:10

Francois Misiak


Under breakpoint properties, you have the option of making it conditional and checking the radio button "Suspend when value changes".

like image 40
Neil Avatar answered Oct 06 '22 01:10

Neil


The closest thing would be editing the breakpoint properties. You could add conditions to check for distinct values. Another way could be adding a breakpoint to the setter method.

You can set the breakpoint properties by right-clicking on an already set breakpoint in the breakpoint view.

like image 41
stacker Avatar answered Oct 06 '22 01:10

stacker


As far as I know, there is no such generic feature in Eclipse. However, you can give some conditions to an existing breakpoint:

Add a breakpoint somewhere in your code. Then, in the "Breakpoint" view, right click on it, then choose "Breakpoint properties". In the panel, you can add a condition that must be verified to make the application stops on this breakpoint (for example if (foo > 0)).

This is not exactly what you want, but I do not think Eclipse provides such feature.

like image 22
Romain Linsolas Avatar answered Oct 06 '22 01:10

Romain Linsolas


Right click on the Breakpoint and select Breakpoint properties.

In the opening screen, choose: Conditional -> Suspend when value changes

like image 25
Sean Patrick Floyd Avatar answered Oct 06 '22 01:10

Sean Patrick Floyd