[Lldb-commits] [lldb] r118672 - in /lldb/trunk: include/lldb/Host/Host.h include/lldb/Symbol/SymbolFile.h source/Host/common/Host.cpp source/Host/macosx/Host.mm source/Interpreter/CommandInterpreter.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h source/Symbol/SymbolFile.cpp source/Symbol/Type.cpp

Greg Clayton gclayton at apple.com
Tue Nov 9 20:57:05 PST 2010


Author: gclayton
Date: Tue Nov  9 22:57:04 2010
New Revision: 118672

URL: http://llvm.org/viewvc/llvm-project?rev=118672&view=rev
Log:
Modified lldb_private::SymboleFile to be able to override where its TypeList
comes from by using a virtual function to provide it from the Module's
SymbolVendor by default. This allows the DWARF parser, when being used to
parse DWARF in .o files with a parent DWARF + debug map parser, to get its
type list from the DWARF + debug map parser so when we go and find full 
definitions for types (that might come from other .o files), we can use the
type list from the debug map parser. Otherwise we ended up mixing clang types
from one .o file (say a const pointer to a forward declaration "class A") with
the a full type from another .o file. This causes expression parsing, when 
copying the clang types from those parsed by the DWARF parser into the 
expression AST, to fail -- for good reason. Now all types are created in the
same list.

Also added host support for crash description strings that can be set before
doing a piece of work. On MacOSX, this ties in with CrashReporter support
that allows a string to be dispalyed when the app crashes and allows 
LLDB.framework to print a description string in the crash log. Right now this
is hookup up the the CommandInterpreter::HandleCommand() where each command
notes that it is about to be executed, so if we crash while trying to do this
command, we should be able to see the command that caused LLDB to exit. For
all other platforms, this is a nop.



Modified:
    lldb/trunk/include/lldb/Host/Host.h
    lldb/trunk/include/lldb/Symbol/SymbolFile.h
    lldb/trunk/source/Host/common/Host.cpp
    lldb/trunk/source/Host/macosx/Host.mm
    lldb/trunk/source/Interpreter/CommandInterpreter.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
    lldb/trunk/source/Symbol/SymbolFile.cpp
    lldb/trunk/source/Symbol/Type.cpp

Modified: lldb/trunk/include/lldb/Host/Host.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=118672&r1=118671&r2=118672&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/Host.h (original)
+++ lldb/trunk/include/lldb/Host/Host.h Tue Nov  9 22:57:04 2010
@@ -297,6 +297,25 @@
     GetLLDBPath (lldb::PathType path_type,
                  FileSpec &file_spec);
 
+    //------------------------------------------------------------------
+    /// Set a string that can be displayed if host application crashes.
+    ///
+    /// Some operating systems have the ability to print a description
+    /// for shared libraries when a program crashes. If the host OS
+    /// supports such a mechanism, it should be implemented to help
+    /// with crash triage.
+    ///
+    /// @param[in] format
+    ///     A printf format that will be used to form a new crash
+    ///     description string.
+    //------------------------------------------------------------------
+    static void
+    SetCrashDescriptionWithFormat (const char *format, ...);
+
+    static void
+    SetCrashDescription (const char *description);
+
+
     static uint32_t
     ListProcessesMatchingName (const char *name, StringList &matches, std::vector<lldb::pid_t> &pids);
     

Modified: lldb/trunk/include/lldb/Symbol/SymbolFile.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolFile.h?rev=118672&r1=118671&r2=118672&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/SymbolFile.h (original)
+++ lldb/trunk/include/lldb/Symbol/SymbolFile.h Tue Nov  9 22:57:04 2010
@@ -80,6 +80,7 @@
     virtual uint32_t        FindFunctions (const RegularExpression& regex, bool append, SymbolContextList& sc_list) = 0;
     virtual uint32_t        FindTypes (const SymbolContext& sc, const ConstString &name, bool append, uint32_t max_matches, TypeList& types) = 0;
 //  virtual uint32_t        FindTypes (const SymbolContext& sc, const RegularExpression& regex, bool append, uint32_t max_matches, TypeList& types) = 0;
+    virtual TypeList *      GetTypeList ();
 
     ObjectFile*             GetObjectFile() { return m_obj_file; }
     const ObjectFile*       GetObjectFile() const { return m_obj_file; }

