ctf: class__fixup_ctf_bitfields has to handle enums

As they can be the "integral type" of bitfields.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2009-03-19 12:14:39 -03:00
parent fbaab74297
commit b27463f995
1 changed files with 15 additions and 5 deletions

View File

@ -790,15 +790,24 @@ static int class__fixup_ctf_bitfields(struct tag *self, struct cu *cu)
pos->bitfield_size = 0;
pos->byte_offset = pos->bit_offset / 8;
if (type->tag != DW_TAG_base_type) {
if (type->tag != DW_TAG_base_type &&
!tag__is_enumeration(type)) {
pos->byte_size = tag__size(type, cu);
pos->bit_size = pos->byte_size * 8;
continue;
}
struct base_type *bt = tag__base_type(type);
size_t integral_bit_size = base_type__name_to_size(bt, cu);
uint16_t type_bit_size;
size_t integral_bit_size;
if (tag__is_enumeration(type)) {
type_bit_size = tag__type(type)->size;
integral_bit_size = sizeof(int) * 8; /* FIXME: always this size? */
} else {
struct base_type *bt = tag__base_type(type);
type_bit_size = bt->bit_size;
integral_bit_size = base_type__name_to_size(bt, cu);
}
/*
* XXX: integral_bit_size can be zero if base_type__name_to_size doesn't
* know about the base_type name, so one has to add there when
@ -808,13 +817,14 @@ static int class__fixup_ctf_bitfields(struct tag *self, struct cu *cu)
*/
pos->byte_size = integral_bit_size / 8;
if (integral_bit_size == 0 || bt->bit_size == integral_bit_size) {
if (integral_bit_size == 0 || type_bit_size == integral_bit_size) {
pos->bit_size = integral_bit_size;
continue;
}
pos->bitfield_offset = pos->bit_offset % integral_bit_size;
pos->bitfield_size = bt->bit_size;
pos->bitfield_size = type_bit_size;
pos->bit_size = type_bit_size;
pos->byte_offset = (((pos->bit_offset / integral_bit_size) *
integral_bit_size) / 8);
}