summaryrefslogtreecommitdiffstats
path: root/source/Symbol/Symtab.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Symbol/Symtab.cpp')
-rw-r--r--source/Symbol/Symtab.cpp62
1 files changed, 49 insertions, 13 deletions
diff --git a/source/Symbol/Symtab.cpp b/source/Symbol/Symtab.cpp
index 907072c..4cc0334 100644
--- a/source/Symbol/Symtab.cpp
+++ b/source/Symbol/Symtab.cpp
@@ -14,6 +14,7 @@
#include "lldb/Core/Section.h"
#include "lldb/Core/Timer.h"
#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/Symtab.h"
#include "lldb/Target/CPPLanguageRuntime.h"
@@ -201,16 +202,16 @@ Symtab::DumpSymbolHeader (Stream *s)
s->Indent(" |Synthetic symbol\n");
s->Indent(" ||Externally Visible\n");
s->Indent(" |||\n");
- s->Indent("Index UserID DSX Type File Address/Value Load Address Size Flags Name\n");
- s->Indent("------- ------ --- ------------ ------------------ ------------------ ------------------ ---------- ----------------------------------\n");
+ s->Indent("Index UserID DSX Type File Address/Value Load Address Size Flags Name\n");
+ 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();
+ const user_id_t match_uid = *(const user_id_t*) key;
+ const user_id_t symbol_uid = ((const Symbol *)p)->GetID();
if (match_uid < symbol_uid)
return -1;
if (match_uid > symbol_uid)
@@ -226,7 +227,7 @@ Symtab::FindSymbolByID (lldb::user_id_t symbol_uid) const
Symbol *symbol = (Symbol*)::bsearch (&symbol_uid,
&m_symbols[0],
m_symbols.size(),
- (uint8_t *)&m_symbols[1] - (uint8_t *)&m_symbols[0],
+ sizeof(m_symbols[0]),
CompareSymbolID);
return symbol;
}
@@ -312,6 +313,13 @@ Symtab::InitNameIndexes()
if (entry.cstring && entry.cstring[0])
{
m_name_to_index.Append (entry);
+
+ if (symbol->ContainsLinkerAnnotations()) {
+ // If the symbol has linker annotations, also add the version without the
+ // annotations.
+ entry.cstring = ConstString(m_objfile->StripLinkerSymbolAnnotations(entry.cstring)).GetCString();
+ m_name_to_index.Append (entry);
+ }
const SymbolType symbol_type = symbol->GetType();
if (symbol_type == eSymbolTypeCode || symbol_type == eSymbolTypeResolver)
@@ -371,8 +379,16 @@ Symtab::InitNameIndexes()
}
entry.cstring = mangled.GetDemangledName().GetCString();
- if (entry.cstring && entry.cstring[0])
+ if (entry.cstring && entry.cstring[0]) {
m_name_to_index.Append (entry);
+
+ if (symbol->ContainsLinkerAnnotations()) {
+ // If the symbol has linker annotations, also add the version without the
+ // annotations.
+ entry.cstring = ConstString(m_objfile->StripLinkerSymbolAnnotations(entry.cstring)).GetCString();
+ m_name_to_index.Append (entry);
+ }
+ }
// If the demangled name turns out to be an ObjC name, and
// is a category name, add the version without categories to the index too.
@@ -546,9 +562,12 @@ Symtab::AppendSymbolIndexesWithType (SymbolType symbol_type, Debug symbol_debug_
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;
+ if (!m_symbols.empty())
+ {
+ const Symbol *first_symbol = &m_symbols[0];
+ if (symbol >= first_symbol && symbol < first_symbol + m_symbols.size())
+ return symbol - first_symbol;
+ }
return UINT32_MAX;
}
@@ -579,14 +598,14 @@ namespace {
addr_t value_a = addr_cache[index_a];
if (value_a == LLDB_INVALID_ADDRESS)
{
- value_a = symbols[index_a].GetAddress().GetFileAddress();
+ value_a = symbols[index_a].GetAddressRef().GetFileAddress();
addr_cache[index_a] = value_a;
}
addr_t value_b = addr_cache[index_b];
if (value_b == LLDB_INVALID_ADDRESS)
{
- value_b = symbols[index_b].GetAddress().GetFileAddress();
+ value_b = symbols[index_b].GetAddressRef().GetFileAddress();
addr_cache[index_b] = value_b;
}
@@ -883,7 +902,7 @@ SymbolWithClosestFileAddress (SymbolSearchInfo *info, const uint32_t *index_ptr)
const addr_t info_file_addr = info->file_addr;
if (symbol->ValueIsAddress())
{
- const addr_t curr_file_addr = symbol->GetAddress().GetFileAddress();
+ const addr_t curr_file_addr = symbol->GetAddressRef().GetFileAddress();
if (info_file_addr < curr_file_addr)
return -1;
@@ -917,7 +936,7 @@ Symtab::InitAddressIndexes()
{
if (pos->ValueIsAddress())
{
- entry.SetRangeBase(pos->GetAddress().GetFileAddress());
+ entry.SetRangeBase(pos->GetAddressRef().GetFileAddress());
entry.SetByteSize(pos->GetByteSize());
entry.data = std::distance(begin, pos);
m_file_addr_to_index.Append(entry);
@@ -1178,3 +1197,20 @@ Symtab::FindFunctionSymbols (const ConstString &name,
return count;
}
+
+const Symbol *
+Symtab::GetParent (Symbol *child_symbol) const
+{
+ uint32_t child_idx = GetIndexForSymbol(child_symbol);
+ if (child_idx != UINT32_MAX && child_idx > 0)
+ {
+ for (uint32_t idx = child_idx - 1; idx != UINT32_MAX; --idx)
+ {
+ const Symbol *symbol = SymbolAtIndex (idx);
+ const uint32_t sibling_idx = symbol->GetSiblingIndex();
+ if (sibling_idx != UINT32_MAX && sibling_idx > child_idx)
+ return symbol;
+ }
+ }
+ return NULL;
+}
OpenPOWER on IntegriCloud