diff options
author | Daniel Jacobowitz <drow@false.org> | 2009-08-28 18:50:49 +0000 |
---|---|---|
committer | Daniel Jacobowitz <drow@false.org> | 2009-08-28 18:50:49 +0000 |
commit | 4a76eae5946577891a09412077a5bbd3ea532885 (patch) | |
tree | 072a437dc31f2c364206b6e61bb53ae2a3d844e0 /gdb/value.c | |
parent | d4b96c9a787ed13b0b9367b5fedb96a4746a5c9d (diff) | |
download | gdb-4a76eae5946577891a09412077a5bbd3ea532885.zip gdb-4a76eae5946577891a09412077a5bbd3ea532885.tar.gz gdb-4a76eae5946577891a09412077a5bbd3ea532885.tar.bz2 |
PR gdb/10565
* value.c (value_primitive_field): Do not save value_offset for
bitfields.
(unpack_bits_as_long): Do not read an entire ULONGEST.
testsuite/
PR gdb/10565
* gdb.base/bitfields.c (struct container, container): New.
(main): Initialize it and call break5.
* gdb.base/bitfields.exp (bitfield_at_offset): New test.
Diffstat (limited to 'gdb/value.c')
-rw-r--r-- | gdb/value.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/gdb/value.c b/gdb/value.c index 330ab15..f26e16c 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1878,7 +1878,7 @@ value_primitive_field (struct value *arg1, int offset, v->bitpos = bitpos % container_bitsize; else v->bitpos = bitpos % 8; - v->offset = value_offset (arg1) + value_embedded_offset (arg1) + v->offset = value_embedded_offset (arg1) + (bitpos - v->bitpos) / 8; v->parent = arg1; value_incref (v->parent); @@ -2031,15 +2031,23 @@ unpack_bits_as_long (struct type *field_type, const gdb_byte *valaddr, ULONGEST val; ULONGEST valmask; int lsbcount; + int bytes_read; - val = extract_unsigned_integer (valaddr + bitpos / 8, - sizeof (val), byte_order); + /* Read the minimum number of bytes required; there may not be + enough bytes to read an entire ULONGEST. */ CHECK_TYPEDEF (field_type); + if (bitsize) + bytes_read = ((bitpos % 8) + bitsize + 7) / 8; + else + bytes_read = TYPE_LENGTH (field_type); + + val = extract_unsigned_integer (valaddr + bitpos / 8, + bytes_read, byte_order); /* Extract bits. See comment above. */ if (gdbarch_bits_big_endian (get_type_arch (field_type))) - lsbcount = (sizeof val * 8 - bitpos % 8 - bitsize); + lsbcount = (bytes_read * 8 - bitpos % 8 - bitsize); else lsbcount = (bitpos % 8); val >>= lsbcount; |