[Lldb-commits] [lldb] r113729 - in /lldb/trunk: include/lldb/Symbol/ClangASTContext.h lldb.xcodeproj/project.pbxproj source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Symbol/ClangASTContext.cpp

Greg Clayton gclayton at apple.com
Sun Sep 12 16:17:56 PDT 2010


Author: gclayton
Date: Sun Sep 12 18:17:56 2010
New Revision: 113729

URL: http://llvm.org/viewvc/llvm-project?rev=113729&view=rev
Log:
Fixed a crash that would happen when using "frame variables" on any struct,
union, or class that contained an enumeration type. When I was creating
the clang enumeration decl, I wasn't calling "EnumDecl::setIntegerType (QualType)" 
which means that if the enum decl was ever asked to figure out it's bit width
(getTypeInfo()) it would crash. We didn't run into this with enum types that 
weren't inside classes because the DWARF already told us how big the type was
and when we printed an enum we would never need to calculate the size, we
would use the pre-cached byte size we got from the DWARF. When the enum was 
in a struct/union/class and we tried to layout the struct, the layout code
would attempt to get the type info and segfault.


Modified:
    lldb/trunk/include/lldb/Symbol/ClangASTContext.h
    lldb/trunk/lldb.xcodeproj/project.pbxproj
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/trunk/source/Symbol/ClangASTContext.cpp

Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=113729&r1=113728&r2=113729&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Sun Sep 12 18:17:56 2010
@@ -351,7 +351,7 @@
     // Enumeration Types
     //------------------------------------------------------------------
     void *
-    CreateEnumerationType (const Declaration &decl, const char *name);
+    CreateEnumerationType (const Declaration &decl, const char *name, void *integer_qual_type);
 
     bool
     AddEnumerationValueToEnumerationType (void * enum_qual_type,

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=113729&r1=113728&r2=113729&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Sun Sep 12 18:17:56 2010
@@ -2325,6 +2325,7 @@
 			isa = PBXProject;
 			buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */;
 			compatibilityVersion = "Xcode 3.1";
+			developmentRegion = English;
 			hasScannedForEncodings = 1;
 			knownRegions = (
 				en,

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=113729&r1=113728&r2=113729&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Sun Sep 12 18:17:56 2010
@@ -2866,8 +2866,10 @@
                                 }
                             }
                         }
+                        
+                        void *enumerator_qual_type = type_list->GetClangASTContext().GetBuiltinTypeForDWARFEncodingAndBitSize (NULL, DW_ATE_signed, byte_size * 8);
 
-                        clang_type = type_list->GetClangASTContext().CreateEnumerationType(decl, type_name_cstr);
+                        clang_type = type_list->GetClangASTContext().CreateEnumerationType(decl, type_name_cstr, enumerator_qual_type);
                         m_die_to_decl_ctx[die] = ClangASTContext::GetDeclContextForType (clang_type);
                         type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, encoding_uid, Type::eIsTypeWithUID, &decl, clang_type));
 
@@ -2876,7 +2878,6 @@
                         if (die->HasChildren())
                         {
                             type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type);
-                            void *enumerator_qual_type = type_list->GetClangASTContext().GetBuiltinTypeForDWARFEncodingAndBitSize (NULL, DW_ATE_signed, byte_size * 8);
                             ParseChildEnumerators(sc, type_sp, enumerator_qual_type, byte_size, dwarf_cu, die);
                             type_list->GetClangASTContext().CompleteTagDeclarationDefinition (clang_type);
                         }

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=113729&r1=113728&r2=113729&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Sun Sep 12 18:17:56 2010
@@ -2610,7 +2610,7 @@
 #pragma mark Enumeration Types
 
 void *
-ClangASTContext::CreateEnumerationType (const Declaration &decl, const char *name)
+ClangASTContext::CreateEnumerationType (const Declaration &decl, const char *name, void *integer_qual_type)
 {
     // TODO: Do something intelligent with the Declaration object passed in
     // like maybe filling in the SourceLocation with it...
@@ -2623,7 +2623,11 @@
                                            SourceLocation(),
                                            NULL);
     if (enum_decl)
+    {
+        // TODO: check if we should be setting the promotion type too?
+        enum_decl->setIntegerType(QualType::getFromOpaquePtr (integer_qual_type));
         return ast_context->getTagDeclType(enum_decl).getAsOpaquePtr();
+    }
     return NULL;
 }
 





More information about the lldb-commits mailing list