Paul,

> >What's the best way to keep a watch of a variable or object 
> in JDEBug?
> >After expanding one of the local variables to the level I 
> want, it collaspes
> >again when I step to the next line.  I'd either like to keep 
> the variable
> >tree expanded, or set up a watch.  (Actually, both features 
> would be nice).
> 
> Keeping the tree expanded from step to step is a relatively difficult 
> programming problem and has the potential of greatly slowing 
> down stepping. 
> The JDE fetches the top-level values of the local variables 
> at each time 
> step. The JDE defers fetch the values of fields until you 
> expand the field. 
> Doing what you ask would require that the JDE keep for each 
> local variable 
> a record of the expanded state of its fields, including the states of 
> children. If you expand the fields, the JDE would have to 
> fetch the values 
> of all the expanded fields. This could be very time-consuming.

        I had to do a similar exercise for one of my projects
in Java. The way I solved it was by keeping the old
tree model just long enough so that I could expand the new 
tree. This should be done only if the method context and stack
depth is still same (or if the this object is still same Object ID -
in JPDA terms). Also this should be done only if the command
was one of Step in, out, over or run to cursor within same method.....

I am assuming there is an equivalent of tree model in
your implementation. Then you can copy the expansion states
into the new tree. This has some added benefits also -

- show variables that newly appear in the new scope in some fasion
  diffing the tree models
- show variables that have changed in a special face

> 
> As for watching a variable, there is a watch command on the 
> JDE menu. It 
> allows you to watch for access or modification of fields of 
> objects. I 
> don't think JPDA provides a means of monitoring local variables.
> 

See benefits above....

-sandip

Reply via email to