LLDB mainline
Classes | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
lldb_private::plugin::dwarf::ManualDWARFIndex Class Reference

#include <ManualDWARFIndex.h>

Inheritance diagram for lldb_private::plugin::dwarf::ManualDWARFIndex:
Inheritance graph
[legend]

Classes

struct  IndexSet
 

Public Member Functions

 ManualDWARFIndex (Module &module, SymbolFileDWARF &dwarf, llvm::DenseSet< dw_offset_t > units_to_avoid={}, llvm::DenseSet< uint64_t > type_sigs_to_avoid={})
 
void Preload () override
 
void GetGlobalVariables (ConstString basename, llvm::function_ref< bool(DWARFDIE die)> callback) override
 Finds global variables with the given base name.
 
void GetGlobalVariables (const RegularExpression &regex, llvm::function_ref< bool(DWARFDIE die)> callback) override
 
void GetGlobalVariables (DWARFUnit &unit, llvm::function_ref< bool(DWARFDIE die)> callback) override
 cu must be the skeleton unit if possible, not GetNonSkeletonUnit().
 
void GetObjCMethods (ConstString class_name, llvm::function_ref< bool(DWARFDIE die)> callback) override
 
void GetCompleteObjCClass (ConstString class_name, bool must_be_implementation, llvm::function_ref< bool(DWARFDIE die)> callback) override
 
void GetTypes (ConstString name, llvm::function_ref< bool(DWARFDIE die)> callback) override
 
void GetTypes (const DWARFDeclContext &context, llvm::function_ref< bool(DWARFDIE die)> callback) override
 
void GetNamespaces (ConstString name, llvm::function_ref< bool(DWARFDIE die)> callback) override
 
void GetFunctions (const Module::LookupInfo &lookup_info, SymbolFileDWARF &dwarf, const CompilerDeclContext &parent_decl_ctx, llvm::function_ref< bool(DWARFDIE die)> callback) override
 
void GetFunctions (const RegularExpression &regex, llvm::function_ref< bool(DWARFDIE die)> callback) override
 
void Dump (Stream &s) override
 
- Public Member Functions inherited from lldb_private::plugin::dwarf::DWARFIndex
 DWARFIndex (Module &module)
 
virtual ~DWARFIndex ()
 
virtual void Preload ()=0
 
virtual void GetGlobalVariables (ConstString basename, llvm::function_ref< bool(DWARFDIE die)> callback)=0
 Finds global variables with the given base name.
 
virtual void GetGlobalVariables (const RegularExpression &regex, llvm::function_ref< bool(DWARFDIE die)> callback)=0
 
virtual void GetGlobalVariables (DWARFUnit &cu, llvm::function_ref< bool(DWARFDIE die)> callback)=0
 cu must be the skeleton unit if possible, not GetNonSkeletonUnit().
 
virtual void GetObjCMethods (ConstString class_name, llvm::function_ref< bool(DWARFDIE die)> callback)=0
 
virtual void GetCompleteObjCClass (ConstString class_name, bool must_be_implementation, llvm::function_ref< bool(DWARFDIE die)> callback)=0
 
virtual void GetTypes (ConstString name, llvm::function_ref< bool(DWARFDIE die)> callback)=0
 
virtual void GetTypes (const DWARFDeclContext &context, llvm::function_ref< bool(DWARFDIE die)> callback)=0
 
virtual void GetFullyQualifiedType (const DWARFDeclContext &context, llvm::function_ref< bool(DWARFDIE die)> callback)
 Finds all DIEs whose fully qualified name matches context.
 
virtual void GetNamespaces (ConstString name, llvm::function_ref< bool(DWARFDIE die)> callback)=0
 
virtual void GetTypesWithQuery (TypeQuery &query, llvm::function_ref< bool(DWARFDIE die)> callback)
 Get type DIEs meeting requires of query.
 
virtual void GetNamespacesWithParents (ConstString name, const CompilerDeclContext &parent_decl_ctx, llvm::function_ref< bool(DWARFDIE die)> callback)
 Get namespace DIEs whose base name match.
 
