From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20933 invoked by alias); 11 Jul 2007 01:26:59 -0000 Received: (qmail 20925 invoked by uid 22791); 11 Jul 2007 01:26:58 -0000 X-Spam-Check-By: sourceware.org Received: from viper.snap.net.nz (HELO viper.snap.net.nz) (202.37.101.8) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 11 Jul 2007 01:26:56 +0000 Received: from kahikatea.snap.net.nz (99.62.255.123.dynamic.snap.net.nz [123.255.62.99]) by viper.snap.net.nz (Postfix) with ESMTP id DC2C63DA14D; Wed, 11 Jul 2007 13:26:51 +1200 (NZST) Received: by kahikatea.snap.net.nz (Postfix, from userid 1000) id 386D48FBF6; Wed, 11 Jul 2007 13:26:48 +1200 (NZST) From: Nick Roberts MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Message-ID: <18068.12759.961280.457617@kahikatea.snap.net.nz> Date: Wed, 11 Jul 2007 01:26:00 -0000 To: Vladimir Prus Cc: gdb-patches@sources.redhat.com Subject: Re: [MI] lvalues and variable_editable In-Reply-To: <200707102114.31334.ghost@cs.msu.su> References: <18048.64048.398970.186217@kahikatea.snap.net.nz> <18066.55213.92057.292881@kahikatea.snap.net.nz> <200707102114.31334.ghost@cs.msu.su> X-Mailer: VM 7.19 under Emacs 22.1.50.13 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-07/txt/msg00167.txt.bz2 > > varobj_editable_p, varobj_changeable_p? >=20 > This last seems best to me. I think that the "varobj_value_changeable" > is more accurate than varobj_changeable, because it specifically means > that var->value never changes, but that's probably not important. OK I'll do this for the patch in question. > > > Also, why is_root_p check? It is possible to create varobj for > > > an expression the creates rvalue of structure type. The children of= =20 > > > such varobj won't be lvalues, and won't be editable, but this code > > > won't catch this case. > >=20 > > I'm not sure what you mean by "won't catch this case" but this is in > > variable_editable_p which is called by varobj_set_value. If the user > > tries to assign a value to a child this check means GDB won't need to > > test if it's not an lvalue. >=20 > Well, ideally if I have a varobj for rvalue structure, I want the childr= en > of such varobj to be reported as non-editable. It does not seem to happe= n, > IIUC. Remember that an rvalue may be an lvalue also. I think you are saying a va= robj with children which aren't lvalues. How would you create such a varobj? N= ote: int m[10]; (gdb)=20 -var-create - * m ^done,name=3D"var1",numchild=3D"10",type=3D"int [10]" (gdb)=20 -var-create - * (float)m ^done,name=3D"var2",numchild=3D"0",type=3D"float" (gdb)=20 -var-create - * 2*m &"Argument to arithmetic operation not a number or boolean.\n" ^error,msg=3D"Argument to arithmetic operation not a number or boolean." > > > > *************** varobj_value_is_changeable_p (struct var > > > > *** 1819,1837 **** > > > > --- 1822,1842 ---- > > > >=20 > > > > type =3D get_value_type (var); > > > >=20 > > > > + > > > > switch (TYPE_CODE (type)) > > > > { > > > > case TYPE_CODE_STRUCT: > > > > case TYPE_CODE_UNION: > > > > case TYPE_CODE_ARRAY: > > > > ! =A0 =A0 case TYPE_CODE_FUNC: > > > > ! =A0 =A0 case TYPE_CODE_METHOD: > > > > ! =A0 =A0 =A0 return 0; > > >=20 > > > In current gdb, assuming this declaration: > > >=20 > > > void (*fp)(); > > >=20 > > > I can create varobj for *fp: > > >=20 > > > -var-create V * *fp > > >=20 > > > and V will be updated if fp changes. With your patch, > > > I get this: > > >=20 > > > -var-create V * *fp > > > ~"varobj.c:2180: internal-error: c_value_of_variable: Asser= tion `varobj_value_is_changeable_p (var)' failed.\n" > > > ~"A problem internal to GDB has been detected,\n" > > > ~"further debugging may prove unreliable.\n" > > > ~"Quit this debugging session? (y or n) " > >=20 > > OK. I had just thought about fp being TYPE_CODE_PTR. > >=20 > > > So, probably TYPE_CODE_FUNC should be handled in variable_editable_= p. > > > I'm not sure about TYPE_CODE_METHOD -- I don't know how to construct > > > an object of that type using any possible expression. > >=20 > > That's where they came from. OK, I'll investigate. It occurs to me t= hat you > > might be create problems with pointers to structs, unions and arrays t= oo. >=20 > We should not have any problems, because we never try to get varobj->val= ue > for object of struct, union or array type. Actually now I've looked at it, I think the problem is in c_value_of_variab= le. I think there should be an extra clause, something like: switch (TYPE_CODE (type)) { + case TYPE_CODE_FUNCTION: + return xstrdup (""); + /* break; */ and a similar one for TYPE_CODE_METHOD, either here or in cplus_value_of_variable. Functions and methods are surely not changeable. --=20 Nick http://www.inet.net.nz/~nick= rob