[Lldb-commits] [lldb] r113678 - in /lldb/trunk: include/lldb/Symbol/Symtab.h include/lldb/lldb-enumerations.h source/Commands/CommandObjectImage.cpp source/Core/Module.cpp source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp source/Symbol/Symbol.cpp source/Symbol/Symtab.cpp

Greg Clayton gclayton at apple.com
Fri Sep 10 20:13:28 PDT 2010


Author: gclayton
Date: Fri Sep 10 22:13:28 2010
New Revision: 113678

URL: http://llvm.org/viewvc/llvm-project?rev=113678&view=rev
Log:
Remove the eSymbolTypeFunction, eSymbolTypeGlobal, and eSymbolTypeStatic.
They will now be represented as:
eSymbolTypeFunction: eSymbolTypeCode with IsDebug() == true
  eSymbolTypeGlobal: eSymbolTypeData with IsDebug() == true and IsExternal() == true
  eSymbolTypeStatic: eSymbolTypeData with IsDebug() == true and IsExternal() == false

This simplifies the logic when dealing with symbols and allows for symbols
to be coalesced into a single symbol most of the time.

Enabled the minimal symbol table for mach-o again after working out all the
kinks. We now get nice concise symbol tables and debugging with DWARF in the
.o files with a debug map in the binary works well again. There were issues
where the SymbolFileDWARFDebugMap symbol file parser was using symbol IDs and
symbol indexes interchangeably. Now that all those issues are resolved 
debugging is working nicely.


Modified:
    lldb/trunk/include/lldb/Symbol/Symtab.h
    lldb/trunk/include/lldb/lldb-enumerations.h
    lldb/trunk/source/Commands/CommandObjectImage.cpp
    lldb/trunk/source/Core/Module.cpp
    lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
    lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
    lldb/trunk/source/Symbol/Symbol.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=113678&r1=113677&r2=113678&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Symtab.h (original)
+++ lldb/trunk/include/lldb/Symbol/Symtab.h Fri Sep 10 22:13:28 2010
@@ -22,6 +22,18 @@
 class Symtab
 {
 public:
+        typedef enum Debug {
+            eDebugNo,    // Not a debug symbol
+            eDebugYes,    // A debug symbol 
+            eDebugAny
+        } Debug;
+
+        typedef enum Visibility {
+            eVisibilityAny,
+            eVisibilityExtern,
+            eVisibilityPrivate
+        } Visibility;
+        
                         Symtab(ObjectFile *objfile);
                         ~Symtab();
 
@@ -31,19 +43,24 @@
             size_t      GetNumSymbols() const;
             void        Dump(Stream *s, Process *process) const;
             void        Dump(Stream *s, Process *process, std::vector<uint32_t>& indexes) const;
-
+            uint32_t    GetIndexForSymbol (const Symbol *symbol) const;
             Symbol *    FindSymbolByID (lldb::user_id_t uid) const;
             Symbol *    SymbolAtIndex (uint32_t idx);
     const   Symbol *    SymbolAtIndex (uint32_t idx) const;
-            Symbol *    FindSymbolWithType (lldb::SymbolType symbol_type, uint32_t &start_idx);
-    const   Symbol *    FindSymbolWithType (lldb::SymbolType symbol_type, uint32_t &start_idx) const;
-            uint32_t    AppendSymbolIndexesWithType (lldb::SymbolType symbol_type, std::vector<uint32_t>& matches, uint32_t start_idx = 0, uint32_t end_index = UINT_MAX) const;
+            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 = UINT_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 = UINT_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);
             uint32_t    AppendSymbolIndexesWithNameAndType (const ConstString& symbol_name, lldb::SymbolType symbol_type, std::vector<uint32_t>& matches);
+            uint32_t    AppendSymbolIndexesWithNameAndType (const ConstString& symbol_name, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t>& matches);
             uint32_t    AppendSymbolIndexesMatchingRegExAndType (const RegularExpression &regex, lldb::SymbolType symbol_type, std::vector<uint32_t>& indexes);
+            uint32_t    AppendSymbolIndexesMatchingRegExAndType (const RegularExpression &regex, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t>& indexes);
             size_t      FindAllSymbolsWithNameAndType (const ConstString &name, lldb::SymbolType symbol_type, std::vector<uint32_t>& symbol_indexes);
-            size_t      FindAllSymbolsMatchingRexExAndType (const RegularExpression &regex, lldb::SymbolType symbol_type, std::vector<uint32_t>& symbol_indexes);
-            Symbol *    FindFirstSymbolWithNameAndType (const ConstString &name, lldb::SymbolType symbol_type = lldb::eSymbolTypeAny);
+            size_t      FindAllSymbolsWithNameAndType (const ConstString &name, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t>& symbol_indexes);
+            size_t      FindAllSymbolsMatchingRexExAndType (const RegularExpression &regex, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t>& symbol_indexes);
+            Symbol *    FindFirstSymbolWithNameAndType (const ConstString &name, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility);
             Symbol *    FindSymbolWithFileAddress (lldb::addr_t file_addr);
 //            Symbol *    FindSymbolContainingAddress (const Address& value, const uint32_t* indexes, uint32_t num_indexes);
 //            Symbol *    FindSymbolContainingAddress (const Address& value);
@@ -69,6 +86,41 @@
     UniqueCStringMap<uint32_t> m_name_to_index;
 
 private:
