[Lldb-commits] [lldb] r153908 - in /lldb/trunk: include/lldb/Symbol/CompileUnit.h include/lldb/Symbol/SymbolVendor.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp source/Symbol/SymbolVendor.cpp

Greg Clayton gclayton at apple.com
Mon Apr 2 15:59:12 PDT 2012


Author: gclayton
Date: Mon Apr  2 17:59:12 2012
New Revision: 153908

URL: http://llvm.org/viewvc/llvm-project?rev=153908&view=rev
Log:
<rdar://problem/11160171>

Fixed an issue where there were more than one way to get a CompileUnitSP created when using SymbolFileDWARF with SymbolFileDWARFDebugMap. This led to an assertion that would fire under certain conditions. Now there is only one way to create the compile unit and it will "do the right thing".


Modified:
    lldb/trunk/include/lldb/Symbol/CompileUnit.h
    lldb/trunk/include/lldb/Symbol/SymbolVendor.h
    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/Symbol/SymbolVendor.cpp

Modified: lldb/trunk/include/lldb/Symbol/CompileUnit.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/CompileUnit.h?rev=153908&r1=153907&r2=153908&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/CompileUnit.h (original)
+++ lldb/trunk/include/lldb/Symbol/CompileUnit.h Mon Apr  2 17:59:12 2012
@@ -32,6 +32,7 @@
 /// files), and a line table.
 //----------------------------------------------------------------------
 class CompileUnit :
+    public STD_ENABLE_SHARED_FROM_THIS(CompileUnit),
     public ModuleChild,
     public FileSpec,
     public UserID,
@@ -105,6 +106,7 @@
     //------------------------------------------------------------------
     /// Destructor
     //------------------------------------------------------------------
+    virtual
     ~CompileUnit();
 
     //------------------------------------------------------------------

Modified: lldb/trunk/include/lldb/Symbol/SymbolVendor.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolVendor.h?rev=153908&r1=153907&r2=153908&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/SymbolVendor.h (original)
+++ lldb/trunk/include/lldb/Symbol/SymbolVendor.h Mon Apr  2 17:59:12 2012
@@ -140,8 +140,8 @@
     GetNumCompileUnits();
 
     virtual bool
-    SetCompileUnitAtIndex (lldb::CompUnitSP& cu,
-                           uint32_t index);
+    SetCompileUnitAtIndex (uint32_t cu_idx,
+                           const lldb::CompUnitSP &cu_sp);
 
     virtual lldb::CompUnitSP
     GetCompileUnitAtIndex(uint32_t idx);

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=153908&r1=153907&r2=153908&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Mon Apr  2 17:59:12 2012
@@ -706,61 +706,86 @@
     return m_ranges.get();
 }
 