Modified: lldb/trunk/source/Host/common/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=118672&r1=118671&r2=118672&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Host.cpp (original)
+++ lldb/trunk/source/Host/common/Host.cpp Tue Nov  9 22:57:04 2010
@@ -867,6 +867,15 @@
     return false;
 }
 
+void
+Host::SetCrashDescriptionWithFormat (const char *format, ...)
+{
+}
+
+void
+Host::SetCrashDescription (const char *description)
+{
+}
 
 lldb::pid_t
 LaunchApplication (const FileSpec &app_file_spec)

Modified: lldb/trunk/source/Host/macosx/Host.mm
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=118672&r1=118671&r2=118672&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/Host.mm (original)
+++ lldb/trunk/source/Host/macosx/Host.mm Tue Nov  9 22:57:04 2010
@@ -528,6 +528,48 @@
 #endif
 }
 
+// On MacOSX CrashReporter will display a string for each shared library if
+// the shared library has an exported symbol named "__crashreporter_info__".
+
+static Mutex&
+GetCrashReporterMutex ()
+{
+    static Mutex g_mutex;
+    return g_mutex;
+}
+
+extern "C" {
+    const char *__crashreporter_info__ = NULL;
+};
+
+asm(".desc ___crashreporter_info__, 0x10");
+
+void
+Host::SetCrashDescriptionWithFormat (const char *format, ...)
+{
+    static StreamString g_crash_description;
+    Mutex::Locker locker (GetCrashReporterMutex ());
+    
+    if (format)
+    {
+        va_list args;
+        va_start (args, format);
+        g_crash_description.PrintfVarArg(format, args);
+        va_end (args);
+        __crashreporter_info__ = g_crash_description.GetData();
+    }
+    else
+    {
+        __crashreporter_info__ = NULL;
+    }
+}
+
+void
+Host::SetCrashDescription (const char *cstr)
+{
+    Mutex::Locker locker (GetCrashReporterMutex ());
+    __crashreporter_info__ = cstr;
+}
 
 bool
 Host::OpenFileInExternalEditor (const FileSpec &file_spec, uint32_t line_no)

Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=118672&r1=118671&r2=118672&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Tue Nov  9 22:57:04 2010
@@ -45,6 +45,7 @@
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Thread.h"
 #include "lldb/Target/TargetList.h"
+#include "lldb/Utility/CleanUp.h"
 
 #include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
@@ -504,6 +505,12 @@
     // FIXME: there should probably be a mutex to make sure only one thread can
     // run the interpreter at a time.
 
+    Host::SetCrashDescriptionWithFormat ("HandleCommand(command = \"%s\")", command_line);
+    
+    // Make a scoped cleanup object that will clear the crash description string 
+    // on exit of this function.
+    lldb_utility::CleanUp <const char *, void> crash_description_cleanup(NULL, Host::SetCrashDescription);
+
     // TODO: this should be a logging channel in lldb.
 //    if (DebugSelf())
 //    {

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=118672&r1=118671&r2=118672&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Tue Nov  9 22:57:04 2010
@@ -117,6 +117,22 @@
     return new SymbolFileDWARF(obj_file);
 }
 
+
+ClangASTContext &
+SymbolFileDWARF::GetClangASTContext()
+{
+    return GetTypeList()->GetClangASTContext();
+}
+
+TypeList *          
+SymbolFileDWARF::GetTypeList ()
+{
+    if (m_debug_map_symfile)
+        return m_debug_map_symfile->GetTypeList();
+    return m_obj_file->GetModule()->GetTypeList();
+
+}
+
 //----------------------------------------------------------------------
 // Gets the first parent that is a lexical block, function or inlined
 // subroutine, or compile unit.
@@ -1057,8 +1073,6 @@
     if (parent_die == NULL)
         return 0;
 
-    TypeList* type_list = m_obj_file->GetModule()->GetTypeList();
-
     size_t count = 0;
     const DWARFDebugInfoEntry *die;
     const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (dwarf_cu->GetAddressByteSize());
@@ -1144,7 +1158,7 @@
                             accessibility = default_accessibility;
                         member_accessibilities.push_back(accessibility);
 
-                        type_list->GetClangASTContext().AddFieldToRecordType (class_clang_type, name, member_type->GetClangType(), accessibility, bit_size);
+                        GetClangASTContext().AddFieldToRecordType (class_clang_type, name, member_type->GetClangType(), accessibility, bit_size);
                     }
                 }
             }
