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

"lldb/Expression/ClangExpressionDeclMap.h" Manages named entities that are defined in LLDB's debug information. More...

#include <ClangExpressionDeclMap.h>

Inheritance diagram for lldb_private::ClangExpressionDeclMap:
Inheritance graph
[legend]

Classes

class  ParserVars
 The following values should not live beyond parsing. More...
 
struct  StructVars
 The following values contain layout information for the materialized struct, but are not specific to a single materialization. More...
 
struct  TargetInfo
 

Public Member Functions

 ClangExpressionDeclMap (bool keep_result_in_memory, Materializer::PersistentVariableDelegate *result_delegate, const lldb::TargetSP &target, const std::shared_ptr< ClangASTImporter > &importer, ValueObject *ctx_obj)
 Constructor.
 
 ~ClangExpressionDeclMap () override
 Destructor.
 
bool WillParse (ExecutionContext &exe_ctx, Materializer *materializer)
 Enable the state needed for parsing and IR transformation.
 
void InstallCodeGenerator (clang::ASTConsumer *code_gen)
 
void InstallDiagnosticManager (DiagnosticManager &diag_manager)
 
void DidParse ()
 Disable the state needed for parsing and IR transformation.
 
bool AddPersistentVariable (const clang::NamedDecl *decl, ConstString name, TypeFromParser type, bool is_result, bool is_lvalue)
 [Used by IRForTarget] Add a variable to the list of persistent variables for the process.
 
bool AddValueToStruct (const clang::NamedDecl *decl, ConstString name, llvm::Value *value, size_t size, lldb::offset_t alignment)
 [Used by IRForTarget] Add a variable to the struct that needs to be materialized each time the expression runs.
 
bool DoStructLayout ()
 [Used by IRForTarget] Finalize the struct, laying out the position of each object in it.
 
bool GetStructInfo (uint32_t &num_elements, size_t &size, lldb::offset_t &alignment)
 [Used by IRForTarget] Get general information about the laid-out struct after DoStructLayout() has been called.
 
bool GetStructElement (const clang::NamedDecl *&decl, llvm::Value *&value, lldb::offset_t &offset, ConstString &name, uint32_t index)
 [Used by IRForTarget] Get specific information about one field of the laid-out struct after DoStructLayout() has been called.
 
bool GetFunctionInfo (const clang::NamedDecl *decl, uint64_t &ptr)
 [Used by IRForTarget] Get information about a function given its Decl.
 
lldb::addr_t GetSymbolAddress (Target &target, Process *process, ConstString name, lldb::SymbolType symbol_type, Module *module=nullptr)
 [Used by IRForTarget] Get the address of a symbol given nothing but its name.
 
lldb::addr_t GetSymbolAddress (ConstString name, lldb::SymbolType symbol_type)
 
TargetInfo GetTargetInfo ()
 
void FindExternalVisibleDecls (NameSearchContext &context) override
 [Used by ClangASTSource] Find all entities matching a given name, using a NameSearchContext to make Decls for them.
 
void FindExternalVisibleDecls (NameSearchContext &context, lldb::ModuleSP module, const CompilerDeclContext &namespace_decl)
 Find all entities matching a given name in a given module/namespace, using a NameSearchContext to make Decls for them.
 
- Public Member Functions inherited from lldb_private::ClangASTSource
 ClangASTSource (const lldb::TargetSP &target, const std::shared_ptr< ClangASTImporter > &importer)
 Constructor.
 
 ~ClangASTSource () override
 Destructor.
 
clang::Decl * GetExternalDecl (clang::GlobalDeclID) override
 Interface stubs.
 
clang::Stmt * GetExternalDeclStmt (uint64_t) override
 
clang::Selector GetExternalSelector (uint32_t) override
 
uint32_t GetNumExternalSelectors () override
 
clang::CXXBaseSpecifier * GetExternalCXXBaseSpecifiers (uint64_t Offset) override
 
void MaterializeVisibleDecls (const clang::DeclContext *DC)
 
void InstallASTContext (TypeSystemClang &ast_context)
 
bool FindExternalVisibleDeclsByName (const clang::DeclContext *DC, clang::DeclarationName Name) override
 Look up all Decls that match a particular name.
 
void FindExternalLexicalDecls (const clang::DeclContext *DC, llvm::function_ref< bool(clang::Decl::Kind)> IsKindWeWant, llvm::SmallVectorImpl< clang::Decl * > &Decls) override
 Enumerate all Decls in a given lexical context.
 
bool layoutRecordType (const clang::RecordDecl *Record, uint64_t &Size, uint64_t &Alignment, llvm::DenseMap< const clang::FieldDecl *, uint64_t > &FieldOffsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &BaseOffsets, llvm::DenseMap< const clang::CXXRecordDecl *, clang::CharUnits > &VirtualBaseOffsets) override
 Specify the layout of the contents of a RecordDecl.
 
void CompleteType (clang::TagDecl *Tag) override
 Complete a TagDecl.
 
void CompleteType (clang::ObjCInterfaceDecl *Class) override
 Complete an ObjCInterfaceDecl.
 
void StartTranslationUnit (clang::ASTConsumer *Consumer) override
 Called on entering a translation unit.
 
void CompleteNamespaceMap (ClangASTImporter::NamespaceMapSP &namespace_map, ConstString name, ClangASTImporter::NamespaceMapSP &parent_map) const override
 Look up the modules containing a given namespace and put the appropriate entries in the namespace map.
 
clang::NamespaceDecl * AddNamespace (NameSearchContext &context, ClangASTImporter::NamespaceMapSP &namespace_decls)
 
