Fix DWARF 4 bitfield support in LLDB to support the DW_AT_data_bit_offset attribute.

<rdar://problem/26321896>

llvm-svn: 274788
This commit is contained in:
Greg Clayton 2016-07-07 19:44:14 +00:00
parent 3a45e03442
commit 19a21d62bf
1 changed files with 18 additions and 8 deletions

View File

@ -2808,6 +2808,7 @@ DWARFASTParserClang::ParseChildMembers(const SymbolContext &sc, const DWARFDIE &
uint32_t member_byte_offset = (parent_die.Tag() == DW_TAG_union_type) ? 0 : UINT32_MAX;
size_t byte_size = 0;
int64_t bit_offset = 0;
uint64_t data_bit_offset = UINT64_MAX;
size_t bit_size = 0;
bool is_external = false; // On DW_TAG_members, this means the member is static
uint32_t i;
@ -2827,6 +2828,7 @@ DWARFASTParserClang::ParseChildMembers(const SymbolContext &sc, const DWARFDIE &
case DW_AT_bit_offset: bit_offset = form_value.Signed(); break;
case DW_AT_bit_size: bit_size = form_value.Unsigned(); break;
case DW_AT_byte_size: byte_size = form_value.Unsigned(); break;
case DW_AT_data_bit_offset: data_bit_offset = form_value.Unsigned(); break;
case DW_AT_data_member_location:
if (form_value.BlockData())
{
@ -3014,6 +3016,12 @@ DWARFASTParserClang::ParseChildMembers(const SymbolContext &sc, const DWARFDIE &
// AT_bit_size indicates the size of the field in bits.
/////////////////////////////////////////////////////////////
if (data_bit_offset != UINT64_MAX)
{
this_field_info.bit_offset = data_bit_offset;
}
else
{
if (byte_size == 0)
byte_size = member_type->GetByteSize();
@ -3027,9 +3035,11 @@ DWARFASTParserClang::ParseChildMembers(const SymbolContext &sc, const DWARFDIE &
{
this_field_info.bit_offset += bit_offset;
}
}
if ((this_field_info.bit_offset >= parent_bit_size) || !last_field_info.NextBitfieldOffsetIsValid(this_field_info.bit_offset))
{
ObjectFile *objfile = die.GetDWARF()->GetObjectFile();
objfile->GetModule()->ReportWarning("0x%8.8" PRIx64 ": %s bitfield named \"%s\" has invalid bit offset (0x%8.8" PRIx64 ") member will be ignored. Please file a bug against the compiler and include the preprocessed output for %s\n",
die.GetID(),
DW_TAG_value_to_name(tag),