-bool
-SymbolFileDWARF::ParseCompileUnit (DWARFCompileUnit* curr_cu, CompUnitSP& compile_unit_sp)
+lldb::CompUnitSP
+SymbolFileDWARF::ParseCompileUnit (DWARFCompileUnit* dwarf_cu, uint32_t cu_idx)
 {
-    if (curr_cu != NULL)
+    CompUnitSP cu_sp;
+    if (dwarf_cu)
     {
-        ModuleSP module_sp (m_obj_file->GetModule());
-        if (!module_sp)
-            return false;
-
-        const DWARFDebugInfoEntry * cu_die = curr_cu->GetCompileUnitDIEOnly ();
-        if (cu_die)
+        CompileUnit *comp_unit = (CompileUnit*)dwarf_cu->GetUserData();
+        if (comp_unit)
         {
-            const char * cu_die_name = cu_die->GetName(this, curr_cu);
-            const char * cu_comp_dir = cu_die->GetAttributeValueAsString(this, curr_cu, DW_AT_comp_dir, NULL);
-            LanguageType cu_language = (LanguageType)cu_die->GetAttributeValueAsUnsigned(this, curr_cu, DW_AT_language, 0);
-            if (cu_die_name)
-            {
-                std::string ramapped_file;
-                FileSpec cu_file_spec;
-
-                if (cu_die_name[0] == '/' || cu_comp_dir == NULL || cu_comp_dir[0] == '\0')
-                {
-                    // If we have a full path to the compile unit, we don't need to resolve
-                    // the file.  This can be expensive e.g. when the source files are NFS mounted.
-                    if (module_sp->RemapSourceFile(cu_die_name, ramapped_file))
-                        cu_file_spec.SetFile (ramapped_file.c_str(), false);
-                    else
-                        cu_file_spec.SetFile (cu_die_name, false);
-                }
-                else
+            // We already parsed this compile unit, had out a shared pointer to it
+            cu_sp = comp_unit->shared_from_this();
+        }
+        else
+        {
+            ModuleSP module_sp (m_obj_file->GetModule());
+            if (module_sp)
+            {
+                const DWARFDebugInfoEntry * cu_die = dwarf_cu->GetCompileUnitDIEOnly ();
+                if (cu_die)
                 {
-                    std::string fullpath(cu_comp_dir);
-                    if (*fullpath.rbegin() != '/')
-                        fullpath += '/';
-                    fullpath += cu_die_name;
-                    if (module_sp->RemapSourceFile (fullpath.c_str(), ramapped_file))
-                        cu_file_spec.SetFile (ramapped_file.c_str(), false);
-                    else
-                        cu_file_spec.SetFile (fullpath.c_str(), false);
-                }
+                    const char * cu_die_name = cu_die->GetName(this, dwarf_cu);
+                    const char * cu_comp_dir = cu_die->GetAttributeValueAsString(this, dwarf_cu, DW_AT_comp_dir, NULL);
+                    LanguageType cu_language = (LanguageType)cu_die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_language, 0);
+                    if (cu_die_name)
+                    {
+                        std::string ramapped_file;
+                        FileSpec cu_file_spec;
+
+                        if (cu_die_name[0] == '/' || cu_comp_dir == NULL || cu_comp_dir[0] == '\0')
+                        {
+                            // If we have a full path to the compile unit, we don't need to resolve
+                            // the file.  This can be expensive e.g. when the source files are NFS mounted.
+                            if (module_sp->RemapSourceFile(cu_die_name, ramapped_file))
+                                cu_file_spec.SetFile (ramapped_file.c_str(), false);
+                            else
+                                cu_file_spec.SetFile (cu_die_name, false);
+                        }
+                        else
+                        {
+                            std::string fullpath(cu_comp_dir);
+                            if (*fullpath.rbegin() != '/')
+                                fullpath += '/';
+                            fullpath += cu_die_name;
+                            if (module_sp->RemapSourceFile (fullpath.c_str(), ramapped_file))
+                                cu_file_spec.SetFile (ramapped_file.c_str(), false);
+                            else
+                                cu_file_spec.SetFile (fullpath.c_str(), false);
+                        }
 
-                compile_unit_sp.reset(new CompileUnit (module_sp,
-                                                       curr_cu,
-                                                       cu_file_spec, 
-                                                       MakeUserID(curr_cu->GetOffset()),
-                                                       cu_language));
-                if (compile_unit_sp.get())
-                {
-                    curr_cu->SetUserData(compile_unit_sp.get());
-                    return true;
+                        cu_sp.reset(new CompileUnit (module_sp,
+                                                     dwarf_cu,
+                                                     cu_file_spec, 
+                                                     MakeUserID(dwarf_cu->GetOffset()),
+                                                     cu_language));
+                        if (cu_sp)
+                        {
+                            dwarf_cu->SetUserData(cu_sp.get());
+                            
+                            if (m_debug_map_symfile)
+                            {
+                                // Let the symbol file register the compile unit with
+                                // the symbol vendor using its compile unit index
+                                // when we are doing DWARF in .o files + debug map
+                                m_debug_map_symfile->SetCompileUnit(this, cu_sp);
+                            }
+                            else
+                            {
+                                // Figure out the compile unit index if we weren't given one
+                                if (cu_idx == UINT32_MAX)
+                                    DebugInfo()->GetCompileUnit(dwarf_cu->GetOffset(), &cu_idx);
+                                
+                                m_obj_file->GetModule()->GetSymbolVendor()->SetCompileUnitAtIndex(cu_idx, cu_sp);
+                            }
+                        }
+                    }
                 }
             }
         }
     }
-    return false;
+    return cu_sp;
 }
 
 uint32_t
@@ -775,22 +800,15 @@
 CompUnitSP
 SymbolFileDWARF::ParseCompileUnitAtIndex(uint32_t cu_idx)
 {
-    CompUnitSP comp_unit;
+    CompUnitSP cu_sp;
     DWARFDebugInfo* info = DebugInfo();
     if (info)
     {
-        DWARFCompileUnit* curr_cu = info->GetCompileUnitAtIndex(cu_idx);
-        if (curr_cu != NULL)
-        {
-            // Our symbol vendor shouldn't be asking us to add a compile unit that
-            // has already been added to it, which this DWARF plug-in knows as it
-            // stores the lldb compile unit (CompileUnit) pointer in each
-            // DWARFCompileUnit object when it gets added.
-            assert(curr_cu->GetUserData() == NULL);
-            ParseCompileUnit(curr_cu, comp_unit);
-        }
+        DWARFCompileUnit* dwarf_cu = info->GetCompileUnitAtIndex(cu_idx);
+        if (dwarf_cu)
+            cu_sp = ParseCompileUnit(dwarf_cu, cu_idx);
     }
-    return comp_unit;
+    return cu_sp;
 }
 
 static void