virtual void FindExternalVisibleDecls (NameSearchContext &context)
 The worker function for FindExternalVisibleDeclsByName.
 
clang::Sema * getSema ()
 
void SetLookupsEnabled (bool lookups_enabled)
 
bool GetLookupsEnabled ()
 
clang::ExternalASTSource * CreateProxy ()
 
bool IgnoreName (const ConstString name, bool ignore_all_dollar_names)
 Returns true if a name should be ignored by name lookup.
 
clang::Decl * CopyDecl (clang::Decl *src_decl)
 Copies a single Decl into the parser's AST context.
 
ClangASTImporter::DeclOrigin GetDeclOrigin (const clang::Decl *decl)
 Determined the origin of a single Decl, if it can be found.
 
TypeSystemClangGetTypeSystem () const
 Returns the TypeSystem that uses this ClangASTSource instance as it's ExternalASTSource.
 
- Public Member Functions inherited from lldb_private::ClangASTImporter::MapCompleter
virtual ~MapCompleter ()
 
virtual void CompleteNamespaceMap (NamespaceMapSP &namespace_map, ConstString name, NamespaceMapSP &parent_map) const =0
 

Protected Member Functions

virtual clang::NamedDecl * GetPersistentDecl (ConstString name)
 Retrieves the declaration with the given name from the storage of persistent declarations.
 
- Protected Member Functions inherited from lldb_private::ClangASTSource
clang::ObjCInterfaceDecl * GetCompleteObjCInterface (const clang::ObjCInterfaceDecl *interface_decl)
 Look for the complete version of an Objective-C interface, and return it if found.
 
void FindExternalVisibleDecls (NameSearchContext &context, lldb::ModuleSP module, CompilerDeclContext &namespace_decl)
 Find all entities matching a given name in a given module, using a NameSearchContext to make Decls for them.
 
void FindObjCMethodDecls (NameSearchContext &context)
 Find all Objective-C methods matching a given selector.
 
void FindObjCPropertyAndIvarDecls (NameSearchContext &context)
 Find all Objective-C properties and ivars with a given name.
 
void LookupInNamespace (NameSearchContext &context)
 Performs lookup into a namespace.
 
CompilerType GuardedCopyType (const CompilerType &src_type)
 A wrapper for TypeSystemClang::CopyType that sets a flag that indicates that we should not respond to queries during import.
 
std::shared_ptr< ClangModulesDeclVendorGetClangModulesDeclVendor ()
 
bool FindObjCMethodDeclsWithOrigin (NameSearchContext &context, clang::ObjCInterfaceDecl *original_interface_decl, const char *log_info)
 
void FindDeclInModules (NameSearchContext &context, ConstString name)
 
void FindDeclInObjCRuntime (NameSearchContext &context, ConstString name)
 
void FillNamespaceMap (NameSearchContext &context, lldb::ModuleSP module_sp, const CompilerDeclContext &namespace_decl)
 Fills the namespace map of the given NameSearchContext.
 
clang::TagDecl * FindCompleteType (const clang::TagDecl *decl)
 

Private Member Functions

void EnableParserVars ()
 Activate parser-specific variables.
 
void DisableParserVars ()
 Deallocate parser-specific variables.
 
void EnableStructVars ()
 Activate struct variables.
 
void DisableStructVars ()
 Deallocate struct variables.
 
lldb::TypeSystemClangSP GetScratchContext (Target &target)
 
uint64_t GetParserID ()
 Get this parser's ID for use in extracting parser- and JIT-specific data from persistent variables.
 
void MaybeRegisterFunctionBody (clang::FunctionDecl *copied_function_decl)
 Should be called on all copied functions.
 
void SearchPersistenDecls (NameSearchContext &context, const ConstString name)
 Searches the persistent decls of the target for entities with the given name.
 
void LookUpLldbClass (NameSearchContext &context)
 Handles looking up $__lldb_class which requires special treatment.
 
void LookUpLldbObjCClass (NameSearchContext &context)
 Handles looking up $__lldb_objc_class which requires special treatment.
 
void LookupLocalVarNamespace (SymbolContext &sym_ctx, NameSearchContext &name_context)
 Handles looking up the synthetic namespace that contains our local variables for the current frame.
 
void LookupInModulesDeclVendor (NameSearchContext &context, ConstString name)
 Lookup entities in the ClangModulesDeclVendor.
 
bool LookupLocalVariable (NameSearchContext &context, ConstString name, SymbolContext &sym_ctx, const CompilerDeclContext &namespace_decl)
 Looks up a local variable.
 
SymbolContextList SearchFunctionsInSymbolContexts (const SymbolContextList &sc_list, const CompilerDeclContext &frame_decl_context)
 Searches for functions in the given SymbolContextList.
 
void LookupFunction (NameSearchContext &context, lldb::ModuleSP module_sp, ConstString name, const CompilerDeclContext &namespace_decl)
 Looks up a function.
 
lldb::VariableSP FindGlobalVariable (Target &target, lldb::ModuleSP &module, ConstString name, const CompilerDeclContext &namespace_decl)
 Given a target, find a variable that matches the given name and type.
 
bool GetVariableValue (lldb::VariableSP &var, lldb_private::Value &var_location, TypeFromUser *found_type=nullptr, TypeFromParser *parser_type=nullptr)
 Get the value of a variable in a given execution context and return the associated Types if needed.
 
