[Lldb-commits] [lldb] r118383 - in /lldb/trunk: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h tools/driver/Driver.cpp

Greg Clayton gclayton at apple.com
Sun Nov 7 13:02:03 PST 2010


Author: gclayton
Date: Sun Nov  7 15:02:03 2010
New Revision: 118383

URL: http://llvm.org/viewvc/llvm-project?rev=118383&view=rev
Log:
Modified the DWARF parser for both the single DWARF file and for the case
where the DWARF is in the .o files so they can track down the actual type for
a forward declaration. This was working before for just DWARF files, but not
for DWARF in .o files where the actual definition was in another .o file.

Modified the main thread name in the driver to be more consistent with the
other LLDB thread names.


Modified:
    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/tools/driver/Driver.cpp

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=118383&r1=118382&r2=118383&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Sun Nov  7 15:02:03 2010
@@ -2534,6 +2534,71 @@
     return NULL;
 }
 
+// This function can be used when a DIE is found that is a forward declaration
+// DIE and we want to try and find a type that has the complete definition.
+TypeSP
+SymbolFileDWARF::FindDefinitionTypeForDIE (
+    DWARFCompileUnit* cu, 
+    const DWARFDebugInfoEntry *die, 
+    const ConstString &type_name
+)
+{
+    TypeSP type_sp;
+
+    if (cu == NULL || die == NULL || !type_name)
+        return type_sp;
+
+    const dw_tag_t type_tag = die->Tag();
+    std::vector<NameToDIE::Info> die_info_array;
+    const size_t num_matches = m_type_index.Find (type_name, die_info_array);
+    if (num_matches > 0)
+    {
+        DWARFCompileUnit* type_cu = NULL;
+        DWARFCompileUnit* curr_cu = cu;
+        DWARFDebugInfo *info = DebugInfo();
+        for (size_t i=0; i<num_matches; ++i)
+        {
+            type_cu = info->GetCompileUnitAtIndex (die_info_array[i].cu_idx);
+            
+            if (type_cu != curr_cu)
+            {
+                type_cu->ExtractDIEsIfNeeded (false);
+                curr_cu = type_cu;
+            }
+
+            DWARFDebugInfoEntry *type_die = type_cu->GetDIEAtIndexUnchecked (die_info_array[i].die_idx);
+            
+            if (type_die != die && type_die->Tag() == type_tag)
+            {
+                // Hold off on comparing parent DIE tags until
+                // we know what happens with stuff in namespaces
+                // for gcc and clang...
+                //DWARFDebugInfoEntry *parent_die = die->GetParent();
+                //DWARFDebugInfoEntry *parent_type_die = type_die->GetParent();
+                //if (parent_die->Tag() == parent_type_die->Tag())
+                {
+                    Type *resolved_type = ResolveType (type_cu, type_die, false);
+                    if (resolved_type && resolved_type != DIE_IS_BEING_PARSED)
+                    {
+                        DEBUG_PRINTF ("resolved 0x%8.8x (cu 0x%8.8x) from %s to 0x%8.8x (cu 0x%8.8x)\n",
+                                      die->GetOffset(), 
+                                      dwarf_cu->GetOffset(), 
+                                      m_obj_file->GetFileSpec().GetFilename().AsCString(),
+                                      type_die->GetOffset(), 
+                                      type_cu->GetOffset());
+                        
+                        m_die_to_type[die] = resolved_type;
+                        type_sp = m_obj_file->GetModule()->GetTypeList()->FindType(resolved_type->GetID());
+                        assert (type_sp.get());
+                        break;
+                    }
+                }
+            }
+        }
+    }
+    return type_sp;
+}
+
 TypeSP
 SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool *type_is_new_ptr)
 {
@@ -2786,50 +2851,24 @@
 
                     if (is_forward_declaration)
                     {
-                        // We have a forward declaration
-                        std::vector<NameToDIE::Info> die_info_array;
-                        const size_t num_matches = m_type_index.Find (type_name_const_str, die_info_array);
-                        DWARFCompileUnit* type_cu = NULL;
-                        DWARFCompileUnit* curr_cu = dwarf_cu;
-                        DWARFDebugInfo *info = DebugInfo();
-                        for (size_t i=0; i<num_matches; ++i)
-                        {
-                            type_cu = info->GetCompileUnitAtIndex (die_info_array[i].cu_idx);
-                            
-                            if (type_cu != curr_cu)
-                            {
-                                type_cu->ExtractDIEsIfNeeded (false);
-                                curr_cu = type_cu;
-                            }
+                        // We have a forward declaration to a type and we need
+                        // to try and find a full declaration. We look in the
+                        // current type index just in case we have a forward
+                        // declaration followed by an actual declarations in the
+                        // DWARF. If this fails, we need to look elsewhere...
+                    
+                        type_sp = FindDefinitionTypeForDIE (dwarf_cu, die, type_name_const_str);
 
-                            DWARFDebugInfoEntry *type_die = type_cu->GetDIEAtIndexUnchecked (die_info_array[i].die_idx);
-                            
-                            if (type_die != die && type_die->Tag() == tag)
-                            {
-                                // Hold off on comparing parent DIE tags until
-                                // we know what happens with stuff in namespaces
-                                // for gcc and clang...
-//                                DWARFDebugInfoEntry *parent_die = die->GetParent();
-//                                DWARFDebugInfoEntry *parent_type_die = type_die->GetParent();
-//                                if (parent_die->Tag() == parent_type_die->Tag())
-                                {
-                                    Type *resolved_type = ResolveType (type_cu, type_die, false);
-                                    if (resolved_type && resolved_type != DIE_IS_BEING_PARSED)
-                                    {
-                                        DEBUG_PRINTF ("resolved 0x%8.8x (cu 0x%8.8x) from %s to 0x%8.8x (cu 0x%8.8x)\n",
-                                                      die->GetOffset(), 
-                                                      dwarf_cu->GetOffset(), 
-                                                      m_obj_file->GetFileSpec().GetFilename().AsCString(),
-                                                      type_die->GetOffset(), 
-                                                      type_cu->GetOffset());
-                                        
-                                        m_die_to_type[die] = resolved_type;
-                                        type_sp = m_obj_file->GetModule()->GetTypeList()->FindType(resolved_type->GetID());
-                                        return type_sp;    
-                                    }
-                                }
-                            }
+                        if (!type_sp)
+                        {
+                            // We weren't able to find a full declaration in
+                            // this DWARF, see if we have a declaration anywhere    
+                            // else...
+                            if (m_debug_map_symfile)
+                                type_sp = m_debug_map_symfile->FindDefinitionTypeForDIE (dwarf_cu, die, type_name_const_str);
                         }
+                        if (type_sp)
+                            return type_sp;
                     }
                     assert (tag_decl_kind != -1);
                     bool clang_type_was_created = false;

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=118383&r1=118382&r2=118383&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Sun Nov  7 15:02:03 2010
@@ -279,6 +279,11 @@
                                 const NameToDIE &name_to_die,
                                 lldb_private::SymbolContextList& sc_list);
 
+    lldb::TypeSP            FindDefinitionTypeForDIE (
+                                DWARFCompileUnit* cu, 
+                                const DWARFDebugInfoEntry *die, 
+                                const lldb_private::ConstString &type_name);
+    
     lldb::TypeSP            GetTypeForDIE (DWARFCompileUnit *cu, 
                                            const DWARFDebugInfoEntry* die);
 

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=118383&r1=118382&r2=118383&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Sun Nov  7 15:02:03 2010
@@ -886,6 +886,23 @@
     return sc_list.GetSize() - initial_size;
 }
 