@@ -1217,11 +1231,11 @@
                     
                     if (class_language == eLanguageTypeObjC)
                     {
-                        type_list->GetClangASTContext().SetObjCSuperClass(class_clang_type, base_class_dctype->GetClangType());
+                        GetClangASTContext().SetObjCSuperClass(class_clang_type, base_class_dctype->GetClangType());
                     }
                     else
                     {
-                        base_classes.push_back (type_list->GetClangASTContext().CreateBaseClassSpecifier (base_class_dctype->GetClangType(), accessibility, is_virtual, is_base_of_class));
+                        base_classes.push_back (GetClangASTContext().CreateBaseClassSpecifier (base_class_dctype->GetClangType(), accessibility, is_virtual, is_base_of_class));
                         assert(base_classes.back());
                     }
                 }
@@ -1288,18 +1302,21 @@
 
     const dw_tag_t tag = die->Tag();
 
-    DEBUG_PRINTF ("0x%8.8x: %s (\"%s\") - resolve forward declaration...\n", die->GetOffset(), DW_TAG_value_to_name(tag), type->GetName().AsCString());
+    DEBUG_PRINTF ("0x%8.8x: %s (\"%s\") - resolve forward declaration...\n", 
+                  die->GetOffset(), 
+                  DW_TAG_value_to_name(tag), 
+                  type->GetName().AsCString());
     assert (clang_type);
     DWARFDebugInfoEntry::Attributes attributes;
 
-    TypeList* type_list = m_obj_file->GetModule()->GetTypeList();
+    ClangASTContext &ast = GetClangASTContext();
 
     switch (tag)
     {
     case DW_TAG_structure_type:
     case DW_TAG_union_type:
     case DW_TAG_class_type:
-        type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type);
+        ast.StartTagDeclarationDefinition (clang_type);
         if (die->HasChildren())
         {
             LanguageType class_language = eLanguageTypeUnknown;
@@ -1386,7 +1403,7 @@
             if (class_language != eLanguageTypeObjC)
             {
                 if (is_a_class && tag_decl_kind != clang::TTK_Class)
-                    type_list->GetClangASTContext().SetTagTypeKind (clang_type, clang::TTK_Class);
+                    ast.SetTagTypeKind (clang_type, clang::TTK_Class);
             }
 
             // Since DW_TAG_structure_type gets used for both classes
@@ -1403,30 +1420,36 @@
             {
                 // This is a class and all members that didn't have
                 // their access specified are private.
-                type_list->GetClangASTContext().SetDefaultAccessForRecordFields (clang_type, eAccessPrivate, &member_accessibilities.front(), member_accessibilities.size());
+                ast.SetDefaultAccessForRecordFields (clang_type, 
+                                                     eAccessPrivate, 
+                                                     &member_accessibilities.front(), 
+                                                     member_accessibilities.size());
             }
 
             if (!base_classes.empty())
             {
-                type_list->GetClangASTContext().SetBaseClassesForClassType (clang_type, &base_classes.front(), base_classes.size());
+                ast.SetBaseClassesForClassType (clang_type, 
+                                                &base_classes.front(), 
+                                                base_classes.size());
 
                 // Clang will copy each CXXBaseSpecifier in "base_classes"
                 // so we have to free them all.
-                ClangASTContext::DeleteBaseClassSpecifiers (&base_classes.front(), base_classes.size());
+                ClangASTContext::DeleteBaseClassSpecifiers (&base_classes.front(), 
+                                                            base_classes.size());
             }
             
         }
-        type_list->GetClangASTContext().CompleteTagDeclarationDefinition (clang_type);
+        ast.CompleteTagDeclarationDefinition (clang_type);
         return clang_type;
 
     case DW_TAG_enumeration_type:
-        type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type);
+        ast.StartTagDeclarationDefinition (clang_type);
         if (die->HasChildren())
         {
             SymbolContext sc(GetCompUnitForDWARFCompUnit(cu));
             ParseChildEnumerators(sc, clang_type, type->GetByteSize(), cu, die);
         }
-        type_list->GetClangASTContext().CompleteTagDeclarationDefinition (clang_type);
+        ast.CompleteTagDeclarationDefinition (clang_type);
         return clang_type;
 
     default:
