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]
Collaboration diagram for lldb_private::ClangExpressionDeclMap:
Collaboration 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. More...
 
 ~ClangExpressionDeclMap () override
 Destructor. More...
 
bool WillParse (ExecutionContext &exe_ctx, Materializer *materializer)
 Enable the state needed for parsing and IR transformation. More...
 
void InstallCodeGenerator (clang::ASTConsumer *code_gen)
 
void DidParse ()
 Disable the state needed for parsing and IR transformation. More...
 
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. More...
 
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. More...
 
bool DoStructLayout ()
 [Used by IRForTarget] Finalize the struct, laying out the position of each object in it. More...
 
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. More...
 
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. More...
 
bool GetFunctionInfo (const clang::NamedDecl *decl, uint64_t &ptr)
 [Used by IRForTarget] Get information about a function given its Decl. More...
 
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. More...
 
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. More...
 
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. More...
 
- Public Member Functions inherited from lldb_private::ClangASTSource
 ClangASTSource (const lldb::TargetSP &target, const std::shared_ptr< ClangASTImporter > &importer)
 Constructor. More...
 
 ~ClangASTSource () override
 Destructor. More...
 
clang::Decl * GetExternalDecl (uint32_t) override
 Interface stubs. More...
 
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. More...
 
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. More...
 
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. More...
 
void CompleteType (clang::TagDecl *Tag) override
 Complete a TagDecl. More...
 
void CompleteType (clang::ObjCInterfaceDecl *Class) override
 Complete an ObjCInterfaceDecl. More...
 
void StartTranslationUnit (clang::ASTConsumer *Consumer) override
 Called on entering a translation unit. More...
 
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. More...
 
clang::NamespaceDecl * AddNamespace (NameSearchContext &context, ClangASTImporter::NamespaceMapSP &namespace_decls)
 
clang::Sema * getSema ()
 
void SetImportInProgress (bool import_in_progress)
 
bool GetImportInProgress ()
 
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. More...
 
clang::Decl * CopyDecl (clang::Decl *src_decl)
 Copies a single Decl into the parser's AST context. More...
 
ClangASTImporter::DeclOrigin GetDeclOrigin (const clang::Decl *decl)
 Determined the origin of a single Decl, if it can be found. More...
 
TypeSystemClangGetTypeSystem () const
 Returns the TypeSystem that uses this ClangASTSource instance as it's ExternalASTSource. More...
 
- Public Member Functions inherited from lldb_private::ClangASTImporter::MapCompleter
virtual ~MapCompleter ()
 

Protected Member Functions

virtual clang::NamedDecl * GetPersistentDecl (ConstString name)
 Retrieves the declaration with the given name from the storage of persistent declarations. More...
 
- 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. More...
 
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. More...
 
void FindObjCMethodDecls (NameSearchContext &context)
 Find all Objective-C methods matching a given selector. More...
 
void FindObjCPropertyAndIvarDecls (NameSearchContext &context)
 Find all Objective-C properties and ivars with a given name. More...
 
void LookupInNamespace (NameSearchContext &context)
 Performs lookup into a namespace. More...
 
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. More...
 
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. More...
 

Private Member Functions

void EnableParserVars ()
 Activate parser-specific variables. More...
 
void DisableParserVars ()
 Deallocate parser-specific variables. More...
 
void EnableStructVars ()
 Activate struct variables. More...
 
void DisableStructVars ()
 Deallocate struct variables. More...
 
uint64_t GetParserID ()
 Get this parser's ID for use in extracting parser- and JIT-specific data from persistent variables. More...
 
void MaybeRegisterFunctionBody (clang::FunctionDecl *copied_function_decl)
 Should be called on all copied functions. More...
 
void SearchPersistenDecls (NameSearchContext &context, const ConstString name)
 Searches the persistent decls of the target for entities with the given name. More...
 
void LookUpLldbClass (NameSearchContext &context)
 Handles looking up $__lldb_class which requires special treatment. More...
 
void LookUpLldbObjCClass (NameSearchContext &context)
 Handles looking up $__lldb_objc_class which requires special treatment. More...
 