ClangExpressionVariable::ParserVarsAddExpressionVariable (NameSearchContext &context, TypeFromParser const &pt, lldb::ValueObjectSP valobj)
 Use the NameSearchContext to generate a Decl for the given LLDB ValueObject, and put it in the list of found entities.
 
void AddOneVariable (NameSearchContext &context, lldb::VariableSP var, lldb::ValueObjectSP valobj)
 Use the NameSearchContext to generate a Decl for the given LLDB Variable, and put it in the Tuple list.
 
void AddOneVariable (NameSearchContext &context, lldb::ValueObjectSP valobj, ValueObjectProviderTy valobj_provider)
 Use the NameSearchContext to generate a Decl for the given ValueObject and put it in the list of found entities.
 
void AddOneVariable (NameSearchContext &context, lldb::ExpressionVariableSP &pvar_sp)
 Use the NameSearchContext to generate a Decl for the given persistent variable, and put it in the list of found entities.
 
void AddOneGenericVariable (NameSearchContext &context, const Symbol &symbol)
 Use the NameSearchContext to generate a Decl for the given LLDB symbol (treated as a variable), and put it in the list of found entities.
 
void AddOneFunction (NameSearchContext &context, Function *fun, Symbol *sym)
 Use the NameSearchContext to generate a Decl for the given function.
 
void AddOneRegister (NameSearchContext &context, const RegisterInfo *reg_info)
 Use the NameSearchContext to generate a Decl for the given register.
 
void AddOneType (NameSearchContext &context, const TypeFromUser &type)
 Use the NameSearchContext to generate a Decl for the given type.
 
void AddContextClassType (NameSearchContext &context, const TypeFromUser &type)
 Adds the class in which the expression is evaluated to the lookup and prepares the class to be used as a context for expression evaluation (for example, it creates a fake member function that will contain the expression LLDB is trying to evaluate).
 
TypeFromUser DeportType (TypeSystemClang &target, TypeSystemClang &source, TypeFromParser parser_type)
 Move a type out of the current ASTContext into another, but make sure to export all components of the type also.
 
TypeSystemClangGetTypeSystemClang ()
 

Private Attributes

ExpressionVariableList m_found_entities
 All entities that were looked up for the parser.
 
ExpressionVariableList m_struct_members
 All entities that need to be placed in the struct.
 
bool m_keep_result_in_memory
 True if result persistent variables generated by this expression should stay in memory.
 
Materializer::PersistentVariableDelegatem_result_delegate
 If non-NULL, used to report expression results to ClangUserExpression.
 
ValueObjectm_ctx_obj
 If not empty, then expression is evaluated in context of this object.
 
std::unique_ptr< ParserVarsm_parser_vars
 
std::unique_ptr< StructVarsm_struct_vars
 

Additional Inherited Members

- Protected Attributes inherited from lldb_private::ClangASTSource
bool m_lookups_enabled
 
const lldb::TargetSP m_target
 The target to use in finding variables and types.
 
clang::ASTContext * m_ast_context
 The AST context requests are coming in for.
 
TypeSystemClangm_clang_ast_context
 The TypeSystemClang for m_ast_context.
 
clang::FileManager * m_file_manager
 The file manager paired with the AST context.
 
std::shared_ptr< ClangASTImporterm_ast_importer_sp
 The target's AST importer.
 
std::set< const clang::Decl * > m_active_lexical_decls
 
std::set< const char * > m_active_lookups
 

Detailed Description

"lldb/Expression/ClangExpressionDeclMap.h" Manages named entities that are defined in LLDB's debug information.

The Clang parser uses the ClangASTSource as an interface to request named entities from outside an expression. The ClangASTSource reports back, listing all possible objects corresponding to a particular name. But it in turn relies on ClangExpressionDeclMap, which performs several important functions.

First, it records what variables and functions were looked up and what Decls were returned for them.

Second, it constructs a struct on behalf of IRForTarget, recording which variables should be placed where and relaying this information back so that IRForTarget can generate context-independent code.

Third, it "materializes" this struct on behalf of the expression command, finding the current values of each variable and placing them into the struct so that it can be passed to the JITted version of the IR.

Fourth and finally, it "dematerializes" the struct after the JITted code has executed, placing the new values back where it found the old ones.

Definition at line 57 of file ClangExpressionDeclMap.h.

Constructor & Destructor Documentation

◆ ClangExpressionDeclMap()

ClangExpressionDeclMap::ClangExpressionDeclMap ( bool  keep_result_in_memory,
Materializer::PersistentVariableDelegate result_delegate,
const lldb::TargetSP target,
const std::shared_ptr< ClangASTImporter > &  importer,
ValueObject ctx_obj 
)

Constructor.

Initializes class variables.

Parameters
[in]keep_result_in_memoryIf true, inhibits the normal deallocation of the memory for the result persistent variable, and instead marks the variable as persisting.
[in]result_delegateIf non-NULL, use this delegate to report result values. This allows the client ClangUserExpression to report a result.
[in]targetThe target to use when parsing.
[in]importerThe ClangASTImporter to use when parsing.
[in]ctx_objIf not empty, then expression is evaluated in context of this object. See the comment to UserExpression::Evaluate for details.

Definition at line 86 of file ClangExpressionDeclMap.cpp.

References EnableStructVars().

◆ ~ClangExpressionDeclMap()

ClangExpressionDeclMap::~ClangExpressionDeclMap ( )
override

Destructor.

Definition at line 98 of file ClangExpressionDeclMap.cpp.

References DidParse(), and DisableStructVars().

Member Function Documentation

◆ AddContextClassType()

void ClangExpressionDeclMap::AddContextClassType ( NameSearchContext context,
const TypeFromUser type 
)
private

