This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] varobj.c
- From: Nick Roberts <nickrob at snap dot net dot nz>
- To: gdb-patches at sourceware dot org
- Date: Thu, 15 Feb 2007 12:05:47 +1300
- Subject: [PATCH] varobj.c
Following Denis' patch, this patch makes GDB throw a user error if a non
root variable is used for -var-update. Currently GDB does:
(gdb)
-var-update var1.1
^done,changelist=[{name="var1.1",in_scope="false"}]
(gdb)
even though the expression that var1.1 represents may be inscope and have
changed value.
with this change:
(gdb)
-var-update var1.1
&"Only root variables can be updated\n"
^error,msg="Only root variables can be updated"
(gdb)
It also uses an assert if changelist is NULL. I'm not sure how changelist
could be NULL, but if it is GDB has really lost the plot.
--
Nick http://www.inet.net.nz/~nickrob
2007-02-15 Nick Roberts <nickrob@snap.net.nz>
* varobj.c (varobj_update): Remove unused local. Use gdb_assert
to check changelist is non-NULL. Call error if the frontend tries
to update a non-root variable.
* varobj.h (enum varobj_update_error): Delete WRONG_PARAM value.
*** varobj.h 13 Feb 2007 21:31:43 +1300 1.8
--- varobj.h 15 Feb 2007 11:38:47 +1300
*************** enum varobj_update_error
*** 45,51 ****
NOT_IN_SCOPE = -1, /* varobj not in scope, can not be updated. */
TYPE_CHANGED = -2, /* varobj type has changed. */
INVALID = -3, /* varobj is not valid anymore. */
- WRONG_PARAM = -4 /* function is called with wrong arguments. */
};
/* String representations of gdb's format codes (defined in varobj.c) */
--- 45,50 ----
*** varobj.c 13 Feb 2007 21:31:43 +1300 1.84
--- varobj.c 15 Feb 2007 11:46:07 +1300
*************** int
*** 1037,1043 ****
varobj_update (struct varobj **varp, struct varobj ***changelist)
{
int changed = 0;
- int error = 0;
int type_changed;
int i;
int vleft;
--- 1037,1042 ----
*************** varobj_update (struct varobj **varp, str
*** 1051,1063 ****
struct frame_info *fi;
/* sanity check: have we been passed a pointer? */
! if (changelist == NULL)
! return WRONG_PARAM;
- /* Only root variables can be updated... */
if (!is_root_p (*varp))
! /* Not a root var. */
! return WRONG_PARAM;
if (!(*varp)->root->is_valid)
return INVALID;
--- 1050,1059 ----
struct frame_info *fi;
/* sanity check: have we been passed a pointer? */
! gdb_assert (changelist);
if (!is_root_p (*varp))
! error (_("Only root variables can be updated"));
if (!(*varp)->root->is_valid)
return INVALID;