Path: blob/main/contrib/llvm-project/lldb/source/Symbol/Symtab.cpp
39587 views
//===-- Symtab.cpp --------------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include <map>9#include <set>1011#include "lldb/Core/DataFileCache.h"12#include "lldb/Core/Module.h"13#include "lldb/Core/RichManglingContext.h"14#include "lldb/Core/Section.h"15#include "lldb/Symbol/ObjectFile.h"16#include "lldb/Symbol/Symbol.h"17#include "lldb/Symbol/SymbolContext.h"18#include "lldb/Symbol/Symtab.h"19#include "lldb/Target/Language.h"20#include "lldb/Utility/DataEncoder.h"21#include "lldb/Utility/Endian.h"22#include "lldb/Utility/RegularExpression.h"23#include "lldb/Utility/Stream.h"24#include "lldb/Utility/Timer.h"2526#include "llvm/ADT/ArrayRef.h"27#include "llvm/ADT/StringRef.h"28#include "llvm/Support/DJB.h"2930using namespace lldb;31using namespace lldb_private;3233Symtab::Symtab(ObjectFile *objfile)34: m_objfile(objfile), m_symbols(), m_file_addr_to_index(*this),35m_name_to_symbol_indices(), m_mutex(),36m_file_addr_to_index_computed(false), m_name_indexes_computed(false),37m_loaded_from_cache(false), m_saved_to_cache(false) {38m_name_to_symbol_indices.emplace(std::make_pair(39lldb::eFunctionNameTypeNone, UniqueCStringMap<uint32_t>()));40m_name_to_symbol_indices.emplace(std::make_pair(41lldb::eFunctionNameTypeBase, UniqueCStringMap<uint32_t>()));42m_name_to_symbol_indices.emplace(std::make_pair(43lldb::eFunctionNameTypeMethod, UniqueCStringMap<uint32_t>()));44m_name_to_symbol_indices.emplace(std::make_pair(45lldb::eFunctionNameTypeSelector, UniqueCStringMap<uint32_t>()));46}4748Symtab::~Symtab() = default;4950void Symtab::Reserve(size_t count) {51// Clients should grab the mutex from this symbol table and lock it manually52// when calling this function to avoid performance issues.53m_symbols.reserve(count);54}5556Symbol *Symtab::Resize(size_t count) {57// Clients should grab the mutex from this symbol table and lock it manually58// when calling this function to avoid performance issues.59m_symbols.resize(count);60return m_symbols.empty() ? nullptr : &m_symbols[0];61}6263uint32_t Symtab::AddSymbol(const Symbol &symbol) {64// Clients should grab the mutex from this symbol table and lock it manually65// when calling this function to avoid performance issues.66uint32_t symbol_idx = m_symbols.size();67auto &name_to_index = GetNameToSymbolIndexMap(lldb::eFunctionNameTypeNone);68name_to_index.Clear();69m_file_addr_to_index.Clear();70m_symbols.push_back(symbol);71m_file_addr_to_index_computed = false;72m_name_indexes_computed = false;73return symbol_idx;74}7576size_t Symtab::GetNumSymbols() const {77std::lock_guard<std::recursive_mutex> guard(m_mutex);78return m_symbols.size();79}8081void Symtab::SectionFileAddressesChanged() {82m_file_addr_to_index.Clear();83m_file_addr_to_index_computed = false;84}8586void Symtab::Dump(Stream *s, Target *target, SortOrder sort_order,87Mangled::NamePreference name_preference) {88std::lock_guard<std::recursive_mutex> guard(m_mutex);8990// s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);91s->Indent();92const FileSpec &file_spec = m_objfile->GetFileSpec();93const char *object_name = nullptr;94if (m_objfile->GetModule())95object_name = m_objfile->GetModule()->GetObjectName().GetCString();9697if (file_spec)98s->Printf("Symtab, file = %s%s%s%s, num_symbols = %" PRIu64,99file_spec.GetPath().c_str(), object_name ? "(" : "",100object_name ? object_name : "", object_name ? ")" : "",101(uint64_t)m_symbols.size());102else103s->Printf("Symtab, num_symbols = %" PRIu64 "", (uint64_t)m_symbols.size());104105if (!m_symbols.empty()) {106switch (sort_order) {107case eSortOrderNone: {108s->PutCString(":\n");109DumpSymbolHeader(s);110const_iterator begin = m_symbols.begin();111const_iterator end = m_symbols.end();112for (const_iterator pos = m_symbols.begin(); pos != end; ++pos) {113s->Indent();114pos->Dump(s, target, std::distance(begin, pos), name_preference);115}116}117break;118119case eSortOrderByName: {120// Although we maintain a lookup by exact name map, the table isn't121// sorted by name. So we must make the ordered symbol list up ourselves.122s->PutCString(" (sorted by name):\n");123DumpSymbolHeader(s);124125std::multimap<llvm::StringRef, const Symbol *> name_map;126for (const Symbol &symbol : m_symbols)127name_map.emplace(symbol.GetName().GetStringRef(), &symbol);128129for (const auto &name_to_symbol : name_map) {130const Symbol *symbol = name_to_symbol.second;131s->Indent();132symbol->Dump(s, target, symbol - &m_symbols[0], name_preference);133}134} break;135136case eSortOrderBySize: {137s->PutCString(" (sorted by size):\n");138DumpSymbolHeader(s);139140std::multimap<size_t, const Symbol *, std::greater<size_t>> size_map;141for (const Symbol &symbol : m_symbols)142size_map.emplace(symbol.GetByteSize(), &symbol);143144size_t idx = 0;145for (const auto &size_to_symbol : size_map) {146const Symbol *symbol = size_to_symbol.second;147s->Indent();148symbol->Dump(s, target, idx++, name_preference);149}150} break;151152case eSortOrderByAddress:153s->PutCString(" (sorted by address):\n");154DumpSymbolHeader(s);155if (!m_file_addr_to_index_computed)156InitAddressIndexes();157const size_t num_entries = m_file_addr_to_index.GetSize();158for (size_t i = 0; i < num_entries; ++i) {159s->Indent();160const uint32_t symbol_idx = m_file_addr_to_index.GetEntryRef(i).data;161m_symbols[symbol_idx].Dump(s, target, symbol_idx, name_preference);162}163break;164}165} else {166s->PutCString("\n");167}168}169170void Symtab::Dump(Stream *s, Target *target, std::vector<uint32_t> &indexes,171Mangled::NamePreference name_preference) const {172std::lock_guard<std::recursive_mutex> guard(m_mutex);173174const size_t num_symbols = GetNumSymbols();175// s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);176s->Indent();177s->Printf("Symtab %" PRIu64 " symbol indexes (%" PRIu64 " symbols total):\n",178(uint64_t)indexes.size(), (uint64_t)m_symbols.size());179s->IndentMore();180181if (!indexes.empty()) {182std::vector<uint32_t>::const_iterator pos;183std::vector<uint32_t>::const_iterator end = indexes.end();184DumpSymbolHeader(s);185for (pos = indexes.begin(); pos != end; ++pos) {186size_t idx = *pos;187if (idx < num_symbols) {188s->Indent();189m_symbols[idx].Dump(s, target, idx, name_preference);190}191}192}193s->IndentLess();194}195196void Symtab::DumpSymbolHeader(Stream *s) {197s->Indent(" Debug symbol\n");198s->Indent(" |Synthetic symbol\n");199s->Indent(" ||Externally Visible\n");200s->Indent(" |||\n");201s->Indent("Index UserID DSX Type File Address/Value Load "202"Address Size Flags Name\n");203s->Indent("------- ------ --- --------------- ------------------ "204"------------------ ------------------ ---------- "205"----------------------------------\n");206}207208static int CompareSymbolID(const void *key, const void *p) {209const user_id_t match_uid = *(const user_id_t *)key;210const user_id_t symbol_uid = ((const Symbol *)p)->GetID();211if (match_uid < symbol_uid)212return -1;213if (match_uid > symbol_uid)214return 1;215return 0;216}217218Symbol *Symtab::FindSymbolByID(lldb::user_id_t symbol_uid) const {219std::lock_guard<std::recursive_mutex> guard(m_mutex);220221Symbol *symbol =222(Symbol *)::bsearch(&symbol_uid, &m_symbols[0], m_symbols.size(),223sizeof(m_symbols[0]), CompareSymbolID);224return symbol;225}226227Symbol *Symtab::SymbolAtIndex(size_t idx) {228// Clients should grab the mutex from this symbol table and lock it manually229// when calling this function to avoid performance issues.230if (idx < m_symbols.size())231return &m_symbols[idx];232return nullptr;233}234235const Symbol *Symtab::SymbolAtIndex(size_t idx) const {236// Clients should grab the mutex from this symbol table and lock it manually237// when calling this function to avoid performance issues.238if (idx < m_symbols.size())239return &m_symbols[idx];240return nullptr;241}242243static bool lldb_skip_name(llvm::StringRef mangled,244Mangled::ManglingScheme scheme) {245switch (scheme) {246case Mangled::eManglingSchemeItanium: {247if (mangled.size() < 3 || !mangled.starts_with("_Z"))248return true;249250// Avoid the following types of symbols in the index.251switch (mangled[2]) {252case 'G': // guard variables253case 'T': // virtual tables, VTT structures, typeinfo structures + names254case 'Z': // named local entities (if we eventually handle255// eSymbolTypeData, we will want this back)256return true;257258default:259break;260}261262// Include this name in the index.263return false;264}265266// No filters for this scheme yet. Include all names in indexing.267case Mangled::eManglingSchemeMSVC:268case Mangled::eManglingSchemeRustV0:269case Mangled::eManglingSchemeD:270case Mangled::eManglingSchemeSwift:271return false;272273// Don't try and demangle things we can't categorize.274case Mangled::eManglingSchemeNone:275return true;276}277llvm_unreachable("unknown scheme!");278}279280void Symtab::InitNameIndexes() {281// Protected function, no need to lock mutex...282if (!m_name_indexes_computed) {283m_name_indexes_computed = true;284ElapsedTime elapsed(m_objfile->GetModule()->GetSymtabIndexTime());285LLDB_SCOPED_TIMER();286287// Collect all loaded language plugins.288std::vector<Language *> languages;289Language::ForEach([&languages](Language *l) {290languages.push_back(l);291return true;292});293294auto &name_to_index = GetNameToSymbolIndexMap(lldb::eFunctionNameTypeNone);295auto &basename_to_index =296GetNameToSymbolIndexMap(lldb::eFunctionNameTypeBase);297auto &method_to_index =298GetNameToSymbolIndexMap(lldb::eFunctionNameTypeMethod);299auto &selector_to_index =300GetNameToSymbolIndexMap(lldb::eFunctionNameTypeSelector);301// Create the name index vector to be able to quickly search by name302const size_t num_symbols = m_symbols.size();303name_to_index.Reserve(num_symbols);304305// The "const char *" in "class_contexts" and backlog::value_type::second306// must come from a ConstString::GetCString()307std::set<const char *> class_contexts;308std::vector<std::pair<NameToIndexMap::Entry, const char *>> backlog;309backlog.reserve(num_symbols / 2);310311// Instantiation of the demangler is expensive, so better use a single one312// for all entries during batch processing.313RichManglingContext rmc;314for (uint32_t value = 0; value < num_symbols; ++value) {315Symbol *symbol = &m_symbols[value];316317// Don't let trampolines get into the lookup by name map If we ever need318// the trampoline symbols to be searchable by name we can remove this and319// then possibly add a new bool to any of the Symtab functions that320// lookup symbols by name to indicate if they want trampolines. We also321// don't want any synthetic symbols with auto generated names in the322// name lookups.323if (symbol->IsTrampoline() || symbol->IsSyntheticWithAutoGeneratedName())324continue;325326// If the symbol's name string matched a Mangled::ManglingScheme, it is327// stored in the mangled field.328Mangled &mangled = symbol->GetMangled();329if (ConstString name = mangled.GetMangledName()) {330name_to_index.Append(name, value);331332if (symbol->ContainsLinkerAnnotations()) {333// If the symbol has linker annotations, also add the version without334// the annotations.335ConstString stripped = ConstString(336m_objfile->StripLinkerSymbolAnnotations(name.GetStringRef()));337name_to_index.Append(stripped, value);338}339340const SymbolType type = symbol->GetType();341if (type == eSymbolTypeCode || type == eSymbolTypeResolver) {342if (mangled.GetRichManglingInfo(rmc, lldb_skip_name)) {343RegisterMangledNameEntry(value, class_contexts, backlog, rmc);344continue;345}346}347}348349// Symbol name strings that didn't match a Mangled::ManglingScheme, are350// stored in the demangled field.351if (ConstString name = mangled.GetDemangledName()) {352name_to_index.Append(name, value);353354if (symbol->ContainsLinkerAnnotations()) {355// If the symbol has linker annotations, also add the version without356// the annotations.357name = ConstString(358m_objfile->StripLinkerSymbolAnnotations(name.GetStringRef()));359name_to_index.Append(name, value);360}361362// If the demangled name turns out to be an ObjC name, and is a category363// name, add the version without categories to the index too.364for (Language *lang : languages) {365for (auto variant : lang->GetMethodNameVariants(name)) {366if (variant.GetType() & lldb::eFunctionNameTypeSelector)367selector_to_index.Append(variant.GetName(), value);368else if (variant.GetType() & lldb::eFunctionNameTypeFull)369name_to_index.Append(variant.GetName(), value);370else if (variant.GetType() & lldb::eFunctionNameTypeMethod)371method_to_index.Append(variant.GetName(), value);372else if (variant.GetType() & lldb::eFunctionNameTypeBase)373basename_to_index.Append(variant.GetName(), value);374}375}376}377}378379for (const auto &record : backlog) {380RegisterBacklogEntry(record.first, record.second, class_contexts);381}382383name_to_index.Sort();384name_to_index.SizeToFit();385selector_to_index.Sort();386selector_to_index.SizeToFit();387basename_to_index.Sort();388basename_to_index.SizeToFit();389method_to_index.Sort();390method_to_index.SizeToFit();391}392}393394void Symtab::RegisterMangledNameEntry(395uint32_t value, std::set<const char *> &class_contexts,396std::vector<std::pair<NameToIndexMap::Entry, const char *>> &backlog,397RichManglingContext &rmc) {398// Only register functions that have a base name.399llvm::StringRef base_name = rmc.ParseFunctionBaseName();400if (base_name.empty())401return;402403// The base name will be our entry's name.404NameToIndexMap::Entry entry(ConstString(base_name), value);405llvm::StringRef decl_context = rmc.ParseFunctionDeclContextName();406407// Register functions with no context.408if (decl_context.empty()) {409// This has to be a basename410auto &basename_to_index =411GetNameToSymbolIndexMap(lldb::eFunctionNameTypeBase);412basename_to_index.Append(entry);413// If there is no context (no namespaces or class scopes that come before414// the function name) then this also could be a fullname.415auto &name_to_index = GetNameToSymbolIndexMap(lldb::eFunctionNameTypeNone);416name_to_index.Append(entry);417return;418}419420// Make sure we have a pool-string pointer and see if we already know the421// context name.422const char *decl_context_ccstr = ConstString(decl_context).GetCString();423auto it = class_contexts.find(decl_context_ccstr);424425auto &method_to_index =426GetNameToSymbolIndexMap(lldb::eFunctionNameTypeMethod);427// Register constructors and destructors. They are methods and create428// declaration contexts.429if (rmc.IsCtorOrDtor()) {430method_to_index.Append(entry);431if (it == class_contexts.end())432class_contexts.insert(it, decl_context_ccstr);433return;434}435436// Register regular methods with a known declaration context.437if (it != class_contexts.end()) {438method_to_index.Append(entry);439return;440}441442// Regular methods in unknown declaration contexts are put to the backlog. We443// will revisit them once we processed all remaining symbols.444backlog.push_back(std::make_pair(entry, decl_context_ccstr));445}446447void Symtab::RegisterBacklogEntry(448const NameToIndexMap::Entry &entry, const char *decl_context,449const std::set<const char *> &class_contexts) {450auto &method_to_index =451GetNameToSymbolIndexMap(lldb::eFunctionNameTypeMethod);452auto it = class_contexts.find(decl_context);453if (it != class_contexts.end()) {454method_to_index.Append(entry);455} else {456// If we got here, we have something that had a context (was inside457// a namespace or class) yet we don't know the entry458method_to_index.Append(entry);459auto &basename_to_index =460GetNameToSymbolIndexMap(lldb::eFunctionNameTypeBase);461basename_to_index.Append(entry);462}463}464465void Symtab::PreloadSymbols() {466std::lock_guard<std::recursive_mutex> guard(m_mutex);467InitNameIndexes();468}469470void Symtab::AppendSymbolNamesToMap(const IndexCollection &indexes,471bool add_demangled, bool add_mangled,472NameToIndexMap &name_to_index_map) const {473LLDB_SCOPED_TIMER();474if (add_demangled || add_mangled) {475std::lock_guard<std::recursive_mutex> guard(m_mutex);476477// Create the name index vector to be able to quickly search by name478const size_t num_indexes = indexes.size();479for (size_t i = 0; i < num_indexes; ++i) {480uint32_t value = indexes[i];481assert(i < m_symbols.size());482const Symbol *symbol = &m_symbols[value];483484const Mangled &mangled = symbol->GetMangled();485if (add_demangled) {486if (ConstString name = mangled.GetDemangledName())487name_to_index_map.Append(name, value);488}489490if (add_mangled) {491if (ConstString name = mangled.GetMangledName())492name_to_index_map.Append(name, value);493}494}495}496}497498uint32_t Symtab::AppendSymbolIndexesWithType(SymbolType symbol_type,499std::vector<uint32_t> &indexes,500uint32_t start_idx,501uint32_t end_index) const {502std::lock_guard<std::recursive_mutex> guard(m_mutex);503504uint32_t prev_size = indexes.size();505506const uint32_t count = std::min<uint32_t>(m_symbols.size(), end_index);507508for (uint32_t i = start_idx; i < count; ++i) {509if (symbol_type == eSymbolTypeAny || m_symbols[i].GetType() == symbol_type)510indexes.push_back(i);511}512513return indexes.size() - prev_size;514}515516uint32_t Symtab::AppendSymbolIndexesWithTypeAndFlagsValue(517SymbolType symbol_type, uint32_t flags_value,518std::vector<uint32_t> &indexes, uint32_t start_idx,519uint32_t end_index) const {520std::lock_guard<std::recursive_mutex> guard(m_mutex);521522uint32_t prev_size = indexes.size();523524const uint32_t count = std::min<uint32_t>(m_symbols.size(), end_index);525526for (uint32_t i = start_idx; i < count; ++i) {527if ((symbol_type == eSymbolTypeAny ||528m_symbols[i].GetType() == symbol_type) &&529m_symbols[i].GetFlags() == flags_value)530indexes.push_back(i);531}532533return indexes.size() - prev_size;534}535536uint32_t Symtab::AppendSymbolIndexesWithType(SymbolType symbol_type,537Debug symbol_debug_type,538Visibility symbol_visibility,539std::vector<uint32_t> &indexes,540uint32_t start_idx,541uint32_t end_index) const {542std::lock_guard<std::recursive_mutex> guard(m_mutex);543544uint32_t prev_size = indexes.size();545546const uint32_t count = std::min<uint32_t>(m_symbols.size(), end_index);547548for (uint32_t i = start_idx; i < count; ++i) {549if (symbol_type == eSymbolTypeAny ||550m_symbols[i].GetType() == symbol_type) {551if (CheckSymbolAtIndex(i, symbol_debug_type, symbol_visibility))552indexes.push_back(i);553}554}555556return indexes.size() - prev_size;557}558559uint32_t Symtab::GetIndexForSymbol(const Symbol *symbol) const {560if (!m_symbols.empty()) {561const Symbol *first_symbol = &m_symbols[0];562if (symbol >= first_symbol && symbol < first_symbol + m_symbols.size())563return symbol - first_symbol;564}565return UINT32_MAX;566}567568struct SymbolSortInfo {569const bool sort_by_load_addr;570const Symbol *symbols;571};572573namespace {574struct SymbolIndexComparator {575const std::vector<Symbol> &symbols;576std::vector<lldb::addr_t> &addr_cache;577578// Getting from the symbol to the Address to the File Address involves some579// work. Since there are potentially many symbols here, and we're using this580// for sorting so we're going to be computing the address many times, cache581// that in addr_cache. The array passed in has to be the same size as the582// symbols array passed into the member variable symbols, and should be583// initialized with LLDB_INVALID_ADDRESS.584// NOTE: You have to make addr_cache externally and pass it in because585// std::stable_sort586// makes copies of the comparator it is initially passed in, and you end up587// spending huge amounts of time copying this array...588589SymbolIndexComparator(const std::vector<Symbol> &s,590std::vector<lldb::addr_t> &a)591: symbols(s), addr_cache(a) {592assert(symbols.size() == addr_cache.size());593}594bool operator()(uint32_t index_a, uint32_t index_b) {595addr_t value_a = addr_cache[index_a];596if (value_a == LLDB_INVALID_ADDRESS) {597value_a = symbols[index_a].GetAddressRef().GetFileAddress();598addr_cache[index_a] = value_a;599}600601addr_t value_b = addr_cache[index_b];602if (value_b == LLDB_INVALID_ADDRESS) {603value_b = symbols[index_b].GetAddressRef().GetFileAddress();604addr_cache[index_b] = value_b;605}606607if (value_a == value_b) {608// The if the values are equal, use the original symbol user ID609lldb::user_id_t uid_a = symbols[index_a].GetID();610lldb::user_id_t uid_b = symbols[index_b].GetID();611if (uid_a < uid_b)612return true;613if (uid_a > uid_b)614return false;615return false;616} else if (value_a < value_b)617return true;618619return false;620}621};622}623624void Symtab::SortSymbolIndexesByValue(std::vector<uint32_t> &indexes,625bool remove_duplicates) const {626std::lock_guard<std::recursive_mutex> guard(m_mutex);627LLDB_SCOPED_TIMER();628// No need to sort if we have zero or one items...629if (indexes.size() <= 1)630return;631632// Sort the indexes in place using std::stable_sort.633// NOTE: The use of std::stable_sort instead of llvm::sort here is strictly634// for performance, not correctness. The indexes vector tends to be "close"635// to sorted, which the stable sort handles better.636637std::vector<lldb::addr_t> addr_cache(m_symbols.size(), LLDB_INVALID_ADDRESS);638639SymbolIndexComparator comparator(m_symbols, addr_cache);640std::stable_sort(indexes.begin(), indexes.end(), comparator);641642// Remove any duplicates if requested643if (remove_duplicates) {644auto last = std::unique(indexes.begin(), indexes.end());645indexes.erase(last, indexes.end());646}647}648649uint32_t Symtab::GetNameIndexes(ConstString symbol_name,650std::vector<uint32_t> &indexes) {651auto &name_to_index = GetNameToSymbolIndexMap(lldb::eFunctionNameTypeNone);652const uint32_t count = name_to_index.GetValues(symbol_name, indexes);653if (count)654return count;655// Synthetic symbol names are not added to the name indexes, but they start656// with a prefix and end with a the symbol UserID. This allows users to find657// these symbols without having to add them to the name indexes. These658// queries will not happen very often since the names don't mean anything, so659// performance is not paramount in this case.660llvm::StringRef name = symbol_name.GetStringRef();661// String the synthetic prefix if the name starts with it.662if (!name.consume_front(Symbol::GetSyntheticSymbolPrefix()))663return 0; // Not a synthetic symbol name664665// Extract the user ID from the symbol name666unsigned long long uid = 0;667if (getAsUnsignedInteger(name, /*Radix=*/10, uid))668return 0; // Failed to extract the user ID as an integer669Symbol *symbol = FindSymbolByID(uid);670if (symbol == nullptr)671return 0;672const uint32_t symbol_idx = GetIndexForSymbol(symbol);673if (symbol_idx == UINT32_MAX)674return 0;675indexes.push_back(symbol_idx);676return 1;677}678679uint32_t Symtab::AppendSymbolIndexesWithName(ConstString symbol_name,680std::vector<uint32_t> &indexes) {681std::lock_guard<std::recursive_mutex> guard(m_mutex);682683if (symbol_name) {684if (!m_name_indexes_computed)685InitNameIndexes();686687return GetNameIndexes(symbol_name, indexes);688}689return 0;690}691692uint32_t Symtab::AppendSymbolIndexesWithName(ConstString symbol_name,693Debug symbol_debug_type,694Visibility symbol_visibility,695std::vector<uint32_t> &indexes) {696std::lock_guard<std::recursive_mutex> guard(m_mutex);697698LLDB_SCOPED_TIMER();699if (symbol_name) {700const size_t old_size = indexes.size();701if (!m_name_indexes_computed)702InitNameIndexes();703704std::vector<uint32_t> all_name_indexes;705const size_t name_match_count =706GetNameIndexes(symbol_name, all_name_indexes);707for (size_t i = 0; i < name_match_count; ++i) {708if (CheckSymbolAtIndex(all_name_indexes[i], symbol_debug_type,709symbol_visibility))710indexes.push_back(all_name_indexes[i]);711}712return indexes.size() - old_size;713}714return 0;715}716717uint32_t718Symtab::AppendSymbolIndexesWithNameAndType(ConstString symbol_name,719SymbolType symbol_type,720std::vector<uint32_t> &indexes) {721std::lock_guard<std::recursive_mutex> guard(m_mutex);722723if (AppendSymbolIndexesWithName(symbol_name, indexes) > 0) {724std::vector<uint32_t>::iterator pos = indexes.begin();725while (pos != indexes.end()) {726if (symbol_type == eSymbolTypeAny ||727m_symbols[*pos].GetType() == symbol_type)728++pos;729else730pos = indexes.erase(pos);731}732}733return indexes.size();734}735736uint32_t Symtab::AppendSymbolIndexesWithNameAndType(737ConstString symbol_name, SymbolType symbol_type,738Debug symbol_debug_type, Visibility symbol_visibility,739std::vector<uint32_t> &indexes) {740std::lock_guard<std::recursive_mutex> guard(m_mutex);741742if (AppendSymbolIndexesWithName(symbol_name, symbol_debug_type,743symbol_visibility, indexes) > 0) {744std::vector<uint32_t>::iterator pos = indexes.begin();745while (pos != indexes.end()) {746if (symbol_type == eSymbolTypeAny ||747m_symbols[*pos].GetType() == symbol_type)748++pos;749else750pos = indexes.erase(pos);751}752}753return indexes.size();754}755756uint32_t Symtab::AppendSymbolIndexesMatchingRegExAndType(757const RegularExpression ®exp, SymbolType symbol_type,758std::vector<uint32_t> &indexes, Mangled::NamePreference name_preference) {759std::lock_guard<std::recursive_mutex> guard(m_mutex);760761uint32_t prev_size = indexes.size();762uint32_t sym_end = m_symbols.size();763764for (uint32_t i = 0; i < sym_end; i++) {765if (symbol_type == eSymbolTypeAny ||766m_symbols[i].GetType() == symbol_type) {767const char *name =768m_symbols[i].GetMangled().GetName(name_preference).AsCString();769if (name) {770if (regexp.Execute(name))771indexes.push_back(i);772}773}774}775return indexes.size() - prev_size;776}777778uint32_t Symtab::AppendSymbolIndexesMatchingRegExAndType(779const RegularExpression ®exp, SymbolType symbol_type,780Debug symbol_debug_type, Visibility symbol_visibility,781std::vector<uint32_t> &indexes, Mangled::NamePreference name_preference) {782std::lock_guard<std::recursive_mutex> guard(m_mutex);783784uint32_t prev_size = indexes.size();785uint32_t sym_end = m_symbols.size();786787for (uint32_t i = 0; i < sym_end; i++) {788if (symbol_type == eSymbolTypeAny ||789m_symbols[i].GetType() == symbol_type) {790if (!CheckSymbolAtIndex(i, symbol_debug_type, symbol_visibility))791continue;792793const char *name =794m_symbols[i].GetMangled().GetName(name_preference).AsCString();795if (name) {796if (regexp.Execute(name))797indexes.push_back(i);798}799}800}801return indexes.size() - prev_size;802}803804Symbol *Symtab::FindSymbolWithType(SymbolType symbol_type,805Debug symbol_debug_type,806Visibility symbol_visibility,807uint32_t &start_idx) {808std::lock_guard<std::recursive_mutex> guard(m_mutex);809810const size_t count = m_symbols.size();811for (size_t idx = start_idx; idx < count; ++idx) {812if (symbol_type == eSymbolTypeAny ||813m_symbols[idx].GetType() == symbol_type) {814if (CheckSymbolAtIndex(idx, symbol_debug_type, symbol_visibility)) {815start_idx = idx;816return &m_symbols[idx];817}818}819}820return nullptr;821}822823void824Symtab::FindAllSymbolsWithNameAndType(ConstString name,825SymbolType symbol_type,826std::vector<uint32_t> &symbol_indexes) {827std::lock_guard<std::recursive_mutex> guard(m_mutex);828829// Initialize all of the lookup by name indexes before converting NAME to a830// uniqued string NAME_STR below.831if (!m_name_indexes_computed)832InitNameIndexes();833834if (name) {835// The string table did have a string that matched, but we need to check836// the symbols and match the symbol_type if any was given.837AppendSymbolIndexesWithNameAndType(name, symbol_type, symbol_indexes);838}839}840841void Symtab::FindAllSymbolsWithNameAndType(842ConstString name, SymbolType symbol_type, Debug symbol_debug_type,843Visibility symbol_visibility, std::vector<uint32_t> &symbol_indexes) {844std::lock_guard<std::recursive_mutex> guard(m_mutex);845846LLDB_SCOPED_TIMER();847// Initialize all of the lookup by name indexes before converting NAME to a848// uniqued string NAME_STR below.849if (!m_name_indexes_computed)850InitNameIndexes();851852if (name) {853// The string table did have a string that matched, but we need to check854// the symbols and match the symbol_type if any was given.855AppendSymbolIndexesWithNameAndType(name, symbol_type, symbol_debug_type,856symbol_visibility, symbol_indexes);857}858}859860void Symtab::FindAllSymbolsMatchingRexExAndType(861const RegularExpression ®ex, SymbolType symbol_type,862Debug symbol_debug_type, Visibility symbol_visibility,863std::vector<uint32_t> &symbol_indexes,864Mangled::NamePreference name_preference) {865std::lock_guard<std::recursive_mutex> guard(m_mutex);866867AppendSymbolIndexesMatchingRegExAndType(regex, symbol_type, symbol_debug_type,868symbol_visibility, symbol_indexes,869name_preference);870}871872Symbol *Symtab::FindFirstSymbolWithNameAndType(ConstString name,873SymbolType symbol_type,874Debug symbol_debug_type,875Visibility symbol_visibility) {876std::lock_guard<std::recursive_mutex> guard(m_mutex);877LLDB_SCOPED_TIMER();878if (!m_name_indexes_computed)879InitNameIndexes();880881if (name) {882std::vector<uint32_t> matching_indexes;883// The string table did have a string that matched, but we need to check884// the symbols and match the symbol_type if any was given.885if (AppendSymbolIndexesWithNameAndType(name, symbol_type, symbol_debug_type,886symbol_visibility,887matching_indexes)) {888std::vector<uint32_t>::const_iterator pos, end = matching_indexes.end();889for (pos = matching_indexes.begin(); pos != end; ++pos) {890Symbol *symbol = SymbolAtIndex(*pos);891892if (symbol->Compare(name, symbol_type))893return symbol;894}895}896}897return nullptr;898}899900typedef struct {901const Symtab *symtab;902const addr_t file_addr;903Symbol *match_symbol;904const uint32_t *match_index_ptr;905addr_t match_offset;906} SymbolSearchInfo;907908// Add all the section file start address & size to the RangeVector, recusively909// adding any children sections.910static void AddSectionsToRangeMap(SectionList *sectlist,911RangeVector<addr_t, addr_t> §ion_ranges) {912const int num_sections = sectlist->GetNumSections(0);913for (int i = 0; i < num_sections; i++) {914SectionSP sect_sp = sectlist->GetSectionAtIndex(i);915if (sect_sp) {916SectionList &child_sectlist = sect_sp->GetChildren();917918// If this section has children, add the children to the RangeVector.919// Else add this section to the RangeVector.920if (child_sectlist.GetNumSections(0) > 0) {921AddSectionsToRangeMap(&child_sectlist, section_ranges);922} else {923size_t size = sect_sp->GetByteSize();924if (size > 0) {925addr_t base_addr = sect_sp->GetFileAddress();926RangeVector<addr_t, addr_t>::Entry entry;927entry.SetRangeBase(base_addr);928entry.SetByteSize(size);929section_ranges.Append(entry);930}931}932}933}934}935936void Symtab::InitAddressIndexes() {937// Protected function, no need to lock mutex...938if (!m_file_addr_to_index_computed && !m_symbols.empty()) {939m_file_addr_to_index_computed = true;940941FileRangeToIndexMap::Entry entry;942const_iterator begin = m_symbols.begin();943const_iterator end = m_symbols.end();944for (const_iterator pos = m_symbols.begin(); pos != end; ++pos) {945if (pos->ValueIsAddress()) {946entry.SetRangeBase(pos->GetAddressRef().GetFileAddress());947entry.SetByteSize(pos->GetByteSize());948entry.data = std::distance(begin, pos);949m_file_addr_to_index.Append(entry);950}951}952const size_t num_entries = m_file_addr_to_index.GetSize();953if (num_entries > 0) {954m_file_addr_to_index.Sort();955956// Create a RangeVector with the start & size of all the sections for957// this objfile. We'll need to check this for any FileRangeToIndexMap958// entries with an uninitialized size, which could potentially be a large959// number so reconstituting the weak pointer is busywork when it is960// invariant information.961SectionList *sectlist = m_objfile->GetSectionList();962RangeVector<addr_t, addr_t> section_ranges;963if (sectlist) {964AddSectionsToRangeMap(sectlist, section_ranges);965section_ranges.Sort();966}967968// Iterate through the FileRangeToIndexMap and fill in the size for any969// entries that didn't already have a size from the Symbol (e.g. if we970// have a plain linker symbol with an address only, instead of debug info971// where we get an address and a size and a type, etc.)972for (size_t i = 0; i < num_entries; i++) {973FileRangeToIndexMap::Entry *entry =974m_file_addr_to_index.GetMutableEntryAtIndex(i);975if (entry->GetByteSize() == 0) {976addr_t curr_base_addr = entry->GetRangeBase();977const RangeVector<addr_t, addr_t>::Entry *containing_section =978section_ranges.FindEntryThatContains(curr_base_addr);979980// Use the end of the section as the default max size of the symbol981addr_t sym_size = 0;982if (containing_section) {983sym_size =984containing_section->GetByteSize() -985(entry->GetRangeBase() - containing_section->GetRangeBase());986}987988for (size_t j = i; j < num_entries; j++) {989FileRangeToIndexMap::Entry *next_entry =990m_file_addr_to_index.GetMutableEntryAtIndex(j);991addr_t next_base_addr = next_entry->GetRangeBase();992if (next_base_addr > curr_base_addr) {993addr_t size_to_next_symbol = next_base_addr - curr_base_addr;994995// Take the difference between this symbol and the next one as996// its size, if it is less than the size of the section.997if (sym_size == 0 || size_to_next_symbol < sym_size) {998sym_size = size_to_next_symbol;999}1000break;1001}1002}10031004if (sym_size > 0) {1005entry->SetByteSize(sym_size);1006Symbol &symbol = m_symbols[entry->data];1007symbol.SetByteSize(sym_size);1008symbol.SetSizeIsSynthesized(true);1009}1010}1011}10121013// Sort again in case the range size changes the ordering1014m_file_addr_to_index.Sort();1015}1016}1017}10181019void Symtab::Finalize() {1020std::lock_guard<std::recursive_mutex> guard(m_mutex);1021// Calculate the size of symbols inside InitAddressIndexes.1022InitAddressIndexes();1023// Shrink to fit the symbols so we don't waste memory1024m_symbols.shrink_to_fit();1025SaveToCache();1026}10271028Symbol *Symtab::FindSymbolAtFileAddress(addr_t file_addr) {1029std::lock_guard<std::recursive_mutex> guard(m_mutex);1030if (!m_file_addr_to_index_computed)1031InitAddressIndexes();10321033const FileRangeToIndexMap::Entry *entry =1034m_file_addr_to_index.FindEntryStartsAt(file_addr);1035if (entry) {1036Symbol *symbol = SymbolAtIndex(entry->data);1037if (symbol->GetFileAddress() == file_addr)1038return symbol;1039}1040return nullptr;1041}10421043Symbol *Symtab::FindSymbolContainingFileAddress(addr_t file_addr) {1044std::lock_guard<std::recursive_mutex> guard(m_mutex);10451046if (!m_file_addr_to_index_computed)1047InitAddressIndexes();10481049const FileRangeToIndexMap::Entry *entry =1050m_file_addr_to_index.FindEntryThatContains(file_addr);1051if (entry) {1052Symbol *symbol = SymbolAtIndex(entry->data);1053if (symbol->ContainsFileAddress(file_addr))1054return symbol;1055}1056return nullptr;1057}10581059void Symtab::ForEachSymbolContainingFileAddress(1060addr_t file_addr, std::function<bool(Symbol *)> const &callback) {1061std::lock_guard<std::recursive_mutex> guard(m_mutex);10621063if (!m_file_addr_to_index_computed)1064InitAddressIndexes();10651066std::vector<uint32_t> all_addr_indexes;10671068// Get all symbols with file_addr1069const size_t addr_match_count =1070m_file_addr_to_index.FindEntryIndexesThatContain(file_addr,1071all_addr_indexes);10721073for (size_t i = 0; i < addr_match_count; ++i) {1074Symbol *symbol = SymbolAtIndex(all_addr_indexes[i]);1075if (symbol->ContainsFileAddress(file_addr)) {1076if (!callback(symbol))1077break;1078}1079}1080}10811082void Symtab::SymbolIndicesToSymbolContextList(1083std::vector<uint32_t> &symbol_indexes, SymbolContextList &sc_list) {1084// No need to protect this call using m_mutex all other method calls are1085// already thread safe.10861087const bool merge_symbol_into_function = true;1088size_t num_indices = symbol_indexes.size();1089if (num_indices > 0) {1090SymbolContext sc;1091sc.module_sp = m_objfile->GetModule();1092for (size_t i = 0; i < num_indices; i++) {1093sc.symbol = SymbolAtIndex(symbol_indexes[i]);1094if (sc.symbol)1095sc_list.AppendIfUnique(sc, merge_symbol_into_function);1096}1097}1098}10991100void Symtab::FindFunctionSymbols(ConstString name, uint32_t name_type_mask,1101SymbolContextList &sc_list) {1102std::vector<uint32_t> symbol_indexes;11031104// eFunctionNameTypeAuto should be pre-resolved by a call to1105// Module::LookupInfo::LookupInfo()1106assert((name_type_mask & eFunctionNameTypeAuto) == 0);11071108if (name_type_mask & (eFunctionNameTypeBase | eFunctionNameTypeFull)) {1109std::vector<uint32_t> temp_symbol_indexes;1110FindAllSymbolsWithNameAndType(name, eSymbolTypeAny, temp_symbol_indexes);11111112unsigned temp_symbol_indexes_size = temp_symbol_indexes.size();1113if (temp_symbol_indexes_size > 0) {1114std::lock_guard<std::recursive_mutex> guard(m_mutex);1115for (unsigned i = 0; i < temp_symbol_indexes_size; i++) {1116SymbolContext sym_ctx;1117sym_ctx.symbol = SymbolAtIndex(temp_symbol_indexes[i]);1118if (sym_ctx.symbol) {1119switch (sym_ctx.symbol->GetType()) {1120case eSymbolTypeCode:1121case eSymbolTypeResolver:1122case eSymbolTypeReExported:1123case eSymbolTypeAbsolute:1124symbol_indexes.push_back(temp_symbol_indexes[i]);1125break;1126default:1127break;1128}1129}1130}1131}1132}11331134if (!m_name_indexes_computed)1135InitNameIndexes();11361137for (lldb::FunctionNameType type :1138{lldb::eFunctionNameTypeBase, lldb::eFunctionNameTypeMethod,1139lldb::eFunctionNameTypeSelector}) {1140if (name_type_mask & type) {1141auto map = GetNameToSymbolIndexMap(type);11421143const UniqueCStringMap<uint32_t>::Entry *match;1144for (match = map.FindFirstValueForName(name); match != nullptr;1145match = map.FindNextValueForName(match)) {1146symbol_indexes.push_back(match->value);1147}1148}1149}11501151if (!symbol_indexes.empty()) {1152llvm::sort(symbol_indexes);1153symbol_indexes.erase(1154std::unique(symbol_indexes.begin(), symbol_indexes.end()),1155symbol_indexes.end());1156SymbolIndicesToSymbolContextList(symbol_indexes, sc_list);1157}1158}11591160const Symbol *Symtab::GetParent(Symbol *child_symbol) const {1161uint32_t child_idx = GetIndexForSymbol(child_symbol);1162if (child_idx != UINT32_MAX && child_idx > 0) {1163for (uint32_t idx = child_idx - 1; idx != UINT32_MAX; --idx) {1164const Symbol *symbol = SymbolAtIndex(idx);1165const uint32_t sibling_idx = symbol->GetSiblingIndex();1166if (sibling_idx != UINT32_MAX && sibling_idx > child_idx)1167return symbol;1168}1169}1170return nullptr;1171}11721173std::string Symtab::GetCacheKey() {1174std::string key;1175llvm::raw_string_ostream strm(key);1176// Symbol table can come from different object files for the same module. A1177// module can have one object file as the main executable and might have1178// another object file in a separate symbol file.1179strm << m_objfile->GetModule()->GetCacheKey() << "-symtab-"1180<< llvm::format_hex(m_objfile->GetCacheHash(), 10);1181return strm.str();1182}11831184void Symtab::SaveToCache() {1185DataFileCache *cache = Module::GetIndexCache();1186if (!cache)1187return; // Caching is not enabled.1188InitNameIndexes(); // Init the name indexes so we can cache them as well.1189const auto byte_order = endian::InlHostByteOrder();1190DataEncoder file(byte_order, /*addr_size=*/8);1191// Encode will return false if the symbol table's object file doesn't have1192// anything to make a signature from.1193if (Encode(file))1194if (cache->SetCachedData(GetCacheKey(), file.GetData()))1195SetWasSavedToCache();1196}11971198constexpr llvm::StringLiteral kIdentifierCStrMap("CMAP");11991200static void EncodeCStrMap(DataEncoder &encoder, ConstStringTable &strtab,1201const UniqueCStringMap<uint32_t> &cstr_map) {1202encoder.AppendData(kIdentifierCStrMap);1203encoder.AppendU32(cstr_map.GetSize());1204for (const auto &entry: cstr_map) {1205// Make sure there are no empty strings.1206assert((bool)entry.cstring);1207encoder.AppendU32(strtab.Add(entry.cstring));1208encoder.AppendU32(entry.value);1209}1210}12111212bool DecodeCStrMap(const DataExtractor &data, lldb::offset_t *offset_ptr,1213const StringTableReader &strtab,1214UniqueCStringMap<uint32_t> &cstr_map) {1215llvm::StringRef identifier((const char *)data.GetData(offset_ptr, 4), 4);1216if (identifier != kIdentifierCStrMap)1217return false;1218const uint32_t count = data.GetU32(offset_ptr);1219cstr_map.Reserve(count);1220for (uint32_t i=0; i<count; ++i)1221{1222llvm::StringRef str(strtab.Get(data.GetU32(offset_ptr)));1223uint32_t value = data.GetU32(offset_ptr);1224// No empty strings in the name indexes in Symtab1225if (str.empty())1226return false;1227cstr_map.Append(ConstString(str), value);1228}1229// We must sort the UniqueCStringMap after decoding it since it is a vector1230// of UniqueCStringMap::Entry objects which contain a ConstString and type T.1231// ConstString objects are sorted by "const char *" and then type T and1232// the "const char *" are point values that will depend on the order in which1233// ConstString objects are created and in which of the 256 string pools they1234// are created in. So after we decode all of the entries, we must sort the1235// name map to ensure name lookups succeed. If we encode and decode within1236// the same process we wouldn't need to sort, so unit testing didn't catch1237// this issue when first checked in.1238cstr_map.Sort();1239return true;1240}12411242constexpr llvm::StringLiteral kIdentifierSymbolTable("SYMB");1243constexpr uint32_t CURRENT_CACHE_VERSION = 1;12441245/// The encoding format for the symbol table is as follows:1246///1247/// Signature signature;1248/// ConstStringTable strtab;1249/// Identifier four character code: 'SYMB'1250/// uint32_t version;1251/// uint32_t num_symbols;1252/// Symbol symbols[num_symbols];1253/// uint8_t num_cstr_maps;1254/// UniqueCStringMap<uint32_t> cstr_maps[num_cstr_maps]1255bool Symtab::Encode(DataEncoder &encoder) const {1256// Name indexes must be computed before calling this function.1257assert(m_name_indexes_computed);12581259// Encode the object file's signature1260CacheSignature signature(m_objfile);1261if (!signature.Encode(encoder))1262return false;1263ConstStringTable strtab;12641265// Encoder the symbol table into a separate encoder first. This allows us1266// gather all of the strings we willl need in "strtab" as we will need to1267// write the string table out before the symbol table.1268DataEncoder symtab_encoder(encoder.GetByteOrder(),1269encoder.GetAddressByteSize());1270symtab_encoder.AppendData(kIdentifierSymbolTable);1271// Encode the symtab data version.1272symtab_encoder.AppendU32(CURRENT_CACHE_VERSION);1273// Encode the number of symbols.1274symtab_encoder.AppendU32(m_symbols.size());1275// Encode the symbol data for all symbols.1276for (const auto &symbol: m_symbols)1277symbol.Encode(symtab_encoder, strtab);12781279// Emit a byte for how many C string maps we emit. We will fix this up after1280// we emit the C string maps since we skip emitting C string maps if they are1281// empty.1282size_t num_cmaps_offset = symtab_encoder.GetByteSize();1283uint8_t num_cmaps = 0;1284symtab_encoder.AppendU8(0);1285for (const auto &pair: m_name_to_symbol_indices) {1286if (pair.second.IsEmpty())1287continue;1288++num_cmaps;1289symtab_encoder.AppendU8(pair.first);1290EncodeCStrMap(symtab_encoder, strtab, pair.second);1291}1292if (num_cmaps > 0)1293symtab_encoder.PutU8(num_cmaps_offset, num_cmaps);12941295// Now that all strings have been gathered, we will emit the string table.1296strtab.Encode(encoder);1297// Followed by the symbol table data.1298encoder.AppendData(symtab_encoder.GetData());1299return true;1300}13011302bool Symtab::Decode(const DataExtractor &data, lldb::offset_t *offset_ptr,1303bool &signature_mismatch) {1304signature_mismatch = false;1305CacheSignature signature;1306StringTableReader strtab;1307{ // Scope for "elapsed" object below so it can measure the time parse.1308ElapsedTime elapsed(m_objfile->GetModule()->GetSymtabParseTime());1309if (!signature.Decode(data, offset_ptr))1310return false;1311if (CacheSignature(m_objfile) != signature) {1312signature_mismatch = true;1313return false;1314}1315// We now decode the string table for all strings in the data cache file.1316if (!strtab.Decode(data, offset_ptr))1317return false;13181319// And now we can decode the symbol table with string table we just decoded.1320llvm::StringRef identifier((const char *)data.GetData(offset_ptr, 4), 4);1321if (identifier != kIdentifierSymbolTable)1322return false;1323const uint32_t version = data.GetU32(offset_ptr);1324if (version != CURRENT_CACHE_VERSION)1325return false;1326const uint32_t num_symbols = data.GetU32(offset_ptr);1327if (num_symbols == 0)1328return true;1329m_symbols.resize(num_symbols);1330SectionList *sections = m_objfile->GetModule()->GetSectionList();1331for (uint32_t i=0; i<num_symbols; ++i) {1332if (!m_symbols[i].Decode(data, offset_ptr, sections, strtab))1333return false;1334}1335}13361337{ // Scope for "elapsed" object below so it can measure the time to index.1338ElapsedTime elapsed(m_objfile->GetModule()->GetSymtabIndexTime());1339const uint8_t num_cstr_maps = data.GetU8(offset_ptr);1340for (uint8_t i=0; i<num_cstr_maps; ++i) {1341uint8_t type = data.GetU8(offset_ptr);1342UniqueCStringMap<uint32_t> &cstr_map =1343GetNameToSymbolIndexMap((lldb::FunctionNameType)type);1344if (!DecodeCStrMap(data, offset_ptr, strtab, cstr_map))1345return false;1346}1347m_name_indexes_computed = true;1348}1349return true;1350}13511352bool Symtab::LoadFromCache() {1353DataFileCache *cache = Module::GetIndexCache();1354if (!cache)1355return false;13561357std::unique_ptr<llvm::MemoryBuffer> mem_buffer_up =1358cache->GetCachedData(GetCacheKey());1359if (!mem_buffer_up)1360return false;1361DataExtractor data(mem_buffer_up->getBufferStart(),1362mem_buffer_up->getBufferSize(),1363m_objfile->GetByteOrder(),1364m_objfile->GetAddressByteSize());1365bool signature_mismatch = false;1366lldb::offset_t offset = 0;1367const bool result = Decode(data, &offset, signature_mismatch);1368if (signature_mismatch)1369cache->RemoveCacheFile(GetCacheKey());1370if (result)1371SetWasLoadedFromCache();1372return result;1373}137413751376