[Lldb-commits] [lldb] r268110 - 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.

Jim Ingham via lldb-commits lldb-commits at lists.llvm.org
Fri Apr 29 14:48:44 PDT 2016


Of course we filed a bug about this, and I'm pretty sure Adrian is done or close to done with the fix.

Searching for a useful interpretation to your question all I can come up with is: "Why are you bothering to work around this rather than fixing clang."  That is actually worth answering, since it may not be obvious that it is very common for debug information to get archived for symbolication of crashes, regression, etc.  So if a bug has been in the compiler for a while, the debugger has to do its best to deal with it.  Expecting somewhat stinky debug information is a sad but true fact of supporting a debugger...

Jim

> On Apr 29, 2016, at 2:36 PM, Zachary Turner via lldb-commits <lldb-commits at lists.llvm.org> wrote:
> 
> If clang is generating bad debug info, do you think you should file a bug against clang for that?
> 
> On Fri, Apr 29, 2016 at 2:32 PM Greg Clayton via lldb-commits <lldb-commits at lists.llvm.org> wrote:
> Author: gclayton
> Date: Fri Apr 29 16:26:46 2016
> New Revision: 268110
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=268110&view=rev
> Log:
> 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>
> 
> 
> Modified:
>     lldb/trunk/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py
>     lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
> 
> Modified: lldb/trunk/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py?rev=268110&r1=268109&r2=268110&view=diff
> ==============================================================================
> --- lldb/trunk/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py (original)
> +++ lldb/trunk/packages/Python/lldbsuite/test/lang/c/bitfields/TestBitfields.py Fri Apr 29 16:26:46 2016
> @@ -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()
> 
> Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=268110&r1=268109&r2=268110&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (original)
> +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Fri Apr 29 16:26:46 2016
> @@ -2645,6 +2645,10 @@ DWARFASTParserClang::ParseChildMembers(c
>      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(c
>                                      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
>                                      {
> 
> 
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits



More information about the lldb-commits mailing list