This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: Assigning values to type casted vars
- From: Nick Roberts <nickrob at snap dot net dot nz>
- To: "Sascha" <sascha at pasalacqua dot de>
- Cc: <gdb at sourceware dot org>
- Date: Mon, 12 Mar 2007 23:30:46 +1300
- Subject: Re: Assigning values to type casted vars
- References: <000001c76478$30c5a1e0$02b2a8c0@insanenotebook>
> Eclipse CDT supports casting variables to a different type. This is done by
> creating an MI var like this:
>
> 1466-var-create - * (int)myValue
> 1466^done,name="var35",numchild="0",value="1",type="int"
>
> 1467-var-show-attributes var35
> 1467^done,attr="editable"
>
> The var is "editable". But in most cases GDB does report an error when
> assigning a value to the var:
>
> 1472-var-assign var35 0x1234
> 1472^error,msg="mi_cmd_var_assign: Could not assign expression to varible
> object"
The fact that the var has the attribute "editable" is a bit of a red herring.
A value can't be assigned because (int)myValue isn't an lvalue. You get the
same error if you do:
-var-create - * 2*myValue
^done,name="var36",numchild="0",value="2",type="int"
-var-assign var36 0x1234
I think it only makes sense to watch such values.
--
Nick http://www.inet.net.nz/~nickrob