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.
llvm-svn: 113223
diff --git a/lldb/source/Symbol/Symtab.cpp b/lldb/source/Symbol/Symtab.cpp
index 7cb7610..74bb65f 100644
--- a/lldb/source/Symbol/Symtab.cpp
+++ b/lldb/source/Symbol/Symtab.cpp
@@ -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)
{