@@ -924,14 +942,14 @@
 SymbolFileDWARF::ParseCompileUnitSupportFiles (const SymbolContext& sc, FileSpecList& support_files)
 {
     assert (sc.comp_unit);
-    DWARFCompileUnit* curr_cu = GetDWARFCompileUnitForUID(sc.comp_unit->GetID());
-    assert (curr_cu);
-    const DWARFDebugInfoEntry * cu_die = curr_cu->GetCompileUnitDIEOnly();
+    DWARFCompileUnit* dwarf_cu = GetDWARFCompileUnitForUID(sc.comp_unit->GetID());
+    assert (dwarf_cu);
+    const DWARFDebugInfoEntry * cu_die = dwarf_cu->GetCompileUnitDIEOnly();
 
     if (cu_die)
     {
-        const char * cu_comp_dir = cu_die->GetAttributeValueAsString(this, curr_cu, DW_AT_comp_dir, NULL);
-        dw_offset_t stmt_list = cu_die->GetAttributeValueAsUnsigned(this, curr_cu, DW_AT_stmt_list, DW_INVALID_OFFSET);
+        const char * cu_comp_dir = cu_die->GetAttributeValueAsString(this, dwarf_cu, DW_AT_comp_dir, NULL);
+        dw_offset_t stmt_list = cu_die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_stmt_list, DW_INVALID_OFFSET);
 
         // All file indexes in DWARF are one based and a file of index zero is
         // supposed to be the compile unit itself.
@@ -1938,7 +1956,7 @@
 
     DWARFDebugInfo* debug_info = DebugInfo();
 
-    DWARFCompileUnit *curr_cu = debug_info->GetCompileUnitContainingDIE (die->GetOffset()).get();
+    DWARFCompileUnit *dwarf_cu = debug_info->GetCompileUnitContainingDIE (die->GetOffset()).get();
     Type *type = m_die_to_type.lookup (die);
 
     const dw_tag_t tag = die->Tag();
@@ -2005,7 +2023,7 @@
                         default_accessibility = eAccessPrivate;
                     }
                     
-                    SymbolContext sc(GetCompUnitForDWARFCompUnit(curr_cu));
+                    SymbolContext sc(GetCompUnitForDWARFCompUnit(dwarf_cu));
                     std::vector<clang::CXXBaseSpecifier *> base_classes;
                     std::vector<int> member_accessibilities;
                     bool is_a_class = false;
@@ -2013,7 +2031,7 @@
                     DWARFDIECollection member_function_dies;
                     
                     ParseChildMembers (sc, 
-                                       curr_cu, 
+                                       dwarf_cu,
                                        die, 
                                        clang_type,
                                        class_language,
@@ -2030,7 +2048,7 @@
                     {
                         for (size_t i=0; i<num_functions; ++i)
                         {
-                            ResolveType(curr_cu, member_function_dies.GetDIEPtrAtIndex(i));
+                            ResolveType(dwarf_cu, member_function_dies.GetDIEPtrAtIndex(i));
                         }
                     }
                     
@@ -2132,7 +2150,7 @@
                 if (type)
                     layout_info.bit_size = type->GetByteSize() * 8;
                 if (layout_info.bit_size == 0)
-                    layout_info.bit_size = die->GetAttributeValueAsUnsigned(this, curr_cu, DW_AT_byte_size, 0) * 8;
+                    layout_info.bit_size = die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_byte_size, 0) * 8;
                 clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type));
                 const clang::RecordType *record_type = clang::dyn_cast<clang::RecordType>(qual_type.getTypePtr());
                 if (record_type)
@@ -2170,8 +2188,8 @@
         ast.StartTagDeclarationDefinition (clang_type);
         if (die->HasChildren())
         {
-            SymbolContext sc(GetCompUnitForDWARFCompUnit(curr_cu));
-            ParseChildEnumerators(sc, clang_type, type->GetByteSize(), curr_cu, die);
+            SymbolContext sc(GetCompUnitForDWARFCompUnit(dwarf_cu));
+            ParseChildEnumerators(sc, clang_type, type->GetByteSize(), dwarf_cu, die);
         }
         ast.CompleteTagDeclarationDefinition (clang_type);
         return clang_type;
