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]

Address of bitfield element bug?


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




Attachment: gdb6.8Ptype.diff.bz2
Description: gdb6.8Ptype.diff.bz2

Attachment: gdbPtype.diff.bz2
Description: gdbPtype.diff.bz2


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