+TypeSP
+SymbolFileDWARFDebugMap::FindDefinitionTypeForDIE (
+    DWARFCompileUnit* cu, 
+    const DWARFDebugInfoEntry *die, 
+    const ConstString &type_name
+)
+{
+    TypeSP type_sp;
+    SymbolFileDWARF *oso_dwarf;
+    for (uint32_t oso_idx = 0; ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx)) != NULL); ++oso_idx)
+    {
+        type_sp = oso_dwarf->FindDefinitionTypeForDIE (cu, die, type_name);
+        if (type_sp)
+            break;
+    }
+    return type_sp;
+}
 
 uint32_t
 SymbolFileDWARFDebugMap::FindTypes 

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=118383&r1=118382&r2=118383&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h Sun Nov  7 15:02:03 2010
@@ -16,6 +16,8 @@
 #include "lldb/Symbol/SymbolFile.h"
 
 class SymbolFileDWARF;
+class DWARFCompileUnit;
+class DWARFDebugInfoEntry;
 
 class SymbolFileDWARFDebugMap : public lldb_private::SymbolFile
 {
@@ -190,6 +192,11 @@
     void
     SetCompileUnit (SymbolFileDWARF *oso_dwarf, const lldb::CompUnitSP &cu_sp);
 
+    lldb::TypeSP
+    FindDefinitionTypeForDIE (DWARFCompileUnit* cu, 
+                              const DWARFDebugInfoEntry *die, 
+                              const lldb_private::ConstString &type_name);    
+
     //------------------------------------------------------------------
     // Member Variables
     //------------------------------------------------------------------

Modified: lldb/trunk/tools/driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=118383&r1=118382&r2=118383&view=diff
==============================================================================
--- lldb/trunk/tools/driver/Driver.cpp (original)
+++ lldb/trunk/tools/driver/Driver.cpp Sun Nov  7 15:02:03 2010
@@ -1375,7 +1375,7 @@
 {
     SBDebugger::Initialize();
     
-    SBHostOS::ThreadCreated ("[main]");
+    SBHostOS::ThreadCreated ("<lldb.driver.main-thread>");
 
     signal (SIGPIPE, SIG_IGN);
     signal (SIGWINCH, sigwinch_handler);





More information about the lldb-commits mailing list