@@ -2184,14 +2202,14 @@
 }
 
 Type*
-SymbolFileDWARF::ResolveType (DWARFCompileUnit* curr_cu, const DWARFDebugInfoEntry* type_die, bool assert_not_being_parsed)
+SymbolFileDWARF::ResolveType (DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry* type_die, bool assert_not_being_parsed)
 {
     if (type_die != NULL)
     {
         Type *type = m_die_to_type.lookup (type_die);
 
         if (type == NULL)
-            type = GetTypeForDIE (curr_cu, type_die).get();
+            type = GetTypeForDIE (dwarf_cu, type_die).get();
 
         if (assert_not_being_parsed)
         { 
@@ -2199,9 +2217,9 @@
                 return type;
             
             GetObjectFile()->GetModule()->ReportError ("Parsing a die that is being parsed die: 0x%8.8x: %s %s",
-                                                                       type_die->GetOffset(), 
-                                                                       DW_TAG_value_to_name(type_die->Tag()), 
-                                                                       type_die->GetName(this, curr_cu));
+                                                       type_die->GetOffset(), 
+                                                       DW_TAG_value_to_name(type_die->Tag()), 
+                                                       type_die->GetName(this, dwarf_cu));
 
         }
         else
@@ -2211,40 +2229,28 @@
 }
 
 CompileUnit*
-SymbolFileDWARF::GetCompUnitForDWARFCompUnit (DWARFCompileUnit* curr_cu, uint32_t cu_idx)
+SymbolFileDWARF::GetCompUnitForDWARFCompUnit (DWARFCompileUnit* dwarf_cu, uint32_t cu_idx)
 {
     // Check if the symbol vendor already knows about this compile unit?
-    if (curr_cu->GetUserData() == NULL)
+    if (dwarf_cu->GetUserData() == NULL)
     {
         // The symbol vendor doesn't know about this compile unit, we
         // need to parse and add it to the symbol vendor object.
-        CompUnitSP dc_cu;
-        ParseCompileUnit(curr_cu, dc_cu);
-        if (dc_cu.get())
-        {
-            // Figure out the compile unit index if we weren't given one
-            if (cu_idx == UINT32_MAX)
-                DebugInfo()->GetCompileUnit(curr_cu->GetOffset(), &cu_idx);
-
-            m_obj_file->GetModule()->GetSymbolVendor()->SetCompileUnitAtIndex(dc_cu, cu_idx);
-            
-            if (m_debug_map_symfile)
-                m_debug_map_symfile->SetCompileUnit(this, dc_cu);
-        }
+        return ParseCompileUnit(dwarf_cu, cu_idx).get();
     }
-    return (CompileUnit*)curr_cu->GetUserData();
+    return (CompileUnit*)dwarf_cu->GetUserData();
 }
 
 bool