◆ AddExpressionVariable()

ClangExpressionVariable::ParserVars * ClangExpressionDeclMap::AddExpressionVariable ( NameSearchContext context,
TypeFromParser const &  pt,
lldb::ValueObjectSP  valobj 
)
private

Use the NameSearchContext to generate a Decl for the given LLDB ValueObject, and put it in the list of found entities.

Helper function used by the other AddOneVariable APIs.

Parameters
[in,out]contextThe NameSearchContext to use when constructing the Decl.
[in]ptThe CompilerType of the variable we're adding a Decl for.
[in]varThe LLDB ValueObject that needs a Decl.

Definition at line 1553 of file ClangExpressionDeclMap.cpp.

References lldb_private::ExpressionVariableList::AddNewlyConstructedVariable(), lldb_private::NameSearchContext::AddVarDecl(), lldb_private::ClangASTSource::CompleteType(), lldb_private::ClangExpressionVariable::EnableParserVars(), GetParserID(), lldb_private::ClangExpressionVariable::GetParserVars(), lldb_private::NameSearchContext::m_decl_name, m_found_entities, and lldb_private::ClangExpressionVariable::ParserVars::m_named_decl.

Referenced by AddOneVariable().

◆ AddOneFunction()

void ClangExpressionDeclMap::AddOneFunction ( NameSearchContext context,
Function fun,
Symbol sym 
)
private

Use the NameSearchContext to generate a Decl for the given function.

(Functions are not placed in the Tuple list.) Can handle both fully typed functions and generic functions.

Parameters
[in]contextThe NameSearchContext to use when constructing the Decl.
[in]funThe Function that needs to be created. If non-NULL, this is a fully-typed function.
[in]symThe Symbol that corresponds to a function that needs to be created with generic type (unitptr_t foo(...)).

Definition at line 1794 of file ClangExpressionDeclMap.cpp.

References lldb_private::NameSearchContext::AddFunDecl(), lldb_private::NameSearchContext::AddGenericFunDecl(), lldb_private::NameSearchContext::AddNamedDecl(), lldb_private::ExpressionVariableList::AddNewlyConstructedVariable(), lldb_private::ConstString::AsCString(), lldb_private::ClangASTSource::CopyDecl(), lldb_private::Address::Dump(), lldb_private::ClangUtil::DumpDecl(), lldb_private::Address::DumpStyleResolvedDescription, lldb_private::Function::DumpSymbolContext(), lldb_private::ClangExpressionVariable::EnableParserVars(), lldb_private::Expressions, lldb_private::Value::FileAddress, lldb_private::Symbol::GetAddress(), lldb_private::Function::GetAddressRange(), lldb_private::AddressRange::GetBaseAddress(), lldb_private::Address::GetCallableLoadAddress(), lldb_private::Function::GetCompileUnit(), lldb_private::StreamString::GetData(), lldb_private::Function::GetDeclContext(), lldb_private::Address::GetFileAddress(), lldb_private::Type::GetFullCompilerType(), lldb_private::UserID::GetID(), lldb_private::CompileUnit::GetLanguage(), lldb_private::GetLog(), lldb_private::Function::GetMangled(), lldb_private::Mangled::GetMangledName(), lldb_private::Type::GetName(), lldb_private::CompilerDeclContext::GetOpaqueDeclContext(), GetParserID(), lldb_private::ClangExpressionVariable::GetParserVars(), lldb_private::Value::GetScalar(), lldb_private::Function::GetType(), lldb_private::CompilerDeclContext::GetTypeSystem(), lldb_private::ClangASTSource::GuardedCopyType(), lldb_private::CPlusPlusLanguage::IsCPPMangledName(), lldb_private::Symbol::IsIndirect(), lldb_private::Language::LanguageIsC(), lldb_private::Language::LanguageIsCPlusPlus(), lldb_private::Language::LanguageIsObjC(), LLDB_INVALID_ADDRESS, LLDB_LOG, lldb_private::Value::LoadAddress, lldb_private::NameSearchContext::m_decl_name, m_found_entities, lldb_private::ClangExpressionVariable::ParserVars::m_lldb_value, lldb_private::ClangExpressionVariable::ParserVars::m_llvm_value, lldb_private::ClangExpressionVariable::ParserVars::m_named_decl, m_parser_vars, and lldb_private::Value::SetValueType().

Referenced by LookupFunction().

◆ AddOneGenericVariable()

void ClangExpressionDeclMap::AddOneGenericVariable ( NameSearchContext context,
const Symbol symbol 
)
private

◆ AddOneRegister()

void ClangExpressionDeclMap::AddOneRegister ( NameSearchContext context,
const RegisterInfo reg_info 
)
private

◆ AddOneType()

void ClangExpressionDeclMap::AddOneType ( NameSearchContext context,
const TypeFromUser type 
)
private

Use the NameSearchContext to generate a Decl for the given type.

(Types are not placed in the Tuple list.)

Parameters
[in]contextThe NameSearchContext to use when constructing the Decl.
[in]typeThe type that needs to be created.

Definition at line 2030 of file ClangExpressionDeclMap.cpp.

References lldb_private::NameSearchContext::AddTypeDecl(), lldb_private::Expressions, lldb_private::GetLog(), lldb_private::ClangASTSource::GuardedCopyType(), and LLDB_LOG.

Referenced by LookUpLldbObjCClass().

◆ AddOneVariable() [1/3]

void ClangExpressionDeclMap::AddOneVariable ( NameSearchContext context,
lldb::ExpressionVariableSP pvar_sp 
)
private

