summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2016-04-29 21:26:46 +0000
committerGreg Clayton <gclayton@apple.com>2016-04-29 21:26:46 +0000
commitd49a8f9b54c3009b6b8f59b1bd133d3907bada3f (patch)
tree939cb5daa565fc8e2494211d2818ccd12b8fc856
parente782c5ee942f3cb817fe39428f505297199ee156 (diff)
downloadbcm5719-llvm-d49a8f9b54c3009b6b8f59b1bd133d3907bada3f.tar.gz
bcm5719-llvm-d49a8f9b54c3009b6b8f59b1bd133d3907bada3f.zip
Watch out for compilers that generate bad bitfield info. If the bit size of a bitfield member doesn't lie within the bit bounds of the type itself, just leave it out so we don't get clang asserting and killing our IDE when it gets unhappy with the information.
https://llvm.org/bugs/show_bug.cgi?id=27515 <rdar://problem/21082998> llvm-svn: 268110
-rw-r--r--lldb/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py1
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp19
2 files changed, 18 insertions, 2 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py b/lldb/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py
index 5f67479d9e8..3caf9162f8a 100644
--- a/lldb/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py
+++ b/lldb/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py
@@ -22,7 +22,6 @@ class BitfieldsTestCase(TestBase):
@skipIfWindows # BitFields exhibit crashes in record layout on Windows (http://llvm.org/pr21800)
@skipIf("llvm.org/pr27510", oslist=["linux"], compiler="clang", compiler_version=[">=", "3.9"]) # expectedFailure, skip to avoid crash
- @skipIf("llvm.org/pr27515", oslist=["macosx"]) # Assertion failed: (Offset >= Size), function insertPadding CGRecordLayoutBuilder.cpp
def test_and_run_command(self):
"""Test 'frame variable ...' on a variable with bitfields."""
self.build()
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 0d53ccf7c42..9451e496ebe 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2645,6 +2645,10 @@ DWARFASTParserClang::ParseChildMembers(const SymbolContext &sc, const DWARFDIE &
if (!parent_die)
return 0;
+ // Get the parent byte size so we can verify any members will fit
+ const uint64_t parent_byte_size = parent_die.GetAttributeValueAsUnsigned(DW_AT_byte_size, UINT64_MAX) * 8;
+ const uint64_t parent_bit_size = parent_byte_size == UINT64_MAX ? UINT64_MAX : parent_byte_size * 8;
+
uint32_t member_idx = 0;
BitfieldInfo last_field_info;
@@ -2890,10 +2894,23 @@ DWARFASTParserClang::ParseChildMembers(const SymbolContext &sc, const DWARFDIE &
if (byte_size == 0)
byte_size = member_type->GetByteSize();
- if (die.GetDWARF()->GetObjectFile()->GetByteOrder() == eByteOrderLittle)
+ ObjectFile *objfile = die.GetDWARF()->GetObjectFile();
+ if (objfile->GetByteOrder() == eByteOrderLittle)
{
this_field_info.bit_offset += byte_size * 8;
this_field_info.bit_offset -= (bit_offset + bit_size);
+
+ if (this_field_info.bit_offset >= parent_bit_size)
+ {
+ 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),
+ name,
+ this_field_info.bit_offset,
+ sc.comp_unit ? sc.comp_unit->GetPath().c_str() : "the source file");
+ this_field_info.Clear();
+ continue;
+ }
}
else
{
OpenPOWER on IntegriCloud