void LookupLocalVarNamespace (SymbolContext &sym_ctx, NameSearchContext &name_context)
 Handles looking up the synthetic namespace that contains our local variables for the current frame. More...
 
void LookupInModulesDeclVendor (NameSearchContext &context, ConstString name)
 Lookup entities in the ClangModulesDeclVendor. More...
 
bool LookupLocalVariable (NameSearchContext &context, ConstString name, SymbolContext &sym_ctx, const CompilerDeclContext &namespace_decl)
 Looks up a local variable. More...
 
SymbolContextList SearchFunctionsInSymbolContexts (const SymbolContextList &sc_list, const CompilerDeclContext &frame_decl_context)
 Searches for functions in the given SymbolContextList. More...
 
void LookupFunction (NameSearchContext &context, lldb::ModuleSP module_sp, ConstString name, const CompilerDeclContext &namespace_decl)
 Looks up a function. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
void AddOneFunction (NameSearchContext &context, Function *fun, Symbol *sym)
 Use the NameSearchContext to generate a Decl for the given function. More...
 
void AddOneRegister (NameSearchContext &context, const RegisterInfo *reg_info)
 Use the NameSearchContext to generate a Decl for the given register. More...
 
void AddOneType (NameSearchContext &context, const TypeFromUser &type)
 Use the NameSearchContext to generate a Decl for the given type. More...
 
void AddThisType (NameSearchContext &context, const TypeFromUser &type)
 Generate a Decl for "*this" and add a member function declaration to it for the expression, then report it. More...
 
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. More...
 
TypeSystemClangGetTypeSystemClang ()
 

Private Attributes

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

Additional Inherited Members

- Protected Attributes inherited from lldb_private::ClangASTSource
bool m_import_in_progress
 
bool m_lookups_enabled
 
const lldb::TargetSP m_target
 The target to use in finding variables and types. More...
 
clang::ASTContext * m_ast_context
 The AST context requests are coming in for. More...
 
TypeSystemClangm_clang_ast_context
 The TypeSystemClang for m_ast_context. More...
 
clang::FileManager * m_file_manager
 The file manager paired with the AST context. More...
 
std::shared_ptr< ClangASTImporterm_ast_importer_sp
 The target's AST importer. More...
 
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 has executed, placing the new values back where it found the old ones.

Definition at line 56 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 65 of file ClangExpressionDeclMap.cpp.

References EnableStructVars().

◆ ~ClangExpressionDeclMap()

ClangExpressionDeclMap::~ClangExpressionDeclMap ( )
override

Destructor.

Definition at line 77 of file ClangExpressionDeclMap.cpp.

References DidParse(), and DisableStructVars().

Member Function Documentation

◆ 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 1708 of file ClangExpressionDeclMap.cpp.

References lldb_private::NameSearchContext::AddFunDecl(), lldb_private::NameSearchContext::AddGenericFunDecl(), lldb_private::NameSearchContext::AddNamedDecl(), lldb_private::ExpressionVariableList::AddNewlyConstructedVariable(), lldb_private::ClangASTSource::CopyDecl(), lldb_private::Address::Dump(), lldb_private::ClangUtil::DumpDecl(), lldb_private::Address::DumpStyleResolvedDescription, lldb_private::ClangExpressionVariable::EnableParserVars(), lldb_private::Value::eValueTypeFileAddress, lldb_private::Value::eValueTypeLoadAddress, lldb_private::Symbol::GetAddress(), lldb_private::Address::GetCallableLoadAddress(), lldb_private::StreamString::GetData(), lldb_private::Address::GetFileAddress(), lldb_private::Type::GetFullCompilerType(), lldb_private::UserID::GetID(), lldb_private::GetLogIfAllCategoriesSet(), lldb_private::Type::GetName(), GetParserID(), lldb_private::ClangExpressionVariable::GetParserVars(), lldb_private::Value::GetScalar(), lldb_private::ClangASTSource::GuardedCopyType(), lldb_private::CPlusPlusLanguage::IsCPPMangledName(), lldb_private::Symbol::IsIndirect(), lldb_private::Language::LanguageIsC(), lldb_private::Language::LanguageIsCPlusPlus(), lldb_private::Language::LanguageIsObjC(), LIBLLDB_LOG_EXPRESSIONS, LLDB_INVALID_ADDRESS, LLDB_LOG, 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, lldb_private::ExpressionVariable::SetCompilerType(), lldb_private::ExpressionVariable::SetName(), and lldb_private::Value::SetValueType().

