Address of bitfield element bug?
Leutwein Tobias (BEG-PG/EES)
Tobias.Leutwein@de.bosch.com
Thu Jan 28 15:15:00 GMT 2010
Hello,
if I want the address of a bitfield element I always get the base address of the variable with gdb 7.0.1.
As an example I build the bitfields example from 7.0.1 (at the current cvs version I didn't find this file):
gcc -g ./gdb/testsuite/gdb.base/bitfields.c -o ./zzz
#./gdb/gdb zzz
GNU gdb (GDB) 7.0.1
(gdb) ptype container
type = struct container {
struct fields one;
struct fields two;
}
(gdb) ptype container.two
type = struct fields {
unsigned char uc;
int s1 : 1;
unsigned int u1 : 1;
int s2 : 2;
unsigned int u2 : 2;
int s3 : 3;
unsigned int u3 : 3;
int s9 : 9;
unsigned int u9 : 9;
signed char sc;
}
(gdb) ptype container.two.u2
type = unsigned int, bitpos = 12, bitsize = 2
(gdb) p/a &container.two.u2
$1 = 0x402030 <container>
(gdb) p/a &container.two
$2 = 0x402038 <container+8>
with the current cvs version (100126) I get the same behaviour.
With the 6.8 gdb the result is like I expect:
#./gdb/gdb zzz
GNU gdb 6.8.0.20080328-cvs (cygwin-special)
(gdb) ptype container.two.u2
type = unsigned int, bitpos = 4, bitsize = 2
(gdb) p/a &container.two.u2
$1 = 0x402039 <container+9>
(gdb) p/a &container.two
$2 = 0x402038 <container+8>
Both gdb's were patched (with the attached files), to see the bitpos of the bitfield element.
In my opinion this is a bug in the 7.0.1 gdb.
Tobias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gdb6.8Ptype.diff.bz2
Type: application/octet-stream
Size: 8062 bytes
Desc: gdb6.8Ptype.diff.bz2
URL: <http://sourceware.org/pipermail/gdb/attachments/20100128/440c274f/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gdbPtype.diff.bz2
Type: application/octet-stream
Size: 7833 bytes
Desc: gdbPtype.diff.bz2
URL: <http://sourceware.org/pipermail/gdb/attachments/20100128/440c274f/attachment-0001.obj>
More information about the Gdb
mailing list