Reputation: 1712
I would like to track the value of a boolean (not Boolean) variable in the Eclipse debugger.
I need to know when it does change and, for this, i need to track it's value through all the execution; not only when it is in scope.
More particularly: I have a class (let's call it myClass
) with a boolean member variable called isAvailable
. My program instantiate 4 or 5 myClass
objects. I am expecting that at the end of the execution the isAvailable
value of all of my objects is set to true
. Contrarily to my excpectation one of myClass
objects has isAvailable
set to false. I need to know which (in a lot of) methods is setting isAvailable
to false.
Upvotes: 3
Views: 10478
Reputation: 32905
You can set a watchpoint on the member field. A watchpoint is like a breakpoint that suspends execution when the field is either accessed or modified (you can configure which conditions you want to stop at). See http://www.vogella.com/articles/EclipseDebugging/article.html#advanced_watchpoint
Upvotes: 4
Reputation: 7512
Put a breakpoint in the method that sets the value for isAvailable
.
When the breakpoint is hit, you'll have the possibility to check the whole execution stack. You will also be able to inspect the object and determine which of the 4 or 5 instances is concerned.
Upvotes: 0
Reputation: 55760
Do you have access to the code the class is in?
Instead of using the variable use setters and getters to access it, then just put a break point on the setter.
IF you just need to know when it changes put a conditional break point and have the expression be something like:
available != this.available
Assuming your setter is of the following format:
public void setAvailable(boolean available){
this.available = available;
}
You can get a conditional break point by right clicking on the break point symbol once you've set a break point.
Here is an FAQ about conditional break points: http://wiki.eclipse.org/FAQ_How_do_I_set_a_conditional_breakpoint%3F
Upvotes: 3