@@ -2066,7 +2089,7 @@
         if (matching_type)
         {
             // We found a type pointer, now find the shared pointer form our type list
-            TypeSP type_sp (m_obj_file->GetModule()->GetTypeList()->FindType(matching_type->GetID()));
+            TypeSP type_sp (GetTypeList()->FindType(matching_type->GetID()));
             assert (type_sp.get() != NULL);
             types.InsertUnique (type_sp);
             if (types.GetSize() >= max_matches)
@@ -2094,7 +2117,7 @@
         if (matching_type)
         {
             // We found a type pointer, now find the shared pointer form our type list
-            TypeSP type_sp (m_obj_file->GetModule()->GetTypeList()->FindType(matching_type->GetID()));
+            TypeSP type_sp (GetTypeList()->FindType(matching_type->GetID()));
             assert (type_sp.get() != NULL);
             types.InsertUnique (type_sp);
             ++num_matches;
@@ -2213,7 +2236,7 @@
                         {
                             function_param_types.push_back (type->GetClangForwardType());
 
-                            clang::ParmVarDecl *param_var_decl = type_list->GetClangASTContext().CreateParameterDeclaration (name, type->GetClangForwardType(), storage);
+                            clang::ParmVarDecl *param_var_decl = GetClangASTContext().CreateParameterDeclaration (name, type->GetClangForwardType(), storage);
                             assert(param_var_decl);
                             function_param_decls.push_back(param_var_decl);
                         }
@@ -2291,13 +2314,12 @@
 
                 if (name && name[0] && got_value)
                 {
-                    TypeList* type_list = m_obj_file->GetModule()->GetTypeList();
-                    type_list->GetClangASTContext().AddEnumerationValueToEnumerationType (enumerator_clang_type, 
-                                                                                          enumerator_clang_type, 
-                                                                                          decl, 
-                                                                                          name, 
-                                                                                          enum_value, 
-                                                                                          enumerator_byte_size * 8);
+                    GetClangASTContext().AddEnumerationValueToEnumerationType (enumerator_clang_type, 
+                                                                               enumerator_clang_type, 
+                                                                               decl, 
+                                                                               name, 
+                                                                               enum_value, 
+                                                                               enumerator_byte_size * 8);
                     ++enumerators_added;
                 }
             }
@@ -2470,7 +2492,7 @@
         else if (type_ptr != DIE_IS_BEING_PARSED)
         {
             // Grab the existing type from the master types lists
-            type_sp = m_obj_file->GetModule()->GetTypeList()->FindType(type_ptr->GetID());
+            type_sp = GetTypeList()->FindType(type_ptr->GetID());
         }
 
     }
@@ -2507,10 +2529,8 @@
                 const char *namespace_name = die->GetAttributeValueAsString(this, cu, DW_AT_name, NULL);
                 if (namespace_name)
                 {
-                    TypeList* type_list = m_obj_file->GetModule()->GetTypeList();
-                    assert(type_list);
                     Declaration decl;   // TODO: fill in the decl object
-                    clang::NamespaceDecl *namespace_decl = type_list->GetClangASTContext().GetUniqueNamespaceDeclaration (namespace_name, decl, GetClangDeclContextForDIE (cu, die->GetParent()));
+                    clang::NamespaceDecl *namespace_decl = GetClangASTContext().GetUniqueNamespaceDeclaration (namespace_name, decl, GetClangDeclContextForDIE (cu, die->GetParent()));
                     if (namespace_decl)
                         m_die_to_decl_ctx[die] = (clang::DeclContext*)namespace_decl;
                     return namespace_decl;
@@ -2534,7 +2554,7 @@
     }
     // Right now we have only one translation unit per module...
     if (m_clang_tu_decl == NULL)
-        m_clang_tu_decl = m_obj_file->GetModule()->GetTypeList()->GetClangASTContext().getASTContext()->getTranslationUnitDecl();
+        m_clang_tu_decl = GetClangASTContext().getASTContext()->getTranslationUnitDecl();
     return m_clang_tu_decl;
 }
 
@@ -2592,7 +2612,7 @@
                                       type_cu->GetOffset());
                         
                         m_die_to_type[die] = resolved_type;