+
+    bool
+    CheckSymbolAtIndex (uint32_t idx, Debug symbol_debug_type, Visibility symbol_visibility) const
+    {
+        switch (symbol_debug_type)
+        {
+        case eDebugNo:
+            if (m_symbols[idx].IsDebug() == true)
+                return false;
+            break;
+            
+        case eDebugYes:
+            if (m_symbols[idx].IsDebug() == false)
+                return false;
+            break;
+
+        case eDebugAny: 
+            break;
+        }
+        
+        switch (symbol_visibility)
+        {
+        case eVisibilityAny:
+            return true;
+
+        case eVisibilityExtern:
+            return m_symbols[idx].IsExternal();
+        
+        case eVisibilityPrivate:
+            return !m_symbols[idx].IsExternal();
+        }
+        return false;
+    }
+
+
     DISALLOW_COPY_AND_ASSIGN (Symtab);
 };
 

Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=113678&r1=113677&r2=113678&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Fri Sep 10 22:13:28 2010
@@ -248,12 +248,8 @@
     eSymbolTypeSourceFile,
     eSymbolTypeHeaderFile,
     eSymbolTypeObjectFile,
-    eSymbolTypeFunction,
-    eSymbolTypeFunctionEnd,
     eSymbolTypeCommonBlock,
     eSymbolTypeBlock,
-    eSymbolTypeStatic,
-    eSymbolTypeGlobal,
     eSymbolTypeLocal,
     eSymbolTypeParam,
     eSymbolTypeVariable,

Modified: lldb/trunk/source/Commands/CommandObjectImage.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectImage.cpp?rev=113678&r1=113677&r2=113678&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectImage.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectImage.cpp Fri Sep 10 22:13:28 2010
@@ -276,7 +276,8 @@
                 if (name_is_regex)
                 {
                     RegularExpression name_regexp(name);
-                    num_matches = symtab->AppendSymbolIndexesMatchingRegExAndType (name_regexp, eSymbolTypeAny,
+                    num_matches = symtab->AppendSymbolIndexesMatchingRegExAndType (name_regexp, 
+                                                                                   eSymbolTypeAny,
                                                                                    match_indexes);
                 }
                 else

Modified: lldb/trunk/source/Core/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=113678&r1=113677&r2=113678&view=diff
==============================================================================
--- lldb/trunk/source/Core/Module.cpp (original)
+++ lldb/trunk/source/Core/Module.cpp Fri Sep 10 22:13:28 2010
@@ -438,7 +438,7 @@
     {
         Symtab *symtab = objfile->GetSymtab();
         if (symtab)
-            return symtab->FindFirstSymbolWithNameAndType (name, symbol_type);
+            return symtab->FindFirstSymbolWithNameAndType (name, symbol_type, Symtab::eDebugAny, Symtab::eVisibilityAny);
     }
     return NULL;
 }
@@ -506,7 +506,7 @@
         if (symtab)
         {
             std::vector<uint32_t> symbol_indexes;
-            symtab->FindAllSymbolsMatchingRexExAndType (regex, symbol_type, symbol_indexes);
+            symtab->FindAllSymbolsMatchingRexExAndType (regex, symbol_type, Symtab::eDebugAny, Symtab::eVisibilityAny, symbol_indexes);
             SymbolIndicesToSymbolContextList (symtab, symbol_indexes, sc_list);
         }
     }

Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=113678&r1=113677&r2=113678&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Fri Sep 10 22:13:28 2010
@@ -206,7 +206,7 @@
     if (m_symtab_ap.get() == NULL)
     {
         m_symtab_ap.reset(new Symtab(this));
-        ParseSymtab (false);
+        ParseSymtab (true);
     }
     return m_symtab_ap.get();
 }
@@ -638,7 +638,7 @@
                     // ...
                     assert (!"UNIMPLEMENTED: Swap all nlist entries");
                 }
-                uint32_t N_SO_index = UINT_MAX;
+                uint32_t N_SO_index = UINT32_MAX;
 
                 MachSymtabSectionInfo section_info (section_list);
                 std::vector<uint32_t> N_FUN_indexes;
@@ -647,8 +647,12 @@
                 std::vector<uint32_t> N_BRAC_indexes;
                 std::vector<uint32_t> N_COMM_indexes;
                 typedef std::map <uint64_t, uint32_t> ValueToSymbolIndexMap;
+                typedef std::map <uint32_t, uint32_t> IndexToIndexMap;
                 ValueToSymbolIndexMap N_FUN_addr_to_sym_idx;
                 ValueToSymbolIndexMap N_STSYM_addr_to_sym_idx;
+                // Any symbols that get merged into another will get an entry
+                // in this map so we know
+                IndexToIndexMap m_index_map;
                 uint32_t nlist_idx = 0;
                 Symbol *symbol_ptr = NULL;
 
@@ -693,21 +697,22 @@
                         case StabGlobalSymbol:    
                             // N_GSYM -- global symbol: name,,NO_SECT,type,0
                             // Sometimes the N_GSYM value contains the address.
+                            sym[sym_idx].SetExternal(true);
                             if (nlist.n_value != 0)
                                 symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value);
-                            type = eSymbolTypeGlobal;
+                            type = eSymbolTypeData;
                             break;
 
                         case StabFunctionName:
                             // N_FNAME -- procedure name (f77 kludge): name,,NO_SECT,0,0
-                            type = eSymbolTypeFunction;
+                            type = eSymbolTypeCompiler;
                             break;
 
                         case StabFunction:       
                             // N_FUN -- procedure: name,,n_sect,linenumber,address
                             if (symbol_name)
                             {
-                                type = eSymbolTypeFunction;
+                                type = eSymbolTypeCode;
                                 symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value);
                                 
                                 N_FUN_addr_to_sym_idx[nlist.n_value] = sym_idx;