-SymbolFileDWARF::GetFunction (DWARFCompileUnit* curr_cu, const DWARFDebugInfoEntry* func_die, SymbolContext& sc)
+SymbolFileDWARF::GetFunction (DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry* func_die, SymbolContext& sc)
 {
     sc.Clear();
     // Check if the symbol vendor already knows about this compile unit?
-    sc.comp_unit = GetCompUnitForDWARFCompUnit(curr_cu, UINT32_MAX);
+    sc.comp_unit = GetCompUnitForDWARFCompUnit(dwarf_cu, UINT32_MAX);
 
     sc.function = sc.comp_unit->FindFunctionByUID (MakeUserID(func_die->GetOffset())).get();
     if (sc.function == NULL)
-        sc.function = ParseCompileUnitFunction(sc, curr_cu, func_die);
+        sc.function = ParseCompileUnitFunction(sc, dwarf_cu, func_die);
         
     if (sc.function)
     {        
@@ -2278,10 +2284,10 @@
             if (cu_offset != DW_INVALID_OFFSET)
             {
                 uint32_t cu_idx;
-                DWARFCompileUnit* curr_cu = debug_info->GetCompileUnit(cu_offset, &cu_idx).get();
-                if (curr_cu)
+                DWARFCompileUnit* dwarf_cu = debug_info->GetCompileUnit(cu_offset, &cu_idx).get();
+                if (dwarf_cu)
                 {
-                    sc.comp_unit = GetCompUnitForDWARFCompUnit(curr_cu, cu_idx);
+                    sc.comp_unit = GetCompUnitForDWARFCompUnit(dwarf_cu, cu_idx);
                     assert(sc.comp_unit != NULL);
                     resolved |= eSymbolContextCompUnit;
 
@@ -2312,18 +2318,18 @@
                         DWARFDebugInfoEntry *block_die = NULL;
                         if (resolve_scope & eSymbolContextBlock)
                         {
-                            curr_cu->LookupAddress(file_vm_addr, &function_die, &block_die);
+                            dwarf_cu->LookupAddress(file_vm_addr, &function_die, &block_die);
                         }
                         else
                         {
-                            curr_cu->LookupAddress(file_vm_addr, &function_die, NULL);
+                            dwarf_cu->LookupAddress(file_vm_addr, &function_die, NULL);
                         }
 
                         if (function_die != NULL)
                         {
                             sc.function = sc.comp_unit->FindFunctionByUID (MakeUserID(function_die->GetOffset())).get();
                             if (sc.function == NULL)
-                                sc.function = ParseCompileUnitFunction(sc, curr_cu, function_die);
+                                sc.function = ParseCompileUnitFunction(sc, dwarf_cu, function_die);
                         }
                         else
                         {
@@ -2373,16 +2379,16 @@
         if (debug_info)
         {
             uint32_t cu_idx;
-            DWARFCompileUnit* curr_cu = NULL;
+            DWARFCompileUnit* dwarf_cu = NULL;
 
-            for (cu_idx = 0; (curr_cu = debug_info->GetCompileUnitAtIndex(cu_idx)) != NULL; ++cu_idx)
+            for (cu_idx = 0; (dwarf_cu = debug_info->GetCompileUnitAtIndex(cu_idx)) != NULL; ++cu_idx)
             {
-                CompileUnit *dc_cu = GetCompUnitForDWARFCompUnit(curr_cu, cu_idx);
+                CompileUnit *dc_cu = GetCompUnitForDWARFCompUnit(dwarf_cu, cu_idx);
                 bool file_spec_matches_cu_file_spec = dc_cu != NULL && FileSpec::Compare(file_spec, *dc_cu, false) == 0;
                 if (check_inlines || file_spec_matches_cu_file_spec)
                 {
                     SymbolContext sc (m_obj_file->GetModule());
-                    sc.comp_unit = GetCompUnitForDWARFCompUnit(curr_cu, cu_idx);
+                    sc.comp_unit = GetCompUnitForDWARFCompUnit(dwarf_cu, cu_idx);
                     assert(sc.comp_unit != NULL);
 
                     uint32_t file_idx = UINT32_MAX;
@@ -2424,13 +2430,13 @@
                                         {
                                             DWARFDebugInfoEntry *function_die = NULL;
                                             DWARFDebugInfoEntry *block_die = NULL;
-                                            curr_cu->LookupAddress(file_vm_addr, &function_die, resolve_scope & eSymbolContextBlock ? &block_die : NULL);
+                                            dwarf_cu->LookupAddress(file_vm_addr, &function_die, resolve_scope & eSymbolContextBlock ? &block_die : NULL);
 
                                             if (function_die != NULL)
                                             {
                                                 sc.function = sc.comp_unit->FindFunctionByUID (MakeUserID(function_die->GetOffset())).get();
                                                 if (sc.function == NULL)
-                                                    sc.function = ParseCompileUnitFunction(sc, curr_cu, function_die);
+                                                    sc.function = ParseCompileUnitFunction(sc, dwarf_cu, function_die);
                                             }
 
                                             if (sc.function != NULL)
@@ -2490,24 +2496,24 @@
         const uint32_t num_compile_units = GetNumCompileUnits();
         for (cu_idx = 0; cu_idx < num_compile_units; ++cu_idx)
         {
-            DWARFCompileUnit* curr_cu = debug_info->GetCompileUnitAtIndex(cu_idx);
+            DWARFCompileUnit* dwarf_cu = debug_info->GetCompileUnitAtIndex(cu_idx);
 
-            bool clear_dies = curr_cu->ExtractDIEsIfNeeded (false) > 1;
+            bool clear_dies = dwarf_cu->ExtractDIEsIfNeeded (false) > 1;
 
-            curr_cu->Index (cu_idx,
-                            m_function_basename_index,
-                            m_function_fullname_index,
-                            m_function_method_index,
-                            m_function_selector_index,
-                            m_objc_class_selectors_index,
-                            m_global_index, 
-                            m_type_index,
-                            m_namespace_index);
+            dwarf_cu->Index (cu_idx,
+                             m_function_basename_index,
+                             m_function_fullname_index,
+                             m_function_method_index,
+                             m_function_selector_index,
+                             m_objc_class_selectors_index,
+                             m_global_index, 
+                             m_type_index,
+                             m_namespace_index);
             
             // Keep memory down by clearing DIEs if this generate function
             // caused them to be parsed
             if (clear_dies)
-                curr_cu->ClearDIEs (true);
+                dwarf_cu->ClearDIEs (true);
         }
         
         m_function_basename_index.Finalize();
@@ -3678,11 +3684,19 @@
 
                             // HACK: Objective C formal parameters "self" and "_cmd" 
                             // are not marked as artificial in the DWARF...
-                            CompileUnit *curr_cu = GetCompUnitForDWARFCompUnit(dwarf_cu, UINT32_MAX);
-                            if (curr_cu && (curr_cu->GetLanguage() == eLanguageTypeObjC || curr_cu->GetLanguage() == eLanguageTypeObjC_plus_plus))
+                            CompileUnit *comp_unit = GetCompUnitForDWARFCompUnit(dwarf_cu, UINT32_MAX);
+                            if (comp_unit)
                             {
-                                if (name && name[0] && (strcmp (name, "self") == 0 || strcmp (name, "_cmd") == 0))
-                                    skip = true;
+                                switch (comp_unit->GetLanguage())
+                                {
+                                    case eLanguageTypeObjC:
+                                    case eLanguageTypeObjC_plus_plus:
+                                        if (name && name[0] && (strcmp (name, "self") == 0 || strcmp (name, "_cmd") == 0))
+                                            skip = true;
+                                        break;
+                                    default:
+                                        break;
+                                }
                             }
                         }
                     }
@@ -3943,19 +3957,19 @@
 }
 
 TypeSP
-SymbolFileDWARF::GetTypeForDIE (DWARFCompileUnit *curr_cu, const DWARFDebugInfoEntry* die)
+SymbolFileDWARF::GetTypeForDIE (DWARFCompileUnit *dwarf_cu, const DWARFDebugInfoEntry* die)
 {
     TypeSP type_sp;
     if (die != NULL)
     {
-        assert(curr_cu != NULL);
+        assert(dwarf_cu != NULL);
         Type *type_ptr = m_die_to_type.lookup (die);
         if (type_ptr == NULL)
         {
-            CompileUnit* lldb_cu = GetCompUnitForDWARFCompUnit(curr_cu);
+            CompileUnit* lldb_cu = GetCompUnitForDWARFCompUnit(dwarf_cu);
             assert (lldb_cu);
             SymbolContext sc(lldb_cu);
-            type_sp = ParseType(sc, curr_cu, die, NULL);
+            type_sp = ParseType(sc, dwarf_cu, die, NULL);
         }
         else if (type_ptr != DIE_IS_BEING_PARSED)
         {
@@ -3997,7 +4011,7 @@
 }
 
 clang::NamespaceDecl *
-SymbolFileDWARF::ResolveNamespaceDIE (DWARFCompileUnit *curr_cu, const DWARFDebugInfoEntry *die)
+SymbolFileDWARF::ResolveNamespaceDIE (DWARFCompileUnit *dwarf_cu, const DWARFDebugInfoEntry *die)
 {
     if (die && die->Tag() == DW_TAG_namespace)
     {
@@ -4008,8 +4022,8 @@
             return namespace_decl;
         else
         {
-            const char *namespace_name = die->GetAttributeValueAsString(this, curr_cu, DW_AT_name, NULL);
-            clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIE (curr_cu, die, NULL);            
+            const char *namespace_name = die->GetAttributeValueAsString(this, dwarf_cu, DW_AT_name, NULL);
+            clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIE (dwarf_cu, die, NULL);
             namespace_decl = GetClangASTContext().GetUniqueNamespaceDeclaration (namespace_name, containing_decl_ctx);
             LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
             if (log)
@@ -4216,8 +4230,8 @@
             const uint32_t num_compile_units = GetNumCompileUnits();
             for (uint32_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx)
             {
-                DWARFCompileUnit* curr_cu = debug_info->GetCompileUnitAtIndex(cu_idx);
-                if (curr_cu != cu && curr_cu->Supports_DW_AT_APPLE_objc_complete_type())
+                DWARFCompileUnit* dwarf_cu = debug_info->GetCompileUnitAtIndex(cu_idx);
+                if (dwarf_cu != cu && dwarf_cu->Supports_DW_AT_APPLE_objc_complete_type())
                 {
                     m_supports_DW_AT_APPLE_objc_complete_type = eLazyBoolYes;
                     break;
@@ -4303,7 +4317,7 @@
                         {
                             DEBUG_PRINTF ("resolved 0x%8.8llx (cu 0x%8.8llx) from %s to 0x%8.8llx (cu 0x%8.8llx)\n",
                                           MakeUserID(die->GetOffset()), 
-                                          MakeUserID(curr_cu->GetOffset()), 
+                                          MakeUserID(dwarf_cu->GetOffset()),
                                           m_obj_file->GetFileSpec().GetFilename().AsCString(),
                                           MakeUserID(type_die->GetOffset()), 
                                           MakeUserID(type_cu->GetOffset()));
@@ -4523,7 +4537,7 @@
                         {
                             DEBUG_PRINTF ("resolved 0x%8.8llx (cu 0x%8.8llx) from %s to 0x%8.8llx (cu 0x%8.8llx)\n",
                                           MakeUserID(die->GetOffset()), 
-                                          MakeUserID(curr_cu->GetOffset()), 
+                                          MakeUserID(dwarf_cu->GetOffset()),
                                           m_obj_file->GetFileSpec().GetFilename().AsCString(),
                                           MakeUserID(type_die->GetOffset()), 
                                           MakeUserID(type_cu->GetOffset()));

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=153908&r1=153907&r2=153908&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Mon Apr  2 17:59:12 2012
@@ -105,7 +105,7 @@
     virtual lldb_private::Type* ResolveTypeUID(lldb::user_id_t type_uid);
     virtual lldb::clang_type_t ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_opaque_type);
 
-    virtual lldb_private::Type* ResolveType (DWARFCompileUnit* cu, const DWARFDebugInfoEntry* type_die, bool assert_not_being_parsed = true);
+    virtual lldb_private::Type* ResolveType (DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry* type_die, bool assert_not_being_parsed = true);
     virtual clang::DeclContext* GetClangDeclContextContainingTypeUID (lldb::user_id_t type_uid);
     virtual clang::DeclContext* GetClangDeclContextForTypeUID (const lldb_private::SymbolContext &sc, lldb::user_id_t type_uid);
 
@@ -296,15 +296,15 @@
     bool                    NamespaceDeclMatchesThisSymbolFile (const lldb_private::ClangNamespaceDecl *namespace_decl);
 
     bool                    DIEIsInNamespace (const lldb_private::ClangNamespaceDecl *namespace_decl, 
-                                              DWARFCompileUnit* cu, 
+                                              DWARFCompileUnit* dwarf_cu, 
                                               const DWARFDebugInfoEntry* die);
 
     DISALLOW_COPY_AND_ASSIGN (SymbolFileDWARF);
-    bool                    ParseCompileUnit (DWARFCompileUnit* cu, lldb::CompUnitSP& compile_unit_sp);
+    lldb::CompUnitSP        ParseCompileUnit (DWARFCompileUnit* dwarf_cu, uint32_t cu_idx);
     DWARFCompileUnit*       GetDWARFCompileUnitForUID(lldb::user_id_t cu_uid);
     DWARFCompileUnit*       GetNextUnparsedDWARFCompileUnit(DWARFCompileUnit* prev_cu);
-    lldb_private::CompileUnit*      GetCompUnitForDWARFCompUnit(DWARFCompileUnit* cu, uint32_t cu_idx = UINT32_MAX);
-    bool                    GetFunction (DWARFCompileUnit* cu, const DWARFDebugInfoEntry* func_die, lldb_private::SymbolContext& sc);
+    lldb_private::CompileUnit*      GetCompUnitForDWARFCompUnit(DWARFCompileUnit* dwarf_cu, uint32_t cu_idx = UINT32_MAX);
+    bool                    GetFunction (DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry* func_die, lldb_private::SymbolContext& sc);
     lldb_private::Function *        ParseCompileUnitFunction (const lldb_private::SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die);
     size_t                  ParseFunctionBlocks (const lldb_private::SymbolContext& sc,
                                                  lldb_private::Block *parent_block,
@@ -314,7 +314,7 @@
                                                  uint32_t depth);
     size_t                  ParseTypes (const lldb_private::SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool parse_siblings, bool parse_children);
     lldb::TypeSP            ParseType (const lldb_private::SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool *type_is_new);
-    lldb_private::Type*     ResolveTypeUID (DWARFCompileUnit* cu, const DWARFDebugInfoEntry* die, bool assert_not_being_parsed);
+    lldb_private::Type*     ResolveTypeUID (DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry* die, bool assert_not_being_parsed);
 
     lldb::VariableSP        ParseVariableDIE(
                                 const lldb_private::SymbolContext& sc,
@@ -406,7 +406,7 @@
                                 lldb_private::SymbolContextList& sc_list);
 
     lldb::TypeSP            FindDefinitionTypeForDIE (
-                                DWARFCompileUnit* cu, 
+                                DWARFCompileUnit* dwarf_cu, 
                                 const DWARFDebugInfoEntry *die, 
                                 const lldb_private::ConstString &type_name);
 

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=153908&r1=153907&r2=153908&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Mon Apr  2 17:59:12 2012
@@ -481,7 +481,8 @@
 
     if (cu_idx < cu_count)
     {
-        if (m_compile_unit_infos[cu_idx].oso_compile_unit_sp.get() == NULL && m_compile_unit_infos[cu_idx].symbol_file_supported)
+        if (m_compile_unit_infos[cu_idx].oso_compile_unit_sp.get() == NULL &&
+            m_compile_unit_infos[cu_idx].symbol_file_supported)
         {
             SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (cu_idx);
             if (oso_dwarf)
@@ -508,8 +509,8 @@
                                                                                             eLanguageTypeUnknown));
 
                     // Let our symbol vendor know about this compile unit
-                    m_obj_file->GetModule()->GetSymbolVendor()->SetCompileUnitAtIndex (m_compile_unit_infos[cu_idx].oso_compile_unit_sp, 
-                                                                                       cu_idx);
+                    m_obj_file->GetModule()->GetSymbolVendor()->SetCompileUnitAtIndex (cu_idx,
+                                                                                       m_compile_unit_infos[cu_idx].oso_compile_unit_sp);
                 }
             }
         }
@@ -1101,18 +1102,19 @@
 SymbolFileDWARFDebugMap::SetCompileUnit (SymbolFileDWARF *oso_dwarf, const CompUnitSP &cu_sp)
 {
     const uint32_t cu_count = GetNumCompileUnits();
-    for (uint32_t i=0; i<cu_count; ++i)
+    for (uint32_t cu_idx=0; cu_idx<cu_count; ++cu_idx)
     {
-        if (m_compile_unit_infos[i].oso_symbol_vendor &&
-            m_compile_unit_infos[i].oso_symbol_vendor->GetSymbolFile() == oso_dwarf)
+        if (m_compile_unit_infos[cu_idx].oso_symbol_vendor &&
+            m_compile_unit_infos[cu_idx].oso_symbol_vendor->GetSymbolFile() == oso_dwarf)
         {
-            if (m_compile_unit_infos[i].oso_compile_unit_sp)
+            if (m_compile_unit_infos[cu_idx].oso_compile_unit_sp)
             {
-                assert (m_compile_unit_infos[i].oso_compile_unit_sp.get() == cu_sp.get());
+                assert (m_compile_unit_infos[cu_idx].oso_compile_unit_sp.get() == cu_sp.get());
             }
             else
             {
-                m_compile_unit_infos[i].oso_compile_unit_sp = cu_sp;
+                m_compile_unit_infos[cu_idx].oso_compile_unit_sp = cu_sp;
+                m_obj_file->GetModule()->GetSymbolVendor()->SetCompileUnitAtIndex(cu_idx, cu_sp);
             }
         }
     }

Modified: lldb/trunk/source/Symbol/SymbolVendor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolVendor.cpp?rev=153908&r1=153907&r2=153908&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/SymbolVendor.cpp (original)
+++ lldb/trunk/source/Symbol/SymbolVendor.cpp Mon Apr  2 17:59:12 2012
@@ -100,7 +100,7 @@
 }
 
 bool
-SymbolVendor::SetCompileUnitAtIndex (CompUnitSP& cu, uint32_t idx)
+SymbolVendor::SetCompileUnitAtIndex (uint32_t idx, const CompUnitSP &cu_sp)
 {
     ModuleSP module_sp(GetModule());
     if (module_sp)
@@ -115,9 +115,15 @@
             // we don't have a race condition, or have a second parse of the same
             // compile unit.
             assert(m_compile_units[idx].get() == NULL);
-            m_compile_units[idx] = cu;
+            m_compile_units[idx] = cu_sp;
             return true;
         }
+        else
+        {
+            // This should NOT happen, and if it does, we want to crash and know
+            // about it
+            assert (idx < num_compile_units);
+        }
     }
     return false;
 }





More information about the lldb-commits mailing list