-                        type_sp = m_obj_file->GetModule()->GetTypeList()->FindType(resolved_type->GetID());
+                        type_sp = GetTypeList()->FindType(resolved_type->GetID());
                         if (!type_sp)
                         {
                             DEBUG_PRINTF("unable to resolve type '%s' from DIE 0x%8.8x\n", type_name.GetCString(), die->GetOffset());
@@ -2618,8 +2638,10 @@
     if (die != NULL)
     {
         Type *type_ptr = m_die_to_type.lookup (die);
+        TypeList* type_list = GetTypeList();
         if (type_ptr == NULL)
         {
+            ClangASTContext &ast = GetClangASTContext();
             if (type_is_new_ptr)
                 *type_is_new_ptr = true;
 
@@ -2632,7 +2654,6 @@
             Type::EncodingDataType encoding_data_type = Type::eEncodingIsUID;
             clang_type_t clang_type = NULL;
 
-            TypeList* type_list = m_obj_file->GetModule()->GetTypeList();
             dw_attr_t attr;
 
             switch (tag)
@@ -2689,7 +2710,9 @@
                     {
                     default:
                     case DW_TAG_base_type:
-                        clang_type = type_list->GetClangASTContext().GetBuiltinTypeForDWARFEncodingAndBitSize (type_name_cstr, encoding, byte_size * 8);
+                        clang_type = ast.GetBuiltinTypeForDWARFEncodingAndBitSize (type_name_cstr, 
+                                                                                   encoding, 
+                                                                                   byte_size * 8);
                         break;
 
                     case DW_TAG_pointer_type:
@@ -2738,20 +2761,29 @@
                         
                         if (type_name_const_str == g_objc_type_name_id)
                         {
-                            clang_type = type_list->GetClangASTContext().GetBuiltInType_objc_id();
+                            clang_type = ast.GetBuiltInType_objc_id();
                         }
                         else if (type_name_const_str == g_objc_type_name_Class)
                         {
-                            clang_type = type_list->GetClangASTContext().GetBuiltInType_objc_Class();
+                            clang_type = ast.GetBuiltInType_objc_Class();
                         }
                         else if (type_name_const_str == g_objc_type_name_selector)
                         {
-                            clang_type = type_list->GetClangASTContext().GetBuiltInType_objc_selector();
+                            clang_type = ast.GetBuiltInType_objc_selector();
                         }
                     }
                         
-                    type_sp.reset( new Type(die->GetOffset(), this, type_name_const_str, byte_size, NULL, encoding_uid, encoding_data_type, &decl, clang_type, clang_type == NULL));
-
+                    type_sp.reset( new Type (die->GetOffset(), 
+                                             this, 
+                                             type_name_const_str, 
+                                             byte_size, 
+                                             NULL, 
+                                             encoding_uid, 
+                                             encoding_data_type, 
+                                             &decl, 
+                                             clang_type, 
+                                             clang_type == NULL));
+                    
                     m_die_to_type[die] = type_sp.get();
 
 //                  Type* encoding_type = GetUniquedTypeForDIEOffset(encoding_uid, type_sp, NULL, 0, 0, false);
@@ -2883,7 +2915,10 @@
                     if (clang_type == NULL)
                     {
                         clang_type_was_created = true;
-                        clang_type = type_list->GetClangASTContext().CreateRecordType (type_name_cstr, tag_decl_kind, GetClangDeclContextForDIE (dwarf_cu, die), class_language);
+                        clang_type = ast.CreateRecordType (type_name_cstr, 
+                                                           tag_decl_kind, 
+                                                           GetClangDeclContextForDIE (dwarf_cu, die), 
+                                                           class_language);
                     }
 
                     // Store a forward declaration to this class type in case any 
@@ -2891,15 +2926,24 @@
                     // types for function prototypes. 
                     m_die_to_decl_ctx[die] = ClangASTContext::GetDeclContextForType (clang_type);
                     const bool is_forward_decl = die->HasChildren();
-                    type_sp.reset (new Type(die->GetOffset(), this, type_name_const_str, byte_size, NULL, LLDB_INVALID_UID, Type::eEncodingIsUID, &decl, clang_type, is_forward_decl));
-
+                    type_sp.reset (new Type (die->GetOffset(), 
+                                             this, 
+                                             type_name_const_str, 
+                                             byte_size, 
+                                             NULL, 
+                                             LLDB_INVALID_UID, 
+                                             Type::eEncodingIsUID, 
+                                             &decl, 
+                                             clang_type, 
+                                             is_forward_decl));
+                    
                     m_die_to_type[die] = type_sp.get();
 
                     if (die->HasChildren() == false && is_forward_declaration == false)
                     {
                         // No children for this struct/union/class, lets finish it
-                        type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type);
-                        type_list->GetClangASTContext().CompleteTagDeclarationDefinition (clang_type);
+                        ast.StartTagDeclarationDefinition (clang_type);
+                        ast.CompleteTagDeclarationDefinition (clang_type);
                     }
                     else if (clang_type_was_created)
                     {
@@ -2970,8 +3014,12 @@
                         clang_type = m_forward_decl_die_to_clang_type.lookup (die);
                         if (clang_type == NULL)
                         {
-                            enumerator_clang_type = type_list->GetClangASTContext().GetBuiltinTypeForDWARFEncodingAndBitSize (NULL, DW_ATE_signed, byte_size * 8);
-                            clang_type = type_list->GetClangASTContext().CreateEnumerationType(decl, type_name_cstr, enumerator_clang_type);
+                            enumerator_clang_type = ast.GetBuiltinTypeForDWARFEncodingAndBitSize (NULL, 
+                                                                                                  DW_ATE_signed, 
+                                                                                                  byte_size * 8);
+                            clang_type = ast.CreateEnumerationType (decl, 
+                                                                    type_name_cstr, 
+                                                                    enumerator_clang_type);
                         }
                         else
                         {
@@ -2980,8 +3028,17 @@
                         }
 
                         m_die_to_decl_ctx[die] = ClangASTContext::GetDeclContextForType (clang_type);
-                        type_sp.reset( new Type(die->GetOffset(), this, type_name_const_str, byte_size, NULL, encoding_uid, Type::eEncodingIsUID, &decl, clang_type, true));
-
+                        type_sp.reset( new Type (die->GetOffset(), 
+                                                 this, 
+                                                 type_name_const_str, 
+                                                 byte_size, 
+                                                 NULL, 
+                                                 encoding_uid, 
+                                                 Type::eEncodingIsUID,
+                                                 &decl, 
+                                                 clang_type, 
+                                                 true));
+                        
                         m_die_to_type[die] = type_sp.get();
 
                         // Leave this as a forward declaration until we need
@@ -3098,7 +3155,7 @@
                     if (func_type)
                         return_clang_type = func_type->GetClangForwardType();
                     else
-                        return_clang_type = type_list->GetClangASTContext().GetBuiltInType_void();
+                        return_clang_type = ast.GetBuiltInType_void();
 
 
                     std::vector<clang_type_t> function_param_types;
@@ -3108,12 +3165,23 @@
                     if (die->HasChildren())
                     {
                         bool skip_artificial = true;
-                        ParseChildParameters (sc, type_sp, dwarf_cu, die, skip_artificial, type_list, function_param_types, function_param_decls);
+                        ParseChildParameters (sc, 
+                                              type_sp, 
+                                              dwarf_cu, 
+                                              die, 
+                                              skip_artificial, 
+                                              type_list, 
+                                              function_param_types, 
+                                              function_param_decls);
                     }
 
                     // clang_type will get the function prototype clang type after this call
-                    clang_type = type_list->GetClangASTContext().CreateFunctionType (return_clang_type, &function_param_types[0], function_param_types.size(), is_variadic, type_quals);
-
+                    clang_type = ast.CreateFunctionType (return_clang_type, 
+                                                         &function_param_types[0], 
+                                                         function_param_types.size(), 
+                                                         is_variadic, 
+                                                         type_quals);
+                    
                     if (type_name_cstr)
                     {
                         bool type_handled = false;
@@ -3157,10 +3225,10 @@
                                         accessibility = eAccessPublic;
 
                                     clang::ObjCMethodDecl *objc_method_decl;
-                                    objc_method_decl = type_list->GetClangASTContext().AddMethodToObjCObjectType (class_opaque_type, 
-                                                                                                                  type_name_cstr,
-                                                                                                                  clang_type,
-                                                                                                                  accessibility);
+                                    objc_method_decl = ast.AddMethodToObjCObjectType (class_opaque_type, 
+                                                                                      type_name_cstr,
+                                                                                      clang_type,
+                                                                                      accessibility);
                                     type_handled = objc_method_decl != NULL;
                                 }
                             }
@@ -3182,14 +3250,14 @@
                                             accessibility = eAccessPublic;
 
                                         clang::CXXMethodDecl *cxx_method_decl;
-                                        cxx_method_decl = type_list->GetClangASTContext().AddMethodToCXXRecordType (class_opaque_type, 
-                                                                                                                    type_name_cstr,
-                                                                                                                    clang_type,
-                                                                                                                    accessibility,
-                                                                                                                    is_virtual,
-                                                                                                                    is_static,
-                                                                                                                    is_inline,
-                                                                                                                    is_explicit);
+                                        cxx_method_decl = ast.AddMethodToCXXRecordType (class_opaque_type, 
+                                                                                        type_name_cstr,
+                                                                                        clang_type,
+                                                                                        accessibility,
+                                                                                        is_virtual,
+                                                                                        is_static,
+                                                                                        is_inline,
+                                                                                        is_explicit);
                                         type_handled = cxx_method_decl != NULL;
                                     }
                                 }
