This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: -var-update @
> > -var-update --all-values var1
> > ^done,changelist=[{name="var1",in_scope="true",new_type="float",new_num_children="0"}]
> > (gdb)
> > -var-update --all-values var2
> > ^done,changelist=[{name="var2",value="-1080652880",in_scope="true",type_changed="false"}]
> > (gdb)
>
> This is weird. I did not look at var1 missing new value (should be easy),
> but the var2 behaviour is strange. Evaluating 'myvar1' by hand gives the
> right value, whereas -var-update gives this apparent garbage. My guess is
> that that parsed expression somehow holds on to frame. I'll look further.
I think the patch below fixes the behaviour for var2. There may be a less
expensive way to do this, e.g, just update the "struct value", but I don't know
how to do that.
> > > > I think we should fix (and document) such floating variable objects
> > >
> > > We should; I was not aware of the bug with wrong value you report above.
There's still no doc or tests for this type of varobj.
> > <snip>
> > I would just suggest a more consistent syntax as currently:
> >
> > -var-update @ Updates all floating variable objects.
> > -var-update * Updates all variable objects.
> > -var-update var1 Updates the variable object var1 (floating or otherwise).
> >
> > -var-create - @ Creates a floating variable object.
> > -var-create - * Creates a fixed frame variable object.
>
> IIUC, the above is that current syntax? If yes, how do you propose to
> change. If this is the proposed syntax, can you spell out the difference
> from the current one?
This is the current syntax which I find confusing because "*" means "fixed" in
one context and "all" in another. I'm not sure how to change it and remain
backward compatible.
--
Nick http://www.inet.net.nz/~nickrob
2008-03-29 Nick Roberts <nickrob@snap.net.nz>
* varobj.c (varobj_update): Always mark floating variable objects
as changed.
(value_of_root): Always recreate a floating variable object.
*** varobj.c.~1.108.~ 2008-03-27 08:02:16.000000000 +1200
--- varobj.c 2008-03-29 17:06:35.000000000 +1200
*************** varobj_update (struct varobj **varp, str
*** 1160,1177 ****
has changed. */
new = value_of_root (varp, &type_changed);
! /* If this is a floating varobj, and its type has changed,
! them note that it's changed. */
! if (type_changed)
VEC_safe_push (varobj_p, result, *varp);
! if (install_new_value ((*varp), new, type_changed))
! {
! /* If type_changed is 1, install_new_value will never return
! non-zero, so we'll never report the same variable twice. */
! gdb_assert (!type_changed);
! VEC_safe_push (varobj_p, result, *varp);
! }
if (new == NULL)
{
--- 1160,1176 ----
has changed. */
new = value_of_root (varp, &type_changed);
! /* If this is a floating varobj, then note that it's changed. */
! if ((*varp)->root->floating)
VEC_safe_push (varobj_p, result, *varp);
! if (install_new_value ((*varp), new, type_changed))
! {
! /* If type_changed is 1, install_new_value will never return
! non-zero, so we'll never report the same variable twice. */
! gdb_assert (!type_changed);
! VEC_safe_push (varobj_p, result, *varp);
! }
if (new == NULL)
{
*************** value_of_root (struct varobj **var_handl
*** 1738,1758 ****
old_type = varobj_get_type (var);
new_type = varobj_get_type (tmp_var);
if (strcmp (old_type, new_type) == 0)
- {
- varobj_delete (tmp_var, NULL, 0);
*type_changed = 0;
- }
else
- {
- tmp_var->obj_name =
- savestring (var->obj_name, strlen (var->obj_name));
- varobj_delete (var, NULL, 0);
-
- install_variable (tmp_var);
- *var_handle = tmp_var;
- var = *var_handle;
*type_changed = 1;
! }
xfree (old_type);
xfree (new_type);
}
--- 1737,1753 ----
old_type = varobj_get_type (var);
new_type = varobj_get_type (tmp_var);
if (strcmp (old_type, new_type) == 0)
*type_changed = 0;
else
*type_changed = 1;
!
! tmp_var->obj_name =
! savestring (var->obj_name, strlen (var->obj_name));
! varobj_delete (var, NULL, 0);
! install_variable (tmp_var);
! *var_handle = tmp_var;
! var = *var_handle;
!
xfree (old_type);
xfree (new_type);
}