Referenced by GetParserID(), and 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 1946 of file ClangExpressionDeclMap.cpp.

References lldb_private::NameSearchContext::AddTypeDecl(), lldb_private::GetLogIfAllCategoriesSet(), lldb_private::ClangASTSource::GuardedCopyType(), LIBLLDB_LOG_EXPRESSIONS, and LLDB_LOG.

Referenced by GetParserID(), and LookUpLldbObjCClass().

◆ AddOneVariable() [1/2]

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

Use the NameSearchContext to generate a Decl for the given LLDB Variable, and put it in the Tuple list.

Parameters
[in]contextThe NameSearchContext to use when constructing the Decl.
[in]varThe LLDB Variable that needs a Decl.
[in]valobjThe LLDB ValueObject for that variable.

Referenced by FindExternalVisibleDecls(), GetParserID(), GetVariableValue(), and LookupLocalVariable().

◆ AddOneVariable() [2/2]

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

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

Parameters
[in]contextThe NameSearchContext to use when constructing the Decl.
[in]pvar_spThe persistent variable that needs a Decl.

◆ AddPersistentVariable()

bool ClangExpressionDeclMap::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.

Parameters
[in]declThe Clang declaration for the persistent variable, used for lookup during parsing.
[in]nameThe name of the persistent variable, usually $something.
[in]typeThe type of the variable, in the Clang parser's context.
Returns
True on success; false otherwise.

Definition at line 187 of file ClangExpressionDeclMap.cpp.

References lldb_private::ExpressionVariableList::AddNewlyConstructedVariable(), DeportType(), lldb_private::ClangExpressionVariable::EnableJITVars(), lldb_private::ClangExpressionVariable::EnableParserVars(), lldb_private::ExpressionVariable::EVIsLLDBAllocated, lldb_private::ExpressionVariable::EVIsProgramReference, lldb_private::ExpressionVariable::EVKeepInTarget, lldb_private::ExpressionVariable::EVNeedsAllocation, lldb_private::ExpressionVariable::EVNeedsFreezeDry, lldb_private::ExecutionContext::GetBestExecutionContextScope(), lldb_private::ClangExpressionVariable::GetJITVars(), lldb_private::GetLogIfAllCategoriesSet(), lldb_private::CompilerType::GetOpaqueQualType(), GetParserID(), lldb_private::ClangExpressionVariable::GetParserVars(), lldb_private::TypeSystemClang::GetScratch(), lldb_private::ExecutionContext::GetTargetPtr(), LIBLLDB_LOG_EXPRESSIONS, LLDB_LOG, lldb_private::ExpressionVariable::m_flags, m_found_entities, lldb_private::ExpressionVariable::m_frozen_sp, m_keep_result_in_memory, lldb_private::ClangExpressionVariable::ParserVars::m_named_decl, lldb_private::ClangExpressionVariable::JITVars::m_offset, m_parser_vars, and m_result_delegate.

Referenced by IRForTarget::CreateResultVariable(), and IRForTarget::RewritePersistentAlloc().

◆ AddThisType()

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

◆ AddValueToStruct()

bool ClangExpressionDeclMap::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.

Parameters
[in]declThe Clang declaration for the variable.
[in]nameThe name of the variable.
[in]valueThe LLVM IR value for this variable.
[in]sizeThe size of the variable in bytes.
[in]alignmentThe required alignment of the variable in bytes.
Returns
True on success; false otherwise.

Definition at line 306 of file ClangExpressionDeclMap.cpp.

References lldb_private::ExpressionVariableList::AddVariable(), lldb_private::ClangExpressionVariable::FindVariableInList(), lldb_private::GetLogIfAllCategoriesSet(), lldb_private::ExpressionVariable::GetName(), GetParserID(), lldb_private::ExpressionVariable::GetRegisterInfo(), LIBLLDB_LOG_EXPRESSIONS, LLDB_LOG, lldb_private::ClangExpressionVariable::JITVars::m_alignment, m_found_entities, lldb_private::ClangExpressionVariable::ParserVars::m_llvm_value, m_parser_vars, m_struct_members, m_struct_vars, and lldb_private::Status::Success().

