[Lldb-commits] [lldb] r243637 - Fix issues with separate symbolfile handling

Tamas Berghammer tberghammer at google.com
Thu Jul 30 05:38:19 PDT 2015


Author: tberghammer
Date: Thu Jul 30 07:38:18 2015
New Revision: 243637

URL: http://llvm.org/viewvc/llvm-project?rev=243637&view=rev
Log:
Fix issues with separate symbolfile handling

Differential revision: http://reviews.llvm.org/D11595

Modified:
    lldb/trunk/source/Core/Module.cpp
    lldb/trunk/source/Host/common/Symbols.cpp
    lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
    lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp

Modified: lldb/trunk/source/Core/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=243637&r1=243636&r2=243637&view=diff
==============================================================================
--- lldb/trunk/source/Core/Module.cpp (original)
+++ lldb/trunk/source/Core/Module.cpp Thu Jul 30 07:38:18 2015
@@ -1500,6 +1500,9 @@ Module::SetSymbolFileFileSpec (const Fil
                     // we don't have to do anything.
                     return;
                 }
+                
+                // Cleare the current symtab as we are going to replace it with a new one
+                obj_file->ClearSymtab();
 
                 // The symbol file might be a directory bundle ("/tmp/a.out.dSYM") instead
                 // of a full path to the symbol file within the bundle

Modified: lldb/trunk/source/Host/common/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Symbols.cpp?rev=243637&r1=243636&r2=243637&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Symbols.cpp (original)
+++ lldb/trunk/source/Host/common/Symbols.cpp Thu Jul 30 07:38:18 2015
@@ -175,7 +175,7 @@ LocateExecutableSymbolFileDsym (const Mo
                         "LocateExecutableSymbolFileDsym (file = %s, arch = %s, uuid = %p)",
                         exec_fspec ? exec_fspec->GetFilename().AsCString ("<NULL>") : "<NULL>",
                         arch ? arch->GetArchitectureName() : "<NULL>",
-                        (void*)uuid);
+                        (const void*)uuid);
 
     FileSpec symbol_fspec;
     // First try and find the dSYM in the same directory as the executable or in
@@ -198,7 +198,7 @@ Symbols::LocateExecutableObjectFile (con
                         "LocateExecutableObjectFile (file = %s, arch = %s, uuid = %p)",
                         exec_fspec ? exec_fspec->GetFilename().AsCString ("<NULL>") : "<NULL>",
                         arch ? arch->GetArchitectureName() : "<NULL>",
-                        (void*)uuid);
+                        (const void*)uuid);
 
     FileSpec objfile_fspec;
     ModuleSpecList module_specs;
@@ -219,7 +219,11 @@ Symbols::LocateExecutableObjectFile (con
 FileSpec
 Symbols::LocateExecutableSymbolFile (const ModuleSpec &module_spec)
 {
-    const char *symbol_filename = module_spec.GetSymbolFileSpec().GetFilename().AsCString();
+    FileSpec symbol_file_spec = module_spec.GetSymbolFileSpec();
+    if (symbol_file_spec.IsAbsolute() && symbol_file_spec.Exists())
+        return symbol_file_spec;
+
+    const char *symbol_filename = symbol_file_spec.GetFilename().AsCString();
     if (symbol_filename && symbol_filename[0])
     {
         FileSpecList debug_file_search_paths (Target::GetDefaultDebugFileSearchPaths());

Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=243637&r1=243636&r2=243637&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Thu Jul 30 07:38:18 2015
@@ -905,8 +905,17 @@ ObjectFileELF::GetAddressByteSize() cons
 AddressClass
 ObjectFileELF::GetAddressClass (addr_t file_addr)
 {
-    auto res = ObjectFile::GetAddressClass (file_addr);
+    Symtab* symtab = GetSymtab();
+    if (!symtab)
+        return eAddressClassUnknown;
+
+    // The address class is determined based on the symtab. Ask it from the object file what
+    // contains the symtab information.
+    ObjectFile* symtab_objfile = symtab->GetObjectFile();
+    if (symtab_objfile != nullptr && symtab_objfile != this)
+        return symtab_objfile->GetAddressClass(file_addr);
 
+    auto res = ObjectFile::GetAddressClass (file_addr);
     if (res != eAddressClassCode)
         return res;
 
@@ -1976,7 +1985,6 @@ ObjectFileELF::ParseSymbols (Symtab *sym
                             m_address_class_map[symbol.st_value] = eAddressClassData;
                         }
                     }
-
                     continue;
                 }
             }
@@ -2031,9 +2039,13 @@ ObjectFileELF::ParseSymbols (Symtab *sym
             }
         }
 