@@ -3199,17 +3267,31 @@
                         if (!type_handled)
                         {
                             // We just have a function that isn't part of a class
-                            clang::FunctionDecl *function_decl = type_list->GetClangASTContext().CreateFunctionDeclaration (type_name_cstr, clang_type, storage, is_inline);
+                            clang::FunctionDecl *function_decl = ast.CreateFunctionDeclaration (type_name_cstr, 
+                                                                                                clang_type, 
+                                                                                                storage, 
+                                                                                                is_inline);
                             
                             // Add the decl to our DIE to decl context map
                             assert (function_decl);
                             m_die_to_decl_ctx[die] = function_decl;
                             if (!function_param_decls.empty())
-                                type_list->GetClangASTContext().SetFunctionParameters (function_decl, &function_param_decls.front(), function_param_decls.size());
+                                ast.SetFunctionParameters (function_decl, 
+                                                           &function_param_decls.front(), 
+                                                           function_param_decls.size());
                         }
                     }
-                    type_sp.reset( new Type(die->GetOffset(), this, type_name_const_str, 0, NULL, LLDB_INVALID_UID, Type::eEncodingIsUID, &decl, clang_type, false));
-
+                    type_sp.reset( new Type (die->GetOffset(), 
+                                             this, 
+                                             type_name_const_str, 
+                                             0, 
+                                             NULL, 
+                                             LLDB_INVALID_UID, 
+                                             Type::eEncodingIsUID, 
+                                             &decl, 
+                                             clang_type, 
+                                             false));
+                    
                     m_die_to_type[die] = type_sp.get();
                     assert(type_sp.get());
                 }