◆ AddOneVariable() [2/3]

void ClangExpressionDeclMap::AddOneVariable ( NameSearchContext context,
lldb::ValueObjectSP  valobj,
ValueObjectProviderTy  valobj_provider 
)
private

◆ AddOneVariable() [3/3]

void ClangExpressionDeclMap::AddOneVariable ( NameSearchContext context,
lldb::VariableSP  var,
lldb::ValueObjectSP  valobj 
)
private

◆ AddPersistentVariable()

bool ClangExpressionDeclMap::AddPersistentVariable ( const clang::NamedDecl *  decl,
ConstString  name,
TypeFromParser  type,
bool  is_result,
bool  is_lvalue 
)

◆ AddValueToStruct()

bool ClangExpressionDeclMap::AddValueToStruct ( const clang::NamedDecl *  decl,
ConstString  name,
llvm::Value *  value,
size_t  size,
lldb::offset_t  alignment 
)

◆ DeportType()

TypeFromUser ClangExpressionDeclMap::DeportType ( TypeSystemClang target,
TypeSystemClang source,
TypeFromParser  parser_type 
)
private

Move a type out of the current ASTContext into another, but make sure to export all components of the type also.

Parameters
[in]targetThe TypeSystemClang to move to.
[in]sourceThe TypeSystemClang to move from. This is assumed to be going away.
[in]parser_typeThe type as it appears in the source context.
Returns
Returns the moved type, or an empty type if there was a problem.

Definition at line 204 of file ClangExpressionDeclMap.cpp.

References lldb_private::TypeSystemClang::getASTContext(), GetScratchContext(), lldb_private::ClangASTSource::m_ast_context, and lldb_private::ClangASTSource::m_ast_importer_sp.

Referenced by AddPersistentVariable().

◆ DidParse()

void ClangExpressionDeclMap::DidParse ( )

◆ DisableParserVars()

void lldb_private::ClangExpressionDeclMap::DisableParserVars ( )
inlineprivate

Deallocate parser-specific variables.

Definition at line 352 of file ClangExpressionDeclMap.h.

References m_parser_vars.

Referenced by DidParse().

◆ DisableStructVars()

void lldb_private::ClangExpressionDeclMap::DisableStructVars ( )
inlineprivate

Deallocate struct variables.

Definition at line 379 of file ClangExpressionDeclMap.h.

References m_struct_vars.

Referenced by ~ClangExpressionDeclMap().

◆ DoStructLayout()

bool ClangExpressionDeclMap::DoStructLayout ( )

[Used by IRForTarget] Finalize the struct, laying out the position of each object in it.

Returns
True on success; false otherwise.

Definition at line 434 of file ClangExpressionDeclMap.cpp.

References m_parser_vars, and m_struct_vars.

Referenced by IRForTarget::ReplaceVariables().

◆ EnableParserVars()

void lldb_private::ClangExpressionDeclMap::EnableParserVars ( )
inlineprivate

Activate parser-specific variables.

Definition at line 346 of file ClangExpressionDeclMap.h.

References m_parser_vars.

Referenced by WillParse().

◆ EnableStructVars()

void lldb_private::ClangExpressionDeclMap::EnableStructVars ( )
inlineprivate

Activate struct variables.

Definition at line 373 of file ClangExpressionDeclMap.h.

References m_struct_vars.

Referenced by ClangExpressionDeclMap().

◆ FindExternalVisibleDecls() [1/2]

void ClangExpressionDeclMap::FindExternalVisibleDecls ( NameSearchContext context)
overridevirtual

◆ FindExternalVisibleDecls() [2/2]

void ClangExpressionDeclMap::FindExternalVisibleDecls ( NameSearchContext context,
lldb::ModuleSP  module,
const CompilerDeclContext namespace_decl 
)

◆ FindGlobalVariable()

lldb::VariableSP ClangExpressionDeclMap::FindGlobalVariable ( Target target,
lldb::ModuleSP module,
ConstString  name,
const CompilerDeclContext namespace_decl 
)
private

Given a target, find a variable that matches the given name and type.

Parameters
[in]targetThe target to use as a basis for finding the variable.
[in]moduleIf non-NULL, the module to search.
[in]nameThe name as a plain C string.
[in]namespace_declIf non-NULL and module is non-NULL, the parent namespace.
Returns
The LLDB Variable found, or NULL if none was found.

Definition at line 628 of file ClangExpressionDeclMap.cpp.

References lldb_private::ModuleList::FindGlobalVariables(), lldb_private::Target::GetImages(), lldb_private::VariableList::GetSize(), and lldb_private::VariableList::GetVariableAtIndex().

Referenced by FindExternalVisibleDecls().

◆ GetFunctionInfo()

bool ClangExpressionDeclMap::GetFunctionInfo ( const clang::NamedDecl *  decl,
uint64_t &  ptr 
)

[Used by IRForTarget] Get information about a function given its Decl.

Parameters
[in]declThe parsed Decl for the Function, as generated by ClangASTSource on ClangExpressionDeclMap's behalf.
[out]ptrThe absolute address of the function in the target.
Returns
True if the information could be retrieved; false otherwise.

Definition at line 501 of file ClangExpressionDeclMap.cpp.

References lldb_private::ClangExpressionVariable::FindVariableInList(), GetParserID(), lldb_private::ClangExpressionVariable::GetParserVars(), lldb_private::Value::GetScalar(), m_found_entities, lldb_private::ClangExpressionVariable::ParserVars::m_lldb_value, and lldb_private::Scalar::ULongLong().

