LLDB  mainline
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
lldb_private::Symtab Class Reference

#include <Symtab.h>

Collaboration diagram for lldb_private::Symtab:
Collaboration graph
[legend]

Classes

class  FileRangeToIndexMapCompare
 

Public Types

enum  Debug { eDebugNo, eDebugYes, eDebugAny }
 
enum  Visibility { eVisibilityAny, eVisibilityExtern, eVisibilityPrivate }
 
typedef std::vector< uint32_tIndexCollection
 
typedef UniqueCStringMap< uint32_tNameToIndexMap
 

Public Member Functions

 Symtab (ObjectFile *objfile)
 
 ~Symtab ()
 
void PreloadSymbols ()
 
void Reserve (size_t count)
 
SymbolResize (size_t count)
 
uint32_t AddSymbol (const Symbol &symbol)
 
size_t GetNumSymbols () const
 
void SectionFileAddressesChanged ()
 
void Dump (Stream *s, Target *target, SortOrder sort_type, Mangled::NamePreference name_preference=Mangled::ePreferDemangled)
 
void Dump (Stream *s, Target *target, std::vector< uint32_t > &indexes, Mangled::NamePreference name_preference=Mangled::ePreferDemangled) const
 
uint32_t GetIndexForSymbol (const Symbol *symbol) const
 
std::recursive_mutex & GetMutex ()
 
SymbolFindSymbolByID (lldb::user_id_t uid) const
 
SymbolSymbolAtIndex (size_t idx)
 
const SymbolSymbolAtIndex (size_t idx) const
 
SymbolFindSymbolWithType (lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, uint32_t &start_idx)
 
const SymbolGetParent (Symbol *symbol) const
 Get the parent symbol for the given symbol. More...
 
uint32_t AppendSymbolIndexesWithType (lldb::SymbolType symbol_type, std::vector< uint32_t > &indexes, uint32_t start_idx=0, uint32_t end_index=UINT32_MAX) const
 
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
 
uint32_t AppendSymbolIndexesWithType (lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector< uint32_t > &matches, uint32_t start_idx=0, uint32_t end_index=UINT32_MAX) const
 
uint32_t AppendSymbolIndexesWithName (ConstString symbol_name, std::vector< uint32_t > &matches)
 
uint32_t AppendSymbolIndexesWithName (ConstString symbol_name, Debug symbol_debug_type, Visibility symbol_visibility, std::vector< uint32_t > &matches)
 
uint32_t AppendSymbolIndexesWithNameAndType (ConstString symbol_name, lldb::SymbolType symbol_type, std::vector< uint32_t > &matches)
 
uint32_t AppendSymbolIndexesWithNameAndType (ConstString symbol_name, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector< uint32_t > &matches)
 
uint32_t AppendSymbolIndexesMatchingRegExAndType (const RegularExpression &regex, lldb::SymbolType symbol_type, std::vector< uint32_t > &indexes)
 
uint32_t AppendSymbolIndexesMatchingRegExAndType (const RegularExpression &regex, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector< uint32_t > &indexes)
 
void FindAllSymbolsWithNameAndType (ConstString name, lldb::SymbolType symbol_type, std::vector< uint32_t > &symbol_indexes)
 
void FindAllSymbolsWithNameAndType (ConstString name, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector< uint32_t > &symbol_indexes)
 
void FindAllSymbolsMatchingRexExAndType (const RegularExpression &regex, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector< uint32_t > &symbol_indexes)
 
SymbolFindFirstSymbolWithNameAndType (ConstString name, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility)
 
SymbolFindSymbolAtFileAddress (lldb::addr_t file_addr)
 
SymbolFindSymbolContainingFileAddress (lldb::addr_t file_addr)
 
void ForEachSymbolContainingFileAddress (lldb::addr_t file_addr, std::function< bool(Symbol *)> const &callback)
 
void FindFunctionSymbols (ConstString name, uint32_t name_type_mask, SymbolContextList &sc_list)
 
void CalculateSymbolSizes ()
 
void SortSymbolIndexesByValue (std::vector< uint32_t > &indexes, bool remove_duplicates) const
 
void Finalize ()
 
void AppendSymbolNamesToMap (const IndexCollection &indexes, bool add_demangled, bool add_mangled, NameToIndexMap &name_to_index_map) const
 
ObjectFileGetObjectFile ()
 

Static Public Member Functions

static void DumpSymbolHeader (Stream *s)
 

Protected Types

typedef std::vector< Symbolcollection
 
typedef collection::iterator iterator
 
typedef collection::const_iterator const_iterator
 
typedef RangeDataVector< lldb::addr_t, lldb::addr_t, uint32_t, 0, FileRangeToIndexMapCompareFileRangeToIndexMap
 

Protected Member Functions

void InitNameIndexes ()
 
void InitAddressIndexes ()
 

Protected Attributes

ObjectFilem_objfile
 
collection m_symbols
 
FileRangeToIndexMap m_file_addr_to_index
 
std::map< lldb::FunctionNameType, UniqueCStringMap< uint32_t > > m_name_to_symbol_indices
 Maps function names to symbol indices (grouped by FunctionNameTypes) More...
 
std::recursive_mutex m_mutex
 
bool m_file_addr_to_index_computed: 1
 
bool m_name_indexes_computed: 1
 

Private Member Functions

UniqueCStringMap< uint32_t > & GetNameToSymbolIndexMap (lldb::FunctionNameType type)
 
bool CheckSymbolAtIndex (size_t idx, Debug symbol_debug_type, Visibility symbol_visibility) const
 
uint32_t GetNameIndexes (ConstString symbol_name, std::vector< uint32_t > &indexes)
 A helper function that looks up full function names. More...
 
void SymbolIndicesToSymbolContextList (std::vector< uint32_t > &symbol_indexes, SymbolContextList &sc_list)
 
void RegisterMangledNameEntry (uint32_t value, std::set< const char * > &class_contexts, std::vector< std::pair< NameToIndexMap::Entry, const char * >> &backlog, RichManglingContext &rmc)
 
void RegisterBacklogEntry (const NameToIndexMap::Entry &entry, const char *decl_context, const std::set< const char * > &class_contexts)
 
 Symtab (const Symtab &)=delete
 
const Symtaboperator= (const Symtab &)=delete
 

Detailed Description

Definition at line 22 of file Symtab.h.

Member Typedef Documentation

◆ collection

typedef std::vector<Symbol> lldb_private::Symtab::collection
protected

Definition at line 144 of file Symtab.h.

◆ const_iterator

typedef collection::const_iterator lldb_private::Symtab::const_iterator
protected

Definition at line 146 of file Symtab.h.

◆ FileRangeToIndexMap

Definition at line 170 of file Symtab.h.

◆ IndexCollection

Definition at line 24 of file Symtab.h.

◆ iterator

typedef collection::iterator lldb_private::Symtab::iterator
protected

Definition at line 145 of file Symtab.h.

◆ NameToIndexMap

Definition at line 25 of file Symtab.h.

Member Enumeration Documentation

◆ Debug

Enumerator
eDebugNo 
eDebugYes 
eDebugAny 

Definition at line 27 of file Symtab.h.

◆ Visibility

Enumerator
eVisibilityAny 
eVisibilityExtern 
eVisibilityPrivate 

Definition at line 33 of file Symtab.h.

Constructor & Destructor Documentation

◆ Symtab() [1/2]

Symtab::Symtab ( ObjectFile objfile)

Definition at line 29 of file Symtab.cpp.

References m_name_to_symbol_indices.

◆ ~Symtab()

Symtab::~Symtab ( )
default

◆ Symtab() [2/2]

lldb_private::Symtab::Symtab ( const Symtab )
privatedelete

Member Function Documentation

◆ AddSymbol()

uint32_t Symtab::AddSymbol ( const Symbol symbol)

◆ AppendSymbolIndexesMatchingRegExAndType() [1/2]

uint32_t Symtab::AppendSymbolIndexesMatchingRegExAndType ( const RegularExpression regex,
lldb::SymbolType  symbol_type,
Debug  symbol_debug_type,
Visibility  symbol_visibility,
std::vector< uint32_t > &  indexes 
)

◆ AppendSymbolIndexesMatchingRegExAndType() [2/2]

uint32_t Symtab::AppendSymbolIndexesMatchingRegExAndType ( const RegularExpression regex,
lldb::SymbolType  symbol_type,
std::vector< uint32_t > &  indexes 
)

◆ AppendSymbolIndexesWithName() [1/2]

uint32_t Symtab::AppendSymbolIndexesWithName ( ConstString  symbol_name,
Debug  symbol_debug_type,
Visibility  symbol_visibility,
std::vector< uint32_t > &  matches 
)

◆ AppendSymbolIndexesWithName() [2/2]

uint32_t Symtab::AppendSymbolIndexesWithName ( ConstString  symbol_name,
std::vector< uint32_t > &  matches 
)

◆ AppendSymbolIndexesWithNameAndType() [1/2]

uint32_t Symtab::AppendSymbolIndexesWithNameAndType ( ConstString  symbol_name,
lldb::SymbolType  symbol_type,
Debug  symbol_debug_type,
Visibility  symbol_visibility,
std::vector< uint32_t > &  matches 
)

Definition at line 721 of file Symtab.cpp.

References AppendSymbolIndexesWithName(), lldb::eSymbolTypeAny, m_mutex, and m_symbols.

◆ AppendSymbolIndexesWithNameAndType() [2/2]

uint32_t Symtab::AppendSymbolIndexesWithNameAndType ( ConstString  symbol_name,
lldb::SymbolType  symbol_type,
std::vector< uint32_t > &  matches 
)

◆ AppendSymbolIndexesWithType() [1/2]

uint32_t Symtab::AppendSymbolIndexesWithType ( lldb::SymbolType  symbol_type,
Debug  symbol_debug_type,
Visibility  symbol_visibility,
std::vector< uint32_t > &  matches,
uint32_t  start_idx = 0,
uint32_t  end_index = UINT32_MAX 
) const

Definition at line 520 of file Symtab.cpp.

References CheckSymbolAtIndex(), lldb::eSymbolTypeAny, m_mutex, and m_symbols.

◆ AppendSymbolIndexesWithType() [2/2]

uint32_t Symtab::AppendSymbolIndexesWithType ( lldb::SymbolType  symbol_type,
std::vector< uint32_t > &  indexes,
uint32_t  start_idx = 0,
uint32_t  end_index = UINT32_MAX 
) const

◆ AppendSymbolIndexesWithTypeAndFlagsValue()

uint32_t Symtab::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 at line 500 of file Symtab.cpp.

References lldb::eSymbolTypeAny, m_mutex, and m_symbols.

Referenced by SymbolFileDWARFDebugMap::InitOSO().

◆ AppendSymbolNamesToMap()

void Symtab::AppendSymbolNamesToMap ( const IndexCollection indexes,
bool  add_demangled,
bool  add_mangled,
NameToIndexMap name_to_index_map 
) const

◆ CalculateSymbolSizes()

void Symtab::CalculateSymbolSizes ( )

◆ CheckSymbolAtIndex()

bool lldb_private::Symtab::CheckSymbolAtIndex ( size_t  idx,
Debug  symbol_debug_type,
Visibility  symbol_visibility 
) const
inlineprivate

◆ Dump() [1/2]

void Symtab::Dump ( Stream s,
Target target,
SortOrder  sort_type,
Mangled::NamePreference  name_preference = Mangled::ePreferDemangled 
)

◆ Dump() [2/2]

void Symtab::Dump ( Stream s,
Target target,
std::vector< uint32_t > &  indexes,
Mangled::NamePreference  name_preference = Mangled::ePreferDemangled 
) const

◆ DumpSymbolHeader()

void Symtab::DumpSymbolHeader ( Stream s)
static

Definition at line 179 of file Symtab.cpp.

References lldb_private::Stream::Indent().

Referenced by Dump().

◆ Finalize()

void lldb_private::Symtab::Finalize ( )
inline

Definition at line 129 of file Symtab.h.

References m_symbols.

Referenced by SymbolFilePDB::AddSymbols().

◆ FindAllSymbolsMatchingRexExAndType()

void Symtab::FindAllSymbolsMatchingRexExAndType ( const RegularExpression regex,
lldb::SymbolType  symbol_type,
Debug  symbol_debug_type,
Visibility  symbol_visibility,
std::vector< uint32_t > &  symbol_indexes 
)

◆ FindAllSymbolsWithNameAndType() [1/2]

void Symtab::FindAllSymbolsWithNameAndType ( ConstString  name,
lldb::SymbolType  symbol_type,
Debug  symbol_debug_type,
Visibility  symbol_visibility,
std::vector< uint32_t > &  symbol_indexes 
)

◆ FindAllSymbolsWithNameAndType() [2/2]

void Symtab::FindAllSymbolsWithNameAndType ( ConstString  name,
lldb::SymbolType  symbol_type,
std::vector< uint32_t > &  symbol_indexes 
)

◆ FindFirstSymbolWithNameAndType()

Symbol * Symtab::FindFirstSymbolWithNameAndType ( ConstString  name,
lldb::SymbolType  symbol_type,
Debug  symbol_debug_type,
Visibility  symbol_visibility 
)

◆ FindFunctionSymbols()

void Symtab::FindFunctionSymbols ( ConstString  name,
uint32_t  name_type_mask,
SymbolContextList sc_list 
)

◆ FindSymbolAtFileAddress()

Symbol * Symtab::FindSymbolAtFileAddress ( lldb::addr_t  file_addr)

◆ FindSymbolByID()

Symbol * Symtab::FindSymbolByID ( lldb::user_id_t  uid) const

◆ FindSymbolContainingFileAddress()

Symbol * Symtab::FindSymbolContainingFileAddress ( lldb::addr_t  file_addr)

◆ FindSymbolWithType()

Symbol * Symtab::FindSymbolWithType ( lldb::SymbolType  symbol_type,
Debug  symbol_debug_type,
Visibility  symbol_visibility,
uint32_t start_idx 
)

Definition at line 787 of file Symtab.cpp.

References CheckSymbolAtIndex(), lldb::eSymbolTypeAny, m_mutex, and m_symbols.

◆ ForEachSymbolContainingFileAddress()

void Symtab::ForEachSymbolContainingFileAddress ( lldb::addr_t  file_addr,
std::function< bool(Symbol *)> const &  callback 
)

◆ GetIndexForSymbol()

uint32_t Symtab::GetIndexForSymbol ( const Symbol symbol) const

◆ GetMutex()

std::recursive_mutex& lldb_private::Symtab::GetMutex ( )
inline

Definition at line 51 of file Symtab.h.

References m_mutex.

◆ GetNameIndexes()

uint32_t Symtab::GetNameIndexes ( ConstString  symbol_name,
std::vector< uint32_t > &  indexes 
)
private

A helper function that looks up full function names.

We generate unique names for synthetic symbols so that users can look them up by name when needed. But because doing so is uncommon in normal debugger use, we trade off some performance at lookup time for faster symbol table building by detecting these symbols and generating their names lazily, rather than adding them to the normal symbol indexes. This function does the job of first consulting the name indexes, and if that fails it extracts the information it needs from the synthetic name and locates the symbol.

Parameters
[in]symbol_nameThe symbol name to search for.
[out]indexesThe vector if symbol indexes to update with results.
Returns
The number of indexes added to the index vector. Zero if no matches were found.

Definition at line 633 of file Symtab.cpp.

References FindSymbolByID(), GetIndexForSymbol(), GetNameToSymbolIndexMap(), lldb_private::ConstString::GetStringRef(), lldb_private::Symbol::GetSyntheticSymbolPrefix(), and UINT32_MAX.

Referenced by AppendSymbolIndexesWithName().

◆ GetNameToSymbolIndexMap()

UniqueCStringMap<uint32_t>& lldb_private::Symtab::GetNameToSymbolIndexMap ( lldb::FunctionNameType  type)
inlineprivate

◆ GetNumSymbols()

size_t Symtab::GetNumSymbols ( ) const

◆ GetObjectFile()

ObjectFile* lldb_private::Symtab::GetObjectFile ( )
inline

◆ GetParent()

const Symbol * Symtab::GetParent ( Symbol symbol) const

Get the parent symbol for the given symbol.

Many symbols in symbol tables are scoped by other symbols that contain one or more symbol. This function will look for such a containing symbol and return it if there is one.

Definition at line 1138 of file Symtab.cpp.

References GetIndexForSymbol(), lldb_private::Symbol::GetSiblingIndex(), SymbolAtIndex(), and UINT32_MAX.

Referenced by SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE().

◆ InitAddressIndexes()

void Symtab::InitAddressIndexes ( )
protected

◆ InitNameIndexes()

void Symtab::InitNameIndexes ( )
protected

◆ operator=()

const Symtab& lldb_private::Symtab::operator= ( const Symtab )
privatedelete

◆ PreloadSymbols()

void Symtab::PreloadSymbols ( )

Definition at line 449 of file Symtab.cpp.

References InitNameIndexes(), and m_mutex.

Referenced by lldb_private::Module::PreloadSymbols().

◆ RegisterBacklogEntry()

void Symtab::RegisterBacklogEntry ( const NameToIndexMap::Entry entry,
const char *  decl_context,
const std::set< const char * > &  class_contexts 
)
private

Definition at line 431 of file Symtab.cpp.

References GetNameToSymbolIndexMap().

Referenced by InitNameIndexes().

◆ RegisterMangledNameEntry()

void Symtab::RegisterMangledNameEntry ( uint32_t  value,
std::set< const char * > &  class_contexts,
std::vector< std::pair< NameToIndexMap::Entry, const char * >> &  backlog,
RichManglingContext rmc 
)
private

◆ Reserve()

void Symtab::Reserve ( size_t  count)

Definition at line 45 of file Symtab.cpp.

References m_symbols.

◆ Resize()

Symbol * Symtab::Resize ( size_t  count)

Definition at line 51 of file Symtab.cpp.

References m_symbols.

Referenced by ObjectFileMachO::ParseSymtab().

◆ SectionFileAddressesChanged()

void Symtab::SectionFileAddressesChanged ( )

Definition at line 76 of file Symtab.cpp.

References GetNameToSymbolIndexMap(), and m_file_addr_to_index_computed.

◆ SortSymbolIndexesByValue()

void Symtab::SortSymbolIndexesByValue ( std::vector< uint32_t > &  indexes,
bool  remove_duplicates 
) const

◆ SymbolAtIndex() [1/2]

Symbol * Symtab::SymbolAtIndex ( size_t  idx)

◆ SymbolAtIndex() [2/2]

const Symbol * Symtab::SymbolAtIndex ( size_t  idx) const

Definition at line 218 of file Symtab.cpp.

References m_symbols.

◆ SymbolIndicesToSymbolContextList()

void Symtab::SymbolIndicesToSymbolContextList ( std::vector< uint32_t > &  symbol_indexes,
SymbolContextList sc_list 
)
private

Member Data Documentation

◆ m_file_addr_to_index

FileRangeToIndexMap lldb_private::Symtab::m_file_addr_to_index
protected

◆ m_file_addr_to_index_computed

bool lldb_private::Symtab::m_file_addr_to_index_computed
protected

◆ m_mutex

std::recursive_mutex lldb_private::Symtab::m_mutex
mutableprotected

◆ m_name_indexes_computed

bool lldb_private::Symtab::m_name_indexes_computed
protected

◆ m_name_to_symbol_indices

std::map<lldb::FunctionNameType, UniqueCStringMap<uint32_t> > lldb_private::Symtab::m_name_to_symbol_indices
protected

Maps function names to symbol indices (grouped by FunctionNameTypes)

Definition at line 180 of file Symtab.h.

Referenced by GetNameToSymbolIndexMap(), and Symtab().

◆ m_objfile

ObjectFile* lldb_private::Symtab::m_objfile
protected

◆ m_symbols

collection lldb_private::Symtab::m_symbols
protected

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