-        // If the symbol section we've found has no data (SHT_NOBITS), then check the module section
-        // list. This can happen if we're parsing the debug file and it has no .text section, for example.
-        if (symbol_section_sp && (symbol_section_sp->GetFileSize() == 0))
+        // symbol_value_offset may contain 0 for ARM symbols or -1 for
+        // THUMB symbols. See above for more details.
+        uint64_t symbol_value = symbol.st_value + symbol_value_offset;
+        if (symbol_section_sp && CalculateType() != ObjectFile::Type::eTypeObjectFile)
+            symbol_value -= symbol_section_sp->GetFileAddress();
+
+        if (symbol_section_sp)
         {
             ModuleSP module_sp(GetModule());
             if (module_sp)
@@ -2051,11 +2063,6 @@ ObjectFileELF::ParseSymbols (Symtab *sym
             }
         }
 
-        // symbol_value_offset may contain 0 for ARM symbols or -1 for
-        // THUMB symbols. See above for more details.
-        uint64_t symbol_value = symbol.st_value + symbol_value_offset;
-        if (symbol_section_sp && CalculateType() != ObjectFile::Type::eTypeObjectFile)
-            symbol_value -= symbol_section_sp->GetFileAddress();
         bool is_global = symbol.getBinding() == STB_GLOBAL;
         uint32_t flags = symbol.st_other << 8 | symbol.st_info | additional_flags;
         bool is_mangled = symbol_name ? (symbol_name[0] == '_' && symbol_name[1] == 'Z') : false;
@@ -2563,8 +2570,6 @@ ObjectFileELF::GetSymtab()
         uint64_t symbol_id = 0;
         lldb_private::Mutex::Locker locker(module_sp->GetMutex());
 
-        m_symtab_ap.reset(new Symtab(this));
-
         // Sharable objects and dynamic executables usually have 2 distinct symbol
         // tables, one named ".symtab", and the other ".dynsym". The dynsym is a smaller
         // version of the symtab that only contains global symbols. The information found
@@ -2578,7 +2583,10 @@ ObjectFileELF::GetSymtab()
             symtab = section_list->FindSectionByType (eSectionTypeELFDynamicSymbols, true).get();
         }
         if (symtab)
+        {
+            m_symtab_ap.reset(new Symtab(symtab->GetObjectFile()));
             symbol_id += ParseSymbolTable (m_symtab_ap.get(), symbol_id, symtab);
+        }
 
         // DT_JMPREL
         //      If present, this entry's d_ptr member holds the address of relocation
@@ -2598,10 +2606,19 @@ ObjectFileELF::GetSymtab()
                 user_id_t reloc_id = reloc_section->GetID();
                 const ELFSectionHeaderInfo *reloc_header = GetSectionHeaderByIndex(reloc_id);
                 assert(reloc_header);
+                
+                if (m_symtab_ap == nullptr)
+                    m_symtab_ap.reset(new Symtab(reloc_section->GetObjectFile()));
 
                 ParseTrampolineSymbols (m_symtab_ap.get(), symbol_id, reloc_header, reloc_id);
             }
         }
+        
+        // If we still don't have any symtab then create an empty instance to avoid do the section
+        // lookup next time.
+        if (m_symtab_ap == nullptr)
+            m_symtab_ap.reset(new Symtab(this));
+            
         m_symtab_ap->CalculateSymbolSizes();
     }
 

Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp?rev=243637&r1=243636&r2=243637&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp Thu Jul 30 07:38:18 2015
@@ -115,6 +115,7 @@ SymbolFileSymtab::CalculateAbilities ()
             if (symtab->AppendSymbolIndexesWithType(eSymbolTypeCode, Symtab::eDebugNo, Symtab::eVisibilityAny, m_code_indexes))
             {
                 symtab->SortSymbolIndexesByValue(m_code_indexes, true);
+                abilities |= Functions;
             }
 
             if (symtab->AppendSymbolIndexesWithType(eSymbolTypeData, m_data_indexes))





More information about the lldb-commits mailing list