◆ GetParserID()

uint64_t lldb_private::ClangExpressionDeclMap::GetParserID ( )
inlineprivate

Get this parser's ID for use in extracting parser- and JIT-specific data from persistent variables.

Definition at line 388 of file ClangExpressionDeclMap.h.

Referenced by AddExpressionVariable(), AddOneFunction(), AddOneGenericVariable(), AddOneRegister(), AddOneVariable(), AddPersistentVariable(), AddValueToStruct(), DidParse(), GetFunctionInfo(), and GetStructElement().

◆ GetPersistentDecl()

clang::NamedDecl * ClangExpressionDeclMap::GetPersistentDecl ( ConstString  name)
protectedvirtual

Retrieves the declaration with the given name from the storage of persistent declarations.

Returns
A persistent decl with the given name or a nullptr.

Definition at line 735 of file ClangExpressionDeclMap.cpp.

References lldb_private::ScratchTypeSystemClang::GetForTarget(), and m_parser_vars.

Referenced by SearchPersistenDecls().

◆ GetScratchContext()

lldb::TypeSystemClangSP lldb_private::ClangExpressionDeclMap::GetScratchContext ( Target target)
inlineprivate

◆ GetStructElement()

bool ClangExpressionDeclMap::GetStructElement ( const clang::NamedDecl *&  decl,
llvm::Value *&  value,
lldb::offset_t offset,
ConstString name,
uint32_t  index 
)

[Used by IRForTarget] Get specific information about one field of the laid-out struct after DoStructLayout() has been called.

Parameters
[out]declThe parsed Decl for the field, as generated by ClangASTSource on ClangExpressionDeclMap's behalf. In the case of the result value, this will have the name $__lldb_result even if the result value ends up having the name $1. This is an implementation detail of IRForTarget.
[out]valueThe IR value for the field (usually a GlobalVariable). In the case of the result value, this will have the correct name ($1, for instance). This is an implementation detail of IRForTarget.
[out]offsetThe offset of the field from the beginning of the struct. As long as the struct is aligned according to its required alignment, this offset will align the field correctly.
[out]nameThe name of the field as used in materialization.
[in]indexThe index of the field about which information is requested.
Returns
True if the information could be retrieved; false otherwise.

Definition at line 465 of file ClangExpressionDeclMap.cpp.

References GetParserID(), lldb_private::ExpressionVariableList::GetSize(), lldb_private::ExpressionVariableList::GetVariableAtIndex(), lldb_private::ClangExpressionVariable::ParserVars::m_llvm_value, lldb_private::ClangExpressionVariable::ParserVars::m_named_decl, lldb_private::ClangExpressionVariable::JITVars::m_offset, m_struct_members, and m_struct_vars.

Referenced by IRForTarget::ReplaceVariables().

◆ GetStructInfo()

bool ClangExpressionDeclMap::GetStructInfo ( uint32_t &  num_elements,
size_t &  size,
lldb::offset_t alignment 
)

[Used by IRForTarget] Get general information about the laid-out struct after DoStructLayout() has been called.

Parameters
[out]num_elementsThe number of elements in the struct.
[out]sizeThe size of the struct, in bytes.
[out]alignmentThe alignment of the struct, in bytes.
Returns
True if the information could be retrieved; false otherwise.

Definition at line 451 of file ClangExpressionDeclMap.cpp.

References lldb_private::ExpressionVariableList::GetSize(), m_struct_members, and m_struct_vars.

Referenced by IRForTarget::ReplaceVariables().

◆ GetSymbolAddress() [1/2]

addr_t ClangExpressionDeclMap::GetSymbolAddress ( ConstString  name,
lldb::SymbolType  symbol_type 
)

Definition at line 616 of file ClangExpressionDeclMap.cpp.

References GetSymbolAddress(), and m_parser_vars.

◆ GetSymbolAddress() [2/2]

addr_t ClangExpressionDeclMap::GetSymbolAddress ( Target target,
Process process,
ConstString  name,
lldb::SymbolType  symbol_type,
lldb_private::Module module = nullptr 
)

[Used by IRForTarget] Get the address of a symbol given nothing but its name.

Parameters
[in]targetThe target to find the symbol in. If not provided, then the current parsing context's Target.
[in]processThe process to use. For Objective-C symbols, the process's Objective-C language runtime may be queried if the process is non-NULL.
[in]nameThe name of the symbol.
[in]moduleThe module to limit the search to. This can be NULL
Returns
Valid load address for the symbol

Definition at line 520 of file ClangExpressionDeclMap.cpp.

References lldb_private::FileSpec::ClearDirectory(), lldb::eSymbolTypeAbsolute, lldb::eSymbolTypeAdditional, lldb::eSymbolTypeBlock, lldb::eSymbolTypeCode, lldb::eSymbolTypeCommonBlock, lldb::eSymbolTypeCompiler, lldb::eSymbolTypeData, lldb::eSymbolTypeException, lldb::eSymbolTypeHeaderFile, lldb::eSymbolTypeInstrumentation, lldb::eSymbolTypeInvalid, lldb::eSymbolTypeLineEntry, lldb::eSymbolTypeLineHeader, lldb::eSymbolTypeLocal, lldb::eSymbolTypeObjCClass, lldb::eSymbolTypeObjCIVar, lldb::eSymbolTypeObjCMetaClass, lldb::eSymbolTypeObjectFile, lldb::eSymbolTypeParam, lldb::eSymbolTypeReExported, lldb::eSymbolTypeResolver, lldb::eSymbolTypeRuntime, lldb::eSymbolTypeScopeBegin, lldb::eSymbolTypeScopeEnd, lldb::eSymbolTypeSourceFile, lldb::eSymbolTypeTrampoline, lldb::eSymbolTypeUndefined, lldb::eSymbolTypeVariable, lldb::eSymbolTypeVariableType, lldb_private::ModuleList::FindFirstModule(), lldb_private::Module::FindSymbolsWithNameAndType(), lldb_private::ModuleList::FindSymbolsWithNameAndType(), lldb_private::ObjCLanguageRuntime::Get(), lldb_private::Address::GetCallableLoadAddress(), lldb_private::Target::GetImages(), lldb_private::Address::GetLoadAddress(), lldb_private::ModuleSpec::GetPlatformFileSpec(), GetSymbolAddress(), lldb_private::Address::IsValid(), LLDB_INVALID_ADDRESS, and lldb_private::LanguageRuntime::LookupRuntimeSymbol().

