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

久未见 提交于 2019-12-09 13:13:25

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/5568599/how-to-set-eclipse-watchpoint-to-activate-when-object-primitive-changes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!