Author: gclayton Date: Wed Apr 20 16:47:56 2016 New Revision: 266922 URL: http://llvm.org/viewvc/llvm-project?rev=266922&view=rev Log: When making an array or stuct/union/class elements, make sure the type is complete. If the type isn't complete, complete the type so that clang won't assert and kill your program. Since the DWARF assists in doing layout, it won't show the array or struct/unions/class elements correctly, but it will stop you from crashing if you have a struct/union/class that contains one of these arrays.
<rdar://problem/25057391> Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 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=266922&r1=266921&r2=266922&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Wed Apr 20 16:47:56 2016 @@ -1656,7 +1656,8 @@ DWARFASTParserClang::ParseTypeFromDWARF DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(), DW_TAG_value_to_name(tag), type_name_cstr); - Type *element_type = dwarf->ResolveTypeUID(DIERef(type_die_form)); + DIERef type_die_ref(type_die_form); + Type *element_type = dwarf->ResolveTypeUID(type_die_ref); if (element_type) { @@ -1665,6 +1666,32 @@ DWARFASTParserClang::ParseTypeFromDWARF if (byte_stride == 0 && bit_stride == 0) byte_stride = element_type->GetByteSize(); CompilerType array_element_type = element_type->GetForwardCompilerType (); + + if (ClangASTContext::IsCXXClassType(array_element_type) && array_element_type.GetCompleteType() == false) + { + ModuleSP module_sp = die.GetModule(); + if (module_sp) + { + if (die.GetCU()->GetProducer() == DWARFCompileUnit::eProducerClang) + module_sp->ReportError ("DWARF DW_TAG_array_type DIE at 0x%8.8x has a class/union/struct element type DIE 0x%8.8x that is a forward declaration, not a complete definition.\nTry compiling the source file with -fno-limit-debug-info or disable -gmodule", + die.GetOffset(), + type_die_ref.die_offset); + else + module_sp->ReportError ("DWARF DW_TAG_array_type DIE at 0x%8.8x has a class/union/struct element type DIE 0x%8.8x that is a forward declaration, not a complete definition.\nPlease file a bug against the compiler and include the preprocessed output for %s", + die.GetOffset(), + type_die_ref.die_offset, + die.GetLLDBCompileUnit() ? die.GetLLDBCompileUnit()->GetPath().c_str() : "the source file"); + } + + // We have no choice other than to pretend that the element class type + // is complete. If we don't do this, clang will crash when trying + // to layout the class. Since we provide layout assistance, all + // ivars in this class and other classes will be fine, this is + // the best we can do short of crashing. + ClangASTContext::StartTagDeclarationDefinition(array_element_type); + ClangASTContext::CompleteTagDeclarationDefinition(array_element_type); + } + uint64_t array_element_bit_stride = byte_stride * 8 + bit_stride; if (element_orders.size() > 0) { _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits