summaryrefslogtreecommitdiffstats
path: root/lldb/source/Symbol/Symtab.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Symbol/Symtab.cpp')
-rw-r--r--lldb/source/Symbol/Symtab.cpp117
1 files changed, 52 insertions, 65 deletions
diff --git a/lldb/source/Symbol/Symtab.cpp b/lldb/source/Symbol/Symtab.cpp
index 4ac30649110..c502b18555f 100644
--- a/lldb/source/Symbol/Symtab.cpp
+++ b/lldb/source/Symbol/Symtab.cpp
@@ -100,9 +100,8 @@ void Symtab::Dump(Stream *s, Target *target, SortOrder sort_order) {
} break;
case eSortOrderByName: {
- // Although we maintain a lookup by exact name map, the table
- // isn't sorted by name. So we must make the ordered symbol list
- // up ourselves.
+ // Although we maintain a lookup by exact name map, the table isn't
+ // sorted by name. So we must make the ordered symbol list up ourselves.
s->PutCString(" (sorted by name):\n");
DumpSymbolHeader(s);
typedef std::multimap<const char *, const Symbol *,
@@ -228,8 +227,8 @@ void Symtab::InitNameIndexes() {
m_name_to_index.Reserve(num_symbols);
#else
// TODO: benchmark this to see if we save any memory. Otherwise we
- // will always keep the memory reserved in the vector unless we pull
- // some STL swap magic and then recopy...
+ // will always keep the memory reserved in the vector unless we pull some
+ // STL swap magic and then recopy...
uint32_t actual_count = 0;
for (const_iterator pos = m_symbols.begin(), end = m_symbols.end();
pos != end; ++pos) {
@@ -255,11 +254,10 @@ void Symtab::InitNameIndexes() {
for (entry.value = 0; entry.value < num_symbols; ++entry.value) {
const Symbol *symbol = &m_symbols[entry.value];
- // Don't let trampolines get into the lookup by name map
- // If we ever need the trampoline symbols to be searchable by name
- // we can remove this and then possibly add a new bool to any of the
- // Symtab functions that lookup symbols by name to indicate if they
- // want trampolines.
+ // Don't let trampolines get into the lookup by name map If we ever need
+ // the trampoline symbols to be searchable by name we can remove this and
+ // then possibly add a new bool to any of the Symtab functions that
+ // lookup symbols by name to indicate if they want trampolines.
if (symbol->IsTrampoline())
continue;
@@ -293,10 +291,9 @@ void Symtab::InitNameIndexes() {
mangled.GetDemangledName(lldb::eLanguageTypeC_plus_plus));
entry.cstring = ConstString(cxx_method.GetBasename());
if (entry.cstring) {
- // ConstString objects permanently store the string in the pool so
- // calling
- // GetCString() on the value gets us a const char * that will
- // never go away
+ // ConstString objects permanently store the string in the pool
+ // so calling GetCString() on the value gets us a const char *
+ // that will never go away
const char *const_context =
ConstString(cxx_method.GetContext()).GetCString();
@@ -312,25 +309,25 @@ void Symtab::InitNameIndexes() {
if (entry_ref[0] == '~' ||
!cxx_method.GetQualifiers().empty()) {
// The first character of the demangled basename is '~' which
- // means we have a class destructor. We can use this information
- // to help us know what is a class and what isn't.
+ // means we have a class destructor. We can use this
+ // information to help us know what is a class and what
+ // isn't.
if (class_contexts.find(const_context) == class_contexts.end())
class_contexts.insert(const_context);
m_method_to_index.Append(entry);
} else {
if (class_contexts.find(const_context) !=
class_contexts.end()) {
- // The current decl context is in our "class_contexts" which
- // means
- // this is a method on a class
+ // The current decl context is in our "class_contexts"
+ // which means this is a method on a class
m_method_to_index.Append(entry);
} else {
- // We don't know if this is a function basename or a method,
- // so put it into a temporary collection so once we are done
- // we can look in class_contexts to see if each entry is a
- // class
- // or just a function and will put any remaining items into
- // m_method_to_index or m_basename_to_index as needed
+ // We don't know if this is a function basename or a
+ // method, so put it into a temporary collection so once we
+ // are done we can look in class_contexts to see if each
+ // entry is a class or just a function and will put any
+ // remaining items into m_method_to_index or
+ // m_basename_to_index as needed
mangled_name_to_index.Append(entry);
symbol_contexts[entry.value] = const_context;
}
@@ -354,9 +351,8 @@ void Symtab::InitNameIndexes() {
}
}
- // 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.
+ // 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.
ObjCLanguage::MethodName objc_method(entry.cstring.GetStringRef(), true);
if (objc_method.IsValid(true)) {
entry.cstring = objc_method.GetSelector();
@@ -383,8 +379,7 @@ void Symtab::InitNameIndexes() {
m_method_to_index.Append(entry);
} else {
// If we got here, we have something that had a context (was inside
- // a namespace or class)
- // yet we don't know if the entry
+ // a namespace or class) yet we don't know if the entry
m_method_to_index.Append(entry);
m_basename_to_index.Append(entry);
}
@@ -520,20 +515,15 @@ struct SymbolIndexComparator {
std::vector<lldb::addr_t> &addr_cache;
// Getting from the symbol to the Address to the File Address involves some
- // work.
- // Since there are potentially many symbols here, and we're using this for
- // sorting so
- // we're going to be computing the address many times, cache that in
- // addr_cache.
- // The array passed in has to be the same size as the symbols array passed
- // into the
- // member variable symbols, and should be initialized with
- // LLDB_INVALID_ADDRESS.
+ // work. Since there are potentially many symbols here, and we're using this
+ // for sorting so we're going to be computing the address many times, cache
+ // that in addr_cache. The array passed in has to be the same size as the
+ // symbols array passed into the member variable symbols, and should be
+ // initialized with LLDB_INVALID_ADDRESS.
// NOTE: You have to make addr_cache externally and pass it in because
// std::stable_sort
// makes copies of the comparator it is initially passed in, and you end up
- // spending
- // huge amounts of time copying this array...
+ // spending huge amounts of time copying this array...
SymbolIndexComparator(const std::vector<Symbol> &s,
std::vector<lldb::addr_t> &a)
@@ -584,8 +574,7 @@ void Symtab::SortSymbolIndexesByValue(std::vector<uint32_t> &indexes,
// NOTE: The use of std::stable_sort instead of std::sort here is strictly for
// performance,
// not correctness. The indexes vector tends to be "close" to sorted, which
- // the
- // stable sort handles better.
+ // the stable sort handles better.
std::vector<lldb::addr_t> addr_cache(m_symbols.size(), LLDB_INVALID_ADDRESS);
@@ -752,14 +741,14 @@ Symtab::FindAllSymbolsWithNameAndType(const ConstString &name,
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(func_cat, "%s", LLVM_PRETTY_FUNCTION);
- // Initialize all of the lookup by name indexes before converting NAME
- // to a uniqued string NAME_STR below.
+ // Initialize all of the lookup by name indexes before converting NAME to a
+ // uniqued string NAME_STR below.
if (!m_name_indexes_computed)
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.
+ // 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);
}
return symbol_indexes.size();
@@ -772,14 +761,14 @@ size_t Symtab::FindAllSymbolsWithNameAndType(
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(func_cat, "%s", LLVM_PRETTY_FUNCTION);
- // Initialize all of the lookup by name indexes before converting NAME
- // to a uniqued string NAME_STR below.
+ // Initialize all of the lookup by name indexes before converting NAME to a
+ // uniqued string NAME_STR below.
if (!m_name_indexes_computed)
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.
+ // 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);
}
@@ -810,8 +799,8 @@ Symbol *Symtab::FindFirstSymbolWithNameAndType(const ConstString &name,
if (name) {
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.
+ // 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, symbol_debug_type,
symbol_visibility,
matching_indexes)) {
@@ -835,8 +824,8 @@ typedef struct {
addr_t match_offset;
} SymbolSearchInfo;
-// Add all the section file start address & size to the RangeVector,
-// recusively adding any children sections.
+// Add all the section file start address & size to the RangeVector, recusively
+// adding any children sections.
static void AddSectionsToRangeMap(SectionList *sectlist,
RangeVector<addr_t, addr_t> &section_ranges) {
const int num_sections = sectlist->GetNumSections(0);
@@ -885,9 +874,9 @@ void Symtab::InitAddressIndexes() {
// Create a RangeVector with the start & size of all the sections for
// this objfile. We'll need to check this for any FileRangeToIndexMap
- // entries with an uninitialized size, which could potentially be a
- // large number so reconstituting the weak pointer is busywork when it
- // is invariant information.
+ // entries with an uninitialized size, which could potentially be a large
+ // number so reconstituting the weak pointer is busywork when it is
+ // invariant information.
SectionList *sectlist = m_objfile->GetSectionList();
RangeVector<addr_t, addr_t> section_ranges;
if (sectlist) {
@@ -922,9 +911,8 @@ void Symtab::InitAddressIndexes() {
if (next_base_addr > curr_base_addr) {
addr_t size_to_next_symbol = next_base_addr - curr_base_addr;
- // Take the difference between this symbol and the next one as its
- // size,
- // if it is less than the size of the section.
+ // Take the difference between this symbol and the next one as
+ // its size, if it is less than the size of the section.
if (sym_size == 0 || size_to_next_symbol < sym_size) {
sym_size = size_to_next_symbol;
}
@@ -958,8 +946,7 @@ void Symtab::CalculateSymbolSizes() {
for (size_t i = 0; i < num_entries; ++i) {
// The entries in the m_file_addr_to_index have calculated the sizes
- // already
- // so we will use this size if we need to.
+ // already so we will use this size if we need to.
const FileRangeToIndexMap::Entry &entry =
m_file_addr_to_index.GetEntryRef(i);
@@ -1086,8 +1073,8 @@ size_t Symtab::FindFunctionSymbols(const ConstString &name,
}
if (name_type_mask & eFunctionNameTypeBase) {
- // From mangled names we can't tell what is a basename and what
- // is a method name, so we just treat them the same
+ // From mangled names we can't tell what is a basename and what is a method
+ // name, so we just treat them the same
if (!m_name_indexes_computed)
InitNameIndexes();
OpenPOWER on IntegriCloud