Referenced by GetSymbolAddress(), IRForTarget::HandleObjCClass(), and IRForTarget::HandleSymbol().

◆ GetTargetInfo()

ClangExpressionDeclMap::TargetInfo ClangExpressionDeclMap::GetTargetInfo ( )

◆ GetTypeSystemClang()

TypeSystemClang * ClangExpressionDeclMap::GetTypeSystemClang ( )
private

◆ GetVariableValue()

bool ClangExpressionDeclMap::GetVariableValue ( lldb::VariableSP var,
lldb_private::Value var_location,
TypeFromUser found_type = nullptr,
TypeFromParser parser_type = nullptr 
)
private

Get the value of a variable in a given execution context and return the associated Types if needed.

Parameters
[in]varThe variable to evaluate.
[out]var_locationThe variable location value to fill in
[out]found_typeThe type of the found value, as it was found in the user process. This is only useful when the variable is being inspected on behalf of the parser, hence the default.
[out]parser_typeThe type of the found value, as it was copied into the parser's AST context. This is only useful when the variable is being inspected on behalf of the parser, hence the default.
Returns
Return true if the value was successfully filled in.

Definition at line 1468 of file ClangExpressionDeclMap.cpp.

References lldb_private::Status::AsCString(), lldb_private::CompilerType::TypeSystemSPWrapper::dyn_cast_or_null(), lldb_private::Expressions, lldb_private::Value::FileAddress, lldb_private::DataExtractor::GetByteSize(), lldb_private::Value::GetContextType(), lldb_private::DataExtractor::GetDataStart(), lldb_private::DWARFExpressionList::GetExpressionData(), lldb_private::Type::GetForwardCompilerType(), lldb_private::Type::GetFullCompilerType(), lldb_private::Address::GetLoadAddress(), lldb_private::GetLog(), lldb_private::Value::GetScalar(), lldb_private::CompilerType::GetTypeSystem(), lldb_private::Value::GetValueType(), lldb_private::ClangASTSource::GuardedCopyType(), lldb_private::Value::HostAddress, lldb_private::Value::Invalid, LLDB_INVALID_ADDRESS, LLDB_LOG, lldb_private::Value::LoadAddress, m_parser_vars, lldb_private::SymbolContext::module_sp, lldb_private::Value::SetCompilerType(), lldb_private::Value::SetValueType(), and lldb_private::Scalar::ULongLong().

Referenced by AddOneVariable().

◆ InstallCodeGenerator()

void ClangExpressionDeclMap::InstallCodeGenerator ( clang::ASTConsumer *  code_gen)

◆ InstallDiagnosticManager()

void ClangExpressionDeclMap::InstallDiagnosticManager ( DiagnosticManager diag_manager)

◆ LookupFunction()

void ClangExpressionDeclMap::LookupFunction ( NameSearchContext context,
lldb::ModuleSP  module_sp,
ConstString  name,
const CompilerDeclContext namespace_decl 
)
private

◆ LookupInModulesDeclVendor()

void ClangExpressionDeclMap::LookupInModulesDeclVendor ( NameSearchContext context,
ConstString  name 
)
private

◆ LookUpLldbClass()

void ClangExpressionDeclMap::LookUpLldbClass ( NameSearchContext context)
private

◆ LookUpLldbObjCClass()

void ClangExpressionDeclMap::LookUpLldbObjCClass ( NameSearchContext context)
private

◆ LookupLocalVariable()

bool ClangExpressionDeclMap::LookupLocalVariable ( NameSearchContext context,
ConstString  name,
SymbolContext sym_ctx,
const CompilerDeclContext namespace_decl 
)
private

Looks up a local variable.

Parameters
[in]contextThe NameSearchContext that can construct Decls for this name.
[in]nameThe name of the entities that need to be found.
[in]sym_ctxThe current SymbolContext of this frame.
[in]namespace_declThe parent namespace if there is one.
Returns
True iff a local variable was found.

Definition at line 1057 of file ClangExpressionDeclMap.cpp.

References AddOneVariable(), lldb_private::SymbolContext::block, lldb_private::ValueObjectVariable::Create(), lldb_private::CompilerDeclContext::FindDeclByName(), lldb_private::Block::GetDeclContext(), lldb_private::StackFrame::GetInScopeVariableList(), lldb_private::ClangExpressionUtil::GetLambdaValueObject(), lldb_private::CompilerDeclContext::IsValid(), lldb_private::NameSearchContext::m_found_variable, and m_parser_vars.

Referenced by FindExternalVisibleDecls().

◆ LookupLocalVarNamespace()

void ClangExpressionDeclMap::LookupLocalVarNamespace ( SymbolContext sym_ctx,
NameSearchContext name_context 
)
private

◆ MaybeRegisterFunctionBody()

void ClangExpressionDeclMap::MaybeRegisterFunctionBody ( clang::FunctionDecl *  copied_function_decl)
private

Should be called on all copied functions.

Definition at line 727 of file ClangExpressionDeclMap.cpp.

References m_parser_vars.

Referenced by LookupInModulesDeclVendor(), and SearchPersistenDecls().

◆ SearchFunctionsInSymbolContexts()

SymbolContextList ClangExpressionDeclMap::SearchFunctionsInSymbolContexts ( const SymbolContextList sc_list,
const CompilerDeclContext frame_decl_context 
)
private

Searches for functions in the given SymbolContextList.

Parameters
[in]sc_listThe SymbolContextList to search.
[in]frame_decl_contextThe current DeclContext of the current frame.
Returns
A SymbolContextList with any found functions in the front and any unknown SymbolContexts which are not functions in the back. The SymbolContexts for the functions are ordered by how close they are to the DeclContext for the given frame DeclContext.

Definition at line 1136 of file ClangExpressionDeclMap.cpp.

References lldb_private::SymbolContextList::Append(), lldb_private::TypeSystemClang::CountDeclLevels(), lldb_private::Function::GetDeclContext(), lldb_private::Type::GetFullCompilerType(), lldb_private::Function::GetName(), lldb_private::CompilerDeclContext::GetOpaqueDeclContext(), lldb_private::SymbolContextList::GetSize(), lldb_private::Function::GetType(), lldb_private::CompilerDeclContext::GetTypeSystem(), lldb_private::ClangASTSource::GuardedCopyType(), lldb_private::CompilerDeclContext::IsClassMethod(), and LLDB_INVALID_DECL_LEVEL.

Referenced by LookupFunction().

◆ SearchPersistenDecls()

void ClangExpressionDeclMap::SearchPersistenDecls ( NameSearchContext context,
const ConstString  name 
)
private

Searches the persistent decls of the target for entities with the given name.

Parameters
[in]contextThe NameSearchContext that can construct Decls for this name.
[in]nameThe name of the entities that need to be found.

Definition at line 749 of file ClangExpressionDeclMap.cpp.

References lldb_private::NameSearchContext::AddNamedDecl(), lldb_private::ClangASTSource::CopyDecl(), lldb_private::Expressions, lldb_private::GetLog(), GetPersistentDecl(), LLDB_LOG, and MaybeRegisterFunctionBody().

Referenced by FindExternalVisibleDecls().

◆ WillParse()

bool ClangExpressionDeclMap::WillParse ( ExecutionContext exe_ctx,
Materializer materializer 
)

Enable the state needed for parsing and IR transformation.

Parameters
[in]exe_ctxThe execution context to use when finding types for variables. Also used to find a "scratch" AST context to store result types.
[in]materializerIf non-NULL, the materializer to populate with information about the variables to use
Returns
True if parsing is possible; false if it is unsafe to continue.

Definition at line 107 of file ClangExpressionDeclMap.cpp.

References lldb::eLanguageTypeC, EnableParserVars(), lldb_private::ScratchTypeSystemClang::GetForTarget(), lldb_private::ExecutionContext::GetFramePtr(), lldb_private::Target::GetPersistentExpressionStateForLanguage(), lldb_private::ExecutionContext::GetProcessPtr(), lldb_private::Thread::GetStackFrameAtIndex(), lldb_private::StackFrame::GetSymbolContext(), GetTargetInfo(), lldb_private::ExecutionContext::GetTargetPtr(), lldb_private::ExecutionContext::GetTargetSP(), lldb_private::ExecutionContext::GetThreadPtr(), and m_parser_vars.

Referenced by lldb_private::ClangUserExpression::Complete(), and lldb_private::ClangUserExpression::TryParse().

Member Data Documentation

◆ m_ctx_obj

ValueObject* lldb_private::ClangExpressionDeclMap::m_ctx_obj
private

If not empty, then expression is evaluated in context of this object.

For details see the comment to UserExpression::Evaluate.

Definition at line 304 of file ClangExpressionDeclMap.h.

Referenced by LookUpLldbClass(), and LookUpLldbObjCClass().

◆ m_found_entities

ExpressionVariableList lldb_private::ClangExpressionDeclMap::m_found_entities
private

◆ m_keep_result_in_memory

bool lldb_private::ClangExpressionDeclMap::m_keep_result_in_memory
private

True if result persistent variables generated by this expression should stay in memory.

Definition at line 298 of file ClangExpressionDeclMap.h.

Referenced by AddPersistentVariable().

◆ m_parser_vars

std::unique_ptr<ParserVars> lldb_private::ClangExpressionDeclMap::m_parser_vars
private

◆ m_result_delegate

Materializer::PersistentVariableDelegate* lldb_private::ClangExpressionDeclMap::m_result_delegate
private

If non-NULL, used to report expression results to ClangUserExpression.

Definition at line 302 of file ClangExpressionDeclMap.h.

Referenced by AddPersistentVariable().

◆ m_struct_members

ExpressionVariableList lldb_private::ClangExpressionDeclMap::m_struct_members
private

All entities that need to be placed in the struct.

Definition at line 297 of file ClangExpressionDeclMap.h.

Referenced by AddValueToStruct(), GetStructElement(), and GetStructInfo().

◆ m_struct_vars

std::unique_ptr<StructVars> lldb_private::ClangExpressionDeclMap::m_struct_vars
private

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