LLDB  mainline
Symtab.cpp
Go to the documentation of this file.
1 //===-- Symtab.cpp --------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include <map>
10 #include <set>
11 
13 #include "lldb/Core/Module.h"
15 #include "lldb/Core/Section.h"
16 #include "lldb/Symbol/ObjectFile.h"
17 #include "lldb/Symbol/Symbol.h"
19 #include "lldb/Symbol/Symtab.h"
20 #include "lldb/Target/Language.h"
22 #include "lldb/Utility/Endian.h"
24 #include "lldb/Utility/Stream.h"
25 #include "lldb/Utility/Timer.h"
26 
27 #include "llvm/ADT/ArrayRef.h"
28 #include "llvm/ADT/StringRef.h"
29 #include "llvm/Support/DJB.h"
30 
31 using namespace lldb;
32 using namespace lldb_private;
33 
34 Symtab::Symtab(ObjectFile *objfile)
35  : m_objfile(objfile), m_symbols(), m_file_addr_to_index(*this),
36  m_name_to_symbol_indices(), m_mutex(),
37  m_file_addr_to_index_computed(false), m_name_indexes_computed(false),
38  m_loaded_from_cache(false), m_saved_to_cache(false) {
39  m_name_to_symbol_indices.emplace(std::make_pair(
40  lldb::eFunctionNameTypeNone, UniqueCStringMap<uint32_t>()));
41  m_name_to_symbol_indices.emplace(std::make_pair(
42  lldb::eFunctionNameTypeBase, UniqueCStringMap<uint32_t>()));
43  m_name_to_symbol_indices.emplace(std::make_pair(
44  lldb::eFunctionNameTypeMethod, UniqueCStringMap<uint32_t>()));
45  m_name_to_symbol_indices.emplace(std::make_pair(
46  lldb::eFunctionNameTypeSelector, UniqueCStringMap<uint32_t>()));
47 }
48 
49 Symtab::~Symtab() = default;
50 
51 void Symtab::Reserve(size_t count) {
52  // Clients should grab the mutex from this symbol table and lock it manually
53  // when calling this function to avoid performance issues.
54  m_symbols.reserve(count);
55 }
56 
57 Symbol *Symtab::Resize(size_t count) {
58  // Clients should grab the mutex from this symbol table and lock it manually
59  // when calling this function to avoid performance issues.
60  m_symbols.resize(count);
61  return m_symbols.empty() ? nullptr : &m_symbols[0];
62 }
63 
65  // Clients should grab the mutex from this symbol table and lock it manually
66  // when calling this function to avoid performance issues.
67  uint32_t symbol_idx = m_symbols.size();
68  auto &name_to_index = GetNameToSymbolIndexMap(lldb::eFunctionNameTypeNone);
69  name_to_index.Clear();
71  m_symbols.push_back(symbol);
74  return symbol_idx;
75 }
76 
77 size_t Symtab::GetNumSymbols() const {
78  std::lock_guard<std::recursive_mutex> guard(m_mutex);
79  return m_symbols.size();
80 }
81 
83  auto &name_to_index = GetNameToSymbolIndexMap(lldb::eFunctionNameTypeNone);
84  name_to_index.Clear();
86 }
87 
88 void Symtab::Dump(Stream *s, Target *target, SortOrder sort_order,
89  Mangled::NamePreference name_preference) {
90  std::lock_guard<std::recursive_mutex> guard(m_mutex);
91 
92  // s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
93  s->Indent();
94  const FileSpec &file_spec = m_objfile->GetFileSpec();
95  const char *object_name = nullptr;
96  if (m_objfile->GetModule())
97  object_name = m_objfile->GetModule()->GetObjectName().GetCString();
98 
99  if (file_spec)
100  s->Printf("Symtab, file = %s%s%s%s, num_symbols = %" PRIu64,
101  file_spec.GetPath().c_str(), object_name ? "(" : "",
102  object_name ? object_name : "", object_name ? ")" : "",
103  (uint64_t)m_symbols.size());
104  else
105  s->Printf("Symtab, num_symbols = %" PRIu64 "", (uint64_t)m_symbols.size());
106 
107  if (!m_symbols.empty()) {
108  switch (sort_order) {
109  case eSortOrderNone: {
110  s->PutCString(":\n");
111  DumpSymbolHeader(s);
112  const_iterator begin = m_symbols.begin();
113  const_iterator end = m_symbols.end();
114  for (const_iterator pos = m_symbols.begin(); pos != end; ++pos) {
115  s->Indent();
116  pos->Dump(s, target, std::distance(begin, pos), name_preference);
117  }
118  }
119  break;
120 
121  case eSortOrderByName: {
122  // Although we maintain a lookup by exact name map, the table isn't
123  // sorted by name. So we must make the ordered symbol list up ourselves.
124  s->PutCString(" (sorted by name):\n");
125  DumpSymbolHeader(s);
126 
127  std::multimap<llvm::StringRef, const Symbol *> name_map;
128  for (const_iterator pos = m_symbols.begin(), end = m_symbols.end();
129  pos != end; ++pos) {
130  const char *name = pos->GetName().AsCString();
131  if (name && name[0])
132  name_map.insert(std::make_pair(name, &(*pos)));
133  }
134 
135  for (const auto &name_to_symbol : name_map) {
136  const Symbol *symbol = name_to_symbol.second;
137  s->Indent();
138  symbol->Dump(s, target, symbol - &m_symbols[0], name_preference);
139  }
140  } break;
141 
142  case eSortOrderByAddress:
143  s->PutCString(" (sorted by address):\n");
144  DumpSymbolHeader(s);
147  const size_t num_entries = m_file_addr_to_index.GetSize();
148  for (size_t i = 0; i < num_entries; ++i) {
149  s->Indent();
150  const uint32_t symbol_idx = m_file_addr_to_index.GetEntryRef(i).data;
151  m_symbols[symbol_idx].Dump(s, target, symbol_idx, name_preference);
152  }
153  break;
154  }
155  } else {
156  s->PutCString("\n");
157  }
158 }
159 
160 void Symtab::Dump(Stream *s, Target *target, std::vector<uint32_t> &indexes,
161  Mangled::NamePreference name_preference) const {
162  std::lock_guard<std::recursive_mutex> guard(m_mutex);
163 
164  const size_t num_symbols = GetNumSymbols();
165  // s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
166  s->Indent();
167  s->Printf("Symtab %" PRIu64 " symbol indexes (%" PRIu64 " symbols total):\n",
168  (uint64_t)indexes.size(), (uint64_t)m_symbols.size());
169  s->IndentMore();
170 
171  if (!indexes.empty()) {
172  std::vector<uint32_t>::const_iterator pos;
173  std::vector<uint32_t>::const_iterator end = indexes.end();
174  DumpSymbolHeader(s);
175  for (pos = indexes.begin(); pos != end; ++pos) {
176  size_t idx = *pos;
177  if (idx < num_symbols) {
178  s->Indent();
179  m_symbols[idx].Dump(s, target, idx, name_preference);
180  }
181  }
182  }
183  s->IndentLess();
184 }
185 
187  s->Indent(" Debug symbol\n");
188  s->Indent(" |Synthetic symbol\n");
189  s->Indent(" ||Externally Visible\n");
190  s->Indent(" |||\n");
191  s->Indent("Index UserID DSX Type File Address/Value Load "
192  "Address Size Flags Name\n");
193  s->Indent("------- ------ --- --------------- ------------------ "
194  "------------------ ------------------ ---------- "
195  "----------------------------------\n");
196 }
197 
198 static int CompareSymbolID(const void *key, const void *p) {
199  const user_id_t match_uid = *(const user_id_t *)key;
200  const user_id_t symbol_uid = ((const Symbol *)p)->GetID();
201  if (match_uid < symbol_uid)
202  return -1;
203  if (match_uid > symbol_uid)
204  return 1;
205  return 0;
206 }
207 
209  std::lock_guard<std::recursive_mutex> guard(m_mutex);
210 
211  Symbol *symbol =
212  (Symbol *)::bsearch(&symbol_uid, &m_symbols[0], m_symbols.size(),
213  sizeof(m_symbols[0]), CompareSymbolID);
214  return symbol;
215 }
216 
218  // Clients should grab the mutex from this symbol table and lock it manually
219  // when calling this function to avoid performance issues.
220  if (idx < m_symbols.size())
221  return &m_symbols[idx];
222  return nullptr;
223 }
224 
225 const Symbol *Symtab::SymbolAtIndex(size_t idx) const {
226  // Clients should grab the mutex from this symbol table and lock it manually
227  // when calling this function to avoid performance issues.
228  if (idx < m_symbols.size())
229  return &m_symbols[idx];
230  return nullptr;
231 }
232 
233 static bool lldb_skip_name(llvm::StringRef mangled,
234  Mangled::ManglingScheme scheme) {
235  switch (scheme) {
236  case Mangled::eManglingSchemeItanium: {
237  if (mangled.size() < 3 || !mangled.startswith("_Z"))
238  return true;
239 
240  // Avoid the following types of symbols in the index.
241  switch (mangled[2]) {
242  case 'G': // guard variables
243  case 'T': // virtual tables, VTT structures, typeinfo structures + names
244  case 'Z': // named local entities (if we eventually handle
245  // eSymbolTypeData, we will want this back)
246  return true;
247 
248  default:
249  break;
250  }
251 
252  // Include this name in the index.
253  return false;
254  }
255 
256  // No filters for this scheme yet. Include all names in indexing.
257  case Mangled::eManglingSchemeMSVC:
258  case Mangled::eManglingSchemeRustV0:
259  case Mangled::eManglingSchemeD:
260  return false;
261 
262  // Don't try and demangle things we can't categorize.
263  case Mangled::eManglingSchemeNone:
264  return true;
265  }
266  llvm_unreachable("unknown scheme!");
267 }
268 
270  // Protected function, no need to lock mutex...
273  ElapsedTime elapsed(m_objfile->GetModule()->GetSymtabIndexTime());
275 
276  // Collect all loaded language plugins.
277  std::vector<Language *> languages;
278  Language::ForEach([&languages](Language *l) {
279  languages.push_back(l);
280  return true;
281  });
282 
283  auto &name_to_index = GetNameToSymbolIndexMap(lldb::eFunctionNameTypeNone);
284  auto &basename_to_index =
285  GetNameToSymbolIndexMap(lldb::eFunctionNameTypeBase);
286  auto &method_to_index =
287  GetNameToSymbolIndexMap(lldb::eFunctionNameTypeMethod);
288  auto &selector_to_index =
289  GetNameToSymbolIndexMap(lldb::eFunctionNameTypeSelector);
290  // Create the name index vector to be able to quickly search by name
291  const size_t num_symbols = m_symbols.size();
292  name_to_index.Reserve(num_symbols);
293 
294  // The "const char *" in "class_contexts" and backlog::value_type::second
295  // must come from a ConstString::GetCString()
296  std::set<const char *> class_contexts;
297  std::vector<std::pair<NameToIndexMap::Entry, const char *>> backlog;
298  backlog.reserve(num_symbols / 2);
299 
300  // Instantiation of the demangler is expensive, so better use a single one
301  // for all entries during batch processing.
303  for (uint32_t value = 0; value < num_symbols; ++value) {
304  Symbol *symbol = &m_symbols[value];
305 
306  // Don't let trampolines get into the lookup by name map If we ever need
307  // the trampoline symbols to be searchable by name we can remove this and
308  // then possibly add a new bool to any of the Symtab functions that
309  // lookup symbols by name to indicate if they want trampolines. We also
310  // don't want any synthetic symbols with auto generated names in the
311  // name lookups.
312  if (symbol->IsTrampoline() || symbol->IsSyntheticWithAutoGeneratedName())
313  continue;
314 
315  // If the symbol's name string matched a Mangled::ManglingScheme, it is
316  // stored in the mangled field.
317  Mangled &mangled = symbol->GetMangled();
318  if (ConstString name = mangled.GetMangledName()) {
319  name_to_index.Append(name, value);
320 
321  if (symbol->ContainsLinkerAnnotations()) {
322  // If the symbol has linker annotations, also add the version without
323  // the annotations.
324  ConstString stripped = ConstString(
325  m_objfile->StripLinkerSymbolAnnotations(name.GetStringRef()));
326  name_to_index.Append(stripped, value);
327  }
328 
329  const SymbolType type = symbol->GetType();
330  if (type == eSymbolTypeCode || type == eSymbolTypeResolver) {
331  if (mangled.DemangleWithRichManglingInfo(rmc, lldb_skip_name))
332  RegisterMangledNameEntry(value, class_contexts, backlog, rmc);
333  }
334  }
335 
336  // Symbol name strings that didn't match a Mangled::ManglingScheme, are
337  // stored in the demangled field.
338  if (ConstString name = mangled.GetDemangledName()) {
339  name_to_index.Append(name, value);
340 
341  if (symbol->ContainsLinkerAnnotations()) {
342  // If the symbol has linker annotations, also add the version without
343  // the annotations.
344  name = ConstString(
345  m_objfile->StripLinkerSymbolAnnotations(name.GetStringRef()));
346  name_to_index.Append(name, value);
347  }
348 
349  // If the demangled name turns out to be an ObjC name, and is a category
350  // name, add the version without categories to the index too.
351  for (Language *lang : languages) {
352  for (auto variant : lang->GetMethodNameVariants(name)) {
353  if (variant.GetType() & lldb::eFunctionNameTypeSelector)
354  selector_to_index.Append(variant.GetName(), value);
355  else if (variant.GetType() & lldb::eFunctionNameTypeFull)
356  name_to_index.Append(variant.GetName(), value);
357  else if (variant.GetType() & lldb::eFunctionNameTypeMethod)
358  method_to_index.Append(variant.GetName(), value);
359  else if (variant.GetType() & lldb::eFunctionNameTypeBase)
360  basename_to_index.Append(variant.GetName(), value);
361  }
362  }
363  }
364  }
365 
366  for (const auto &record : backlog) {
367  RegisterBacklogEntry(record.first, record.second, class_contexts);
368  }
369 
370  name_to_index.Sort();
371  name_to_index.SizeToFit();
372  selector_to_index.Sort();
373  selector_to_index.SizeToFit();
374  basename_to_index.Sort();
375  basename_to_index.SizeToFit();
376  method_to_index.Sort();
377  method_to_index.SizeToFit();
378  }
379 }
380 
382  uint32_t value, std::set<const char *> &class_contexts,
383  std::vector<std::pair<NameToIndexMap::Entry, const char *>> &backlog,
384  RichManglingContext &rmc) {
385  // Only register functions that have a base name.
386  rmc.ParseFunctionBaseName();
387  llvm::StringRef base_name = rmc.GetBufferRef();
388  if (base_name.empty())
389  return;
390 
391  // The base name will be our entry's name.
392  NameToIndexMap::Entry entry(ConstString(base_name), value);
393 
395  llvm::StringRef decl_context = rmc.GetBufferRef();
396 
397  // Register functions with no context.
398  if (decl_context.empty()) {
399  // This has to be a basename
400  auto &basename_to_index =
401  GetNameToSymbolIndexMap(lldb::eFunctionNameTypeBase);
402  basename_to_index.Append(entry);
403  // If there is no context (no namespaces or class scopes that come before
404  // the function name) then this also could be a fullname.
405  auto &name_to_index = GetNameToSymbolIndexMap(lldb::eFunctionNameTypeNone);
406  name_to_index.Append(entry);
407  return;
408  }
409 
410  // Make sure we have a pool-string pointer and see if we already know the
411  // context name.
412  const char *decl_context_ccstr = ConstString(decl_context).GetCString();
413  auto it = class_contexts.find(decl_context_ccstr);
414 
415  auto &method_to_index =
416  GetNameToSymbolIndexMap(lldb::eFunctionNameTypeMethod);
417  // Register constructors and destructors. They are methods and create
418  // declaration contexts.
419  if (rmc.IsCtorOrDtor()) {
420  method_to_index.Append(entry);
421  if (it == class_contexts.end())
422  class_contexts.insert(it, decl_context_ccstr);
423  return;
424  }
425 
426  // Register regular methods with a known declaration context.
427  if (it != class_contexts.end()) {
428  method_to_index.Append(entry);
429  return;
430  }
431 
432  // Regular methods in unknown declaration contexts are put to the backlog. We
433  // will revisit them once we processed all remaining symbols.
434  backlog.push_back(std::make_pair(entry, decl_context_ccstr));
435 }
436 
438  const NameToIndexMap::Entry &entry, const char *decl_context,
439  const std::set<const char *> &class_contexts) {
440  auto &method_to_index =
441  GetNameToSymbolIndexMap(lldb::eFunctionNameTypeMethod);
442  auto it = class_contexts.find(decl_context);
443  if (it != class_contexts.end()) {
444  method_to_index.Append(entry);
445  } else {
446  // If we got here, we have something that had a context (was inside
447  // a namespace or class) yet we don't know the entry
448  method_to_index.Append(entry);
449  auto &basename_to_index =
450  GetNameToSymbolIndexMap(lldb::eFunctionNameTypeBase);
451  basename_to_index.Append(entry);
452  }
453 }
454 
456  std::lock_guard<std::recursive_mutex> guard(m_mutex);
457  InitNameIndexes();
458 }
459 
461  bool add_demangled, bool add_mangled,
462  NameToIndexMap &name_to_index_map) const {
464  if (add_demangled || add_mangled) {
465  std::lock_guard<std::recursive_mutex> guard(m_mutex);
466 
467  // Create the name index vector to be able to quickly search by name
468  const size_t num_indexes = indexes.size();
469  for (size_t i = 0; i < num_indexes; ++i) {
470  uint32_t value = indexes[i];
471  assert(i < m_symbols.size());
472  const Symbol *symbol = &m_symbols[value];
473 
474  const Mangled &mangled = symbol->GetMangled();
475  if (add_demangled) {
476  if (ConstString name = mangled.GetDemangledName())
477  name_to_index_map.Append(name, value);
478  }
479 
480  if (add_mangled) {
481  if (ConstString name = mangled.GetMangledName())
482  name_to_index_map.Append(name, value);
483  }
484  }
485  }
486 }
487 
489  std::vector<uint32_t> &indexes,
490  uint32_t start_idx,
491  uint32_t end_index) const {
492  std::lock_guard<std::recursive_mutex> guard(m_mutex);
493 
494  uint32_t prev_size = indexes.size();
495 
496  const uint32_t count = std::min<uint32_t>(m_symbols.size(), end_index);
497 
498  for (uint32_t i = start_idx; i < count; ++i) {
499  if (symbol_type == eSymbolTypeAny || m_symbols[i].GetType() == symbol_type)
500  indexes.push_back(i);
501  }
502 
503  return indexes.size() - prev_size;
504 }
505 
507  SymbolType symbol_type, uint32_t flags_value,
508  std::vector<uint32_t> &indexes, uint32_t start_idx,
509  uint32_t end_index) const {
510  std::lock_guard<std::recursive_mutex> guard(m_mutex);
511 
512  uint32_t prev_size = indexes.size();
513 
514  const uint32_t count = std::min<uint32_t>(m_symbols.size(), end_index);
515 
516  for (uint32_t i = start_idx; i < count; ++i) {
517  if ((symbol_type == eSymbolTypeAny ||
518  m_symbols[i].GetType() == symbol_type) &&
519  m_symbols[i].GetFlags() == flags_value)
520  indexes.push_back(i);
521  }
522 
523  return indexes.size() - prev_size;
524 }
525 
527  Debug symbol_debug_type,
528  Visibility symbol_visibility,
529  std::vector<uint32_t> &indexes,
530  uint32_t start_idx,
531  uint32_t end_index) const {
532  std::lock_guard<std::recursive_mutex> guard(m_mutex);
533 
534  uint32_t prev_size = indexes.size();
535 
536  const uint32_t count = std::min<uint32_t>(m_symbols.size(), end_index);
537 
538  for (uint32_t i = start_idx; i < count; ++i) {
539  if (symbol_type == eSymbolTypeAny ||
540  m_symbols[i].GetType() == symbol_type) {
541  if (CheckSymbolAtIndex(i, symbol_debug_type, symbol_visibility))
542  indexes.push_back(i);
543  }
544  }
545 
546  return indexes.size() - prev_size;
547 }
548 
550  if (!m_symbols.empty()) {
551  const Symbol *first_symbol = &m_symbols[0];
552  if (symbol >= first_symbol && symbol < first_symbol + m_symbols.size())
553  return symbol - first_symbol;
554  }
555  return UINT32_MAX;
556 }
557 
559  const bool sort_by_load_addr;
560  const Symbol *symbols;
561 };
562 
563 namespace {
564 struct SymbolIndexComparator {
565  const std::vector<Symbol> &symbols;
566  std::vector<lldb::addr_t> &addr_cache;
567 
568  // Getting from the symbol to the Address to the File Address involves some
569  // work. Since there are potentially many symbols here, and we're using this
570  // for sorting so we're going to be computing the address many times, cache
571  // that in addr_cache. The array passed in has to be the same size as the
572  // symbols array passed into the member variable symbols, and should be
573  // initialized with LLDB_INVALID_ADDRESS.
574  // NOTE: You have to make addr_cache externally and pass it in because
575  // std::stable_sort
576  // makes copies of the comparator it is initially passed in, and you end up
577  // spending huge amounts of time copying this array...
578 
579  SymbolIndexComparator(const std::vector<Symbol> &s,
580  std::vector<lldb::addr_t> &a)
581  : symbols(s), addr_cache(a) {
582  assert(symbols.size() == addr_cache.size());
583  }
584  bool operator()(uint32_t index_a, uint32_t index_b) {
585  addr_t value_a = addr_cache[index_a];
586  if (value_a == LLDB_INVALID_ADDRESS) {
587  value_a = symbols[index_a].GetAddressRef().GetFileAddress();
588  addr_cache[index_a] = value_a;
589  }
590 
591  addr_t value_b = addr_cache[index_b];
592  if (value_b == LLDB_INVALID_ADDRESS) {
593  value_b = symbols[index_b].GetAddressRef().GetFileAddress();
594  addr_cache[index_b] = value_b;
595  }
596 
597  if (value_a == value_b) {
598  // The if the values are equal, use the original symbol user ID
599  lldb::user_id_t uid_a = symbols[index_a].GetID();
600  lldb::user_id_t uid_b = symbols[index_b].GetID();
601  if (uid_a < uid_b)
602  return true;
603  if (uid_a > uid_b)
604  return false;
605  return false;
606  } else if (value_a < value_b)
607  return true;
608 
609  return false;
610  }
611 };
612 }
613 
614 void Symtab::SortSymbolIndexesByValue(std::vector<uint32_t> &indexes,
615  bool remove_duplicates) const {
616  std::lock_guard<std::recursive_mutex> guard(m_mutex);
618  // No need to sort if we have zero or one items...
619  if (indexes.size() <= 1)
620  return;
621 
622  // Sort the indexes in place using std::stable_sort.
623  // NOTE: The use of std::stable_sort instead of llvm::sort here is strictly
624  // for performance, not correctness. The indexes vector tends to be "close"
625  // to sorted, which the stable sort handles better.
626 
627  std::vector<lldb::addr_t> addr_cache(m_symbols.size(), LLDB_INVALID_ADDRESS);
628 
629  SymbolIndexComparator comparator(m_symbols, addr_cache);
630  std::stable_sort(indexes.begin(), indexes.end(), comparator);
631 
632  // Remove any duplicates if requested
633  if (remove_duplicates) {
634  auto last = std::unique(indexes.begin(), indexes.end());
635  indexes.erase(last, indexes.end());
636  }
637 }
638 
640  std::vector<uint32_t> &indexes) {
641  auto &name_to_index = GetNameToSymbolIndexMap(lldb::eFunctionNameTypeNone);
642  const uint32_t count = name_to_index.GetValues(symbol_name, indexes);
643  if (count)
644  return count;
645  // Synthetic symbol names are not added to the name indexes, but they start
646  // with a prefix and end with a the symbol UserID. This allows users to find
647  // these symbols without having to add them to the name indexes. These
648  // queries will not happen very often since the names don't mean anything, so
649  // performance is not paramount in this case.
650  llvm::StringRef name = symbol_name.GetStringRef();
651  // String the synthetic prefix if the name starts with it.
652  if (!name.consume_front(Symbol::GetSyntheticSymbolPrefix()))
653  return 0; // Not a synthetic symbol name
654 
655  // Extract the user ID from the symbol name
656  unsigned long long uid = 0;
657  if (getAsUnsignedInteger(name, /*Radix=*/10, uid))
658  return 0; // Failed to extract the user ID as an integer
659  Symbol *symbol = FindSymbolByID(uid);
660  if (symbol == nullptr)
661  return 0;
662  const uint32_t symbol_idx = GetIndexForSymbol(symbol);
663  if (symbol_idx == UINT32_MAX)
664  return 0;
665  indexes.push_back(symbol_idx);
666  return 1;
667 }
668 
670  std::vector<uint32_t> &indexes) {
671  std::lock_guard<std::recursive_mutex> guard(m_mutex);
672 
673  if (symbol_name) {
675  InitNameIndexes();
676 
677  return GetNameIndexes(symbol_name, indexes);
678  }
679  return 0;
680 }
681 
683  Debug symbol_debug_type,
684  Visibility symbol_visibility,
685  std::vector<uint32_t> &indexes) {
686  std::lock_guard<std::recursive_mutex> guard(m_mutex);
687 
689  if (symbol_name) {
690  const size_t old_size = indexes.size();
692  InitNameIndexes();
693 
694  std::vector<uint32_t> all_name_indexes;
695  const size_t name_match_count =
696  GetNameIndexes(symbol_name, all_name_indexes);
697  for (size_t i = 0; i < name_match_count; ++i) {
698  if (CheckSymbolAtIndex(all_name_indexes[i], symbol_debug_type,
699  symbol_visibility))
700  indexes.push_back(all_name_indexes[i]);
701  }
702  return indexes.size() - old_size;
703  }
704  return 0;
705 }
706 
707 uint32_t
709  SymbolType symbol_type,
710  std::vector<uint32_t> &indexes) {
711  std::lock_guard<std::recursive_mutex> guard(m_mutex);
712 
713  if (AppendSymbolIndexesWithName(symbol_name, indexes) > 0) {
714  std::vector<uint32_t>::iterator pos = indexes.begin();
715  while (pos != indexes.end()) {
716  if (symbol_type == eSymbolTypeAny ||
717  m_symbols[*pos].GetType() == symbol_type)
718  ++pos;
719  else
720  pos = indexes.erase(pos);
721  }
722  }
723  return indexes.size();
724 }
725 
727  ConstString symbol_name, SymbolType symbol_type,
728  Debug symbol_debug_type, Visibility symbol_visibility,
729  std::vector<uint32_t> &indexes) {
730  std::lock_guard<std::recursive_mutex> guard(m_mutex);
731 
732  if (AppendSymbolIndexesWithName(symbol_name, symbol_debug_type,
733  symbol_visibility, indexes) > 0) {
734  std::vector<uint32_t>::iterator pos = indexes.begin();
735  while (pos != indexes.end()) {
736  if (symbol_type == eSymbolTypeAny ||
737  m_symbols[*pos].GetType() == symbol_type)
738  ++pos;
739  else
740  pos = indexes.erase(pos);
741  }
742  }
743  return indexes.size();
744 }
745 
747  const RegularExpression &regexp, SymbolType symbol_type,
748  std::vector<uint32_t> &indexes) {
749  std::lock_guard<std::recursive_mutex> guard(m_mutex);
750 
751  uint32_t prev_size = indexes.size();
752  uint32_t sym_end = m_symbols.size();
753 
754  for (uint32_t i = 0; i < sym_end; i++) {
755  if (symbol_type == eSymbolTypeAny ||
756  m_symbols[i].GetType() == symbol_type) {
757  const char *name = m_symbols[i].GetName().AsCString();
758  if (name) {
759  if (regexp.Execute(name))
760  indexes.push_back(i);
761  }
762  }
763  }
764  return indexes.size() - prev_size;
765 }
766 
768  const RegularExpression &regexp, SymbolType symbol_type,
769  Debug symbol_debug_type, Visibility symbol_visibility,
770  std::vector<uint32_t> &indexes) {
771  std::lock_guard<std::recursive_mutex> guard(m_mutex);
772 
773  uint32_t prev_size = indexes.size();
774  uint32_t sym_end = m_symbols.size();
775 
776  for (uint32_t i = 0; i < sym_end; i++) {
777  if (symbol_type == eSymbolTypeAny ||
778  m_symbols[i].GetType() == symbol_type) {
779  if (!CheckSymbolAtIndex(i, symbol_debug_type, symbol_visibility))
780  continue;
781 
782  const char *name = m_symbols[i].GetName().AsCString();
783  if (name) {
784  if (regexp.Execute(name))
785  indexes.push_back(i);
786  }
787  }
788  }
789  return indexes.size() - prev_size;
790 }
791 
793  Debug symbol_debug_type,
794  Visibility symbol_visibility,
795  uint32_t &start_idx) {
796  std::lock_guard<std::recursive_mutex> guard(m_mutex);
797 
798  const size_t count = m_symbols.size();
799  for (size_t idx = start_idx; idx < count; ++idx) {
800  if (symbol_type == eSymbolTypeAny ||
801  m_symbols[idx].GetType() == symbol_type) {
802  if (CheckSymbolAtIndex(idx, symbol_debug_type, symbol_visibility)) {
803  start_idx = idx;
804  return &m_symbols[idx];
805  }
806  }
807  }
808  return nullptr;
809 }
810 
811 void
813  SymbolType symbol_type,
814  std::vector<uint32_t> &symbol_indexes) {
815  std::lock_guard<std::recursive_mutex> guard(m_mutex);
816 
817  // Initialize all of the lookup by name indexes before converting NAME to a
818  // uniqued string NAME_STR below.
820  InitNameIndexes();
821 
822  if (name) {
823  // The string table did have a string that matched, but we need to check
824  // the symbols and match the symbol_type if any was given.
825  AppendSymbolIndexesWithNameAndType(name, symbol_type, symbol_indexes);
826  }
827 }
828 
830  ConstString name, SymbolType symbol_type, Debug symbol_debug_type,
831  Visibility symbol_visibility, std::vector<uint32_t> &symbol_indexes) {
832  std::lock_guard<std::recursive_mutex> guard(m_mutex);
833 
835  // Initialize all of the lookup by name indexes before converting NAME to a
836  // uniqued string NAME_STR below.
838  InitNameIndexes();
839 
840  if (name) {
841  // The string table did have a string that matched, but we need to check
842  // the symbols and match the symbol_type if any was given.
843  AppendSymbolIndexesWithNameAndType(name, symbol_type, symbol_debug_type,
844  symbol_visibility, symbol_indexes);
845  }
846 }
847 
849  const RegularExpression &regex, SymbolType symbol_type,
850  Debug symbol_debug_type, Visibility symbol_visibility,
851  std::vector<uint32_t> &symbol_indexes) {
852  std::lock_guard<std::recursive_mutex> guard(m_mutex);
853 
854  AppendSymbolIndexesMatchingRegExAndType(regex, symbol_type, symbol_debug_type,
855  symbol_visibility, symbol_indexes);
856 }
857 
859  SymbolType symbol_type,
860  Debug symbol_debug_type,
861  Visibility symbol_visibility) {
862  std::lock_guard<std::recursive_mutex> guard(m_mutex);
865  InitNameIndexes();
866 
867  if (name) {
868  std::vector<uint32_t> matching_indexes;
869  // The string table did have a string that matched, but we need to check
870  // the symbols and match the symbol_type if any was given.
871  if (AppendSymbolIndexesWithNameAndType(name, symbol_type, symbol_debug_type,
872  symbol_visibility,
873  matching_indexes)) {
874  std::vector<uint32_t>::const_iterator pos, end = matching_indexes.end();
875  for (pos = matching_indexes.begin(); pos != end; ++pos) {
876  Symbol *symbol = SymbolAtIndex(*pos);
877 
878  if (symbol->Compare(name, symbol_type))
879  return symbol;
880  }
881  }
882  }
883  return nullptr;
884 }
885 
886 typedef struct {
887  const Symtab *symtab;
893 
894 // Add all the section file start address & size to the RangeVector, recusively
895 // adding any children sections.
896 static void AddSectionsToRangeMap(SectionList *sectlist,
897  RangeVector<addr_t, addr_t> &section_ranges) {
898  const int num_sections = sectlist->GetNumSections(0);
899  for (int i = 0; i < num_sections; i++) {
900  SectionSP sect_sp = sectlist->GetSectionAtIndex(i);
901  if (sect_sp) {
902  SectionList &child_sectlist = sect_sp->GetChildren();
903 
904  // If this section has children, add the children to the RangeVector.
905  // Else add this section to the RangeVector.
906  if (child_sectlist.GetNumSections(0) > 0) {
907  AddSectionsToRangeMap(&child_sectlist, section_ranges);
908  } else {
909  size_t size = sect_sp->GetByteSize();
910  if (size > 0) {
911  addr_t base_addr = sect_sp->GetFileAddress();
913  entry.SetRangeBase(base_addr);
914  entry.SetByteSize(size);
915  section_ranges.Append(entry);
916  }
917  }
918  }
919  }
920 }
921 
923  // Protected function, no need to lock mutex...
924  if (!m_file_addr_to_index_computed && !m_symbols.empty()) {
926 
928  const_iterator begin = m_symbols.begin();
929  const_iterator end = m_symbols.end();
930  for (const_iterator pos = m_symbols.begin(); pos != end; ++pos) {
931  if (pos->ValueIsAddress()) {
932  entry.SetRangeBase(pos->GetAddressRef().GetFileAddress());
933  entry.SetByteSize(pos->GetByteSize());
934  entry.data = std::distance(begin, pos);
936  }
937  }
938  const size_t num_entries = m_file_addr_to_index.GetSize();
939  if (num_entries > 0) {
941 
942  // Create a RangeVector with the start & size of all the sections for
943  // this objfile. We'll need to check this for any FileRangeToIndexMap
944  // entries with an uninitialized size, which could potentially be a large
945  // number so reconstituting the weak pointer is busywork when it is
946  // invariant information.
947  SectionList *sectlist = m_objfile->GetSectionList();
948  RangeVector<addr_t, addr_t> section_ranges;
949  if (sectlist) {
950  AddSectionsToRangeMap(sectlist, section_ranges);
951  section_ranges.Sort();
952  }
953 
954  // Iterate through the FileRangeToIndexMap and fill in the size for any
955  // entries that didn't already have a size from the Symbol (e.g. if we
956  // have a plain linker symbol with an address only, instead of debug info
957  // where we get an address and a size and a type, etc.)
958  for (size_t i = 0; i < num_entries; i++) {
961  if (entry->GetByteSize() == 0) {
962  addr_t curr_base_addr = entry->GetRangeBase();
963  const RangeVector<addr_t, addr_t>::Entry *containing_section =
964  section_ranges.FindEntryThatContains(curr_base_addr);
965 
966  // Use the end of the section as the default max size of the symbol
967  addr_t sym_size = 0;
968  if (containing_section) {
969  sym_size =
970  containing_section->GetByteSize() -
971  (entry->GetRangeBase() - containing_section->GetRangeBase());
972  }
973 
974  for (size_t j = i; j < num_entries; j++) {
975  FileRangeToIndexMap::Entry *next_entry =
977  addr_t next_base_addr = next_entry->GetRangeBase();
978  if (next_base_addr > curr_base_addr) {
979  addr_t size_to_next_symbol = next_base_addr - curr_base_addr;
980 
981  // Take the difference between this symbol and the next one as
982  // its size, if it is less than the size of the section.
983  if (sym_size == 0 || size_to_next_symbol < sym_size) {
984  sym_size = size_to_next_symbol;
985  }
986  break;
987  }
988  }
989 
990  if (sym_size > 0) {
991  entry->SetByteSize(sym_size);
992  Symbol &symbol = m_symbols[entry->data];
993  symbol.SetByteSize(sym_size);
994  symbol.SetSizeIsSynthesized(true);
995  }
996  }
997  }
998 
999  // Sort again in case the range size changes the ordering
1001  }
1002  }
1003 }
1004 
1006  std::lock_guard<std::recursive_mutex> guard(m_mutex);
1007  // Calculate the size of symbols inside InitAddressIndexes.
1009  // Shrink to fit the symbols so we don't waste memory
1010  if (m_symbols.capacity() > m_symbols.size()) {
1011  collection new_symbols(m_symbols.begin(), m_symbols.end());
1012  m_symbols.swap(new_symbols);
1013  }
1014  SaveToCache();
1015 }
1016 
1018  std::lock_guard<std::recursive_mutex> guard(m_mutex);
1021 
1022  const FileRangeToIndexMap::Entry *entry =
1024  if (entry) {
1025  Symbol *symbol = SymbolAtIndex(entry->data);
1026  if (symbol->GetFileAddress() == file_addr)
1027  return symbol;
1028  }
1029  return nullptr;
1030 }
1031 
1033  std::lock_guard<std::recursive_mutex> guard(m_mutex);
1034 
1037 
1038  const FileRangeToIndexMap::Entry *entry =
1040  if (entry) {
1041  Symbol *symbol = SymbolAtIndex(entry->data);
1042  if (symbol->ContainsFileAddress(file_addr))
1043  return symbol;
1044  }
1045  return nullptr;
1046 }
1047 
1049  addr_t file_addr, std::function<bool(Symbol *)> const &callback) {
1050  std::lock_guard<std::recursive_mutex> guard(m_mutex);
1051 
1054 
1055  std::vector<uint32_t> all_addr_indexes;
1056 
1057  // Get all symbols with file_addr
1058  const size_t addr_match_count =
1060  all_addr_indexes);
1061 
1062  for (size_t i = 0; i < addr_match_count; ++i) {
1063  Symbol *symbol = SymbolAtIndex(all_addr_indexes[i]);
1064  if (symbol->ContainsFileAddress(file_addr)) {
1065  if (!callback(symbol))
1066  break;
1067  }
1068  }
1069 }
1070 
1072  std::vector<uint32_t> &symbol_indexes, SymbolContextList &sc_list) {
1073  // No need to protect this call using m_mutex all other method calls are
1074  // already thread safe.
1075 
1076  const bool merge_symbol_into_function = true;
1077  size_t num_indices = symbol_indexes.size();
1078  if (num_indices > 0) {
1079  SymbolContext sc;
1080  sc.module_sp = m_objfile->GetModule();
1081  for (size_t i = 0; i < num_indices; i++) {
1082  sc.symbol = SymbolAtIndex(symbol_indexes[i]);
1083  if (sc.symbol)
1084  sc_list.AppendIfUnique(sc, merge_symbol_into_function);
1085  }
1086  }
1087 }
1088 
1090  SymbolContextList &sc_list) {
1091  std::vector<uint32_t> symbol_indexes;
1092 
1093  // eFunctionNameTypeAuto should be pre-resolved by a call to
1094  // Module::LookupInfo::LookupInfo()
1095  assert((name_type_mask & eFunctionNameTypeAuto) == 0);
1096 
1097  if (name_type_mask & (eFunctionNameTypeBase | eFunctionNameTypeFull)) {
1098  std::vector<uint32_t> temp_symbol_indexes;
1099  FindAllSymbolsWithNameAndType(name, eSymbolTypeAny, temp_symbol_indexes);
1100 
1101  unsigned temp_symbol_indexes_size = temp_symbol_indexes.size();
1102  if (temp_symbol_indexes_size > 0) {
1103  std::lock_guard<std::recursive_mutex> guard(m_mutex);
1104  for (unsigned i = 0; i < temp_symbol_indexes_size; i++) {
1105  SymbolContext sym_ctx;
1106  sym_ctx.symbol = SymbolAtIndex(temp_symbol_indexes[i]);
1107  if (sym_ctx.symbol) {
1108  switch (sym_ctx.symbol->GetType()) {
1109  case eSymbolTypeCode:
1110  case eSymbolTypeResolver:
1111  case eSymbolTypeReExported:
1112  case eSymbolTypeAbsolute:
1113  symbol_indexes.push_back(temp_symbol_indexes[i]);
1114  break;
1115  default:
1116  break;
1117  }
1118  }
1119  }
1120  }
1121  }
1122 
1124  InitNameIndexes();
1125 
1126  for (lldb::FunctionNameType type :
1127  {lldb::eFunctionNameTypeBase, lldb::eFunctionNameTypeMethod,
1128  lldb::eFunctionNameTypeSelector}) {
1129  if (name_type_mask & type) {
1130  auto map = GetNameToSymbolIndexMap(type);
1131 
1132  const UniqueCStringMap<uint32_t>::Entry *match;
1133  for (match = map.FindFirstValueForName(name); match != nullptr;
1134  match = map.FindNextValueForName(match)) {
1135  symbol_indexes.push_back(match->value);
1136  }
1137  }
1138  }
1139 
1140  if (!symbol_indexes.empty()) {
1141  llvm::sort(symbol_indexes.begin(), symbol_indexes.end());
1142  symbol_indexes.erase(
1143  std::unique(symbol_indexes.begin(), symbol_indexes.end()),
1144  symbol_indexes.end());
1145  SymbolIndicesToSymbolContextList(symbol_indexes, sc_list);
1146  }
1147 }
1148 
1149 const Symbol *Symtab::GetParent(Symbol *child_symbol) const {
1150  uint32_t child_idx = GetIndexForSymbol(child_symbol);
1151  if (child_idx != UINT32_MAX && child_idx > 0) {
1152  for (uint32_t idx = child_idx - 1; idx != UINT32_MAX; --idx) {
1153  const Symbol *symbol = SymbolAtIndex(idx);
1154  const uint32_t sibling_idx = symbol->GetSiblingIndex();
1155  if (sibling_idx != UINT32_MAX && sibling_idx > child_idx)
1156  return symbol;
1157  }
1158  }
1159  return nullptr;
1160 }
1161 
1163  std::string key;
1164  llvm::raw_string_ostream strm(key);
1165  // Symbol table can come from different object files for the same module. A
1166  // module can have one object file as the main executable and might have
1167  // another object file in a separate symbol file.
1168  strm << m_objfile->GetModule()->GetCacheKey() << "-symtab-"
1169  << llvm::format_hex(m_objfile->GetCacheHash(), 10);
1170  return strm.str();
1171 }
1172 
1175  if (!cache)
1176  return; // Caching is not enabled.
1177  InitNameIndexes(); // Init the name indexes so we can cache them as well.
1178  const auto byte_order = endian::InlHostByteOrder();
1179  DataEncoder file(byte_order, /*addr_size=*/8);
1180  // Encode will return false if the symbol table's object file doesn't have
1181  // anything to make a signature from.
1182  if (Encode(file))
1183  if (cache->SetCachedData(GetCacheKey(), file.GetData()))
1185 }
1186 
1187 constexpr llvm::StringLiteral kIdentifierCStrMap("CMAP");
1188 
1189 static void EncodeCStrMap(DataEncoder &encoder, ConstStringTable &strtab,
1190  const UniqueCStringMap<uint32_t> &cstr_map) {
1191  encoder.AppendData(kIdentifierCStrMap);
1192  encoder.AppendU32(cstr_map.GetSize());
1193  for (const auto &entry: cstr_map) {
1194  // Make sure there are no empty strings.
1195  assert((bool)entry.cstring);
1196  encoder.AppendU32(strtab.Add(entry.cstring));
1197  encoder.AppendU32(entry.value);
1198  }
1199 }
1200 
1201 bool DecodeCStrMap(const DataExtractor &data, lldb::offset_t *offset_ptr,
1202  const StringTableReader &strtab,
1203  UniqueCStringMap<uint32_t> &cstr_map) {
1204  llvm::StringRef identifier((const char *)data.GetData(offset_ptr, 4), 4);
1205  if (identifier != kIdentifierCStrMap)
1206  return false;
1207  const uint32_t count = data.GetU32(offset_ptr);
1208  for (uint32_t i=0; i<count; ++i)
1209  {
1210  llvm::StringRef str(strtab.Get(data.GetU32(offset_ptr)));
1211  uint32_t value = data.GetU32(offset_ptr);
1212  // No empty strings in the name indexes in Symtab
1213  if (str.empty())
1214  return false;
1215  cstr_map.Append(ConstString(str), value);
1216  }
1217  return true;
1218 }
1219 
1220 constexpr llvm::StringLiteral kIdentifierSymbolTable("SYMB");
1222 
1223 /// The encoding format for the symbol table is as follows:
1224 ///
1225 /// Signature signature;
1226 /// ConstStringTable strtab;
1227 /// Identifier four character code: 'SYMB'
1228 /// uint32_t version;
1229 /// uint32_t num_symbols;
1230 /// Symbol symbols[num_symbols];
1231 /// uint8_t num_cstr_maps;
1232 /// UniqueCStringMap<uint32_t> cstr_maps[num_cstr_maps]
1233 bool Symtab::Encode(DataEncoder &encoder) const {
1234  // Name indexes must be computed before calling this function.
1235  assert(m_name_indexes_computed);
1236 
1237  // Encode the object file's signature
1238  CacheSignature signature(m_objfile);
1239  if (!signature.Encode(encoder))
1240  return false;
1241  ConstStringTable strtab;
1242 
1243  // Encoder the symbol table into a separate encoder first. This allows us
1244  // gather all of the strings we willl need in "strtab" as we will need to
1245  // write the string table out before the symbol table.
1246  DataEncoder symtab_encoder(encoder.GetByteOrder(),
1247  encoder.GetAddressByteSize());
1248  symtab_encoder.AppendData(kIdentifierSymbolTable);
1249  // Encode the symtab data version.
1250  symtab_encoder.AppendU32(CURRENT_CACHE_VERSION);
1251  // Encode the number of symbols.
1252  symtab_encoder.AppendU32(m_symbols.size());
1253  // Encode the symbol data for all symbols.
1254  for (const auto &symbol: m_symbols)
1255  symbol.Encode(symtab_encoder, strtab);
1256 
1257  // Emit a byte for how many C string maps we emit. We will fix this up after
1258  // we emit the C string maps since we skip emitting C string maps if they are
1259  // empty.
1260  size_t num_cmaps_offset = symtab_encoder.GetByteSize();
1261  uint8_t num_cmaps = 0;
1262  symtab_encoder.AppendU8(0);
1263  for (const auto &pair: m_name_to_symbol_indices) {
1264  if (pair.second.IsEmpty())
1265  continue;
1266  ++num_cmaps;
1267  symtab_encoder.AppendU8(pair.first);
1268  EncodeCStrMap(symtab_encoder, strtab, pair.second);
1269  }
1270  if (num_cmaps > 0)
1271  symtab_encoder.PutU8(num_cmaps_offset, num_cmaps);
1272 
1273  // Now that all strings have been gathered, we will emit the string table.
1274  strtab.Encode(encoder);
1275  // Followed the the symbol table data.
1276  encoder.AppendData(symtab_encoder.GetData());
1277  return true;
1278 }
1279 
1280 bool Symtab::Decode(const DataExtractor &data, lldb::offset_t *offset_ptr,
1281  bool &signature_mismatch) {
1282  signature_mismatch = false;
1283  CacheSignature signature;
1284  StringTableReader strtab;
1285  { // Scope for "elapsed" object below so it can measure the time parse.
1286  ElapsedTime elapsed(m_objfile->GetModule()->GetSymtabParseTime());
1287  if (!signature.Decode(data, offset_ptr))
1288  return false;
1289  if (CacheSignature(m_objfile) != signature) {
1290  signature_mismatch = true;
1291  return false;
1292  }
1293  // We now decode the string table for all strings in the data cache file.
1294  if (!strtab.Decode(data, offset_ptr))
1295  return false;
1296 
1297  // And now we can decode the symbol table with string table we just decoded.
1298  llvm::StringRef identifier((const char *)data.GetData(offset_ptr, 4), 4);
1299  if (identifier != kIdentifierSymbolTable)
1300  return false;
1301  const uint32_t version = data.GetU32(offset_ptr);
1302  if (version != CURRENT_CACHE_VERSION)
1303  return false;
1304  const uint32_t num_symbols = data.GetU32(offset_ptr);
1305  if (num_symbols == 0)
1306  return true;
1307  m_symbols.resize(num_symbols);
1308  SectionList *sections = m_objfile->GetModule()->GetSectionList();
1309  for (uint32_t i=0; i<num_symbols; ++i) {
1310  if (!m_symbols[i].Decode(data, offset_ptr, sections, strtab))
1311  return false;
1312  }
1313  }
1314 
1315  { // Scope for "elapsed" object below so it can measure the time to index.
1316  ElapsedTime elapsed(m_objfile->GetModule()->GetSymtabIndexTime());
1317  const uint8_t num_cstr_maps = data.GetU8(offset_ptr);
1318  for (uint8_t i=0; i<num_cstr_maps; ++i) {
1319  uint8_t type = data.GetU8(offset_ptr);
1320  UniqueCStringMap<uint32_t> &cstr_map =
1321  GetNameToSymbolIndexMap((lldb::FunctionNameType)type);
1322  if (!DecodeCStrMap(data, offset_ptr, strtab, cstr_map))
1323  return false;
1324  }
1325  m_name_indexes_computed = true;
1326  }
1327  return true;
1328 }
1329 
1332  if (!cache)
1333  return false;
1334 
1335  std::unique_ptr<llvm::MemoryBuffer> mem_buffer_up =
1336  cache->GetCachedData(GetCacheKey());
1337  if (!mem_buffer_up)
1338  return false;
1339  DataExtractor data(mem_buffer_up->getBufferStart(),
1340  mem_buffer_up->getBufferSize(),
1343  bool signature_mismatch = false;
1344  lldb::offset_t offset = 0;
1345  const bool result = Decode(data, &offset, signature_mismatch);
1346  if (signature_mismatch)
1347  cache->RemoveCacheFile(GetCacheKey());
1348  if (result)
1350  return result;
1351 }
RegularExpression.h
SymbolSearchInfo::symtab
const Symtab * symtab
Definition: Symtab.cpp:887
lldb_private::Stream::IndentLess
void IndentLess(unsigned amount=2)
Decrement the current indentation level.
Definition: Stream.cpp:171
lldb_private::ConstStringTable::Encode
bool Encode(DataEncoder &encoder)
Definition: DataFileCache.cpp:265
lldb_private::eSortOrderByAddress
@ eSortOrderByAddress
Definition: lldb-private-enumerations.h:110
lldb_private::Range::GetRangeBase
BaseType GetRangeBase() const
Definition: RangeMap.h:46
lldb_private::Symtab::m_file_addr_to_index
FileRangeToIndexMap m_file_addr_to_index
Definition: Symtab.h:272
lldb_private::RegularExpression
Definition: RegularExpression.h:18
lldb_private::StringTableReader
Many cache files require string tables to store data efficiently.
Definition: DataFileCache.h:201
lldb_private::ObjectFile::GetFileSpec
virtual FileSpec & GetFileSpec()
Get accessor to the object file specification.
Definition: ObjectFile.h:292
lldb_private::Symtab::m_objfile
ObjectFile * m_objfile
Definition: Symtab.h:270
lldb::eSymbolTypeCode
@ eSymbolTypeCode
Definition: lldb-enumerations.h:616
lldb_private::Symtab::SetWasSavedToCache
void SetWasSavedToCache()
Definition: Symtab.h:234
SymbolSearchInfo::file_addr
const addr_t file_addr
Definition: Symtab.cpp:888
lldb_private::Symtab::AppendSymbolIndexesWithTypeAndFlagsValue
uint32_t AppendSymbolIndexesWithTypeAndFlagsValue(lldb::SymbolType symbol_type, uint32_t flags_value, std::vector< uint32_t > &indexes, uint32_t start_idx=0, uint32_t end_index=UINT32_MAX) const
Definition: Symtab.cpp:506
lldb_private::Symtab::AppendSymbolNamesToMap
void AppendSymbolNamesToMap(const IndexCollection &indexes, bool add_demangled, bool add_mangled, NameToIndexMap &name_to_index_map) const
Definition: Symtab.cpp:460
lldb_private::RangeDataVector::GetEntryRef
Entry & GetEntryRef(size_t i)
Definition: RangeMap.h:488
lldb_private::Symbol::GetSyntheticSymbolPrefix
static llvm::StringRef GetSyntheticSymbolPrefix()
Definition: Symbol.h:234
lldb_private::Symtab::GetNameToSymbolIndexMap
UniqueCStringMap< uint32_t > & GetNameToSymbolIndexMap(lldb::FunctionNameType type)
Definition: Symtab.h:284
lldb_private::DataFileCache::GetCachedData
std::unique_ptr< llvm::MemoryBuffer > GetCachedData(llvm::StringRef key)
Get cached data from the cache directory for the specified key.
Definition: DataFileCache.cpp:67
lldb_private::Symbol::SetSizeIsSynthesized
void SetSizeIsSynthesized(bool b)
Definition: Symbol.h:164
lldb_private::RangeVector::Sort
void Sort()
Definition: RangeMap.h:174
lldb_private::Symbol
Definition: Symbol.h:20
lldb_private::Module::GetIndexCache
static DataFileCache * GetIndexCache()
Get the global index file cache.
Definition: Module.cpp:1688
lldb_private::Symtab::GetParent
const Symbol * GetParent(Symbol *symbol) const
Get the parent symbol for the given symbol.
Definition: Symtab.cpp:1149
lldb_private::Symtab::PreloadSymbols
void PreloadSymbols()
Definition: Symtab.cpp:455
lldb_private::ConstStringTable
Many cache files require string tables to store data efficiently.
Definition: DataFileCache.h:169
lldb_private::Symtab::m_symbols
collection m_symbols
Definition: Symtab.h:271
lldb_private::Symtab::Debug
Debug
Definition: Symtab.h:27
lldb_private::ElapsedTime
A class that measures elapsed time in an exception safe way.
Definition: Statistics.h:65
SymbolSearchInfo
Definition: Symtab.cpp:886
Module.h
lldb_private::RichManglingContext::IsCtorOrDtor
bool IsCtorOrDtor() const
If this symbol describes a constructor or destructor.
Definition: RichManglingContext.cpp:69
lldb_private::RangeDataVector::Sort
void Sort()
Definition: RangeMap.h:410
lldb_private::Symtab::~Symtab
~Symtab()
lldb_private::SymbolContextList
Definition: SymbolContext.h:379
lldb_private::StringTableReader::Get
llvm::StringRef Get(uint32_t offset) const
Definition: DataFileCache.cpp:303
AddSectionsToRangeMap
static void AddSectionsToRangeMap(SectionList *sectlist, RangeVector< addr_t, addr_t > &section_ranges)
Definition: Symtab.cpp:896
lldb_private::SectionList
Definition: Section.h:34
lldb::offset_t
uint64_t offset_t
Definition: lldb-types.h:87
lldb_private::RangeDataVector::Clear
void Clear()
Definition: RangeMap.h:472
lldb_private::Stream
Definition: Stream.h:28
lldb_private::RangeData
Definition: RangeMap.h:372
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
Language.h
lldb_private::Symtab::SymbolAtIndex
Symbol * SymbolAtIndex(size_t idx)
Definition: Symtab.cpp:217
lldb_private::Symbol::IsSyntheticWithAutoGeneratedName
bool IsSyntheticWithAutoGeneratedName() const
Definition: Symbol.cpp:573
SymbolSortInfo::sort_by_load_addr
const bool sort_by_load_addr
Definition: Symtab.cpp:559
lldb_private::SectionList::GetNumSections
size_t GetNumSections(uint32_t depth) const
Definition: Section.cpp:535
lldb_private::SymbolContext
Definition: SymbolContext.h:33
lldb_private::Target
Definition: Target.h:452
Section.h
lldb_private::Symtab::SetWasLoadedFromCache
void SetWasLoadedFromCache()
Definition: Symtab.h:228
lldb_private::eSortOrderNone
@ eSortOrderNone
Definition: lldb-private-enumerations.h:110
lldb_private::RangeVector::Append
void Append(const Entry &entry)
Definition: RangeMap.h:136
lldb_private::Symtab::FindFunctionSymbols
void FindFunctionSymbols(ConstString name, uint32_t name_type_mask, SymbolContextList &sc_list)
Definition: Symtab.cpp:1089
DataFileCache.h
lldb_private::CacheSignature::Decode
bool Decode(const DataExtractor &data, lldb::offset_t *offset_ptr)
Decode a serialized version of this object from data.
Definition: DataFileCache.cpp:222
lldb_private::Symtab::Encode
bool Encode(DataEncoder &encoder) const
Encode this object into a data encoder object.
Definition: Symtab.cpp:1233
lldb_private::ConstStringTable::Add
uint32_t Add(ConstString s)
Add a string into the string table.
Definition: DataFileCache.cpp:252
lldb_private::DataFileCache::SetCachedData
bool SetCachedData(llvm::StringRef key, llvm::ArrayRef< uint8_t > data)
Set cached data for the specified key.
Definition: DataFileCache.cpp:100
lldb_private::Symtab::FindFirstSymbolWithNameAndType
Symbol * FindFirstSymbolWithNameAndType(ConstString name, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility)
Definition: Symtab.cpp:858
lldb_private::Symbol::ContainsFileAddress
bool ContainsFileAddress(lldb::addr_t file_addr) const
Definition: Symbol.cpp:569
lldb_private::RangeDataVector::FindEntryThatContains
Entry * FindEntryThatContains(B addr)
Definition: RangeMap.h:513
lldb_private::Symbol::Dump
void Dump(Stream *s, Target *target, uint32_t index, Mangled::NamePreference name_preference=Mangled::ePreferDemangled) const
Definition: Symbol.cpp:214
lldb_private::FileSpec
Definition: FileSpec.h:56
elapsed
static double elapsed(const StatsTimepoint &start, const StatsTimepoint &end)
Definition: Statistics.cpp:36
lldb::eSymbolTypeAny
@ eSymbolTypeAny
Definition: lldb-enumerations.h:613
lldb_private::SymbolContext::symbol
Symbol * symbol
The Symbol for a given query.
Definition: SymbolContext.h:323
lldb_private::ObjectFile::GetSectionList
virtual SectionList * GetSectionList(bool update_module_section_list=true)
Gets the section list for the currently selected architecture (and object for archives).
Definition: ObjectFile.cpp:587
lldb_private::Symtab::m_mutex
std::recursive_mutex m_mutex
Definition: Symtab.h:278
lldb_private::Symbol::SetByteSize
void SetByteSize(lldb::addr_t size)
Definition: Symbol.h:186
lldb_private::DataFileCache::RemoveCacheFile
Status RemoveCacheFile(llvm::StringRef key)
Remove the cache file associated with the key.
Definition: DataFileCache.cpp:148
lldb_private::Symtab::LoadFromCache
bool LoadFromCache()
Load the symbol table from the index cache.
Definition: Symtab.cpp:1330
lldb_private::RangeDataVector::Append
void Append(const Entry &entry)
Definition: RangeMap.h:408
lldb_private::RangeDataVector::FindEntryIndexesThatContain
uint32_t FindEntryIndexesThatContain(B addr, std::vector< uint32_t > &indexes)
Definition: RangeMap.h:503
kIdentifierSymbolTable
constexpr llvm::StringLiteral kIdentifierSymbolTable("SYMB")
lldb_private::Stream::Indent
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
Definition: Stream.cpp:130
lldb_private::Symtab::m_name_to_symbol_indices
std::map< lldb::FunctionNameType, UniqueCStringMap< uint32_t > > m_name_to_symbol_indices
Maps function names to symbol indices (grouped by FunctionNameTypes)
Definition: Symtab.h:276
EncodeCStrMap
static void EncodeCStrMap(DataEncoder &encoder, ConstStringTable &strtab, const UniqueCStringMap< uint32_t > &cstr_map)
Definition: Symtab.cpp:1189
lldb_private::DataExtractor
Definition: DataExtractor.h:48
lldb_private::Symtab::Dump
void Dump(Stream *s, Target *target, SortOrder sort_type, Mangled::NamePreference name_preference=Mangled::ePreferDemangled)
Definition: Symtab.cpp:88
lldb_private::ConstString::GetStringRef
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
Definition: ConstString.h:202
CURRENT_CACHE_VERSION
constexpr uint32_t CURRENT_CACHE_VERSION
Definition: Symtab.cpp:1221
lldb_private::Symtab::DumpSymbolHeader
static void DumpSymbolHeader(Stream *s)
Definition: Symtab.cpp:186
lldb_private::UniqueCStringMap::GetSize
size_t GetSize() const
Definition: UniqueCStringMap.h:148
lldb_private::Symtab::Finalize
void Finalize()
Definition: Symtab.cpp:1005
kIdentifierCStrMap
constexpr llvm::StringLiteral kIdentifierCStrMap("CMAP")
lldb_private::StringTableReader::Decode
bool Decode(const DataExtractor &data, lldb::offset_t *offset_ptr)
Definition: DataFileCache.cpp:287
lldb_private::UniqueCStringMap::FindFirstValueForName
const Entry * FindFirstValueForName(ConstString unique_cstr) const
Definition: UniqueCStringMap.h:98
lldb_private::Symtab::GetNameIndexes
uint32_t GetNameIndexes(ConstString symbol_name, std::vector< uint32_t > &indexes)
A helper function that looks up full function names.
Definition: Symtab.cpp:639
lldb_private::ObjectFile::StripLinkerSymbolAnnotations
virtual llvm::StringRef StripLinkerSymbolAnnotations(llvm::StringRef symbol_name) const
Definition: ObjectFile.h:680
lldb_private::RichManglingContext::ParseFunctionBaseName
void ParseFunctionBaseName()
Get the base name of a function.
Definition: RichManglingContext.cpp:115
lldb_private::RichManglingContext::ParseFunctionDeclContextName
void ParseFunctionDeclContextName()
Get the context name for a function.
Definition: RichManglingContext.cpp:133
lldb_private::Symtab::m_file_addr_to_index_computed
bool m_file_addr_to_index_computed
Definition: Symtab.h:279
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::ObjectFile::GetByteOrder
virtual lldb::ByteOrder GetByteOrder() const =0
Gets whether endian swapping should occur when extracting data from this object file.
lldb_private::DataExtractor::GetU8
uint8_t GetU8(lldb::offset_t *offset_ptr) const
Extract a uint8_t value from *offset_ptr.
Definition: DataExtractor.cpp:318
lldb_private::Symtab::FindSymbolContainingFileAddress
Symbol * FindSymbolContainingFileAddress(lldb::addr_t file_addr)
Definition: Symtab.cpp:1032
lldb_private::Symtab::SaveToCache
void SaveToCache()
Save the symbol table data out into a cache.
Definition: Symtab.cpp:1173
Timer.h
lldb_private::CacheSignature
A signature for a given file on disk.
Definition: DataFileCache.h:97
DataEncoder.h
lldb_private::Symtab::const_iterator
collection::const_iterator const_iterator
Definition: Symtab.h:242
lldb_private::SectionList::GetSectionAtIndex
lldb::SectionSP GetSectionAtIndex(size_t idx) const
Definition: Section.cpp:546
lldb_private::Range
Definition: Process.h:61
LLDB_SCOPED_TIMER
#define LLDB_SCOPED_TIMER()
Definition: Timer.h:83
lldb_private::Symbol::Compare
bool Compare(ConstString name, lldb::SymbolType type) const
Definition: Symbol.cpp:334
lldb_private::SymbolContextList::AppendIfUnique
bool AppendIfUnique(const SymbolContext &sc, bool merge_symbol_into_function)
Definition: SymbolContext.cpp:1209
lldb_private::Symtab::GetIndexForSymbol
uint32_t GetIndexForSymbol(const Symbol *symbol) const
Definition: Symtab.cpp:549
lldb_private::Symtab::InitAddressIndexes
void InitAddressIndexes()
Definition: Symtab.cpp:922
lldb_private::Symtab::FindSymbolWithType
Symbol * FindSymbolWithType(lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, uint32_t &start_idx)
Definition: Symtab.cpp:792
lldb_private::Symbol::ContainsLinkerAnnotations
bool ContainsLinkerAnnotations() const
Definition: Symbol.h:205
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::Symtab::FindSymbolAtFileAddress
Symbol * FindSymbolAtFileAddress(lldb::addr_t file_addr)
Definition: Symtab.cpp:1017
lldb_private::Symbol::GetMangled
Mangled & GetMangled()
Definition: Symbol.h:121
lldb::SymbolType
SymbolType
Symbol types.
Definition: lldb-enumerations.h:612
lldb_private::RangeVector
Definition: RangeMap.h:125
lldb_private::UniqueCStringMap< uint32_t >
lldb_private::Symtab::RegisterBacklogEntry
void RegisterBacklogEntry(const NameToIndexMap::Entry &entry, const char *decl_context, const std::set< const char * > &class_contexts)
Definition: Symtab.cpp:437
ObjectFile.h
lldb_private::RangeDataVector::FindEntryStartsAt
const Entry * FindEntryStartsAt(B addr) const
Definition: RangeMap.h:542
Symbol.h
lldb_private::Symtab::GetNumSymbols
size_t GetNumSymbols() const
Definition: Symtab.cpp:77
lldb_private::Symtab::Reserve
void Reserve(size_t count)
Definition: Symtab.cpp:51
SymbolSearchInfo::match_index_ptr
const uint32_t * match_index_ptr
Definition: Symtab.cpp:890
lldb_private::Symtab::InitNameIndexes
void InitNameIndexes()
Definition: Symtab.cpp:269
lldb_private::CacheSignature::Encode
bool Encode(DataEncoder &encoder)
Encode this object into a data encoder object.
Definition: DataFileCache.cpp:200
lldb_private::Symtab::AddSymbol
uint32_t AddSymbol(const Symbol &symbol)
Definition: Symtab.cpp:64
lldb_private::Symtab::CheckSymbolAtIndex
bool CheckSymbolAtIndex(size_t idx, Debug symbol_debug_type, Visibility symbol_visibility) const
Definition: Symtab.h:289
lldb_private::RichManglingContext
Uniform wrapper for access to rich mangling information from different providers.
Definition: RichManglingContext.h:25
lldb_private::UniqueCStringMap::Append
void Append(ConstString unique_cstr, const T &value)
Definition: UniqueCStringMap.h:42
lldb_private::Symtab::AppendSymbolIndexesWithType
uint32_t AppendSymbolIndexesWithType(lldb::SymbolType symbol_type, std::vector< uint32_t > &indexes, uint32_t start_idx=0, uint32_t end_index=UINT32_MAX) const
Definition: Symtab.cpp:488
lldb_private::Symtab
Definition: Symtab.h:22
lldb_private::Symtab::AppendSymbolIndexesWithName
uint32_t AppendSymbolIndexesWithName(ConstString symbol_name, std::vector< uint32_t > &matches)
Definition: Symtab.cpp:669
uint32_t
lldb_private::Stream::IndentMore
void IndentMore(unsigned amount=2)
Increment the current indentation level.
Definition: Stream.cpp:168
lldb_private::Language
Definition: Language.h:29
lldb_private::RangeDataVector::GetSize
size_t GetSize() const
Definition: RangeMap.h:476
DecodeCStrMap
bool DecodeCStrMap(const DataExtractor &data, lldb::offset_t *offset_ptr, const StringTableReader &strtab, UniqueCStringMap< uint32_t > &cstr_map)
Definition: Symtab.cpp:1201
SymbolSearchInfo::match_symbol
Symbol * match_symbol
Definition: Symtab.cpp:889
lldb_skip_name
static bool lldb_skip_name(llvm::StringRef mangled, Mangled::ManglingScheme scheme)
Definition: Symtab.cpp:233
lldb_private::endian::InlHostByteOrder
lldb::ByteOrder InlHostByteOrder()
Definition: Endian.h:25
lldb_private::Symtab::FindSymbolByID
Symbol * FindSymbolByID(lldb::user_id_t uid) const
Definition: Symtab.cpp:208
Symtab.h
lldb_private::Range::SetRangeBase
void SetRangeBase(BaseType b)
Definition: RangeMap.h:48
lldb_private::Range::GetByteSize
SizeType GetByteSize() const
Definition: RangeMap.h:71
UINT32_MAX
#define UINT32_MAX
Definition: lldb-defines.h:19
lldb_private::Symtab::Visibility
Visibility
Definition: Symtab.h:33
lldb_private::Range::SetByteSize
void SetByteSize(SizeType s)
Definition: RangeMap.h:73
lldb_private::RichManglingContext::GetBufferRef
llvm::StringRef GetBufferRef() const
Obtain a StringRef to the internal buffer that holds the result of the most recent ParseXy() operatio...
Definition: RichManglingContext.h:61
lldb_private::ModuleChild::GetModule
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
Definition: ModuleChild.cpp:24
lldb_private::Symtab::Decode
bool Decode(const DataExtractor &data, lldb::offset_t *offset_ptr, bool &uuid_mismatch)
Decode a serialized version of this object from data.
Definition: Symtab.cpp:1280
lldb_private::Symtab::AppendSymbolIndexesWithNameAndType
uint32_t AppendSymbolIndexesWithNameAndType(ConstString symbol_name, lldb::SymbolType symbol_type, std::vector< uint32_t > &matches)
Definition: Symtab.cpp:708
lldb_private::SymbolContext::module_sp
lldb::ModuleSP module_sp
The Module for a given query.
Definition: SymbolContext.h:318
lldb_private::Symbol::GetFileAddress
lldb::addr_t GetFileAddress() const
Definition: Symbol.cpp:488
lldb_private::DataExtractor::GetU32
uint32_t GetU32(lldb::offset_t *offset_ptr) const
Extract a uint32_t value from *offset_ptr.
Definition: DataExtractor.cpp:427
lldb_private::ObjectFile::GetCacheHash
uint32_t GetCacheHash()
Get a hash that can be used for caching object file releated information.
Definition: ObjectFile.cpp:755
lldb_private::Symtab::SectionFileAddressesChanged
void SectionFileAddressesChanged()
Definition: Symtab.cpp:82
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:74
lldb_private::ConstString::GetCString
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:216
lldb_private::SortOrder
SortOrder
Definition: lldb-private-enumerations.h:110
lldb_private::Stream::Printf
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
lldb_private::DataFileCache
This class enables data to be cached into a directory using the llvm caching code.
Definition: DataFileCache.h:40
SymbolSortInfo::symbols
const Symbol * symbols
Definition: Symtab.cpp:560
lldb::user_id_t
uint64_t user_id_t
Definition: lldb-types.h:84
lldb::eSymbolTypeReExported
@ eSymbolTypeReExported
Definition: lldb-enumerations.h:643
SymbolContext.h
lldb_private::Symtab::GetCacheKey
std::string GetCacheKey()
Get the cache key string for this symbol table.
Definition: Symtab.cpp:1162
lldb_private::Symtab::RegisterMangledNameEntry
void RegisterMangledNameEntry(uint32_t value, std::set< const char * > &class_contexts, std::vector< std::pair< NameToIndexMap::Entry, const char * >> &backlog, RichManglingContext &rmc)
Definition: Symtab.cpp:381
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::RangeDataVector::GetMutableEntryAtIndex
Entry * GetMutableEntryAtIndex(size_t i)
Definition: RangeMap.h:482
lldb_private::ObjectFile::GetAddressByteSize
virtual uint32_t GetAddressByteSize() const =0
Gets the address size in bytes for the current object file.
lldb_private::Symtab::AppendSymbolIndexesMatchingRegExAndType
uint32_t AppendSymbolIndexesMatchingRegExAndType(const RegularExpression &regex, lldb::SymbolType symbol_type, std::vector< uint32_t > &indexes)
Definition: Symtab.cpp:746
lldb_private::Symtab::FindAllSymbolsWithNameAndType
void FindAllSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, std::vector< uint32_t > &symbol_indexes)
Definition: Symtab.cpp:812
lldb_private::Symbol::IsTrampoline
bool IsTrampoline() const
Definition: Symbol.cpp:175
lldb_private::RegularExpression::Execute
bool Execute(llvm::StringRef string, llvm::SmallVectorImpl< llvm::StringRef > *matches=nullptr) const
Execute a regular expression match using the compiled regular expression that is already in this obje...
Definition: RegularExpression.cpp:23
lldb_private::Symtab::SortSymbolIndexesByValue
void SortSymbolIndexesByValue(std::vector< uint32_t > &indexes, bool remove_duplicates) const
Definition: Symtab.cpp:614
Entry
FormatEntity::Entry Entry
Definition: FormatEntity.cpp:82
lldb_private::eSortOrderByName
@ eSortOrderByName
Definition: lldb-private-enumerations.h:110
lldb_private::DataExtractor::GetData
const void * GetData(lldb::offset_t *offset_ptr, lldb::offset_t length) const
Extract length bytes from *offset_ptr.
Definition: DataExtractor.h:337
lldb_private::RangeVector::FindEntryThatContains
const Entry * FindEntryThatContains(B addr) const
Definition: RangeMap.h:295
lldb_private::Symtab::m_name_indexes_computed
bool m_name_indexes_computed
Definition: Symtab.h:279
RichManglingContext.h
Stream.h
lldb_private::Symtab::Resize
Symbol * Resize(size_t count)
Definition: Symtab.cpp:57
lldb_private::Stream::PutCString
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:63
lldb_private::UniqueCStringMap::FindNextValueForName
const Entry * FindNextValueForName(const Entry *entry_ptr) const
Definition: UniqueCStringMap.h:111
lldb_private::Symtab::collection
std::vector< Symbol > collection
Definition: Symtab.h:240
lldb::eSymbolTypeResolver
@ eSymbolTypeResolver
Definition: lldb-enumerations.h:617
lldb_private::Language::ForEach
static void ForEach(std::function< bool(Language *)> callback)
Definition: Language.cpp:100
lldb_private::Symtab::IndexCollection
std::vector< uint32_t > IndexCollection
Definition: Symtab.h:24
lldb_private::RangeData::data
DataType data
Definition: RangeMap.h:375
lldb::eSymbolTypeAbsolute
@ eSymbolTypeAbsolute
Definition: lldb-enumerations.h:615
lldb_private::FileSpec::GetPath
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition: FileSpec.cpp:346
lldb_private::Symbol::GetType
lldb::SymbolType GetType() const
Definition: Symbol.h:143
lldb
Definition: SBAddress.h:15
Endian.h
lldb_private::Symtab::FindAllSymbolsMatchingRexExAndType
void FindAllSymbolsMatchingRexExAndType(const RegularExpression &regex, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector< uint32_t > &symbol_indexes)
Definition: Symtab.cpp:848
lldb_private::Symtab::SymbolIndicesToSymbolContextList
void SymbolIndicesToSymbolContextList(std::vector< uint32_t > &symbol_indexes, SymbolContextList &sc_list)
Definition: Symtab.cpp:1071
lldb_private::ObjectFile
Definition: ObjectFile.h:60
SymbolSortInfo
Definition: Symtab.cpp:558
lldb_private::Symtab::ForEachSymbolContainingFileAddress
void ForEachSymbolContainingFileAddress(lldb::addr_t file_addr, std::function< bool(Symbol *)> const &callback)
Definition: Symtab.cpp:1048
CompareSymbolID
static int CompareSymbolID(const void *key, const void *p)
Definition: Symtab.cpp:198
lldb_private::Symbol::GetSiblingIndex
uint32_t GetSiblingIndex() const
Definition: Symbol.cpp:171
SymbolSearchInfo::match_offset
addr_t match_offset
Definition: Symtab.cpp:891