Referenced by IRForTarget::MaybeHandleVariable().

◆ 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 177 of file ClangExpressionDeclMap.cpp.

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

Referenced by AddPersistentVariable(), and GetParserID().

◆ DidParse()

void ClangExpressionDeclMap::DidParse ( )

◆ DisableParserVars()

void lldb_private::ClangExpressionDeclMap::DisableParserVars ( )
inlineprivate

Deallocate parser-specific variables.

Definition at line 346 of file ClangExpressionDeclMap.h.

Referenced by DidParse().

◆ DisableStructVars()

void lldb_private::ClangExpressionDeclMap::DisableStructVars ( )
inlineprivate

Deallocate struct variables.

Definition at line 376 of file ClangExpressionDeclMap.h.

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 394 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 340 of file ClangExpressionDeclMap.h.

Referenced by GetVariableValue(), and WillParse().

◆ EnableStructVars()

void lldb_private::ClangExpressionDeclMap::EnableStructVars ( )
inlineprivate

Activate struct variables.

Definition at line 370 of file ClangExpressionDeclMap.h.

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 592 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(), and GetParserID().

◆ 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 461 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

◆ 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 704 of file ClangExpressionDeclMap.cpp.

References lldb_private::TypeSystemClang::GetScratch(), and m_parser_vars.

Referenced by lldb_private::ClangExpressionDeclMap::TargetInfo::IsValid(), and SearchPersistenDecls().