@@ -717,7 +722,7 @@
                             }
                             else
                             {
-                                type = eSymbolTypeFunctionEnd;
+                                type = eSymbolTypeCompiler;
 
                                 if ( !N_FUN_indexes.empty() )
                                 {
@@ -738,7 +743,7 @@
                             // N_STSYM -- static symbol: name,,n_sect,type,address
                             N_STSYM_addr_to_sym_idx[nlist.n_value] = sym_idx;
                             symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value);
-                            type = eSymbolTypeStatic;
+                            type = eSymbolTypeData;
                             break;
 
                         case StabLocalCommon:
@@ -814,20 +819,15 @@
                             type = eSymbolTypeSourceFile;
                             if (symbol_name == NULL)
                             {
-                                if (N_SO_index == UINT_MAX)
-                                {
-                                    // Skip the extra blank N_SO entries that happen when the entire
-                                    // path is contained in the second consecutive N_SO STAB.
-                                    if (minimize)
-                                        add_nlist = false;
-                                }
-                                else
+                                if (minimize)
+                                    add_nlist = false;
+                                if (N_SO_index != UINT32_MAX)
                                 {
                                     // Set the size of the N_SO to the terminating index of this N_SO
                                     // so that we can always skip the entire N_SO if we need to navigate
                                     // more quickly at the source level when parsing STABS
                                     symbol_ptr = symtab->SymbolAtIndex(N_SO_index);
-                                    symbol_ptr->SetByteSize(sym_idx + 1);
+                                    symbol_ptr->SetByteSize(sym_idx + (minimize ? 0 : 1));
                                     symbol_ptr->SetSizeIsSibling(true);
                                 }
                                 N_NSYM_indexes.clear();
@@ -835,14 +835,30 @@
                                 N_BRAC_indexes.clear();
                                 N_COMM_indexes.clear();
                                 N_FUN_indexes.clear();
-                                N_SO_index = UINT_MAX;
+                                N_SO_index = UINT32_MAX;
                             }
-                            else if (symbol_name[0] == '/')
+                            else
                             {
                                 // We use the current number of symbols in the symbol table in lieu of
                                 // using nlist_idx in case we ever start trimming entries out
-                                N_SO_index = sym_idx;
+                                if (symbol_name[0] == '/')
+                                    N_SO_index = sym_idx;
+                                else if (minimize && (N_SO_index == sym_idx - 1))
+                                {
+                                    const char *so_path = sym[sym_idx - 1].GetMangled().GetDemangledName().AsCString();
+                                    if (so_path && so_path[0])
+                                    {
+                                        std::string full_so_path (so_path);
+                                        if (*full_so_path.rbegin() != '/')
+                                            full_so_path += '/';
+                                        full_so_path += symbol_name;
+                                        sym[sym_idx - 1].GetMangled().SetValue(full_so_path.c_str(), false);
+                                        add_nlist = false;
+                                        m_index_map[nlist_idx] = sym_idx - 1;
+                                    }
+                                }
                             }
+                            
                             break;
 
                         case StabObjectFileName:
@@ -1103,45 +1119,48 @@
 
                         if (symbol_name)
                             sym[sym_idx].GetMangled().SetValue(symbol_name, symbol_name_is_mangled);
-                        if (type == eSymbolTypeCode)
+                        if (is_debug == false)
                         {
-                            // See if we can find a N_FUN entry for any code symbols.
-                            // If we do find a match, and the name matches, then we
-                            // can merge the two into just the function symbol to avoid
-                            // duplicate entries in the symbol table
-                            ValueToSymbolIndexMap::const_iterator pos = N_FUN_addr_to_sym_idx.find (nlist.n_value);
-                            if (pos != N_FUN_addr_to_sym_idx.end())
+                            if (type == eSymbolTypeCode)
                             {
-                                if ((symbol_name_is_mangled == true && sym[sym_idx].GetMangled().GetMangledName() == sym[pos->second].GetMangled().GetMangledName()) ||
-                                    (symbol_name_is_mangled == false && sym[sym_idx].GetMangled().GetDemangledName() == sym[pos->second].GetMangled().GetDemangledName()))
+                                // See if we can find a N_FUN entry for any code symbols.
+                                // If we do find a match, and the name matches, then we
+                                // can merge the two into just the function symbol to avoid
+                                // duplicate entries in the symbol table
+                                ValueToSymbolIndexMap::const_iterator pos = N_FUN_addr_to_sym_idx.find (nlist.n_value);
+                                if (pos != N_FUN_addr_to_sym_idx.end())
                                 {
-                                
-                                    // We just need the flags from the linker symbol, so put these flags
-                                    // into the N_FUN flags to avoid duplicate symbols in the symbol table
-                                    sym[pos->second].SetFlags (nlist.n_type << 16 | nlist.n_desc);
-                                    sym[sym_idx].GetMangled().Clear();
-                                    continue;
+                                    if ((symbol_name_is_mangled == true && sym[sym_idx].GetMangled().GetMangledName() == sym[pos->second].GetMangled().GetMangledName()) ||
+                                        (symbol_name_is_mangled == false && sym[sym_idx].GetMangled().GetDemangledName() == sym[pos->second].GetMangled().GetDemangledName()))
+                                    {
+                                        m_index_map[nlist_idx] = pos->second;
+                                        // We just need the flags from the linker symbol, so put these flags
+                                        // into the N_FUN flags to avoid duplicate symbols in the symbol table
+                                        sym[pos->second].SetFlags (nlist.n_type << 16 | nlist.n_desc);
+                                        sym[sym_idx].Clear();
+                                        continue;
+                                    }
                                 }
                             }
-                        }
-                        else if (type == eSymbolTypeData)
-                        {
-                            // See if we can find a N_STSYM entry for any data symbols.
-                            // If we do find a match, and the name matches, then we
-                            // can merge the two into just the Static symbol to avoid
-                            // duplicate entries in the symbol table
-                            ValueToSymbolIndexMap::const_iterator pos = N_STSYM_addr_to_sym_idx.find (nlist.n_value);
-                            if (pos != N_STSYM_addr_to_sym_idx.end())
+                            else if (type == eSymbolTypeData)
                             {
-                                if ((symbol_name_is_mangled == true && sym[sym_idx].GetMangled().GetMangledName() == sym[pos->second].GetMangled().GetMangledName()) ||
-                                    (symbol_name_is_mangled == false && sym[sym_idx].GetMangled().GetDemangledName() == sym[pos->second].GetMangled().GetDemangledName()))
+                                // See if we can find a N_STSYM entry for any data symbols.
+                                // If we do find a match, and the name matches, then we
+                                // can merge the two into just the Static symbol to avoid
+                                // duplicate entries in the symbol table
+                                ValueToSymbolIndexMap::const_iterator pos = N_STSYM_addr_to_sym_idx.find (nlist.n_value);
+                                if (pos != N_STSYM_addr_to_sym_idx.end())
                                 {
-                                
-                                    // We just need the flags from the linker symbol, so put these flags
-                                    // into the N_STSYM flags to avoid duplicate symbols in the symbol table
-                                    sym[pos->second].SetFlags (nlist.n_type << 16 | nlist.n_desc);
-                                    sym[sym_idx].GetMangled().Clear();
-                                    continue;
+                                    if ((symbol_name_is_mangled == true && sym[sym_idx].GetMangled().GetMangledName() == sym[pos->second].GetMangled().GetMangledName()) ||
+                                        (symbol_name_is_mangled == false && sym[sym_idx].GetMangled().GetDemangledName() == sym[pos->second].GetMangled().GetDemangledName()))
+                                    {
+                                        m_index_map[nlist_idx] = pos->second;
+                                        // We just need the flags from the linker symbol, so put these flags
+                                        // into the N_STSYM flags to avoid duplicate symbols in the symbol table
+                                        sym[pos->second].SetFlags (nlist.n_type << 16 | nlist.n_desc);
+                                        sym[sym_idx].Clear();
+                                        continue;
+                                    }
                                 }
                             }
                         }
@@ -1171,13 +1190,13 @@
 
                 Symbol *global_symbol = NULL;
                 for (nlist_idx = 0;
-                     nlist_idx < symtab_load_command.nsyms && (global_symbol = symtab->FindSymbolWithType(eSymbolTypeGlobal, nlist_idx)) != NULL;
+                     nlist_idx < symtab_load_command.nsyms && (global_symbol = symtab->FindSymbolWithType (eSymbolTypeData, Symtab::eDebugYes, Symtab::eVisibilityAny, nlist_idx)) != NULL;
                      nlist_idx++)
                 {
                     if (global_symbol->GetValue().GetFileAddress() == 0)
                     {
                         std::vector<uint32_t> indexes;
-                        if (symtab->AppendSymbolIndexesWithName(global_symbol->GetMangled().GetName(), indexes) > 0)
+                        if (symtab->AppendSymbolIndexesWithName (global_symbol->GetMangled().GetName(), indexes) > 0)
                         {
                             std::vector<uint32_t>::const_iterator pos;
                             std::vector<uint32_t>::const_iterator end = indexes.end();
@@ -1200,6 +1219,7 @@
 
                     if (indirect_symbol_indexes_sp && indirect_symbol_indexes_sp->GetByteSize())
                     {
+                        IndexToIndexMap::const_iterator end_index_pos = m_index_map.end();
                         DataExtractor indirect_symbol_index_data (indirect_symbol_indexes_sp, m_data.GetByteOrder(), m_data.GetAddressByteSize());
 
                         for (uint32_t sect_idx = 1; sect_idx < m_mach_sections.size(); ++sect_idx)
@@ -1224,7 +1244,12 @@
                                     uint32_t symbol_stub_offset = symbol_stub_index * 4;
                                     if (indirect_symbol_index_data.ValidOffsetForDataOfSize(symbol_stub_offset, 4))
                                     {
-                                        const uint32_t symbol_index = indirect_symbol_index_data.GetU32 (&symbol_stub_offset);
+                                        uint32_t symbol_index = indirect_symbol_index_data.GetU32 (&symbol_stub_offset);
+
+                                        IndexToIndexMap::const_iterator index_pos = m_index_map.find (symbol_index);
+                                        assert (index_pos == end_index_pos); // TODO: remove this assert if it fires, else remove m_index_map
+                                        if (index_pos != end_index_pos)
+                                            symbol_index = index_pos->second;
 
                                         Symbol *stub_symbol = symtab->FindSymbolByID (symbol_index);
 

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=113678&r1=113677&r2=113678&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Fri Sep 10 22:13:28 2010
@@ -91,8 +91,8 @@
         std::vector<uint32_t> oso_indexes;
         const uint32_t oso_index_count = symtab->AppendSymbolIndexesWithType(eSymbolTypeObjectFile, oso_indexes);
 
-        symtab->AppendSymbolIndexesWithType(eSymbolTypeFunction, m_func_indexes);
-        symtab->AppendSymbolIndexesWithType(eSymbolTypeGlobal, m_glob_indexes);
+        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);
@@ -109,6 +109,12 @@
                 if (m_compile_unit_infos[i].so_symbol->GetSiblingIndex() == 0)
                     m_compile_unit_infos[i].so_symbol = symtab->SymbolAtIndex(oso_indexes[i] - 2);
                 m_compile_unit_infos[i].oso_symbol = symtab->SymbolAtIndex(oso_indexes[i]);
+                uint32_t sibling_idx = m_compile_unit_infos[i].so_symbol->GetSiblingIndex();
+                assert (sibling_idx != 0);
+                assert (sibling_idx > i + 1);
+                m_compile_unit_infos[i].last_symbol = symtab->SymbolAtIndex (sibling_idx - 1);
+                m_compile_unit_infos[i].first_symbol_index = symtab->GetIndexForSymbol(m_compile_unit_infos[i].so_symbol);
+                m_compile_unit_infos[i].last_symbol_index = symtab->GetIndexForSymbol(m_compile_unit_infos[i].last_symbol);
             }
         }
     }
@@ -243,7 +249,9 @@
                 //SectionList *oso_sections = oso_objfile->Sections();
                 // Now we need to make sections that map from zero based object
                 // file addresses to where things eneded up in the main executable.
-                uint32_t oso_start_idx = comp_unit_info->oso_symbol->GetID() + 1;
+                uint32_t oso_start_idx = exe_symtab->GetIndexForSymbol (comp_unit_info->oso_symbol);
+                assert (oso_start_idx != UINT32_MAX);
+                oso_start_idx += 1;
                 const uint32_t oso_end_idx = comp_unit_info->so_symbol->GetSiblingIndex();
                 uint32_t sect_id = 0x10000;
                 for (uint32_t idx = oso_start_idx; idx < oso_end_idx; ++idx)
@@ -251,9 +259,12 @@
                     Symbol *exe_symbol = exe_symtab->SymbolAtIndex(idx);
                     if (exe_symbol)
                     {
+                        if (exe_symbol->IsDebug() == false)
+                            continue;
+
                         switch (exe_symbol->GetType())
                         {
-                        case eSymbolTypeFunction:
+                        case eSymbolTypeCode:
                             {
                                 // For each N_FUN, or function that we run into in the debug map
                                 // we make a new section that we add to the sections found in the
@@ -265,7 +276,7 @@
                                 // correctly to the new addresses in the main executable.
 
                                 // First we find the original symbol in the .o file's symbol table
-                                Symbol *oso_fun_symbol = oso_symtab->FindFirstSymbolWithNameAndType(exe_symbol->GetMangled().GetName(), eSymbolTypeCode);
+                                Symbol *oso_fun_symbol = oso_symtab->FindFirstSymbolWithNameAndType(exe_symbol->GetMangled().GetName(), eSymbolTypeCode, Symtab::eDebugNo, Symtab::eVisibilityAny);
                                 if (oso_fun_symbol)
                                 {
                                     // If we found the symbol, then we
@@ -299,8 +310,7 @@
                             }
                             break;
 
-                        case eSymbolTypeGlobal:
-                        case eSymbolTypeStatic:
+                        case eSymbolTypeData:
                             {
                                 // For each N_GSYM we remap the address for the global by making
                                 // a new section that we add to the sections found in the .o file.
@@ -317,7 +327,7 @@
 
 #if 0
                                 // First we find the non-stab entry that corresponds to the N_GSYM in the executable
-                                Symbol *exe_gsym_symbol = exe_symtab->FindFirstSymbolWithNameAndType(exe_symbol->GetMangled().GetName(), eSymbolTypeData);
+                                Symbol *exe_gsym_symbol = exe_symtab->FindFirstSymbolWithNameAndType(exe_symbol->GetMangled().GetName(), eSymbolTypeData, Symtab::eDebugNo, Symtab::eVisibilityAny);
 #else
                                 // The mach-o object file parser already matches up the N_GSYM with with the non-stab
                                 // entry, so we shouldn't have to do that. If this ever changes, enable the code above
@@ -325,7 +335,7 @@
                                 Symbol *exe_gsym_symbol = exe_symbol;
 #endif
                                 // Next we find the non-stab entry that corresponds to the N_GSYM in the .o file
-                                Symbol *oso_gsym_symbol = oso_symtab->FindFirstSymbolWithNameAndType(exe_symbol->GetMangled().GetName(), eSymbolTypeData);
+                                Symbol *oso_gsym_symbol = oso_symtab->FindFirstSymbolWithNameAndType(exe_symbol->GetMangled().GetName(), eSymbolTypeData, Symtab::eDebugNo, Symtab::eVisibilityAny);
                                 if (exe_gsym_symbol && oso_gsym_symbol)
                                 {
                                     // If we found the symbol, then we
@@ -598,7 +608,7 @@
             resolved_flags |= eSymbolContextSymbol;
 
             uint32_t oso_idx = 0;
-            CompileUnitInfo* comp_unit_info = GetCompileUnitInfoForSymbolWithIndex (sc.symbol->GetID(), &oso_idx);
+            CompileUnitInfo* comp_unit_info = GetCompileUnitInfoForSymbolWithID (sc.symbol->GetID(), &oso_idx);
             if (comp_unit_info)
             {
                 SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (oso_idx);
@@ -709,7 +719,7 @@
     if (symtab)
     {
         std::vector<uint32_t> indexes;
-        const size_t match_count = m_obj_file->GetSymtab()->FindAllSymbolsWithNameAndType (name, eSymbolTypeGlobal, indexes);
+        const size_t match_count = m_obj_file->GetSymtab()->FindAllSymbolsWithNameAndType (name, eSymbolTypeData, Symtab::eDebugYes, Symtab::eVisibilityAny, indexes);
         if (match_count)
         {
             PrivateFindGlobalVariables (name, indexes, max_matches, variables);
@@ -728,14 +738,29 @@
 
 
 int
-SymbolFileDWARFDebugMap::SymbolContainsSymbolIndex (uint32_t *symbol_idx_ptr, const CompileUnitInfo *comp_unit_info)
+SymbolFileDWARFDebugMap::SymbolContainsSymbolWithIndex (uint32_t *symbol_idx_ptr, const CompileUnitInfo *comp_unit_info)
 {
     const uint32_t symbol_idx = *symbol_idx_ptr;
 
-    if (symbol_idx < comp_unit_info->so_symbol->GetID())
+    if (symbol_idx < comp_unit_info->first_symbol_index)
+        return -1;
+
+    if (symbol_idx <= comp_unit_info->last_symbol_index)
+        return 0;
+
+    return 1;
+}
+
+
+int
+SymbolFileDWARFDebugMap::SymbolContainsSymbolWithID (user_id_t *symbol_idx_ptr, const CompileUnitInfo *comp_unit_info)
+{
+    const user_id_t symbol_id = *symbol_idx_ptr;
+
+    if (symbol_id < comp_unit_info->so_symbol->GetID())
         return -1;
 
-    if (symbol_idx < comp_unit_info->so_symbol->GetSiblingIndex())
+    if (symbol_id <= comp_unit_info->last_symbol->GetID())
         return 0;
 
     return 1;
@@ -749,7 +774,7 @@
     CompileUnitInfo *comp_unit_info = NULL;
     if (oso_index_count)
     {
-        comp_unit_info = (CompileUnitInfo*)bsearch(&symbol_idx, &m_compile_unit_infos[0], m_compile_unit_infos.size(), sizeof(CompileUnitInfo), (comparison_function)SymbolContainsSymbolIndex);
+        comp_unit_info = (CompileUnitInfo*)bsearch(&symbol_idx, &m_compile_unit_infos[0], m_compile_unit_infos.size(), sizeof(CompileUnitInfo), (comparison_function)SymbolContainsSymbolWithIndex);
     }
 
     if (oso_idx_ptr)
@@ -762,6 +787,27 @@
     return comp_unit_info;
 }
 
+SymbolFileDWARFDebugMap::CompileUnitInfo*
+SymbolFileDWARFDebugMap::GetCompileUnitInfoForSymbolWithID (user_id_t symbol_id, uint32_t *oso_idx_ptr)
+{
+    const uint32_t oso_index_count = m_compile_unit_infos.size();
+    CompileUnitInfo *comp_unit_info = NULL;
+    if (oso_index_count)
+    {
+        comp_unit_info = (CompileUnitInfo*)bsearch(&symbol_id, &m_compile_unit_infos[0], m_compile_unit_infos.size(), sizeof(CompileUnitInfo), (comparison_function)SymbolContainsSymbolWithID);
+    }
+
+    if (oso_idx_ptr)
+    {
+        if (comp_unit_info != NULL)
+            *oso_idx_ptr = comp_unit_info - &m_compile_unit_infos[0];
+        else
+            *oso_idx_ptr = UINT32_MAX;
+    }
+    return comp_unit_info;
+}
+
+
 static void
 RemoveFunctionsWithModuleNotEqualTo (Module *module, SymbolContextList &sc_list, uint32_t start_idx)
 {

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=113678&r1=113677&r2=113678&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h Fri Sep 10 22:13:28 2010
@@ -105,26 +105,29 @@
         lldb_private::FileSpec so_file;
         lldb_private::Symbol *so_symbol;
         lldb_private::Symbol *oso_symbol;
+        lldb_private::Symbol *last_symbol;
+        uint32_t first_symbol_index;
+        uint32_t last_symbol_index;
         lldb::ModuleSP oso_module_sp;
         lldb::CompUnitSP oso_compile_unit_sp;
         lldb_private::SymbolVendor *oso_symbol_vendor;
-//      lldb_private::shared_ptr<SymbolFileDWARF> oso_dwarf_sp;
-//      lldb_private::shared_ptr<SymbolVendor> oso_dwarf_sp;
         std::vector<uint32_t> function_indexes;
         std::vector<uint32_t> static_indexes;
         lldb::SharedPtr<lldb_private::SectionList>::Type debug_map_sections_sp;
 
         CompileUnitInfo() :
-            so_file(),
-            so_symbol(NULL),
-            oso_symbol(NULL),
-            oso_module_sp(),
-            oso_compile_unit_sp(),
-            oso_symbol_vendor(NULL),
-//          oso_dwarf_sp(),
-            function_indexes(),
-            static_indexes(),
-            debug_map_sections_sp()
+            so_file (),
+            so_symbol (NULL),
+            oso_symbol (NULL),
+            last_symbol (NULL),
+            first_symbol_index (UINT32_MAX),
+            last_symbol_index (UINT32_MAX),
+            oso_module_sp (),
+            oso_compile_unit_sp (),
+            oso_symbol_vendor (NULL),
+            function_indexes (),
+            static_indexes (),
+            debug_map_sections_sp ()
         {
         }
     };
@@ -162,11 +165,17 @@
     SymbolFileDWARF *
     GetSymbolFileByOSOIndex (uint32_t oso_idx);
 
-    CompileUnitInfo*
+    CompileUnitInfo *
     GetCompileUnitInfoForSymbolWithIndex (uint32_t symbol_idx, uint32_t *oso_idx_ptr);
+    
+    CompileUnitInfo *
+    GetCompileUnitInfoForSymbolWithID (lldb::user_id_t symbol_id, uint32_t *oso_idx_ptr);
+
+    static int
+    SymbolContainsSymbolWithIndex (uint32_t *symbol_idx_ptr, const CompileUnitInfo *comp_unit_info);
 
     static int
-    SymbolContainsSymbolIndex (uint32_t *symbol_idx_ptr, const CompileUnitInfo *comp_unit_info);
+    SymbolContainsSymbolWithID (lldb::user_id_t *symbol_idx_ptr, const CompileUnitInfo *comp_unit_info);
 
     uint32_t
     PrivateFindGlobalVariables (const lldb_private::ConstString &name,

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=113678&r1=113677&r2=113678&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp Fri Sep 10 22:13:28 2010
@@ -90,14 +90,14 @@
         {
             abilities |= CompileUnits;
         }
-        symtab->AppendSymbolIndexesWithType(eSymbolTypeFunction, m_func_indexes);
+        symtab->AppendSymbolIndexesWithType(eSymbolTypeCode, Symtab::eDebugYes, Symtab::eVisibilityAny, m_func_indexes);
         if (!m_func_indexes.empty())
         {
             symtab->SortSymbolIndexesByValue(m_func_indexes, true);
             abilities |= Functions;
         }
 
-        symtab->AppendSymbolIndexesWithType(eSymbolTypeCode, m_code_indexes);
+        symtab->AppendSymbolIndexesWithType(eSymbolTypeCode, Symtab::eDebugNo, Symtab::eVisibilityAny, m_code_indexes);
         if (!m_code_indexes.empty())
         {
             symtab->SortSymbolIndexesByValue(m_code_indexes, true);
@@ -319,8 +319,7 @@
     {
         const uint32_t start_size = sc_list.GetSize();
         std::vector<uint32_t> symbol_indexes;
-        symtab->FindAllSymbolsWithNameAndType (name, eSymbolTypeFunction, symbol_indexes);
-        symtab->FindAllSymbolsWithNameAndType (name, eSymbolTypeCode, symbol_indexes);
+        symtab->FindAllSymbolsWithNameAndType (name, eSymbolTypeCode, Symtab::eDebugAny, Symtab::eVisibilityAny, symbol_indexes);
         const uint32_t num_matches = symbol_indexes.size();
         if (num_matches)
         {

Modified: lldb/trunk/source/Symbol/Symbol.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symbol.cpp?rev=113678&r1=113677&r2=113678&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Symbol.cpp (original)
+++ lldb/trunk/source/Symbol/Symbol.cpp Fri Sep 10 22:13:28 2010
@@ -268,7 +268,7 @@
 uint32_t
 Symbol::GetPrologueByteSize ()
 {
-    if (m_type == eSymbolTypeCode || m_type == eSymbolTypeFunction)
+    if (m_type == eSymbolTypeCode)
     {
         if (!m_type_data_resolved)
         {
@@ -326,12 +326,8 @@
     ENUM_TO_CSTRING(SourceFile);
     ENUM_TO_CSTRING(HeaderFile);
     ENUM_TO_CSTRING(ObjectFile);
-    ENUM_TO_CSTRING(Function);
-    ENUM_TO_CSTRING(FunctionEnd);
     ENUM_TO_CSTRING(CommonBlock);
     ENUM_TO_CSTRING(Block);
-    ENUM_TO_CSTRING(Static);
-    ENUM_TO_CSTRING(Global);
     ENUM_TO_CSTRING(Local);
     ENUM_TO_CSTRING(Param);
     ENUM_TO_CSTRING(Variable);

Modified: lldb/trunk/source/Symbol/Symtab.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symtab.cpp?rev=113678&r1=113677&r2=113678&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Symtab.cpp (original)
+++ lldb/trunk/source/Symbol/Symtab.cpp Fri Sep 10 22:13:28 2010
@@ -218,7 +218,7 @@
 }
 
 uint32_t
-Symtab::AppendSymbolIndexesWithType(SymbolType symbol_type, std::vector<uint32_t>& indexes, uint32_t start_idx, uint32_t end_index) const
+Symtab::AppendSymbolIndexesWithType (SymbolType symbol_type, std::vector<uint32_t>& indexes, uint32_t start_idx, uint32_t end_index) const
 {
     uint32_t prev_size = indexes.size();
 
@@ -233,6 +233,35 @@
     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
+{
+    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)
+        {
+            if (CheckSymbolAtIndex(i, symbol_debug_type, symbol_visibility))
+                indexes.push_back(i);
+        }
+    }
+
+    return indexes.size() - prev_size;
+}
+
+
+uint32_t
+Symtab::GetIndexForSymbol (const Symbol *symbol) const
+{
+    const Symbol *first_symbol = &m_symbols[0];
+    if (symbol >= first_symbol && symbol < first_symbol + m_symbols.size())
+        return symbol - first_symbol;
+    return UINT32_MAX;
+}
+
 struct SymbolSortInfo
 {
     const bool sort_by_load_addr;
@@ -291,7 +320,7 @@
 }
 
 uint32_t
-Symtab::AppendSymbolIndexesWithName(const ConstString& symbol_name, std::vector<uint32_t>& indexes)
+Symtab::AppendSymbolIndexesWithName (const ConstString& symbol_name, std::vector<uint32_t>& indexes)
 {
     Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__);
     if (symbol_name)
@@ -314,7 +343,31 @@
 }
 
 uint32_t
-Symtab::AppendSymbolIndexesWithNameAndType(const ConstString& symbol_name, SymbolType symbol_type, std::vector<uint32_t>& indexes)
+Symtab::AppendSymbolIndexesWithName (const ConstString& symbol_name, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t>& indexes)
+{
+    Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__);
+    if (symbol_name)
+    {
+        const size_t old_size = indexes.size();
+        if (m_name_to_index.IsEmpty())
+            InitNameIndexes();
+
+        const char *symbol_cstr = symbol_name.GetCString();
+        const UniqueCStringMap<uint32_t>::Entry *entry_ptr;
+        for (entry_ptr = m_name_to_index.FindFirstValueForName (symbol_cstr);
+             entry_ptr!= NULL;
+             entry_ptr = m_name_to_index.FindNextValueForName (symbol_cstr, entry_ptr))
+        {
+            if (CheckSymbolAtIndex(entry_ptr->value, symbol_debug_type, symbol_visibility))
+                indexes.push_back (entry_ptr->value);
+        }
+        return indexes.size() - old_size;
+    }
+    return 0;
+}
+
+uint32_t
+Symtab::AppendSymbolIndexesWithNameAndType (const ConstString& symbol_name, SymbolType symbol_type, std::vector<uint32_t>& indexes)
 {
     if (AppendSymbolIndexesWithName(symbol_name, indexes) > 0)
     {
@@ -331,6 +384,24 @@
 }
 
 uint32_t
+Symtab::AppendSymbolIndexesWithNameAndType (const ConstString& symbol_name, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t>& indexes)
+{
+    if (AppendSymbolIndexesWithName(symbol_name, symbol_debug_type, symbol_visibility, indexes) > 0)
+    {
+        std::vector<uint32_t>::iterator pos = indexes.begin();
+        while (pos != indexes.end())
+        {
+            if (symbol_type == eSymbolTypeAny || m_symbols[*pos].GetType() == symbol_type)
+                ++pos;
+            else
+                indexes.erase(pos);
+        }
+    }
+    return indexes.size();
+}
+
+
+uint32_t
 Symtab::AppendSymbolIndexesMatchingRegExAndType (const RegularExpression &regexp, SymbolType symbol_type, std::vector<uint32_t>& indexes)
 {
     uint32_t prev_size = indexes.size();
@@ -352,31 +423,44 @@
 
 }
 
-Symbol *
-Symtab::FindSymbolWithType(SymbolType symbol_type, uint32_t& start_idx)
+uint32_t
+Symtab::AppendSymbolIndexesMatchingRegExAndType (const RegularExpression &regexp, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t>& indexes)
 {
-    const size_t count = m_symbols.size();
-    for (uint32_t idx = start_idx; idx < count; ++idx)
+    uint32_t prev_size = indexes.size();
+    uint32_t sym_end = m_symbols.size();
+
+    for (int i = 0; i < sym_end; i++)
     {
-        if (symbol_type == eSymbolTypeAny || m_symbols[idx].GetType() == symbol_type)
+        if (symbol_type == eSymbolTypeAny || m_symbols[i].GetType() == symbol_type)
         {
-            start_idx = idx;
-            return &m_symbols[idx];
+            if (CheckSymbolAtIndex(i, symbol_debug_type, symbol_visibility) == false)
+                continue;
+
+            const char *name = m_symbols[i].GetMangled().GetName().AsCString();
+            if (name)
+            {
+                if (regexp.Execute (name))
+                    indexes.push_back(i);
+            }
         }
     }
-    return NULL;
+    return indexes.size() - prev_size;
+
 }
 
-const Symbol *
-Symtab::FindSymbolWithType(SymbolType symbol_type, uint32_t& start_idx) const
+Symbol *
+Symtab::FindSymbolWithType (SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, uint32_t& start_idx)
 {
     const size_t count = m_symbols.size();
     for (uint32_t idx = start_idx; idx < count; ++idx)
     {
         if (symbol_type == eSymbolTypeAny || m_symbols[idx].GetType() == symbol_type)
         {
-            start_idx = idx;
-            return &m_symbols[idx];
+            if (CheckSymbolAtIndex(idx, symbol_debug_type, symbol_visibility))
+            {
+                start_idx = idx;
+                return &m_symbols[idx];
+            }
         }
     }
     return NULL;
@@ -395,20 +479,38 @@
     {
         // The string table did have a string that matched, but we need
         // to check the symbols and match the symbol_type if any was given.
-        AppendSymbolIndexesWithNameAndType(name, symbol_type, symbol_indexes);
+        AppendSymbolIndexesWithNameAndType (name, symbol_type, symbol_indexes);
+    }
+    return symbol_indexes.size();
+}
+
+size_t
+Symtab::FindAllSymbolsWithNameAndType (const ConstString &name, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t>& symbol_indexes)
+{
+    Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__);
+    // Initialize all of the lookup by name indexes before converting NAME
+    // to a uniqued string NAME_STR below.
+    if (m_name_to_index.IsEmpty())
+        InitNameIndexes();
+
+    if (name)
+    {
+        // The string table did have a string that matched, but we need
+        // to check the symbols and match the symbol_type if any was given.
+        AppendSymbolIndexesWithNameAndType (name, symbol_type, symbol_debug_type, symbol_visibility, symbol_indexes);
     }
     return symbol_indexes.size();
 }
 
 size_t
-Symtab::FindAllSymbolsMatchingRexExAndType (const RegularExpression &regex, SymbolType symbol_type, std::vector<uint32_t>& symbol_indexes)
+Symtab::FindAllSymbolsMatchingRexExAndType (const RegularExpression &regex, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t>& symbol_indexes)
 {
-    AppendSymbolIndexesMatchingRegExAndType(regex, symbol_type, symbol_indexes);
+    AppendSymbolIndexesMatchingRegExAndType(regex, symbol_type, symbol_debug_type, symbol_visibility, symbol_indexes);
     return symbol_indexes.size();
 }
 
 Symbol *
-Symtab::FindFirstSymbolWithNameAndType (const ConstString &name, SymbolType symbol_type)
+Symtab::FindFirstSymbolWithNameAndType (const ConstString &name, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility)
 {
     Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__);
     if (m_name_to_index.IsEmpty())
@@ -419,7 +521,7 @@
         std::vector<uint32_t> matching_indexes;
         // The string table did have a string that matched, but we need
         // to check the symbols and match the symbol_type if any was given.
-        if (AppendSymbolIndexesWithNameAndType(name, symbol_type, matching_indexes))
+        if (AppendSymbolIndexesWithNameAndType (name, symbol_type, symbol_debug_type, symbol_visibility, matching_indexes))
         {
             std::vector<uint32_t>::const_iterator pos, end = matching_indexes.end();
             for (pos = matching_indexes.begin(); pos != end; ++pos)
@@ -514,9 +616,6 @@
 {
     if (m_addr_indexes.empty())
     {
-        AppendSymbolIndexesWithType (eSymbolTypeFunction, m_addr_indexes);
-        AppendSymbolIndexesWithType (eSymbolTypeGlobal, m_addr_indexes);
-        AppendSymbolIndexesWithType (eSymbolTypeStatic, m_addr_indexes);
         AppendSymbolIndexesWithType (eSymbolTypeCode, m_addr_indexes);
         AppendSymbolIndexesWithType (eSymbolTypeTrampoline, m_addr_indexes);
         AppendSymbolIndexesWithType (eSymbolTypeData, m_addr_indexes);





More information about the lldb-commits mailing list