Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a possibility to break on every object reference in eclipse debugger?

Suppose I have a class

public class MyClass {

    private Set<String> set = new HashSet<String>();

    //and many methods here

}

is there a possibility to make an eclipse debugger stop at every line where set member is used?

like image 422
Łukasz Bownik Avatar asked Jan 13 '09 11:01

Łukasz Bownik


People also ask

How do I enable break points in Eclipse?

Breakpoints 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.

What can the Eclipse debugger do?

Eclipse allows running an application in Debug mode which helps with stepping through each line of code in a program. Eclipse also provides a Debug Perspective which is a set of views grouped together that help inspect code and make the debugging process very effective.

How do I debug multiple threads in Eclipse?

Start debug session. When the breakpoint in run is hit, you can go to another breakpoint, enable that breakpoint if it was disabled. Then right click on the breakpoint -> go to Filters, now you can select the thread you want the breakpoint to be remain enabled for and you can uncheck the rest of the threads.


1 Answers

I haven't used Eclipse for a while, but from what I remember this was possible in the Callisto release at least. If you set a breakpoint on the line containing the declaration, and then go into the advanced properties for that breakpoint, I believe you can set options for modification and access of that variable.

Edit: I just checked with Eclipse Europa. It does work broadly as I thought; the breakpoint is called a watchpoint when you set it on a variable; and in the "Breakpoint Properties" page (accessible by right-clicking on the breakpoint's bauble in the margin, and possibly in other ways) you can determine whether the debugger should stop on "Field access" and "Field Modification". In your case, you want the first one selected.

like image 157
Andrzej Doyle Avatar answered Oct 06 '22 01:10

Andrzej Doyle