This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: -var-update using formatted value


> My logic for making the change was that changes in string values were only
> detected if their first character changed.  For example the change
> "GNU" to GDB":
>  strcpy (fred, "GNU");
>  strcpy (fred, "GDB");
>
> $4 = 0x804a018 "GNU"
> $5 = 0x804a018 "GDB"

Good point.  I wouldn't have thought of that.

> In Eclipse how does the user know if he is looking at a binary or decimal value?

In the CDT, they use 0b as a prefix (e.g., 0b1101).
And as Daniel mentions:  "it would be nice to be able to type binary numbers in GDB."
Currently (to my knowledge) there is no way to assign a binary value to a variable object.
It would be nice to be able to do
-var-assign var1 0b1011
So I like the idea of GDB supporting the 0b prefix.

Independently of that though, after thinking about the problem some more, I believe there
are other issues with the current comparison for var-update.

For example, in your example of strings changing from 
natural value: 0x804a018 "GNU" to
natural value: 0x804a018 "GDB"
If the variable object tracking this has its format set to anything else than natural,
the actual string is not printed and the value seems to stay the same so
-var-update will not detect the change in value.

Another example is the case of a double changing from value 1.1 to 1.2
If the variable object tracking this has its format set to anything else than natural,
both 1.1 and 1.2 values are truncated to 1 or 0x1 etc, and -var-update will again
miss the change in value.

So I'm thinking that it is a good idea to use the printed value to do the comparison
for var-update, but that it should always use the natural format to do this.

My concern was if there is a type that would have the same value in natural format map to
two different values for some other format.  I was originally worried about boolean,
which could show 'true' for anything different than 0, but I noticed that GDB will
always show 1 or 0x1 etc for a boolean that is anything but 0; so I think this is also OK.

But of course, there may be other details I am not aware of.

Always using the natural format to do the var-update comparison would also
prevent -var-update from showing a change after the use of -var-set-format
when the program did not actually advance, and the variable did not actually change.

Marc


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]