@@ -3289,12 +3371,23 @@
                             for (pos = element_orders.rbegin(); pos != end; ++pos)
                             {
                                 num_elements = *pos;
-                                clang_type = type_list->GetClangASTContext().CreateArrayType (array_element_type, num_elements, num_elements * array_element_bit_stride);
+                                clang_type = ast.CreateArrayType (array_element_type, 
+                                                                  num_elements, 
+                                                                  num_elements * array_element_bit_stride);
                                 array_element_type = clang_type;
                                 array_element_bit_stride = array_element_bit_stride * num_elements;
                             }
                             ConstString empty_name;
-                            type_sp.reset( new Type(die->GetOffset(), this, empty_name, array_element_bit_stride / 8, NULL, LLDB_INVALID_UID, Type::eEncodingIsUID, &decl, clang_type, false));
+                            type_sp.reset( new Type (die->GetOffset(), 
+                                                     this, 
+                                                     empty_name, 
+                                                     array_element_bit_stride / 8, 
+                                                     NULL, 
+                                                     LLDB_INVALID_UID, 
+                                                     Type::eEncodingIsUID, 
+                                                     &decl, 
+                                                     clang_type, 
+                                                     false));
                             m_die_to_type[die] = type_sp.get();
                         }
                     }
@@ -3332,11 +3425,22 @@
                         clang_type_t pointee_clang_type = pointee_type->GetClangType();
                         clang_type_t class_clang_type = class_type->GetClangType();
 
-                        clang_type = type_list->GetClangASTContext().CreateMemberPointerType(pointee_clang_type, class_clang_type);
+                        clang_type = ast.CreateMemberPointerType(pointee_clang_type, 
+                                                                 class_clang_type);
 
-                        size_t byte_size = ClangASTType::GetClangTypeBitWidth (type_list->GetClangASTContext().getASTContext(), clang_type) / 8;
+                        size_t byte_size = ClangASTType::GetClangTypeBitWidth (ast.getASTContext(), 
+                                                                               clang_type) / 8;
 
-                        type_sp.reset( new Type(die->GetOffset(), this, type_name_const_str, byte_size, NULL, LLDB_INVALID_UID, Type::eEncodingIsUID, NULL, clang_type, false));
+                        type_sp.reset( new Type (die->GetOffset(), 
+                                                 this, 
+                                                 type_name_const_str, 
+                                                 byte_size, 
+                                                 NULL, 
+                                                 LLDB_INVALID_UID, 
+                                                 Type::eEncodingIsUID, 
+                                                 NULL, 
+                                                 clang_type, 
+                                                 false));
                         m_die_to_type[die] = type_sp.get();
                     }
                                             
