Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Assigning values to type casted vars
@ 2007-03-12  7:29 Sascha
  2007-03-12 10:31 ` Nick Roberts
  0 siblings, 1 reply; 2+ messages in thread
From: Sascha @ 2007-03-12  7:29 UTC (permalink / raw)
  To: gdb

Hi,

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 error occurs for most casts like int -> int, int -> char, char -> int,
... . It only seems to work for struct -> int, struct -> short int, ...
(most of the time).

Does this happen for reason, or should I raise a bug ?

Eclipse CDT bug:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=73598

Sascha


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Assigning values to type casted vars
  2007-03-12  7:29 Assigning values to type casted vars Sascha
@ 2007-03-12 10:31 ` Nick Roberts
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Roberts @ 2007-03-12 10:31 UTC (permalink / raw)
  To: Sascha; +Cc: gdb

 > 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-03-12 10:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-12  7:29 Assigning values to type casted vars Sascha
2007-03-12 10:31 ` Nick Roberts

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox