Author: tberghammer
Date: Fri Oct  9 07:43:08 2015
New Revision: 249827

URL: http://llvm.org/viewvc/llvm-project?rev=249827&view=rev
Log:
Fix a crash, an UB and add some assert to dwo symbol file handling

Modified:
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
    lldb/trunk/source/Symbol/ClangASTContext.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=249827&r1=249826&r2=249827&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
(original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Fri Oct  
9 07:43:08 2015
@@ -772,6 +772,10 @@ DWARFASTParserClang::ParseTypeFromDWARF
                             // will automatically call the SymbolFile virtual 
function
                             // "SymbolFileDWARF::CompleteType(Type *)"
                             // When the definition needs to be defined.
+                            
assert(!dwarf->GetForwardDeclClangTypeToDie().count(ClangASTContext::RemoveFastQualifiers(clang_type).GetOpaqueQualType())
 &&
+                                   "Type already in the forward declaration 
map!");
+                            
assert(((SymbolFileDWARF*)m_ast.GetSymbolFile())->UserIDMatches(die.GetDIERef().GetUID())
 &&
+                                   "Adding incorrect type to forward 
declaration map");
                             
dwarf->GetForwardDeclDieToClangType()[die.GetDIE()] = 
clang_type.GetOpaqueQualType();
                             
dwarf->GetForwardDeclClangTypeToDie()[ClangASTContext::RemoveFastQualifiers(clang_type).GetOpaqueQualType()]
 = die.GetDIERef();
                             m_ast.SetHasExternalStorage 
(clang_type.GetOpaqueQualType(), true);

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=249827&r1=249826&r2=249827&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Oct  9 
07:43:08 2015
@@ -1555,6 +1555,8 @@ SymbolFileDWARF::CompleteType (CompilerT
     DWARFDebugInfo* debug_info = DebugInfo();
     DWARFDIE dwarf_die = debug_info->GetDIE(die_it->getSecond());
 
+    assert(UserIDMatches(die_it->getSecond().GetUID()) && "CompleteType called 
on the wrong SymbolFile");
+
     // Once we start resolving this type, remove it from the forward 
declaration
     // map in case anyone child members or other types require this type to 
get resolved.
     // The type will get resolved when all of the calls to 
SymbolFileDWARF::ResolveClangOpaqueTypeDefinition

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp?rev=249827&r1=249826&r2=249827&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp Fri Oct  
9 07:43:08 2015
@@ -125,3 +125,9 @@ SymbolFileDWARFDwo::GetLocationListForma
 {
     return DWARFExpression::SplitDwarfLocationList;
 }
+
+TypeSystem*
+SymbolFileDWARFDwo::GetTypeSystemForLanguage(LanguageType language)
+{
+    return GetBaseSymbolFile()->GetTypeSystemForLanguage(language);
+}

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h?rev=249827&r1=249826&r2=249827&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h Fri Oct  9 
07:43:08 2015
@@ -41,6 +41,9 @@ public:
     lldb_private::DWARFExpression::LocationListFormat
     GetLocationListFormat() const override;
 
+    lldb_private::TypeSystem*
+    GetTypeSystemForLanguage(lldb::LanguageType language) override;
+
 protected:
     DIEToTypePtr&
     GetDIEToType() override;

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=249827&r1=249826&r2=249827&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Fri Oct  9 07:43:08 2015
@@ -2593,14 +2593,16 @@ ClangASTContext::IsArrayType (lldb::opaq
     {
         default:
             break;
-            
+
         case clang::Type::ConstantArray:
             if (element_type_ptr)
                 element_type_ptr->SetCompilerType (getASTContext(), 
llvm::cast<clang::ConstantArrayType>(qual_type)->getElementType());
             if (size)
                 *size = 
llvm::cast<clang::ConstantArrayType>(qual_type)->getSize().getLimitedValue(ULLONG_MAX);
+            if (is_incomplete)
+                *is_incomplete = false;
             return true;
-            
+
         case clang::Type::IncompleteArray:
             if (element_type_ptr)
                 element_type_ptr->SetCompilerType (getASTContext(), 
llvm::cast<clang::IncompleteArrayType>(qual_type)->getElementType());
@@ -2609,21 +2611,25 @@ ClangASTContext::IsArrayType (lldb::opaq
             if (is_incomplete)
                 *is_incomplete = true;
             return true;
-            
+
         case clang::Type::VariableArray:
             if (element_type_ptr)
                 element_type_ptr->SetCompilerType (getASTContext(), 
llvm::cast<clang::VariableArrayType>(qual_type)->getElementType());
             if (size)
                 *size = 0;
+            if (is_incomplete)
+                *is_incomplete = false;
             return true;
-            
+
         case clang::Type::DependentSizedArray:
             if (element_type_ptr)
                 element_type_ptr->SetCompilerType (getASTContext(), 
llvm::cast<clang::DependentSizedArrayType>(qual_type)->getElementType());
             if (size)
                 *size = 0;
+            if (is_incomplete)
+                *is_incomplete = false;
             return true;
-            
+
         case clang::Type::Typedef:
             return 
IsArrayType(llvm::cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(),
                                element_type_ptr,


_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to