Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Eclipse watchpoint to activate when object/primitive changes?

I'm trying to refactor some rather horrible code at the moment. It's passing around objects in a very convoluted manner I can't keep track of and apparently directly accessing primitives within the objects at some other location in the code. I'm trying to figure out how I can use the debugger to find out when/where an object I'm interested in is used after it gets passed into the confusing black box of code which passes these objects.

What I would like is a way to set a watchpoints that breaks when an Object (or primitive) is modified. I know that watchpoints can be set on variables, but this isn't what I want. The variable pointing to the object I'm interested in disappears at the end of the function call, I want a way to continue to track the object after this function returns.

Can anyone tell me if Eclipse has this functionality? I'm using Helios.

Thanks

like image 645
drew Avatar asked Apr 06 '11 15:04

drew


1 Answers

You can set a watchpoint on each field of the class you are interested in.

Alternatively, you can find all places in the source referring a certain field by using the call hierarchy (click on the field, and press Ctrl-Alt-H). This has the advantage that you are not only finding where the field is accessed in a particular execution of the program, but for all possible executions.

Note that neither method will notice if the field is accessed using reflection.

like image 155
meriton Avatar answered Nov 15 '22 00:11

meriton