[Lldb-commits] [lldb] r123889 - in /lldb/trunk: include/lldb/Symbol/Symtab.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp source/Symbol/Symtab.cpp

Greg Clayton gclayton at apple.com
Wed Jan 19 22:08:59 PST 2011


Author: gclayton
Date: Thu Jan 20 00:08:59 2011
New Revision: 123889

URL: http://llvm.org/viewvc/llvm-project?rev=123889&view=rev
Log:
Made the DWARF + debug map symbol file parser be much more efficient when it isn't
going to actually be used as the symbol file plug-in by looking only for suitable
N_OSO symbols and avoiding sorting function (N_FUN) and global/static (N_GSYM/N_STSYM)
symbols when there are no suitable N_OSO objects.


Modified:
    lldb/trunk/include/lldb/Symbol/Symtab.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
    lldb/trunk/source/Symbol/Symtab.cpp

Modified: lldb/trunk/include/lldb/Symbol/Symtab.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Symtab.h?rev=123889&r1=123888&r2=123889&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Symtab.h (original)
+++ lldb/trunk/include/lldb/Symbol/Symtab.h Thu Jan 20 00:08:59 2011
@@ -55,6 +55,7 @@
             Symbol *    FindSymbolWithType (lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, uint32_t &start_idx);
 //    const   Symbol *    FindSymbolWithType (lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, uint32_t &start_idx) const;
             uint32_t    AppendSymbolIndexesWithType (lldb::SymbolType symbol_type, std::vector<uint32_t>& indexes, uint32_t start_idx = 0, uint32_t end_index = UINT32_MAX) const;
+            uint32_t    AppendSymbolIndexesWithTypeAndFlagsValue (lldb::SymbolType symbol_type, uint32_t flags_value, std::vector<uint32_t>& indexes, uint32_t start_idx = 0, uint32_t end_index = UINT32_MAX) const;
             uint32_t    AppendSymbolIndexesWithType (lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t>& matches, uint32_t start_idx = 0, uint32_t end_index = UINT32_MAX) const;
             uint32_t    AppendSymbolIndexesWithName (const ConstString& symbol_name, std::vector<uint32_t>& matches);
             uint32_t    AppendSymbolIndexesWithName (const ConstString& symbol_name, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t>& matches);

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=123889&r1=123888&r2=123889&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Thu Jan 20 00:08:59 2011
@@ -103,18 +103,29 @@
     Symtab* symtab = m_obj_file->GetSymtab();
     if (symtab)
     {
-        //StreamFile s(0, 4, eByteOrderHost, stdout);
         std::vector<uint32_t> oso_indexes;
-        const uint32_t oso_index_count = symtab->AppendSymbolIndexesWithType(eSymbolTypeObjectFile, oso_indexes);
+//      StreamFile s(stdout);
+//      symtab->Dump(&s, NULL, eSortOrderNone);
 
-        symtab->AppendSymbolIndexesWithType (eSymbolTypeCode, Symtab::eDebugYes, Symtab::eVisibilityAny, m_func_indexes);
-        symtab->AppendSymbolIndexesWithType (eSymbolTypeData, Symtab::eDebugYes, Symtab::eVisibilityAny, m_glob_indexes);
+        // When a mach-o symbol is encoded, the n_type field is encoded in bits
+        // 23:16, and the n_desc field is encoded in bits 15:0.
+        // 
+        // To find all N_OSO entries that are part of the DWARF + debug map
+        // we find only object file symbols with the flags value as follows:
+        // bits 23:16 == 0x66 (N_OSO)
+        // bits 15: 0 == 0x0001 (specifies this is a debug map object file)
+        const uint32_t k_oso_symbol_flags_value = 0x660001u;
 
-        symtab->SortSymbolIndexesByValue(m_func_indexes, true);
-        symtab->SortSymbolIndexesByValue(m_glob_indexes, true);
+        const uint32_t oso_index_count = symtab->AppendSymbolIndexesWithTypeAndFlagsValue(eSymbolTypeObjectFile, k_oso_symbol_flags_value, oso_indexes);
 
         if (oso_index_count > 0)
         {
+            symtab->AppendSymbolIndexesWithType (eSymbolTypeCode, Symtab::eDebugYes, Symtab::eVisibilityAny, m_func_indexes);
+            symtab->AppendSymbolIndexesWithType (eSymbolTypeData, Symtab::eDebugYes, Symtab::eVisibilityAny, m_glob_indexes);
+
+            symtab->SortSymbolIndexesByValue(m_func_indexes, true);
+            symtab->SortSymbolIndexesByValue(m_glob_indexes, true);
+
             m_compile_unit_infos.resize(oso_index_count);
 //          s.Printf("%s N_OSO symbols:\n", __PRETTY_FUNCTION__);
 //          symtab->Dump(&s, oso_indexes);

Modified: lldb/trunk/source/Symbol/Symtab.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symtab.cpp?rev=123889&r1=123888&r2=123889&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Symtab.cpp (original)
+++ lldb/trunk/source/Symbol/Symtab.cpp Thu Jan 20 00:08:59 2011
@@ -332,6 +332,24 @@
 }
 
 uint32_t
+Symtab::AppendSymbolIndexesWithTypeAndFlagsValue (SymbolType symbol_type, uint32_t flags_value, std::vector<uint32_t>& indexes, uint32_t start_idx, uint32_t end_index) const
+{
+    Mutex::Locker locker (m_mutex);
+
+    uint32_t prev_size = indexes.size();
+
+    const uint32_t count = std::min<uint32_t> (m_symbols.size(), end_index);
+
+    for (uint32_t i = start_idx; i < count; ++i)
+    {
+        if ((symbol_type == eSymbolTypeAny || m_symbols[i].GetType() == symbol_type) && m_symbols[i].GetFlags() == flags_value)
+            indexes.push_back(i);
+    }
+
+    return indexes.size() - prev_size;
+}
+
+uint32_t
 Symtab::AppendSymbolIndexesWithType (SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t>& indexes, uint32_t start_idx, uint32_t end_index) const
 {
     Mutex::Locker locker (m_mutex);





More information about the lldb-commits mailing list