[Lldb-commits] [lldb] r246172 - More cleanup to make sure no one plays with DWARFDebugInfoEntry. Clients outside of DWARFDebugInfoEntry of DWARFCompileUnit should use DWARFDIE only.

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Thu Aug 27 11:09:45 PDT 2015


Author: gclayton
Date: Thu Aug 27 13:09:44 2015
New Revision: 246172

URL: http://llvm.org/viewvc/llvm-project?rev=246172&view=rev
Log:
More cleanup to make sure no one plays with DWARFDebugInfoEntry. Clients outside of DWARFDebugInfoEntry of DWARFCompileUnit should use DWARFDIE only.


Modified:
    lldb/trunk/include/lldb/Symbol/ClangASTContext.h
    lldb/trunk/include/lldb/Symbol/TypeSystem.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h
    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=246172&r1=246171&r2=246172&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Thu Aug 27 13:09:44 2015
@@ -35,6 +35,7 @@
 
 
 // Forward definitions for DWARF plug-in for type parsing
+class DWARFDebugInfoEntry;
 class DWARFDIE;
 class DWARFDIECollection;
 
@@ -1198,14 +1199,7 @@ protected:
                                 DWARFDIECollection &failures);
 
     clang::DeclContext *
-    GetCachedClangDeclContextForDIE (const DWARFDebugInfoEntry *die)
-    {
-        DIEToDeclContextMap::iterator pos = m_die_to_decl_ctx.find(die);
-        if (pos != m_die_to_decl_ctx.end())
-            return pos->second;
-        else
-            return NULL;
-    }
+    GetCachedClangDeclContextForDIE (const DWARFDIE &die);
 
     void
     LinkDeclContextToDIE (clang::DeclContext *decl_ctx,

Modified: lldb/trunk/include/lldb/Symbol/TypeSystem.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/TypeSystem.h?rev=246172&r1=246171&r2=246172&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/TypeSystem.h (original)
+++ lldb/trunk/include/lldb/Symbol/TypeSystem.h Thu Aug 27 13:09:44 2015
@@ -19,7 +19,6 @@
 #include "clang/AST/Type.h"
 
 class DWARFDIE;
-class DWARFDebugInfoEntry;
 
 namespace lldb_private {
     

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=246172&r1=246171&r2=246172&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Thu Aug 27 13:09:44 2015
@@ -396,7 +396,7 @@ DWARFCompileUnit::BuildAddressRangeTable
     size_t num_debug_aranges = debug_aranges->GetNumRanges();
     
     // First get the compile unit DIE only and check if it has a DW_AT_ranges
-    const DWARFDebugInfoEntry* die = GetCompileUnitDIEOnly();
+    const DWARFDebugInfoEntry* die = GetCompileUnitDIEPtrOnly();
     
     const dw_offset_t cu_offset = GetOffset();
     if (die)
@@ -996,7 +996,7 @@ DWARFCompileUnit::ParseProducerInfo ()
     m_producer_version_minor = UINT32_MAX;
     m_producer_version_update = UINT32_MAX;
 
-    const DWARFDebugInfoEntry *die = GetCompileUnitDIEOnly();
+    const DWARFDebugInfoEntry *die = GetCompileUnitDIEPtrOnly();
     if (die)
     {
 
@@ -1087,7 +1087,7 @@ DWARFCompileUnit::GetLanguageType()
     if (m_language_type != eLanguageTypeUnknown)
         return m_language_type;
 
-    const DWARFDebugInfoEntry *die = GetCompileUnitDIEOnly();
+    const DWARFDebugInfoEntry *die = GetCompileUnitDIEPtrOnly();
     if (die)
         m_language_type = LanguageTypeFromDWARF(die->GetAttributeValueAsUnsigned(m_dwarf2Data, this, DW_AT_language, 0));
     return m_language_type;
@@ -1104,7 +1104,7 @@ DWARFCompileUnit::GetIsOptimized ()
 {
     if (m_is_optimized == eLazyBoolCalculate)
     {
-        const DWARFDebugInfoEntry *die = GetCompileUnitDIEOnly();
+        const DWARFDebugInfoEntry *die = GetCompileUnitDIEPtrOnly();
         if (die)
         {
             m_is_optimized = eLazyBoolNo;

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h?rev=246172&r1=246171&r2=246172&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h Thu Aug 27 13:09:44 2015
@@ -68,13 +68,10 @@ public:
         m_base_addr = base_addr;
     }
 
-    const DWARFDebugInfoEntry*
+    DWARFDIE
     GetCompileUnitDIEOnly()
     {
-        ExtractDIEsIfNeeded (true);
-        if (m_die_array.empty())
-            return NULL;
-        return &m_die_array[0];
+        return DWARFDIE(this, GetCompileUnitDIEPtrOnly());
     }
 
     DWARFDIE
@@ -83,15 +80,6 @@ public:
         return DWARFDIE(this, DIEPtr());
     }
 
-    const DWARFDebugInfoEntry*
-    DIEPtr()
-    {
-        ExtractDIEsIfNeeded (false);
-        if (m_die_array.empty())
-            return NULL;
-        return &m_die_array[0];
-    }
-
     void
     AddDIE (DWARFDebugInfoEntry& die)
     {
@@ -115,12 +103,6 @@ public:
         return m_die_array.size() > 1;
     }
 
-    DWARFDebugInfoEntry*
-    GetDIEAtIndexUnchecked (uint32_t idx)
-    {
-        return &m_die_array[idx];
-    }
-
     DWARFDIE
     GetDIE (dw_offset_t die_offset);
 
@@ -160,12 +142,6 @@ public:
     bool
     Supports_unnamed_objc_bitfields ();
 
-//    void
-//    AddGlobalDIEByIndex (uint32_t die_idx);
-//
-//    void
-//    AddGlobal (const DWARFDebugInfoEntry* die);
-//
     void
     Index (const uint32_t cu_idx,
            NameToDIE& func_basenames,
@@ -232,6 +208,26 @@ protected:
     void
     ParseProducerInfo ();
 private:
+
+    const DWARFDebugInfoEntry*
+    GetCompileUnitDIEPtrOnly()
+    {
+        ExtractDIEsIfNeeded (true);
+        if (m_die_array.empty())
+            return NULL;
+        return &m_die_array[0];
+    }
+
+    const DWARFDebugInfoEntry*
+    DIEPtr()
+    {
+        ExtractDIEsIfNeeded (false);
+        if (m_die_array.empty())
+            return NULL;
+        return &m_die_array[0];
+    }
+
+
     DISALLOW_COPY_AND_ASSIGN (DWARFCompileUnit);
 };
 

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp?rev=246172&r1=246171&r2=246172&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp Thu Aug 27 13:09:44 2015
@@ -13,8 +13,6 @@
 
 #include "lldb/Core/Stream.h"
 
-#include "DWARFDebugInfoEntry.h"
-
 using namespace lldb_private;
 using namespace std;
 
@@ -56,5 +54,5 @@ DWARFDIECollection::Dump(Stream *s, cons
     if (title && title[0] != '\0')
         s->Printf( "%s\n", title);
     for (const auto &die : m_dies)
-        s->Printf( "0x%8.8x\n", die.GetDIE()->GetOffset());
+        s->Printf( "0x%8.8x\n", die.GetOffset());
 }

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp?rev=246172&r1=246171&r2=246172&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp Thu Aug 27 13:09:44 2015
@@ -204,8 +204,8 @@ DWARFDebugInfo::ContainsCompileUnit (con
     return false;
 }
 
-static bool
-OffsetLessThanCompileUnitOffset (dw_offset_t offset, const DWARFCompileUnitSP& cu_sp)
+bool
+DWARFDebugInfo::OffsetLessThanCompileUnitOffset (dw_offset_t offset, const DWARFCompileUnitSP& cu_sp)
 {
     return offset < cu_sp->GetOffset();
 }
@@ -307,26 +307,6 @@ DWARFDebugInfo::GetDIEContainingOffset (
 }
 
 //----------------------------------------------------------------------
-// AddCompileUnit
-//----------------------------------------------------------------------
-void
-DWARFDebugInfo::AddCompileUnit(DWARFCompileUnitSP& cu)
-{
-    m_compile_units.push_back(cu);
-}
-
-/*
-void
-DWARFDebugInfo::AddDIE(DWARFDebugInfoEntry& die)
-{
-    m_die_array.push_back(die);
-}
-*/
-
-
-
-
-//----------------------------------------------------------------------
 // Parse
 //
 // Parses the .debug_info section and uses the .debug_abbrev section
@@ -656,10 +636,10 @@ DWARFDebugInfo::Dump (Stream *s, const u
     ParseCompileUnitHeadersIfNeeded();
     for (pos = m_compile_units.begin(); pos != m_compile_units.end(); ++pos)
     {
-        const DWARFCompileUnitSP& cu_sp = *pos;
-        DumpCallback(m_dwarf2Data, cu_sp.get(), NULL, 0, curr_depth, &dumpInfo);
+        DWARFCompileUnit *cu = pos->get();
+        DumpCallback(m_dwarf2Data, cu, NULL, 0, curr_depth, &dumpInfo);
         
-        const DWARFDIE die = cu_sp->DIE();
+        const DWARFDIE die = cu->DIE();
         if (die)
             die.Dump(s, recurse_depth);
     }

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h?rev=246172&r1=246171&r2=246172&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h Thu Aug 27 13:09:44 2015
@@ -22,14 +22,12 @@ typedef std::multimap<const char*, dw_of
 typedef CStringToDIEMap::iterator CStringToDIEMapIter;
 typedef CStringToDIEMap::const_iterator CStringToDIEMapConstIter;
 
-typedef std::shared_ptr<DWARFCompileUnit> DWARFCompileUnitSP;
-
 class DWARFDebugInfo
 {
 public:
     typedef dw_offset_t (*Callback)(
         SymbolFileDWARF* dwarf2Data,
-        DWARFCompileUnit* cu_shared_ptr,
+        DWARFCompileUnit* cu,
         DWARFDebugInfoEntry* die,
         const dw_offset_t next_offset,
         const uint32_t depth,
@@ -42,7 +40,6 @@ public:
     LookupAddress(const dw_addr_t address,
                   const dw_offset_t cu_offset);    // Can be valid (find in .debug_aranges), or DW_INVALID_OFFSET if we need to search manually
 
-    void AddCompileUnit(DWARFCompileUnitSP& cu);
     size_t GetNumCompileUnits();
     bool ContainsCompileUnit (const DWARFCompileUnit *cu) const;
     DWARFCompileUnit* GetCompileUnitAtIndex (uint32_t idx);
@@ -70,8 +67,17 @@ public:
     GetCompileUnitAranges ();
 
 protected:
-    SymbolFileDWARF* m_dwarf2Data;
+    typedef std::shared_ptr<DWARFCompileUnit> DWARFCompileUnitSP;
+
+    static bool
+    OffsetLessThanCompileUnitOffset (dw_offset_t offset, const DWARFCompileUnitSP& cu_sp);
+
     typedef std::vector<DWARFCompileUnitSP>     CompileUnitColl;
+
+    //----------------------------------------------------------------------
+    // Member variables
+    //----------------------------------------------------------------------
+    SymbolFileDWARF* m_dwarf2Data;
     CompileUnitColl m_compile_units;
     std::unique_ptr<DWARFDebugAranges> m_cu_aranges_ap; // A quick address to compile unit table
 

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp?rev=246172&r1=246171&r2=246172&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp Thu Aug 27 13:09:44 2015
@@ -380,276 +380,6 @@ DWARFDebugInfoEntry::DumpAncestry
 }
 
 //----------------------------------------------------------------------
-// Compare two DIE by comparing all their attributes values, and
-// following all DW_FORM_ref attributes and comparing their contents as
-// well (except for DW_AT_sibling attributes.
-//
-//  DWARFDebugInfoEntry::CompareState compare_state;
-//  int result = DWARFDebugInfoEntry::Compare(this, 0x00017ccb, 0x0001eb2b, compare_state, false, true);
-//----------------------------------------------------------------------
-//int
-//DWARFDebugInfoEntry::Compare
-//(
-//    SymbolFileDWARF* dwarf2Data,
-//    dw_offset_t a_die_offset,
-//    dw_offset_t b_die_offset,
-//    CompareState &compare_state,
-//    bool compare_siblings,
-//    bool compare_children
-//)
-//{
-//    if (a_die_offset == b_die_offset)
-//        return 0;
-//
-//    DWARFCompileUnitSP a_cu_sp;
-//    DWARFCompileUnitSP b_cu_sp;
-//    const DWARFDebugInfoEntry* a_die = dwarf2Data->DebugInfo()->GetDIEPtr(a_die_offset, &a_cu_sp);
-//    const DWARFDebugInfoEntry* b_die = dwarf2Data->DebugInfo()->GetDIEPtr(b_die_offset, &b_cu_sp);
-//
-//    return Compare(dwarf2Data, a_cu_sp.get(), a_die, b_cu_sp.get(), b_die, compare_state, compare_siblings, compare_children);
-//}
-//
-//int
-//DWARFDebugInfoEntry::Compare
-//(
-//    SymbolFileDWARF* dwarf2Data,
-//    DWARFCompileUnit* a_cu, const DWARFDebugInfoEntry* a_die,
-//    DWARFCompileUnit* b_cu, const DWARFDebugInfoEntry* b_die,
-//    CompareState &compare_state,
-//    bool compare_siblings,
-//    bool compare_children
-//)
-//{
-//    if (a_die == b_die)
-//        return 0;
-//
-//    if (!compare_state.AddTypePair(a_die->GetOffset(), b_die->GetOffset()))
-//    {
-//        // We are already comparing both of these types, so let
-//        // compares complete for the real result
-//        return 0;
-//    }
-//
-//    //printf("DWARFDebugInfoEntry::Compare(0x%8.8x, 0x%8.8x)\n", a_die->GetOffset(), b_die->GetOffset());
-//
-//    // Do we have two valid DIEs?
-//    if (a_die && b_die)
-//    {
-//        // Both DIE are valid
-//        int result = 0;
-//
-//        const dw_tag_t a_tag = a_die->Tag();
-//        const dw_tag_t b_tag = b_die->Tag();
-//        if (a_tag == 0 && b_tag == 0)
-//            return 0;
-//
-//        //printf("    comparing tags: %s and %s\n", DW_TAG_value_to_name(a_tag), DW_TAG_value_to_name(b_tag));
-//
-//        if (a_tag < b_tag)
-//            return -1;
-//        else if (a_tag > b_tag)
-//            return 1;
-//
-//        DWARFAttributes a_attrs;
-//        DWARFAttributes b_attrs;
-//        size_t a_attr_count = a_die->GetAttributes(dwarf2Data, a_cu, a_attrs);
-//        size_t b_attr_count = b_die->GetAttributes(dwarf2Data, b_cu, b_attrs);
-//        if (a_attr_count != b_attr_count)
-//        {
-//            a_attrs.RemoveAttribute(DW_AT_sibling);
-//            b_attrs.RemoveAttribute(DW_AT_sibling);
-//        }
-//
-//        a_attr_count = a_attrs.Size();
-//        b_attr_count = b_attrs.Size();
-//
-//        DWARFFormValue a_form_value;
-//        DWARFFormValue b_form_value;
-//
-//        if (a_attr_count != b_attr_count)
-//        {
-//            uint32_t is_decl_index = a_attrs.FindAttributeIndex(DW_AT_declaration);
-//            uint32_t a_name_index = UINT32_MAX;
-//            uint32_t b_name_index = UINT32_MAX;
-//            if (is_decl_index != UINT32_MAX)
-//            {
-//                if (a_attr_count == 2)
-//                {
-//                    a_name_index = a_attrs.FindAttributeIndex(DW_AT_name);
-//                    b_name_index = b_attrs.FindAttributeIndex(DW_AT_name);
-//                }
-//            }
-//            else
-//            {
-//                is_decl_index = b_attrs.FindAttributeIndex(DW_AT_declaration);
-//                if (is_decl_index != UINT32_MAX && a_attr_count == 2)
-//                {
-//                    a_name_index = a_attrs.FindAttributeIndex(DW_AT_name);
-//                    b_name_index = b_attrs.FindAttributeIndex(DW_AT_name);
-//                }
-//            }
-//            if (a_name_index != UINT32_MAX && b_name_index != UINT32_MAX)
-//            {
-//                if (a_attrs.ExtractFormValueAtIndex(dwarf2Data, a_name_index, a_form_value) &&
-//                    b_attrs.ExtractFormValueAtIndex(dwarf2Data, b_name_index, b_form_value))
-//                {
-//                    result = DWARFFormValue::Compare (a_form_value, b_form_value, a_cu, b_cu, &dwarf2Data->get_debug_str_data());
-//                    if (result == 0)
-//                    {
-//                        a_attr_count = b_attr_count = 0;
-//                        compare_children = false;
-//                    }
-//                }
-//            }
-//        }
-//
-//        if (a_attr_count < b_attr_count)
-//            return -1;
-//        if (a_attr_count > b_attr_count)
-//            return 1;
-//
-//
-//        // The number of attributes are the same...
-//        if (a_attr_count > 0)
-//        {
-//            const DWARFDataExtractor* debug_str_data_ptr = &dwarf2Data->get_debug_str_data();
-//
-//            uint32_t i;
-//            for (i=0; i<a_attr_count; ++i)
-//            {
-//                const dw_attr_t a_attr = a_attrs.AttributeAtIndex(i);
-//                const dw_attr_t b_attr = b_attrs.AttributeAtIndex(i);
-//                //printf("    comparing attributes\n\t\t0x%8.8x: %s %s\t\t0x%8.8x: %s %s\n",
-//                //                a_attrs.DIEOffsetAtIndex(i), DW_FORM_value_to_name(a_attrs.FormAtIndex(i)), DW_AT_value_to_name(a_attr),
-//                //                b_attrs.DIEOffsetAtIndex(i), DW_FORM_value_to_name(b_attrs.FormAtIndex(i)), DW_AT_value_to_name(b_attr));
-//
-//                if (a_attr < b_attr)
-//                    return -1;
-//                else if (a_attr > b_attr)
-//                    return 1;
-//
-//                switch (a_attr)
-//                {
-//                // Since we call a form of GetAttributes which inlines the
-//                // attributes from DW_AT_abstract_origin and DW_AT_specification
-//                // we don't care if their values mismatch...
-//                case DW_AT_abstract_origin:
-//                case DW_AT_specification:
-//                case DW_AT_sibling:
-//                case DW_AT_containing_type:
-//                    //printf("        action = IGNORE\n");
-//                    result = 0;
-//                    break;  // ignore
-//
-//                default:
-//                    if (a_attrs.ExtractFormValueAtIndex(dwarf2Data, i, a_form_value) &&
-//                        b_attrs.ExtractFormValueAtIndex(dwarf2Data, i, b_form_value))
-//                        result = DWARFFormValue::Compare (a_form_value, b_form_value, a_cu, b_cu, debug_str_data_ptr);
-//                    break;
-//                }
-//
-//                //printf("\t  result = %i\n", result);
-//
-//                if (result != 0)
-//                {
-//                    // Attributes weren't equal, lets see if we care?
-//                    switch (a_attr)
-//                    {
-//                    case DW_AT_decl_file:
-//                        // TODO: add the ability to compare files in two different compile units
-//                        if (a_cu == b_cu)
-//                        {
-//                            //printf("        action = RETURN RESULT\n");
-//                            return result;  // Only return the compare results when the compile units are the same and the decl_file attributes can be compared
-//                        }
-//                        else
-//                        {
-//                            result = 0;
-//                            //printf("        action = IGNORE\n");
-//                        }
-//                        break;
-//
-//                    default:
-//                        switch (a_attrs.FormAtIndex(i))
-//                        {
-//                        case DW_FORM_ref1:
-//                        case DW_FORM_ref2:
-//                        case DW_FORM_ref4:
-//                        case DW_FORM_ref8:
-//                        case DW_FORM_ref_udata:
-//                        case DW_FORM_ref_addr:
-//                            //printf("    action = COMPARE DIEs 0x%8.8x 0x%8.8x\n", (dw_offset_t)a_form_value.Reference(a_cu), (dw_offset_t)b_form_value.Reference(b_cu));
-//                            // These attribute values refer to other DIEs, so lets compare those instead of their DIE offsets...
-//                            result = Compare(dwarf2Data, a_form_value.Reference(a_cu), b_form_value.Reference(b_cu), compare_state, false, true);
-//                            if (result != 0)
-//                                return result;
-//                            break;
-//
-//                        default:
-//                            // We do care that they were different, return this result...
-//                            //printf("        action = RETURN RESULT\n");
-//                            return result;
-//                        }
-//                    }
-//                }
-//            }
-//        }
-//        //printf("    SUCCESS\n\t\t0x%8.8x: %s\n\t\t0x%8.8x: %s\n", a_die->GetOffset(), DW_TAG_value_to_name(a_tag), b_die->GetOffset(), DW_TAG_value_to_name(b_tag));
-//
-//        if (compare_children)
-//        {
-//            bool a_has_children = a_die->HasChildren();
-//            bool b_has_children = b_die->HasChildren();
-//            if (a_has_children == b_has_children)
-//            {
-//                // Both either have kids or don't
-//                if (a_has_children)
-//                    result = Compare(   dwarf2Data,
-//                                        a_cu, a_die->GetFirstChild(),
-//                                        b_cu, b_die->GetFirstChild(),
-//                                        compare_state, true, compare_children);
-//                else
-//                    result = 0;
-//            }
-//            else if (!a_has_children)
-//                result = -1;    // A doesn't have kids, but B does
-//            else
-//                result = 1; // A has kids, but B doesn't
-//        }
-//
-//        if (compare_siblings)
-//        {
-//            result = Compare(   dwarf2Data,
-//                                a_cu, a_die->GetSibling(),
-//                                b_cu, b_die->GetSibling(),
-//                                compare_state, true, compare_children);
-//        }
-//
-//        return result;
-//    }
-//
-//    if (a_die == NULL)
-//        return -1;  // a_die is NULL, yet b_die is non-NULL
-//    else
-//        return 1;   // a_die is non-NULL, yet b_die is NULL
-//
-//}
-//
-//
-//int
-//DWARFDebugInfoEntry::Compare
-//(
-//  SymbolFileDWARF* dwarf2Data,
-//  const DWARFCompileUnit* cu_a,
-//  const DWARFDebugInfoEntry* die_a,
-//  const DWARFCompileUnit* cu_a,
-//  const DWARFDebugInfoEntry* die_b,
-//  CompareState &compare_state
-//)
-//{
-//}
-
-//----------------------------------------------------------------------
 // GetDIENamesAndRanges
 //
 // Gets the valid address ranges for a given DIE by looking for a
@@ -945,10 +675,10 @@ DWARFDebugInfoEntry::DumpLocation
     Stream &s
 ) const
 {
-    const DWARFDebugInfoEntry *cu_die = cu->GetCompileUnitDIEOnly();
+    const DWARFDIE cu_die = cu->GetCompileUnitDIEOnly();
     const char *cu_name = NULL;
-    if (cu_die != NULL)
-        cu_name = cu_die->GetName (dwarf2Data, cu);
+    if (cu_die)
+        cu_name = cu_die.GetName ();
     const char *obj_file_name = NULL;
     ObjectFile *obj_file = dwarf2Data->GetObjectFile();
     if (obj_file)
@@ -1398,24 +1128,20 @@ DWARFDebugInfoEntry::GetAttributeAddress
 }
 
 size_t
-DWARFDebugInfoEntry::GetAttributeAddressRanges(SymbolFileDWARF* dwarf2Data,
-                                               const DWARFCompileUnit* cu,
-                                               DWARFRangeList &ranges,
-                                               bool check_hi_lo_pc) const
+DWARFDebugInfoEntry::GetAttributeAddressRanges (SymbolFileDWARF* dwarf2Data,
+                                                const DWARFCompileUnit* cu,
+                                                DWARFRangeList &ranges,
+                                                bool check_hi_lo_pc) const
 {
     ranges.Clear();
     
-    dw_offset_t ranges_offset = GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_ranges, DW_INVALID_OFFSET);
-    if (ranges_offset != DW_INVALID_OFFSET)
+    dw_offset_t debug_ranges_offset = GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_ranges, DW_INVALID_OFFSET);
+    if (debug_ranges_offset != DW_INVALID_OFFSET)
     {
-        dw_offset_t debug_ranges_offset = GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_ranges, DW_INVALID_OFFSET);
-        if (debug_ranges_offset != DW_INVALID_OFFSET)
-        {
-            DWARFDebugRanges* debug_ranges = dwarf2Data->DebugRanges();
-            
-            debug_ranges->FindRanges(debug_ranges_offset, ranges);
-            ranges.Slide (cu->GetBaseAddress());
-        }
+        DWARFDebugRanges* debug_ranges = dwarf2Data->DebugRanges();
+        
+        debug_ranges->FindRanges(debug_ranges_offset, ranges);
+        ranges.Slide (cu->GetBaseAddress());
     }
     else if (check_hi_lo_pc)
     {

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h?rev=246172&r1=246171&r2=246172&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h Thu Aug 27 13:09:44 2015
@@ -20,7 +20,6 @@
 #include "DWARFDefines.h"
 
 class SymbolFileDWARF;
-class DWARFDebugInfoEntry;
 
 //----------------------------------------------------------------------
 // DWARFDebugLine

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h?rev=246172&r1=246171&r2=246172&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h Thu Aug 27 13:09:44 2015
@@ -20,11 +20,6 @@
 #include "lldb/Core/RegularExpression.h"
 #include "lldb/Core/MappedHash.h"
 
-
-class SymbolFileDWARF;
-class DWARFCompileUnit;
-class DWARFDebugInfoEntry;
-
 struct DWARFMappedHash
 {
     struct DIEInfo
@@ -217,12 +212,6 @@ struct DWARFMappedHash
     };
     
     typedef std::vector<Atom> AtomArray;
-    
-    static uint32_t 
-    GetTypeFlags (SymbolFileDWARF *dwarf2Data,
-                  const DWARFCompileUnit* cu,
-                  const DWARFDebugInfoEntry* die);
-    
 
     static const char *
     GetAtomTypeName (uint16_t atom)
@@ -523,64 +512,6 @@ struct DWARFMappedHash
         }
     };
     
-//    class ExportTable
-//    {
-//    public:
-//        ExportTable ();
-//        
-//        void
-//        AppendNames (DWARFDebugPubnamesSet &pubnames_set,
-//                     StringTable &string_table);
-//        
-//        void
-//        AppendNamesEntry (SymbolFileDWARF *dwarf2Data,
-//                          const DWARFCompileUnit* cu,
-//                          const DWARFDebugInfoEntry* die,
-//                          StringTable &string_table);
-//        
-//        void
-//        AppendTypesEntry (DWARFData *dwarf2Data,
-//                          const DWARFCompileUnit* cu,
-//                          const DWARFDebugInfoEntry* die,
-//                          StringTable &string_table);
-//        
-//        size_t
-//        Save (BinaryStreamBuf &names_data, const StringTable &string_table);
-//        
-//        void
-//        AppendName (const char *name, 
-//                    uint32_t die_offset, 
-//                    StringTable &string_table,
-//                    dw_offset_t name_debug_str_offset = DW_INVALID_OFFSET); // If "name" has already been looked up, then it can be supplied
-//        void
-//        AppendType (const char *name, 
-//                    uint32_t die_offset, 
-//                    StringTable &string_table);
-//        
-//        
-//    protected:
-//        struct Entry
-//        {
-//            uint32_t hash;
-//            uint32_t str_offset;
-//            uint32_t die_offset;
-//        };
-//        
-//        // Map uniqued .debug_str offset to the corresponding DIE offsets
-//        typedef std::map<uint32_t, DIEInfoArray> NameInfo;
-//        // Map a name hash to one or more name infos
-//        typedef std::map<uint32_t, NameInfo> BucketEntry;
-//        
-//        static uint32_t
-//        GetByteSize (const NameInfo &name_info);
-//        
-//        typedef std::vector<BucketEntry> BucketEntryColl;
-//        typedef std::vector<Entry> EntryColl;
-//        EntryColl m_entries;
-//        
-//    };
-    
-    
     // A class for reading and using a saved hash table from a block of data
     // in memory
     class MemoryTable : public MappedHash::MemoryTable<uint32_t, DWARFMappedHash::Header, DIEInfoArray>

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=246172&r1=246171&r2=246172&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu Aug 27 13:09:44 2015
@@ -61,7 +61,6 @@
 #include "DWARFDebugAbbrev.h"
 #include "DWARFDebugAranges.h"
 #include "DWARFDebugInfo.h"
-#include "DWARFDebugInfoEntry.h"
 #include "DWARFDebugLine.h"
 #include "DWARFDebugPubnames.h"
 #include "DWARFDebugRanges.h"
@@ -923,17 +922,17 @@ SymbolFileDWARF::ParseCompileUnit (DWARF
                 ModuleSP module_sp (m_obj_file->GetModule());
                 if (module_sp)
                 {
-                    const DWARFDebugInfoEntry * cu_die = dwarf_cu->GetCompileUnitDIEOnly ();
+                    const DWARFDIE cu_die = dwarf_cu->GetCompileUnitDIEOnly ();
                     if (cu_die)
                     {
-                        FileSpec cu_file_spec{cu_die->GetName(this, dwarf_cu), false};
+                        FileSpec cu_file_spec{cu_die.GetName(), false};
                         if (cu_file_spec)
                         {
                             // 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 (cu_file_spec.IsRelative())
                             {
-                                const char *cu_comp_dir{cu_die->GetAttributeValueAsString(this, dwarf_cu, DW_AT_comp_dir, nullptr)};
+                                const char *cu_comp_dir{cu_die.GetAttributeValueAsString(DW_AT_comp_dir, nullptr)};
                                 cu_file_spec.PrependPathComponent(resolveCompDir(cu_comp_dir));
                             }
 
@@ -942,7 +941,7 @@ SymbolFileDWARF::ParseCompileUnit (DWARF
                                 cu_file_spec.SetFile(remapped_file, false);
                         }
 
-                        LanguageType cu_language = DWARFCompileUnit::LanguageTypeFromDWARF(cu_die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_language, 0));
+                        LanguageType cu_language = DWARFCompileUnit::LanguageTypeFromDWARF(cu_die.GetAttributeValueAsUnsigned(DW_AT_language, 0));
 
                         bool is_optimized = dwarf_cu->GetIsOptimized ();
                         cu_sp.reset(new CompileUnit (module_sp,
@@ -1038,12 +1037,9 @@ SymbolFileDWARF::ParseCompileUnitLanguag
     assert (sc.comp_unit);
     DWARFCompileUnit* dwarf_cu = GetDWARFCompileUnit(sc.comp_unit);
     if (dwarf_cu)
-    {
-        const DWARFDebugInfoEntry *die = dwarf_cu->GetCompileUnitDIEOnly();
-        if (die)
-            return DWARFCompileUnit::LanguageTypeFromDWARF(die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_language, 0));
-    }
-    return eLanguageTypeUnknown;
+        return dwarf_cu->GetLanguageType();
+    else
+        return eLanguageTypeUnknown;
 }
 
 size_t
@@ -1078,13 +1074,13 @@ SymbolFileDWARF::ParseCompileUnitSupport
     DWARFCompileUnit* dwarf_cu = GetDWARFCompileUnit(sc.comp_unit);
     if (dwarf_cu)
     {
-        const DWARFDebugInfoEntry * cu_die = dwarf_cu->GetCompileUnitDIEOnly();
+        const DWARFDIE cu_die = dwarf_cu->GetCompileUnitDIEOnly();
 
         if (cu_die)
         {
-            const char * cu_comp_dir = resolveCompDir(cu_die->GetAttributeValueAsString(this, dwarf_cu, DW_AT_comp_dir, nullptr));
+            const char * cu_comp_dir = resolveCompDir(cu_die.GetAttributeValueAsString(DW_AT_comp_dir, nullptr));
 
-            dw_offset_t stmt_list = cu_die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_stmt_list, DW_INVALID_OFFSET);
+            const dw_offset_t stmt_list = cu_die.GetAttributeValueAsUnsigned(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.
@@ -1177,10 +1173,10 @@ SymbolFileDWARF::ParseCompileUnitLineTab
     DWARFCompileUnit* dwarf_cu = GetDWARFCompileUnit(sc.comp_unit);
     if (dwarf_cu)
     {
-        const DWARFDebugInfoEntry *dwarf_cu_die = dwarf_cu->GetCompileUnitDIEOnly();
+        const DWARFDIE dwarf_cu_die = dwarf_cu->GetCompileUnitDIEOnly();
         if (dwarf_cu_die)
         {
-            const dw_offset_t cu_line_offset = dwarf_cu_die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_stmt_list, DW_INVALID_OFFSET);
+            const dw_offset_t cu_line_offset = dwarf_cu_die.GetAttributeValueAsUnsigned(DW_AT_stmt_list, DW_INVALID_OFFSET);
             if (cu_line_offset != DW_INVALID_OFFSET)
             {
                 std::unique_ptr<LineTable> line_table_ap(new LineTable(sc.comp_unit));
@@ -1489,8 +1485,7 @@ bool
 SymbolFileDWARF::HasForwardDeclForClangType (const CompilerType &clang_type)
 {
     CompilerType clang_type_no_qualifiers = ClangASTContext::RemoveFastQualifiers(clang_type);
-    const DWARFDebugInfoEntry* die = m_forward_decl_clang_type_to_die.lookup (clang_type_no_qualifiers.GetOpaqueQualType());
-    return die != NULL;
+    return m_forward_decl_clang_type_to_die.lookup (clang_type_no_qualifiers.GetOpaqueQualType()) != nullptr;
 }
 
 
@@ -1632,11 +1627,11 @@ SymbolFileDWARF::UpdateExternalModuleLis
     {
         DWARFCompileUnit* dwarf_cu = debug_info->GetCompileUnitAtIndex(cu_idx);
         
-        const DWARFDebugInfoEntry *die = dwarf_cu->GetCompileUnitDIEOnly();
-        if (die && die->HasChildren() == false)
+        const DWARFDIE die = dwarf_cu->GetCompileUnitDIEOnly();
+        if (die && die.HasChildren() == false)
         {
-            const uint64_t name_strp = die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_name, UINT64_MAX);
-            const uint64_t dwo_path_strp = die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_GNU_dwo_name, UINT64_MAX);
+            const uint64_t name_strp = die.GetAttributeValueAsUnsigned (DW_AT_name, UINT64_MAX);
+            const uint64_t dwo_path_strp = die.GetAttributeValueAsUnsigned (DW_AT_GNU_dwo_name, UINT64_MAX);
             
             if (name_strp != UINT64_MAX)
             {
@@ -3321,7 +3316,7 @@ SymbolFileDWARF::DIEDeclContextsMatch (c
 
     // Make sure the top item in the decl context die array is always 
     // DW_TAG_compile_unit. If it isn't then something went wrong in
-    // the DWARFDebugInfoEntry::GetDeclContextDIEs() function...
+    // the DWARFDIE::GetDeclContextDIEs() function...
     assert (decl_ctx_1.GetDIEAtIndex (count1 - 1).Tag() == DW_TAG_compile_unit);
 
 #endif

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=246172&r1=246171&r2=246172&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h Thu Aug 27 13:09:44 2015
@@ -22,11 +22,8 @@
 #include "UniqueDWARFASTType.h"
 
 class SymbolFileDWARF;
-class DWARFCompileUnit;
 class DWARFDebugAranges;
-class DWARFDebugInfoEntry;
 class DWARFDeclContext;
-class DebugMapModule;
 
 class SymbolFileDWARFDebugMap : public lldb_private::SymbolFile
 {

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp?rev=246172&r1=246171&r2=246172&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp Thu Aug 27 13:09:44 2015
@@ -15,8 +15,6 @@
 // Project includes
 #include "lldb/Symbol/Declaration.h"
 
-#include "DWARFDebugInfoEntry.h"
-
 bool
 UniqueDWARFASTTypeList::Find (const DWARFDIE &die,
                               const lldb_private::Declaration &decl,

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h?rev=246172&r1=246171&r2=246172&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h Thu Aug 27 13:09:44 2015
@@ -21,10 +21,6 @@
 #include "lldb/Symbol/Declaration.h"
 #include "DWARFDIE.h"
 
-class DWARFCompileUnit;
-class DWARFDebugInfoEntry;
-class SymbolFileDWARF;
-
 class UniqueDWARFASTType
 {
 public:

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=246172&r1=246171&r2=246172&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Thu Aug 27 13:09:44 2015
@@ -8761,7 +8761,6 @@ ClangASTContext::DumpTypeDescription (vo
 
 #include "Plugins/SymbolFile/DWARF/DWARFCompileUnit.h"
 #include "Plugins/SymbolFile/DWARF/DWARFDebugInfo.h"
-#include "Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h"
 #include "Plugins/SymbolFile/DWARF/DWARFDeclContext.h"
 #include "Plugins/SymbolFile/DWARF/DWARFDefines.h"
 #include "Plugins/SymbolFile/DWARF/DWARFDIE.h"
@@ -10539,20 +10538,6 @@ ClangASTContext::ParseChildArrayInfo (co
     }
 }
 
-//clang::DeclContext*
-//ClangASTContext::GetClangDeclContextContainingTypeUID (SymbolFileDWARF *dwarf, lldb::user_id_t type_uid)
-//{
-//    DWARFDebugInfo* debug_info = dwarf->DebugInfo();
-//    if (debug_info && dwarf->UserIDMatches(type_uid))
-//    {
-//        DWARFCompileUnitSP cu_sp;
-//        const DWARFDebugInfoEntry* die = debug_info->GetDIEPtr(type_uid, &cu_sp);
-//        if (die)
-//            return GetClangDeclContextContainingDIE (dwarf, cu_sp.get(), die, NULL);
-//    }
-//    return NULL;
-//}
-//
 //----------------------------------------------------------------------
 // CompilerDeclContext functions
 //----------------------------------------------------------------------
@@ -10694,7 +10679,7 @@ ClangASTContext::GetClangDeclContextForD
 {
     if (die)
     {
-        clang::DeclContext *decl_ctx = GetCachedClangDeclContextForDIE (die.GetDIE());
+        clang::DeclContext *decl_ctx = GetCachedClangDeclContextForDIE (die);
         if (decl_ctx)
             return decl_ctx;
 
@@ -10719,7 +10704,7 @@ ClangASTContext::GetClangDeclContextForD
         {
             Type* type = die.GetDWARF()->ResolveType (die);
             if (type)
-                decl_ctx = GetCachedClangDeclContextForDIE (die.GetDIE());
+                decl_ctx = GetCachedClangDeclContextForDIE (die);
         }
 
         if (decl_ctx)
@@ -12244,6 +12229,17 @@ ClangASTContext::ParseTypeFromDWARF (con
     return type_sp;
 }
 
+clang::DeclContext *
+ClangASTContext::GetCachedClangDeclContextForDIE (const DWARFDIE &die)
+{
+    if (die)
+    {
+        DIEToDeclContextMap::iterator pos = m_die_to_decl_ctx.find(die.GetDIE());
+        if (pos != m_die_to_decl_ctx.end())
+            return pos->second;
+    }
+    return nullptr;
+}
 
 void
 ClangASTContext::LinkDeclContextToDIE (clang::DeclContext *decl_ctx, const DWARFDIE &die)
@@ -12491,8 +12487,6 @@ ClangASTContext::CopyUniqueClassMethodTy
     const uint32_t src_size_artificial = src_name_to_die_artificial.GetSize ();
     const uint32_t dst_size_artificial = dst_name_to_die_artificial.GetSize ();
 
-    UniqueCStringMap<const DWARFDebugInfoEntry *> name_to_die_artificial_not_in_src;
-
     if (src_size_artificial && dst_size_artificial)
     {
         dst_name_to_die_artificial.Sort();




More information about the lldb-commits mailing list