@@ -3379,10 +3483,7 @@
                 if (type_sp.unique())
                 {
                     // We are ready to put this type into the uniqued list up at the module level
-                    m_obj_file->GetModule()->GetTypeList()->Insert (type_sp);
-                    
-                    if (m_debug_map_symfile)
-                        m_debug_map_symfile->GetObjectFile()->GetModule()->GetTypeList()->Insert (type_sp);
+                    type_list->Insert (type_sp);
 
                     m_die_to_type[die] = type_sp.get();
                 }
@@ -3390,7 +3491,7 @@
         }
         else if (type_ptr != DIE_IS_BEING_PARSED)
         {
-            type_sp = m_obj_file->GetModule()->GetTypeList()->FindType(type_ptr->GetID());
+            type_sp = type_list->FindType(type_ptr->GetID());
         }
     }
     return type_sp;

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=118672&r1=118671&r2=118672&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Tue Nov  9 22:57:04 2010
@@ -109,6 +109,7 @@
     virtual uint32_t        FindFunctions(const lldb_private::RegularExpression& regex, bool append, lldb_private::SymbolContextList& sc_list);
     virtual uint32_t        FindTypes (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name, bool append, uint32_t max_matches, lldb_private::TypeList& types);
 //  virtual uint32_t        FindTypes(const lldb_private::SymbolContext& sc, const lldb_private::RegularExpression& regex, bool append, uint32_t max_matches, lldb::Type::Encoding encoding, lldb::user_id_t udt_uid, lldb_private::TypeList& types);
+    virtual lldb_private::TypeList *GetTypeList ();
 
 
     //------------------------------------------------------------------
@@ -297,6 +298,9 @@
                                 m_debug_map_symfile = debug_map_symfile;
                             }
 
+    lldb_private::ClangASTContext &
+                            GetClangASTContext();
+
     SymbolFileDWARFDebugMap *       m_debug_map_symfile;
     clang::TranslationUnitDecl *    m_clang_tu_decl;
     lldb_private::Flags             m_flags;

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=118672&r1=118671&r2=118672&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Tue Nov  9 22:57:04 2010
@@ -72,6 +72,12 @@
 {
 }
 
+lldb_private::ClangASTContext &       
+SymbolFileDWARFDebugMap::GetClangASTContext ()
+{
+    return GetTypeList()->GetClangASTContext();
+}
+
 void
 SymbolFileDWARFDebugMap::InitOSO ()
 {

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h?rev=118672&r1=118671&r2=118672&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h Tue Nov  9 22:57:04 2010
@@ -197,6 +197,9 @@
                               const DWARFDebugInfoEntry *die, 
                               const lldb_private::ConstString &type_name);    
 
+    lldb_private::ClangASTContext &       
+    GetClangASTContext ();
+
     //------------------------------------------------------------------
     // Member Variables
     //------------------------------------------------------------------

Modified: lldb/trunk/source/Symbol/SymbolFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolFile.cpp?rev=118672&r1=118671&r2=118672&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/SymbolFile.cpp (original)
+++ lldb/trunk/source/Symbol/SymbolFile.cpp Tue Nov  9 22:57:04 2010
@@ -9,7 +9,9 @@
 
 #include "lldb/lldb-private.h"
 #include "lldb/Symbol/SymbolFile.h"
+#include "lldb/Core/Module.h"
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Symbol/ObjectFile.h"
 
 using namespace lldb_private;
 
@@ -47,4 +49,8 @@
     return best_sym_file_ap.release();
 }
 
-
+TypeList *
+SymbolFile::GetTypeList ()
+{
+    return m_obj_file->GetModule()->GetTypeList();
+}

Modified: lldb/trunk/source/Symbol/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=118672&r1=118671&r2=118672&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Type.cpp (original)
+++ lldb/trunk/source/Symbol/Type.cpp Tue Nov  9 22:57:04 2010
@@ -412,7 +412,7 @@
 lldb_private::TypeList*
 lldb_private::Type::GetTypeList()
 {
-    return GetSymbolFile()->GetObjectFile()->GetModule()->GetTypeList();
+    return GetSymbolFile()->GetTypeList();
 }
 
 const lldb_private::Declaration &





More information about the lldb-commits mailing list