mirror of
https://github.com/intel/llvm.git
synced 2026-01-17 14:48:27 +08:00
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
This commit is contained in:
@@ -32,6 +32,7 @@ public:
|
||||
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 @@ public:
|
||||
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;
|
||||
|
||||
|
||||
@@ -878,6 +878,10 @@ ObjectFileMachO::ParseSymtab (bool minimize)
|
||||
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 @@ ObjectFileMachO::ParseSymtab (bool minimize)
|
||||
{
|
||||
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);
|
||||
|
||||
@@ -136,6 +136,31 @@ Symtab::DumpSymbolHeader (Stream *s)
|
||||
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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user