virtual void GetFunctions (const Module::LookupInfo &lookup_info, SymbolFileDWARF &dwarf, const CompilerDeclContext &parent_decl_ctx, llvm::function_ref< bool(DWARFDIE die)> callback)=0
 
virtual void GetFunctions (const RegularExpression &regex, llvm::function_ref< bool(DWARFDIE die)> callback)=0
 
virtual void Dump (Stream &s)=0
 
StatsDuration::Duration GetIndexTime ()
 
void ResetStatistics ()
 

Private Member Functions

void Index ()
 
bool Decode (const DataExtractor &data, lldb::offset_t *offset_ptr, bool &signature_mismatch)
 Decode a serialized version of this object from data.
 
bool Encode (DataEncoder &encoder) const
 Encode this object into a data encoder object.
 
std::string GetCacheKey ()
 Get the cache key string for this symbol table.
 
void SaveToCache ()
 Save the symbol table data out into a cache.
 
bool LoadFromCache ()
 Load the symbol table from the index cache.
 
void IndexUnit (DWARFUnit &unit, SymbolFileDWARFDwo *dwp, IndexSet &set)
 
bool IsPartial () const
 Return true if this manual DWARF index is covering only part of the DWARF.
 

Static Private Member Functions

static void IndexUnitImpl (DWARFUnit &unit, const lldb::LanguageType cu_language, IndexSet &set)
 

Private Attributes

SymbolFileDWARFm_dwarf
 The DWARF file which we are indexing.
 
llvm::DenseSet< dw_offset_tm_units_to_avoid
 Which dwarf units should we skip while building the index.
 
llvm::DenseSet< uint64_t > m_type_sigs_to_avoid
 
IndexSet m_set
 
bool m_indexed = false
 

Additional Inherited Members

- Protected Member Functions inherited from lldb_private::plugin::dwarf::DWARFIndex
bool ProcessFunctionDIE (const Module::LookupInfo &lookup_info, DWARFDIE die, const CompilerDeclContext &parent_decl_ctx, llvm::function_ref< bool(DWARFDIE die)> callback)
 Helper function implementing common logic for processing function dies.
 
DIERefCallbackImpl DIERefCallback (llvm::function_ref< bool(DWARFDIE die)> callback, llvm::StringRef name={}) const
 
void ReportInvalidDIERef (DIERef ref, llvm::StringRef name) const
 
bool GetFullyQualifiedTypeImpl (const DWARFDeclContext &context, DWARFDIE die, llvm::function_ref< bool(DWARFDIE die)> callback)
 Implementation of GetFullyQualifiedType to check a single entry, shareable with derived classes.
 
bool ProcessTypeDIEMatchQuery (TypeQuery &query, DWARFDIE die, llvm::function_ref< bool(DWARFDIE die)> callback)
 Check if the type die can meet the requirements of query.
 
bool ProcessNamespaceDieMatchParents (const CompilerDeclContext &parent_decl_ctx, DWARFDIE die, llvm::function_ref< bool(DWARFDIE die)> callback)
 
- Protected Attributes inherited from lldb_private::plugin::dwarf::DWARFIndex
Modulem_module
 
StatsDuration m_index_time
 

Detailed Description

Definition at line 21 of file ManualDWARFIndex.h.

Constructor & Destructor Documentation

◆ ManualDWARFIndex()

lldb_private::plugin::dwarf::ManualDWARFIndex::ManualDWARFIndex ( Module module,
SymbolFileDWARF dwarf,
llvm::DenseSet< dw_offset_t units_to_avoid = {},
llvm::DenseSet< uint64_t >  type_sigs_to_avoid = {} 
)
inline

Definition at line 23 of file ManualDWARFIndex.h.

Member Function Documentation

◆ Decode()

bool ManualDWARFIndex::Decode ( const DataExtractor data,
lldb::offset_t offset_ptr,
bool &  signature_mismatch 
)
private

Decode a serialized version of this object from data.

Parameters
dataThe decoder object that references the serialized data.
offset_ptrA pointer that contains the offset from which the data will be decoded from that gets updated as data gets decoded.
strtabAll strings in cache files are put into string tables for efficiency and cache file size reduction. Strings are stored as uint32_t string table offsets in the cache data.

Definition at line 694 of file ManualDWARFIndex.cpp.

References lldb_private::CacheSignature::Decode(), lldb_private::plugin::dwarf::ManualDWARFIndex::IndexSet::Decode(), lldb_private::SymbolFileCommon::GetObjectFile(), m_dwarf, and m_set.

Referenced by LoadFromCache().

◆ Dump()

void ManualDWARFIndex::Dump ( Stream s)
overridevirtual

◆ Encode()

bool ManualDWARFIndex::Encode ( DataEncoder encoder) const
private

Encode this object into a data encoder object.

This allows this object to be serialized to disk.

Parameters
encoderA data encoder object that serialized bytes will be encoded into.
strtabAll strings in cache files are put into string tables for efficiency and cache file size reduction. Strings are stored as uint32_t string table offsets in the cache data.
Returns
True if the symbol table's object file can generate a valid signature and all data for the symbol table was encoded, false otherwise.

Definition at line 712 of file ManualDWARFIndex.cpp.

References lldb_private::CacheSignature::Encode(), lldb_private::plugin::dwarf::ManualDWARFIndex::IndexSet::Encode(), lldb_private::SymbolFileCommon::GetObjectFile(), m_dwarf, and m_set.

Referenced by SaveToCache().

◆ GetCacheKey()

std::string ManualDWARFIndex::GetCacheKey ( )
private

Get the cache key string for this symbol table.

The cache key must start with the module's cache key and is followed by information that indicates this key is for caching the symbol table contents and should also include the has of the object file. A module can be represented by an ObjectFile object for the main executable, but can also have a symbol file that is from the same or a different object file. This means we might have two symbol tables cached in the index cache, one for the main executable and one for the symbol file.

Returns
The unique cache key used to save and retrieve data from the index cache.

Definition at line 725 of file ManualDWARFIndex.cpp.

References lldb_private::ObjectFile::GetCacheHash(), lldb_private::ModuleChild::GetModule(), lldb_private::SymbolFileCommon::GetObjectFile(), IsPartial(), and m_dwarf.

Referenced by LoadFromCache(), and SaveToCache().

◆ GetCompleteObjCClass()

void ManualDWARFIndex::GetCompleteObjCClass ( ConstString  class_name,
bool  must_be_implementation,
llvm::function_ref< bool(DWARFDIE die)>  callback 
)
overridevirtual

◆ GetFunctions() [1/2]

void ManualDWARFIndex::GetFunctions ( const Module::LookupInfo lookup_info,
SymbolFileDWARF dwarf,
const CompilerDeclContext parent_decl_ctx,
llvm::function_ref< bool(DWARFDIE die)>  callback 
)
overridevirtual

◆ GetFunctions() [2/2]

void ManualDWARFIndex::GetFunctions ( const RegularExpression regex,
llvm::function_ref< bool(DWARFDIE die)>  callback 
)
overridevirtual

◆ GetGlobalVariables() [1/3]

void ManualDWARFIndex::GetGlobalVariables ( const RegularExpression regex,
llvm::function_ref< bool(DWARFDIE die)>  callback 
)
overridevirtual

◆ GetGlobalVariables() [2/3]

void ManualDWARFIndex::GetGlobalVariables ( ConstString  basename,
llvm::function_ref< bool(DWARFDIE die)>  callback 
)
overridevirtual

Finds global variables with the given base name.

Any additional filtering (e.g., to only retrieve variables from a given context) should be done by the consumer.

Implements lldb_private::plugin::dwarf::DWARFIndex.

Definition at line 420 of file ManualDWARFIndex.cpp.

References lldb_private::plugin::dwarf::DWARFIndex::DIERefCallback(), lldb_private::plugin::dwarf::NameToDIE::Find(), lldb_private::ConstString::GetStringRef(), lldb_private::plugin::dwarf::ManualDWARFIndex::IndexSet::globals, Index(), and m_set.

Referenced by lldb_private::plugin::dwarf::DebugNamesDWARFIndex::GetGlobalVariables().

◆ GetGlobalVariables() [3/3]

void ManualDWARFIndex::GetGlobalVariables ( DWARFUnit cu,
llvm::function_ref< bool(DWARFDIE die)>  callback 
)
overridevirtual

◆ GetNamespaces()

void ManualDWARFIndex::GetNamespaces ( ConstString  name,
llvm::function_ref< bool(DWARFDIE die)>  callback 
)
overridevirtual

◆ GetObjCMethods()

void ManualDWARFIndex::GetObjCMethods ( ConstString  class_name,
llvm::function_ref< bool(DWARFDIE die)>  callback 
)
overridevirtual

◆ GetTypes() [1/2]

void ManualDWARFIndex::GetTypes ( const DWARFDeclContext context,
llvm::function_ref< bool(DWARFDIE die)>  callback 
)
overridevirtual

◆ GetTypes() [2/2]

void ManualDWARFIndex::GetTypes ( ConstString  name,
llvm::function_ref< bool(DWARFDIE die)>  callback 
)
overridevirtual

◆ Index()

void ManualDWARFIndex::Index ( )
private

Definition at line 34 of file ManualDWARFIndex.cpp.

References lldb_private::plugin::dwarf::NameToDIE::Append(), lldb_private::Stream::AsRawOstream(), lldb_private::plugin::dwarf::DWARFDebugInfo::ContainsTypeUnits(), lldb_private::plugin::dwarf::SymbolFileDWARF::DebugInfo(), lldb::eDescriptionLevelBrief, elapsed(), lldb_private::plugin::dwarf::DWARFUnit::ExtractDIEsScoped(), lldb_private::plugin::dwarf::NameToDIE::Finalize(), lldb_private::plugin::dwarf::ManualDWARFIndex::IndexSet::function_basenames, lldb_private::plugin::dwarf::ManualDWARFIndex::IndexSet::function_fullnames, lldb_private::plugin::dwarf::ManualDWARFIndex::IndexSet::function_methods, lldb_private::plugin::dwarf::ManualDWARFIndex::IndexSet::function_selectors, lldb_private::StreamString::GetData(), lldb_private::Module::GetDescription(), lldb_private::plugin::dwarf::SymbolFileDWARF::GetDwpSymbolFile(), lldb_private::plugin::dwarf::DWARFDebugInfo::GetNumUnits(), lldb_private::plugin::dwarf::DWARFUnit::GetOffset(), lldb_private::Debugger::GetThreadPool(), lldb_private::plugin::dwarf::DWARFDebugInfo::GetUnitAtIndex(), lldb_private::plugin::dwarf::ManualDWARFIndex::IndexSet::globals, lldb_private::Progress::Increment(), IndexUnit(), LLDB_SCOPED_TIMERF, LoadFromCache(), m_dwarf, lldb_private::plugin::dwarf::DWARFIndex::m_index_time, m_indexed, lldb_private::plugin::dwarf::DWARFIndex::m_module, m_set, m_type_sigs_to_avoid, m_units_to_avoid, lldb_private::plugin::dwarf::ManualDWARFIndex::IndexSet::namespaces, lldb_private::plugin::dwarf::ManualDWARFIndex::IndexSet::objc_class_selectors, SaveToCache(), lldb_private::SymbolFileCommon::SetDebugInfoIndexWasLoadedFromCache(), and lldb_private::plugin::dwarf::ManualDWARFIndex::IndexSet::types.

Referenced by GetCompleteObjCClass(), GetFunctions(), GetGlobalVariables(), GetNamespaces(), GetObjCMethods(), GetTypes(), and Preload().

◆ IndexUnit()

void ManualDWARFIndex::IndexUnit ( DWARFUnit unit,
SymbolFileDWARFDwo dwp,
IndexSet set 
)
private

◆ IndexUnitImpl()

void ManualDWARFIndex::IndexUnitImpl ( DWARFUnit unit,
const lldb::LanguageType  cu_language,
IndexSet set 
)
staticprivate

◆ IsPartial()

bool ManualDWARFIndex::IsPartial ( ) const
private

Return true if this manual DWARF index is covering only part of the DWARF.

An instance of this class will be used to index all of the DWARF, but also when we have .debug_names we will use one to index any compile or type units that are not covered by the .debug_names table.

Returns
True if this index is a partial index, false otherwise.

Definition at line 720 of file ManualDWARFIndex.cpp.

References m_type_sigs_to_avoid, and m_units_to_avoid.

Referenced by GetCacheKey().

◆ LoadFromCache()

bool ManualDWARFIndex::LoadFromCache ( )
private

Load the symbol table from the index cache.

Quickly load the finalized symbol table from the index cache. This saves time when the debugger starts up. The index cache file for the symbol table has the modification time set to the same time as the main module. If the cache file exists and the modification times match, we will load the symbol table from the serlized cache file.

Returns
True if the symbol table was successfully loaded from the index cache, false if the symbol table wasn't cached or was out of date.

Definition at line 755 of file ManualDWARFIndex.cpp.

References Decode(), lldb_private::ObjectFile::GetAddressByteSize(), lldb_private::DataFileCache::GetCachedData(), GetCacheKey(), lldb_private::Module::GetIndexCache(), lldb_private::SymbolFileCommon::GetObjectFile(), lldb_private::endian::InlHostByteOrder(), m_dwarf, and lldb_private::DataFileCache::RemoveCacheFile().

Referenced by Index().

◆ Preload()

void lldb_private::plugin::dwarf::ManualDWARFIndex::Preload ( )
inlineoverridevirtual

◆ SaveToCache()

void ManualDWARFIndex::SaveToCache ( )
private

Save the symbol table data out into a cache.

The symbol table will only be saved to a cache file if caching is enabled.

We cache the contents of the symbol table since symbol tables in LLDB take some time to initialize. This is due to the many sources for data that are used to create a symbol table:

  • standard symbol table
  • dynamic symbol table (ELF)
  • compressed debug info sections
  • unwind information
  • function pointers found in runtimes for global constructor/destructors
  • other sources. All of the above sources are combined and one symbol table results after all sources have been considered.

Definition at line 778 of file ManualDWARFIndex.cpp.

References Encode(), lldb_private::ObjectFile::GetAddressByteSize(), GetCacheKey(), lldb_private::DataEncoder::GetData(), lldb_private::Module::GetIndexCache(), lldb_private::SymbolFileCommon::GetObjectFile(), lldb_private::endian::InlHostByteOrder(), m_dwarf, lldb_private::DataFileCache::SetCachedData(), and lldb_private::SymbolFileCommon::SetDebugInfoIndexWasSavedToCache().

Referenced by Index().

Member Data Documentation

◆ m_dwarf

SymbolFileDWARF* lldb_private::plugin::dwarf::ManualDWARFIndex::m_dwarf
private

The DWARF file which we are indexing.

Definition at line 182 of file ManualDWARFIndex.h.

Referenced by Decode(), Encode(), GetCacheKey(), Index(), LoadFromCache(), and SaveToCache().

◆ m_indexed

bool lldb_private::plugin::dwarf::ManualDWARFIndex::m_indexed = false
private

Definition at line 188 of file ManualDWARFIndex.h.

Referenced by Index().

◆ m_set

IndexSet lldb_private::plugin::dwarf::ManualDWARFIndex::m_set
private

◆ m_type_sigs_to_avoid

llvm::DenseSet<uint64_t> lldb_private::plugin::dwarf::ManualDWARFIndex::m_type_sigs_to_avoid
private

Definition at line 185 of file ManualDWARFIndex.h.

Referenced by Index(), and IsPartial().

◆ m_units_to_avoid

llvm::DenseSet<dw_offset_t> lldb_private::plugin::dwarf::ManualDWARFIndex::m_units_to_avoid
private

Which dwarf units should we skip while building the index.

Definition at line 184 of file ManualDWARFIndex.h.

Referenced by Index(), and IsPartial().


The documentation for this class was generated from the following files: