Jake
Jake

Reputation: 610

Is there a way to set a breakpoint on variable access in Python with PyDev?

I have a global variable (I know) that is being changed from a good value to a bad value somewhere. I don't know where, and I'd like to find out where. I would like my debugger (Eclipse/PyDev) to break any time any code writes to this global variable, something akin to hardware breakpoints in OllyDBG.

One trick I've found that sometimes works in this situation is to refactor the variable as a property and then set a breakpoint in that property's setter: any access to the variable goes through the setter and I get what I want from the debugger. This isn't working in this case.

Ideas?

Upvotes: 4

Views: 2740

Answers (1)

Fabio Zadrozny
Fabio Zadrozny

Reputation: 25332

Unfortunately, PyDev does not have such a feature (and after thinking a bit on how would that be implemented, I couldn't come up with a way to implement that) -- your solution on changing it for a property is the one I use when I need that feature (and it won't work for a global variable as you said... in this case, instead of having a global variable I usually have a 'holder' instance that contains the variables, in which case it's still possible to create a property for it to work).

@slowdog: that was a different question related to watchpoints (which actually works on PyDev now).

Upvotes: 2

Related Questions