◆ 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 425 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, 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 411 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 ( 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 480 of file ClangExpressionDeclMap.cpp.

References lldb_private::ConstString::Clear(), 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::Symbol::GetAddress(), lldb_private::Address::GetCallableLoadAddress(), lldb_private::SymbolContextList::GetContextAtIndex(), lldb_private::FileSpec::GetDirectory(), lldb_private::Target::GetImages(), lldb_private::Address::GetLoadAddress(), lldb_private::ModuleSpec::GetPlatformFileSpec(), lldb_private::Symbol::GetReExportedSymbolName(), lldb_private::Symbol::GetReExportedSymbolSharedLibrary(), lldb_private::SymbolContextList::GetSize(), lldb_private::Symbol::GetType(), lldb_private::Address::IsValid(), LLDB_INVALID_ADDRESS, lldb_private::LanguageRuntime::LookupRuntimeSymbol(), and lldb_private::SymbolContext::symbol.

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

◆ GetSymbolAddress() [2/2]

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

Definition at line 580 of file ClangExpressionDeclMap.cpp.

References GetSymbolAddress(), and m_parser_vars.

◆ 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 1444 of file ClangExpressionDeclMap.cpp.

References lldb_private::ExpressionVariableList::AddNewlyConstructedVariable(), AddOneVariable(), lldb_private::NameSearchContext::AddVarDecl(), lldb_private::Status::AsCString(), lldb_private::ClangASTSource::CompleteType(), lldb_private::ClangUtil::DumpDecl(), lldb_private::Value::eContextTypeInvalid, EnableParserVars(), lldb_private::Value::eValueTypeFileAddress, lldb_private::Value::eValueTypeHostAddress, lldb_private::Value::eValueTypeLoadAddress, lldb_private::ExpressionVariable::EVTypeIsReference, lldb_private::DataExtractor::GetByteSize(), lldb_private::Value::GetContextType(), lldb_private::DataExtractor::GetDataStart(), lldb_private::DWARFExpression::GetExpressionData(), lldb_private::Type::GetForwardCompilerType(), lldb_private::Type::GetFullCompilerType(), lldb_private::Address::GetLoadAddress(), lldb_private::GetLogIfAllCategoriesSet(), GetParserID(), lldb_private::Value::GetScalar(), lldb_private::CompilerType::GetTypeSystem(), lldb_private::Value::GetValueType(), lldb_private::ClangASTSource::GuardedCopyType(), LIBLLDB_LOG_EXPRESSIONS, LLDB_INVALID_ADDRESS, LLDB_LOG, lldb_private::NameSearchContext::m_decl_name, m_found_entities, lldb_private::ClangExpressionVariable::ParserVars::m_lldb_value, lldb_private::ClangExpressionVariable::ParserVars::m_lldb_var, lldb_private::ClangExpressionVariable::ParserVars::m_llvm_value, lldb_private::ClangExpressionVariable::ParserVars::m_named_decl, m_parser_vars, lldb_private::SymbolContext::module_sp, lldb_private::Value::SetCompilerType(), lldb_private::Value::SetValueType(), lldb_private::ClangUtil::ToString(), and lldb_private::Scalar::ULongLong().

Referenced by GetParserID().

◆ InstallCodeGenerator()

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

◆ 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 1050 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::CompilerDeclContext::IsValid(), lldb_private::NameSearchContext::m_found_variable, and m_parser_vars.

Referenced by FindExternalVisibleDecls(), and GetParserID().

◆ LookupLocalVarNamespace()

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

Handles looking up the synthetic namespace that contains our local variables for the current frame.

Parameters
[in]sym_ctxThe current SymbolContext of this frame.
[in]name_contextThe NameSearchContext that can construct Decls for this name.

Definition at line 978 of file ClangExpressionDeclMap.cpp.

References lldb_private::NameSearchContext::AddNamedDecl(), lldb_private::SymbolContext::block, lldb_private::Block::GetDeclContext(), lldb_private::CompilerDeclContext::GetTypeSystem(), lldb_private::TypeSystemClang::GetUniqueNamespaceDeclaration(), lldb_private::ClangASTSource::m_clang_ast_context, and lldb_private::NameSearchContext::m_found_local_vars_nsp.

Referenced by FindExternalVisibleDecls(), and GetParserID().

◆ MaybeRegisterFunctionBody()

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

Should be called on all copied functions.

Definition at line 696 of file ClangExpressionDeclMap.cpp.

References m_parser_vars.

Referenced by GetParserID(), 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 1105 of file ClangExpressionDeclMap.cpp.

References lldb_private::SymbolContextList::Append(), lldb_private::TypeSystemClang::CountDeclLevels(), lldb_private::SymbolContext::function, lldb_private::SymbolContextList::GetContextAtIndex(), lldb_private::CompilerDeclContext::GetOpaqueDeclContext(), lldb_private::SymbolContextList::GetSize(), lldb_private::CompilerDeclContext::GetTypeSystem(), lldb_private::ClangASTSource::GuardedCopyType(), lldb_private::CompilerDeclContext::IsClassMethod(), and LLDB_INVALID_DECL_LEVEL.

Referenced by GetParserID(), and 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 718 of file ClangExpressionDeclMap.cpp.

References lldb_private::NameSearchContext::AddNamedDecl(), lldb_private::ClangASTSource::CopyDecl(), lldb_private::GetLogIfAllCategoriesSet(), GetPersistentDecl(), LIBLLDB_LOG_EXPRESSIONS, LLDB_LOG, and MaybeRegisterFunctionBody().

Referenced by FindExternalVisibleDecls(), and GetParserID().

◆ 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 86 of file ClangExpressionDeclMap.cpp.

References lldb::eLanguageTypeC, EnableParserVars(), lldb_private::ExecutionContext::GetFramePtr(), lldb_private::Target::GetPersistentExpressionStateForLanguage(), lldb_private::ExecutionContext::GetProcessPtr(), lldb_private::TypeSystemClang::GetScratch(), 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::Parse().

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 301 of file ClangExpressionDeclMap.h.

Referenced by LookUpLldbClass(), and LookUpLldbObjCClass().

◆ m_found_entities

ExpressionVariableList lldb_private::ClangExpressionDeclMap::m_found_entities
private

All entities that were looked up for the parser.

Definition at line 292 of file ClangExpressionDeclMap.h.

Referenced by AddOneFunction(), AddOneGenericVariable(), AddOneRegister(), AddPersistentVariable(), AddValueToStruct(), DidParse(), GetFunctionInfo(), and GetVariableValue().

◆ 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 295 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 299 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 294 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: