[Lldb-commits] [lldb] r113223 - in /lldb/trunk: include/lldb/Symbol/Symtab.h source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp source/Symbol/Symtab.cpp

Greg Clayton gclayton at apple.com
Tue Sep 7 10:36:17 PDT 2010


Author: gclayton
Date: Tue Sep  7 12:36:17 2010
New Revision: 113223

URL: http://llvm.org/viewvc/llvm-project?rev=113223&view=rev
Log:
Added Symtab::FindSymbolByID() in preparation for enabling the minimal
symbol tables. Minimal symbol tables enable us to merge two symbols, one
debug symbol and one linker symbol, into a single symbol that can carry
just as much information and will avoid duplicate symbols in the symbol
table.


Modified:
    lldb/trunk/include/lldb/Symbol/Symtab.h
    lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.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=113223&r1=113222&r2=113223&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Symtab.h (original)
+++ lldb/trunk/include/lldb/Symbol/Symtab.h Tue Sep  7 12:36:17 2010
@@ -32,6 +32,7 @@
             void        Dump(Stream *s, Process *process) const;
             void        Dump(Stream *s, Process *process, std::vector<uint32_t>& indexes) 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);
@@ -55,7 +56,7 @@
     static  void        DumpSymbolHeader (Stream *s);
 
 protected:
-    typedef std::vector<Symbol>     collection;
+    typedef std::vector<Symbol>         collection;
     typedef collection::iterator        iterator;
     typedef collection::const_iterator  const_iterator;
 

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=113223&r1=113222&r2=113223&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Tue Sep  7 12:36:17 2010
@@ -878,6 +878,10 @@
                         case StabIncludeFileName:
                             // N_SOL - #included file name: name,,n_sect,0,address
                             type = eSymbolTypeHeaderFile;
+
+                            // We currently don't use the header files on darwin
+                            if (minimize)
+                                add_nlist = false;
                             break;
 
                         case StabCompilerParameters:  
@@ -1175,7 +1179,13 @@
                                     {
                                         const uint32_t symbol_index = indirect_symbol_index_data.GetU32 (&symbol_stub_offset);
 
-                                        Symbol *stub_symbol = symtab->SymbolAtIndex(symbol_index);
+                                        Symbol *stub_symbol;
+                                        if (minimize)
+                                            stub_symbol = symtab->FindSymbolByID (symbol_index);
+                                        else
+                                            stub_symbol = symtab->SymbolAtIndex (symbol_index);
+
+                                        assert (stub_symbol);
                                         if (stub_symbol)
                                         {
                                             Address so_addr(symbol_stub_addr, section_list);

Modified: lldb/trunk/source/Symbol/Symtab.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symtab.cpp?rev=113223&r1=113222&r2=113223&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Symtab.cpp (original)
+++ lldb/trunk/source/Symbol/Symtab.cpp Tue Sep  7 12:36:17 2010
@@ -136,6 +136,31 @@
     s->Indent("------- ------ --- ------------ ------------------ ------------------ ------------------ ---------- ----------------------------------\n");
 }
 
+
+static int
+CompareSymbolID (const void *key, const void *p)
+{
+    const user_id_t match_uid = *(user_id_t*) key;
+    const user_id_t symbol_uid = ((Symbol *)p)->GetID();
+    if (match_uid < symbol_uid)
+        return -1;
+    if (match_uid > symbol_uid)
+        return 1;
+    return 0;
+}
+
+Symbol *
+Symtab::FindSymbolByID (lldb::user_id_t symbol_uid) const
+{
+    Symbol *symbol = (Symbol*)::bsearch (&symbol_uid, 
+                                         &m_symbols[0], 
+                                         m_symbols.size(), 
+                                         sizeof(Symbol), 
+                                         CompareSymbolID);
+    return symbol;
+}
+
+
 Symbol *
 Symtab::SymbolAtIndex(uint32_t idx)
 {





More information about the lldb-commits mailing list