52#include "clang/AST/ASTConsumer.h"
53#include "clang/AST/ASTContext.h"
54#include "clang/AST/ASTImporter.h"
55#include "clang/AST/Decl.h"
56#include "clang/AST/DeclarationName.h"
57#include "clang/AST/RecursiveASTVisitor.h"
79 if (
auto thisThisValSP = thisValSP->GetChildMemberWithName(
"this"))
87 bool keep_result_in_memory,
90 const std::shared_ptr<ClangASTImporter> &importer,
ValueObject *ctx_obj)
91 :
ClangASTSource(target, importer), m_found_entities(), m_struct_members(),
92 m_keep_result_in_memory(keep_result_in_memory),
93 m_result_delegate(result_delegate), m_ctx_obj(ctx_obj), m_parser_vars(),
120 lldb::eSymbolContextEverything);
130 m_parser_vars->m_persistent_vars = llvm::cast<ClangPersistentVariables>(
144 clang::ASTConsumer *code_gen) {
158 entity_index < num_entities; ++entity_index) {
162 llvm::cast<ClangExpressionVariable>(var_sp.get())
166 for (
size_t pvar_index = 0,
168 pvar_index < num_pvars; ++pvar_index) {
170 m_parser_vars->m_persistent_vars->GetVariableAtIndex(pvar_index));
172 llvm::dyn_cast<ClangExpressionVariable>(pvar_sp.get()))
209 parser_type.GetTypeSystem().GetSharedPointer().get());
221 auto ast = parser_type.GetTypeSystem().dyn_cast_or_null<
TypeSystemClang>();
228 std::string msg = llvm::formatv(
"redefinition of persistent variable '{0}'",
241 if (target ==
nullptr)
245 if (!clang_ast_context)
250 uint32_t offset =
m_parser_vars->m_materializer->AddResultVariable(
279 if (target ==
nullptr)
289 LLDB_LOG(log,
"Persistent variable's type wasn't copied successfully");
301 ->CreatePersistentVariable(
310 var->m_frozen_sp->SetHasCompleteType();
313 var->m_flags |= ClangExpressionVariable::EVNeedsFreezeDry;
316 ClangExpressionVariable::EVKeepInTarget;
321 var->m_flags |= ClangExpressionVariable::EVIsProgramReference;
323 var->m_flags |= ClangExpressionVariable::EVIsLLDBAllocated;
324 var->m_flags |= ClangExpressionVariable::EVNeedsAllocation;
328 var->m_flags |= ClangExpressionVariable::EVKeepInTarget;
331 LLDB_LOG(log,
"Created persistent variable with flags {0:x}", var->m_flags);
345 llvm::Value *value,
size_t size,
350 bool is_persistent_variable =
false;
366 is_persistent_variable =
true;
372 LLDB_LOG(log,
"Adding value for (NamedDecl*){0} [{1} - {2}] to the structure",
373 decl, name, var->GetName());
379 llvm::cast<ClangExpressionVariable>(var)->GetParserVars(
GetParserID());
384 llvm::cast<ClangExpressionVariable>(var)->GetJITVars(
GetParserID())) {
387 LLDB_LOG(log,
"Already placed at {0:x}", jit_vars->m_offset);
390 llvm::cast<ClangExpressionVariable>(var)->EnableJITVars(
GetParserID());
393 llvm::cast<ClangExpressionVariable>(var)->GetJITVars(
GetParserID());
405 if (is_persistent_variable) {
407 offset =
m_parser_vars->m_materializer->AddPersistentVariable(
408 var_sp,
nullptr, err);
411 offset =
m_parser_vars->m_materializer->AddSymbol(*sym, err);
412 else if (
const RegisterInfo *reg_info = var->GetRegisterInfo())
413 offset =
m_parser_vars->m_materializer->AddRegister(*reg_info, err);
426 LLDB_LOG(log,
"Placed at {0:x}", offset);
485 llvm::cast<ClangExpressionVariable>(member_sp.get())
488 llvm::cast<ClangExpressionVariable>(member_sp.get())
491 if (!parser_vars || !jit_vars || !member_sp->GetValueObject())
497 name = member_sp->GetName();
539 const Address sym_address = sym_ctx.symbol->GetAddress();
544 switch (sym_ctx.symbol->GetType()) {
555 ConstString reexport_name = sym_ctx.symbol->GetReExportedSymbolName();
560 sym_ctx.symbol->GetReExportedSymbolSharedLibrary();
564 if (!reexport_module_sp) {
571 target, process, sym_ctx.symbol->GetReExportedSymbolName(),
572 symbol_type, reexport_module_sp.get());
614 return symbol_load_addr;
634 if (module && namespace_decl)
635 module->FindGlobalVariables(name, namespace_decl, -1, vars);
646 if (frame ==
nullptr)
650 lldb::eSymbolContextBlock);
651 if (sym_ctx.
block ==
nullptr)
655 if (!frame_decl_context)
658 return llvm::dyn_cast_or_null<TypeSystemClang>(
675 "ClangExpressionDeclMap::FindExternalVisibleDecls for "
676 "'{0}' in a NULL DeclContext",
678 else if (
const NamedDecl *context_named_decl =
681 "ClangExpressionDeclMap::FindExternalVisibleDecls for "
683 name, context_named_decl->getNameAsString());
686 "ClangExpressionDeclMap::FindExternalVisibleDecls for "
691 if (
const NamespaceDecl *namespace_context =
693 if (namespace_context->getName().str() ==
708 LLDB_LOGV(log,
" CEDM::FEVD Inspecting (NamespaceMap*){0:x} ({1} entries)",
709 namespace_map.get(), namespace_map->size());
712 LLDB_LOG(log,
" CEDM::FEVD Searching namespace {0} in module {1}",
713 n.second.GetName(), n.first->GetFileSpec().GetFilename());
720 LLDB_LOG(log,
" CEDM::FEVD Searching the root namespace");
729 FunctionDecl *copied_function_decl) {
730 if (copied_function_decl->getBody() &&
m_parser_vars->m_code_gen) {
731 clang::DeclGroupRef decl_group_ref(copied_function_decl);
732 m_parser_vars->m_code_gen->HandleTopLevelDecl(decl_group_ref);
747 return m_parser_vars->m_persistent_vars->GetPersistentDecl(name);
756 if (!persistent_decl)
759 Decl *parser_persistent_decl =
CopyDecl(persistent_decl);
761 if (!parser_persistent_decl)
764 NamedDecl *parser_named_decl = dyn_cast<NamedDecl>(parser_persistent_decl);
766 if (!parser_named_decl)
769 if (clang::FunctionDecl *parser_function_decl =
770 llvm::dyn_cast<clang::FunctionDecl>(parser_named_decl)) {
774 LLDB_LOG(log,
" CEDM::FEVD Found persistent decl {0}", name);
784 if (frame !=
nullptr)
786 lldb::eSymbolContextBlock);
791 if (!ctx_obj_ptr || status.
Fail())
800 if (frame ==
nullptr)
811 if (!function_decl_ctx)
814 clang::CXXMethodDecl *method_decl =
818 if (
auto capturedThis = GetCapturedThisValueObject(frame)) {
832 " CEDM::FEVD Adding captured type ({0} for"
833 " $__lldb_class: {1}",
834 capturedThis->GetTypeName(), capturedThis->GetName());
840 clang::CXXRecordDecl *class_decl = method_decl->getParent();
842 QualType class_qual_type(class_decl->getTypeForDecl(), 0);
845 class_qual_type.getAsOpaquePtr(),
848 LLDB_LOG(log,
" CEDM::FEVD Adding type for $__lldb_class: {0}",
849 class_qual_type.getAsString());
868 if (this_var && this_var->IsInScope(frame) &&
869 this_var->LocationIsValidForFrame(frame)) {
870 Type *this_type = this_var->GetType();
878 LLDB_LOG(log,
" FEVD Adding type for $__lldb_class: {0}",
893 if (!ctx_obj_ptr || status.
Fail())
906 lldb::eSymbolContextBlock);
916 if (!function_decl_ctx)
919 clang::ObjCMethodDecl *method_decl =
923 ObjCInterfaceDecl *self_interface = method_decl->getClassInterface();
928 const clang::Type *interface_type = self_interface->getTypeForDecl();
935 QualType(interface_type, 0).getAsOpaquePtr(),
938 LLDB_LOG(log,
" FEVD[{0}] Adding type for $__lldb_objc_class: {1}",
956 if (!self_var->IsInScope(frame))
958 if (!self_var->LocationIsValidForFrame(frame))
961 Type *self_type = self_var->GetType();
975 if (!self_clang_type)
978 LLDB_LOG(log,
" FEVD[{0}] Adding type for $__lldb_objc_class: {1}",
988 if (sym_ctx.
block ==
nullptr)
992 if (!frame_decl_context)
1000 clang::NamespaceDecl *namespace_decl =
1003 if (!namespace_decl)
1007 clang::DeclContext *ctxt = clang::Decl::castToDeclContext(namespace_decl);
1008 ctxt->setHasExternalVisibleStorage(
true);
1019 std::shared_ptr<ClangModulesDeclVendor> modules_decl_vendor =
1021 if (!modules_decl_vendor)
1024 bool append =
false;
1025 uint32_t max_matches = 1;
1026 std::vector<clang::NamedDecl *> decls;
1028 if (!modules_decl_vendor->FindDecls(name, append, max_matches, decls))
1031 assert(!decls.empty() &&
"FindDecls returned true but no decls?");
1032 clang::NamedDecl *
const decl_from_modules = decls[0];
1035 " CAS::FEVD Matching decl found for "
1036 "\"{0}\" in the modules",
1039 clang::Decl *copied_decl =
CopyDecl(decl_from_modules);
1041 LLDB_LOG(log,
" CAS::FEVD - Couldn't export a "
1042 "declaration from the modules");
1046 if (
auto copied_function = dyn_cast<clang::FunctionDecl>(copied_decl)) {
1053 }
else if (
auto copied_var = dyn_cast<clang::VarDecl>(copied_decl)) {
1062 if (sym_ctx.
block ==
nullptr)
1073 for (
size_t i = 0; i < vars->GetSize(); i++)
1074 vars->GetVariableAtIndex(i)->GetDecl();
1079 std::vector<CompilerDecl> found_decls =
1083 bool variable_found =
false;
1085 for (
size_t vi = 0, ve = vars->GetSize(); vi != ve; ++vi) {
1086 VariableSP candidate_var = vars->GetVariableAtIndex(vi);
1087 if (candidate_var->GetDecl() == decl) {
1088 var = candidate_var;
1093 if (var && !variable_found) {
1094 variable_found =
true;
1105 if (!variable_found) {
1109 if (
auto capture = lambda->GetChildMemberWithName(varname)) {
1117 if (
auto capture = find_capture(name, frame)) {
1118 variable_found =
true;
1120 AddOneVariable(context, std::move(capture), std::move(find_capture));
1124 return variable_found;
1130struct FuncDeclInfo {
1133 uint32_t m_decl_lvl;
1146 std::vector<FuncDeclInfo> decl_infos;
1147 decl_infos.reserve(sc_list.
GetSize());
1148 clang::DeclContext *frame_decl_ctx =
1158 Function *function = sym_ctx.function;
1160 sc_sym_list.
Append(sym_ctx);
1167 if (!func_decl_context || func_decl_context.
IsClassMethod())
1172 if (!copied_func_type) {
1173 sc_sym_list.
Append(sym_ctx);
1177 fdi.m_sym_ctx = sym_ctx;
1178 fdi.m_name = function->
GetName();
1179 fdi.m_copied_type = copied_func_type;
1181 if (fdi.m_copied_type && func_decl_context) {
1186 clang::DeclContext *func_decl_ctx =
1189 &fdi.m_name, &fdi.m_copied_type);
1191 decl_infos.emplace_back(fdi);
1196 std::multimap<CompilerType, const FuncDeclInfo *> matches;
1197 for (
const FuncDeclInfo &fdi : decl_infos) {
1199 auto q = matches.find(t);
1200 if (q != matches.end()) {
1201 if (q->second->m_decl_lvl > fdi.m_decl_lvl)
1204 else if (q->second->m_decl_lvl < fdi.m_decl_lvl)
1208 matches.insert(std::make_pair(t, &fdi));
1213 for (
const auto &q : matches)
1214 sc_func_list.
Append(q.second->m_sym_ctx);
1217 sc_func_list.
Append(sc_sym_list);
1218 return sc_func_list;
1229 std::vector<clang::NamedDecl *> decls_from_modules;
1232 if (std::shared_ptr<ClangModulesDeclVendor> decl_vendor =
1234 decl_vendor->FindDecls(name,
false,
UINT32_MAX, decls_from_modules);
1239 if (namespace_decl && module_sp) {
1244 module_sp->FindFunctions(name, namespace_decl, eFunctionNameTypeBase,
1245 function_options, sc_list);
1246 }
else if (target && !namespace_decl) {
1255 name, eFunctionNameTypeFull | eFunctionNameTypeBase, function_options,
1272 if (frame !=
nullptr)
1274 lldb::eSymbolContextBlock);
1280 if (frame_decl_context) {
1286 Symbol *extern_symbol =
nullptr;
1287 Symbol *non_extern_symbol =
nullptr;
1290 if (sym_ctx.function) {
1303 }
else if (sym_ctx.symbol) {
1304 Symbol *symbol = sym_ctx.symbol;
1307 if (symbol ==
nullptr)
1312 extern_symbol = symbol;
1314 non_extern_symbol = symbol;
1319 for (clang::NamedDecl *decl : decls_from_modules) {
1320 if (llvm::isa<clang::FunctionDecl>(decl)) {
1321 clang::NamedDecl *copied_decl =
1322 llvm::cast_or_null<FunctionDecl>(
CopyDecl(decl));
1332 if (extern_symbol) {
1335 }
else if (non_extern_symbol) {
1357 Target *target =
nullptr;
1364 if (frame !=
nullptr)
1366 lldb::eSymbolContextBlock);
1369 if (!namespace_decl)
1372 if (name.
GetStringRef().starts_with(
"$") && !namespace_decl) {
1373 if (name ==
"$__lldb_class") {
1378 if (name ==
"$__lldb_objc_class") {
1404 llvm::StringRef reg_name = name.
GetStringRef().substr(1);
1408 m_parser_vars->m_exe_ctx.GetRegisterContext()->GetRegisterInfoByName(
1412 LLDB_LOG(log,
" CEDM::FEVD Found register {0}", reg_info->
name);
1420 bool local_var_lookup = !namespace_decl || (namespace_decl.
GetName() ==
1422 if (frame && local_var_lookup)
1450 const Symbol *data_symbol =
1453 if (!
error.Success()) {
1454 const unsigned diag_id =
1456 clang::DiagnosticsEngine::Level::Error,
"%0");
1461 std::string
warning(
"got name from symbols: ");
1463 const unsigned diag_id =
1465 clang::DiagnosticsEngine::Level::Warning,
"%0");
1479 Type *var_type = var->GetType();
1482 LLDB_LOG(log,
"Skipped a definition because it has no type");
1488 if (!var_clang_type) {
1489 LLDB_LOG(log,
"Skipped a definition because it has no Clang type");
1497 LLDB_LOG(log,
"Skipped a definition because it has no Clang AST");
1506 if (var->GetLocationIsConstantValueData()) {
1522 "Couldn't copy a variable's type into the parser's AST context");
1535 var->CalculateSymbolContext(&var_sc);
1561 clang::QualType parser_opaque_type =
1562 QualType::getFromOpaquePtr(pt.GetOpaqueQualType());
1564 if (parser_opaque_type.isNull())
1567 if (
const clang::Type *parser_type = parser_opaque_type.getTypePtr()) {
1568 if (
const TagType *tag_type = dyn_cast<TagType>(parser_type))
1570 if (
const ObjCObjectPointerType *objc_object_ptr_type =
1571 dyn_cast<ObjCObjectPointerType>(parser_type))
1572 CompleteType(objc_object_ptr_type->getInterfaceDecl());
1575 bool is_reference = pt.IsReferenceType();
1577 NamedDecl *var_decl =
nullptr;
1581 var_decl = context.
AddVarDecl(pt.GetLValueReferenceType());
1583 std::string decl_name(context.
m_decl_name.getAsString());
1596 entity->m_flags |= ClangExpressionVariable::EVTypeIsReference;
1609 Value var_location = valobj->GetValue();
1617 LLDB_LOG(log,
"Skipped a definition because it has no Clang AST");
1625 "Couldn't copy a variable's type into the parser's AST context");
1639 LLDB_LOG(log,
" CEDM::FEVD Found variable {0}, returned\n{1} (original {2})",
1668 LLDB_LOG(log,
" CEDM::FEVD Found variable {0}, returned\n{1} (original {2})",
1682 llvm::cast<ClangExpressionVariable>(pvar_sp.get())->GetTypeFromUser());
1686 if (!parser_type.GetOpaqueQualType()) {
1687 LLDB_LOG(log,
" CEDM::FEVD Couldn't import type for pvar {0}",
1688 pvar_sp->GetName());
1692 NamedDecl *var_decl =
1693 context.
AddVarDecl(parser_type.GetLValueReferenceType());
1695 llvm::cast<ClangExpressionVariable>(pvar_sp.get())
1698 llvm::cast<ClangExpressionVariable>(pvar_sp.get())
1704 LLDB_LOG(log,
" CEDM::FEVD Added pvar {0}, returned\n{1}",
1716 if (target ==
nullptr)
1720 if (!scratch_ast_context)
1725 .GetLValueReferenceType());
1729 NamedDecl *var_decl = context.
AddVarDecl(parser_type);
1731 std::string decl_name(context.
m_decl_name.getAsString());
1734 m_parser_vars->m_exe_ctx.GetBestExecutionContextScope(), entity_name,
1756 LLDB_LOG(log,
" CEDM::FEVD Found variable {0}, returned\n{1}", decl_name,
1769 LLDB_LOG(log,
" Tried to add a type for {0}, but couldn't get one",
1776 NamedDecl *var_decl = context.
AddVarDecl(parser_clang_type);
1784 std::string decl_name(context.
m_decl_name.getAsString());
1786 entity->SetRegisterInfo(reg_info);
1793 entity->m_flags |= ClangExpressionVariable::EVBareRegister;
1795 LLDB_LOG(log,
" CEDM::FEVD Added register {0}, returned\n{1}",
1806 NamedDecl *function_decl =
nullptr;
1810 bool is_indirect_function =
false;
1824 if (llvm::isa<TypeSystemClang>(type_system)) {
1825 clang::DeclContext *src_decl_context =
1828 clang::FunctionDecl *src_function_decl =
1829 llvm::dyn_cast_or_null<clang::FunctionDecl>(src_decl_context);
1830 if (src_function_decl &&
1831 src_function_decl->getTemplateSpecializationInfo()) {
1832 clang::FunctionTemplateDecl *function_template =
1833 src_function_decl->getTemplateSpecializationInfo()->getTemplate();
1834 clang::FunctionTemplateDecl *copied_function_template =
1835 llvm::dyn_cast_or_null<clang::FunctionTemplateDecl>(
1837 if (copied_function_template) {
1844 " CEDM::FEVD Imported decl for function template"
1845 " {0} (description {1}), returned\n{2}",
1846 copied_function_template->getNameAsString(),
1853 }
else if (src_function_decl) {
1854 if (clang::FunctionDecl *copied_function_decl =
1855 llvm::dyn_cast_or_null<clang::FunctionDecl>(
1863 " CEDM::FEVD Imported decl for function {0} "
1864 "(description {1}), returned\n{2}",
1865 copied_function_decl->getNameAsString(), ss.
GetData(),
1872 LLDB_LOG(log,
" Failed to import the function decl for '{0}'",
1873 src_function_decl->getName());
1879 if (!function_type) {
1880 LLDB_LOG(log,
" Skipped a function because it has no type");
1886 if (!function_clang_type) {
1887 LLDB_LOG(log,
" Skipped a function because it has no Clang type");
1894 if (copied_function_type) {
1895 function_decl = context.
AddFunDecl(copied_function_type, extern_c);
1897 if (!function_decl) {
1898 LLDB_LOG(log,
" Failed to create a function decl for '{0}' ({1:x})",
1906 " Failed to import the function type '{0}' ({1:x})"
1907 " into the expression parser AST context",
1912 }
else if (symbol) {
1917 LLDB_LOG(log,
" AddOneFunction called with no function and no symbol");
1932 std::string decl_name(context.
m_decl_name.getAsString());
1934 entity->SetCompilerType(function_clang_type);
1958 fun_address.
Dump(&ss,
1963 " CEDM::FEVD Found {0} function {1} (description {2}), "
1965 (function ?
"specific" :
"generic"), decl_name, ss.
GetData(),
1976 if (!copied_clang_type) {
1978 "ClangExpressionDeclMap::AddThisType - Couldn't import the type");
1990 void_clang_type, &void_ptr_clang_type, 1,
false, 0);
1992 const bool is_virtual =
false;
1993 const bool is_static =
false;
1994 const bool is_inline =
false;
1995 const bool is_explicit =
false;
1996 const bool is_attr_used =
true;
1997 const bool is_artificial =
false;
2002 is_explicit, is_attr_used, is_artificial);
2005 " CEDM::AddThisType Added function $__lldb_expr "
2006 "(description {0}) for this type\n{1}",
2011 if (!copied_clang_type.
IsValid())
2014 TypeSourceInfo *type_source_info =
m_ast_context->getTrivialTypeSourceInfo(
2017 if (!type_source_info)
2024 TypedefDecl *typedef_decl = TypedefDecl::Create(
2026 SourceLocation(), context.
m_decl_name.getAsIdentifierInfo(),
2039 if (!copied_clang_type) {
2043 "ClangExpressionDeclMap::AddOneType - Couldn't import the type");
static const char * g_lldb_local_vars_namespace_cstr
static llvm::raw_ostream & error(Stream &strm)
static llvm::raw_ostream & warning(Stream &strm)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOGV(log,...)
#define LLDB_INVALID_DECL_LEVEL
Address & GetBaseAddress()
Get accessor for the base address of the range.
A section + offset based address class.
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
lldb::addr_t GetCallableLoadAddress(Target *target, bool is_indirect=false) const
Get the load address as a callable code load address.
@ DumpStyleResolvedDescription
Display the details about what an address resolves to.
bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, DumpStyle fallback_style=DumpStyleInvalid, uint32_t addr_byte_size=UINT32_MAX, bool all_ranges=false, std::optional< Stream::HighlightSettings > settings=std::nullopt) const
Dump a description of this object to a Stream.
lldb::addr_t GetFileAddress() const
Get the file address.
bool IsValid() const
Check if the object state is valid.
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
lldb::ByteOrder GetByteOrder() const
Returns the byte order for the architecture specification.
A class that describes a single lexical block.
CompilerDeclContext GetDeclContext()
static bool IsCPPMangledName(llvm::StringRef name)
std::shared_ptr< NamespaceMap > NamespaceMapSP
std::pair< lldb::ModuleSP, CompilerDeclContext > NamespaceMapItem
Provider for named objects defined in the debug info for Clang.
clang::ASTContext * m_ast_context
The AST context requests are coming in for.
clang::Decl * CopyDecl(clang::Decl *src_decl)
Copies a single Decl into the parser's AST context.
bool IgnoreName(const ConstString name, bool ignore_all_dollar_names)
Returns true if a name should be ignored by name lookup.
virtual void FindExternalVisibleDecls(NameSearchContext &context)
The worker function for FindExternalVisibleDeclsByName.
std::shared_ptr< ClangModulesDeclVendor > GetClangModulesDeclVendor()
void CompleteType(clang::TagDecl *Tag) override
Complete a TagDecl.
CompilerType GuardedCopyType(const CompilerType &src_type)
A wrapper for TypeSystemClang::CopyType that sets a flag that indicates that we should not respond to...
std::shared_ptr< ClangASTImporter > m_ast_importer_sp
The target's AST importer.
TypeSystemClang * m_clang_ast_context
The TypeSystemClang for m_ast_context.
const lldb::TargetSP m_target
The target to use in finding variables and types.
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::ParserVars * AddExpressionVariable(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 o...
std::unique_ptr< StructVars > m_struct_vars
void EnableParserVars()
Activate parser-specific variables.
uint64_t GetParserID()
Get this parser's ID for use in extracting parser- and JIT-specific data from persistent variables.
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.
TargetInfo GetTargetInfo()
bool LookupLocalVariable(NameSearchContext &context, ConstString name, SymbolContext &sym_ctx, const CompilerDeclContext &namespace_decl)
Looks up a local variable.
void DisableStructVars()
Deallocate struct variables.
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 lis...
void FindExternalVisibleDecls(NameSearchContext &context) override
[Used by ClangASTSource] Find all entities matching a given name, using a NameSearchContext to make D...
void AddOneFunction(NameSearchContext &context, Function *fun, Symbol *sym)
Use the NameSearchContext to generate a Decl for the given function.
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 DoStructL...
bool DoStructLayout()
[Used by IRForTarget] Finalize the struct, laying out the position of each object in it.
void MaybeRegisterFunctionBody(clang::FunctionDecl *copied_function_decl)
Should be called on all copied functions.
void EnableStructVars()
Activate struct variables.
void AddOneGenericVariable(NameSearchContext &context, const Symbol &symbol)
Use the NameSearchContext to generate a Decl for the given LLDB symbol (treated as a variable),...
void DidParse()
Disable the state needed for parsing and IR transformation.
void AddOneRegister(NameSearchContext &context, const RegisterInfo *reg_info)
Use the NameSearchContext to generate a Decl for the given register.
bool WillParse(ExecutionContext &exe_ctx, Materializer *materializer)
Enable the state needed for parsing and IR transformation.
void LookUpLldbObjCClass(NameSearchContext &context)
Handles looking up $__lldb_objc_class which requires special treatment.
void DisableParserVars()
Deallocate parser-specific variables.
void LookupLocalVarNamespace(SymbolContext &sym_ctx, NameSearchContext &name_context)
Handles looking up the synthetic namespace that contains our local variables for the current frame.
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 expres...
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.
void InstallDiagnosticManager(DiagnosticManager &diag_manager)
void LookUpLldbClass(NameSearchContext &context)
Handles looking up $__lldb_class which requires special treatment.
ClangExpressionDeclMap(bool keep_result_in_memory, Materializer::PersistentVariableDelegate *result_delegate, const lldb::TargetSP &target, const std::shared_ptr< ClangASTImporter > &importer, ValueObject *ctx_obj)
Constructor.
bool m_keep_result_in_memory
True if result persistent variables generated by this expression should stay in memory.
bool GetFunctionInfo(const clang::NamedDecl *decl, uint64_t &ptr)
[Used by IRForTarget] Get information about a function given its Decl.
lldb::TypeSystemClangSP GetScratchContext(Target &target)
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 a...
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 be...
SymbolContextList SearchFunctionsInSymbolContexts(const SymbolContextList &sc_list, const CompilerDeclContext &frame_decl_context)
Searches for functions in the given SymbolContextList.
ExpressionVariableList m_struct_members
All entities that need to be placed in the struct.
ExpressionVariableList m_found_entities
All entities that were looked up for the parser.
~ClangExpressionDeclMap() override
Destructor.
void SearchPersistenDecls(NameSearchContext &context, const ConstString name)
Searches the persistent decls of the target for entities with the given name.
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...
Materializer::PersistentVariableDelegate * m_result_delegate
If non-NULL, used to report expression results to ClangUserExpression.
void LookupFunction(NameSearchContext &context, lldb::ModuleSP module_sp, ConstString name, const CompilerDeclContext &namespace_decl)
Looks up a function.
void LookupInModulesDeclVendor(NameSearchContext &context, ConstString name)
Lookup entities in the ClangModulesDeclVendor.
void AddOneType(NameSearchContext &context, const TypeFromUser &type)
Use the NameSearchContext to generate a Decl for the given type.
TypeSystemClang * GetTypeSystemClang()
ValueObject * m_ctx_obj
If not empty, then expression is evaluated in context of this object.
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.
std::unique_ptr< ParserVars > m_parser_vars
void InstallCodeGenerator(clang::ASTConsumer *code_gen)
virtual clang::NamedDecl * GetPersistentDecl(ConstString name)
Retrieves the declaration with the given name from the storage of persistent declarations.
The following values should not live beyond parsing.
ValueObjectProviderTy m_lldb_valobj_provider
Callback that provides a ValueObject for the specified frame.
const lldb_private::Symbol * m_lldb_sym
The original symbol for this variable, if it was a symbol.
lldb_private::Value m_lldb_value
The value found in LLDB for this variable.
lldb::VariableSP m_lldb_var
The original variable for this variable.
llvm::Value * m_llvm_value
The IR value corresponding to this variable; usually a GlobalValue.
const clang::NamedDecl * m_named_decl
The Decl corresponding to this variable.
"lldb/Expression/ClangExpressionVariable.h" Encapsulates one variable for the expression parser.
static ClangExpressionVariable * FindVariableInList(ExpressionVariableList &list, const clang::NamedDecl *decl, uint64_t parser_id)
Utility functions for dealing with ExpressionVariableLists in Clang- specific ways.
ParserVars * GetParserVars(uint64_t parser_id)
Access parser-specific variables.
JITVars * GetJITVars(uint64_t parser_id)
void EnableJITVars(uint64_t parser_id)
Make this variable usable for materializing for the JIT by allocating space for JIT-specific variable...
void EnableParserVars(uint64_t parser_id)
Make this variable usable by the parser by allocating space for parser- specific variables.
lldb::LanguageType GetLanguage()
Represents a generic declaration context in a program.
std::vector< CompilerDecl > FindDeclByName(ConstString name, const bool ignore_using_decls)
ConstString GetName() const
bool IsClassMethod()
Checks if this decl context represents a method of a class.
TypeSystem * GetTypeSystem() const
void * GetOpaqueDeclContext() const
Represents a generic declaration such as a function declaration.
std::shared_ptr< TypeSystemType > dyn_cast_or_null()
Return a shared_ptr<TypeSystemType> if dyn_cast succeeds.
Generic representation of a type in a programming language.
TypeSystemSPWrapper GetTypeSystem() const
Accessors.
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
lldb::opaque_compiler_type_t GetOpaqueQualType() const
CompilerType GetLValueReferenceType() const
Return a new CompilerType that is a L value reference to this type if this type is valid and the type...
bool IsAggregateType() const
CompilerType GetPointeeType() const
If this type is a pointer type, return the type that the pointer points to, else return an invalid ty...
bool GetCompleteType() const
Type Completion.
A uniqued constant string class.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
"lldb/Expression/DWARFExpressionList.h" Encapsulates a range map from file address range to a single ...
bool GetExpressionData(DataExtractor &data, lldb::addr_t func_load_addr=LLDB_INVALID_ADDRESS, lldb::addr_t file_addr=0) const
Get the expression data at the file address.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
ExecutionContextScope * GetBestExecutionContextScope() const
const lldb::TargetSP & GetTargetSP() const
Get accessor to get the target shared pointer.
StackFrame * GetFramePtr() const
Returns a pointer to the frame object.
Target * GetTargetPtr() const
Returns a pointer to the target object.
Process * GetProcessPtr() const
Returns a pointer to the process object.
Thread * GetThreadPtr() const
Returns a pointer to the thread object.
lldb::ExpressionVariableSP AddNewlyConstructedVariable(ExpressionVariable *var)
size_t GetSize()
Implementation of methods in ExpressionVariableListBase.
lldb::ExpressionVariableSP GetVariableAtIndex(size_t index)
size_t AddVariable(const lldb::ExpressionVariableSP &var_sp)
void ClearDirectory()
Clear the directory in this object.
A class that describes a function.
const AddressRange & GetAddressRange()
ConstString GetName() const
const Mangled & GetMangled() const
void DumpSymbolContext(Stream *s) override
Dump the object's symbol context to the stream s.
Type * GetType()
Get accessor for the type that describes the function return value type, and parameter types.
CompilerDeclContext GetDeclContext()
Get the DeclContext for this function, if available.
CompileUnit * GetCompileUnit()
Get accessor for the compile unit that owns this function.
virtual lldb::addr_t LookupRuntimeSymbol(ConstString name)
static bool LanguageIsC(lldb::LanguageType language)
static bool LanguageIsCPlusPlus(lldb::LanguageType language)
static bool LanguageIsObjC(lldb::LanguageType language)
ConstString & GetMangledName()
Mangled name get accessor.
void FindFunctions(ConstString name, lldb::FunctionNameType name_type_mask, const ModuleFunctionSearchOptions &options, SymbolContextList &sc_list) const
void FindGlobalVariables(ConstString name, size_t max_matches, VariableList &variable_list) const
Find global and static variables by name.
lldb::ModuleSP FindFirstModule(const ModuleSpec &module_spec) const
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list) const
FileSpec & GetPlatformFileSpec()
A class that describes an executable image and its associated object and symbol files.
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list)
static ObjCLanguageRuntime * Get(Process &process)
A plug-in interface definition class for debugging a process.
lldb::ByteOrder GetByteOrder() const
uint32_t GetAddressByteSize() const
unsigned long long ULongLong(unsigned long long fail_value=0) const
static lldb::TypeSystemClangSP GetForTarget(Target &target, std::optional< IsolatedASTKind > ast_kind=DefaultAST, bool create_on_demand=true)
Returns the scratch TypeSystemClang for the given target.
This base class provides an interface to stack frames.
VariableList * GetVariableList(bool get_file_globals, Status *error_ptr)
Retrieve the list of variables that are in scope at this StackFrame's pc.
lldb::VariableListSP GetInScopeVariableList(bool get_file_globals, bool must_have_valid_location=false)
Retrieve the list of variables that are in scope at this StackFrame's pc.
const SymbolContext & GetSymbolContext(lldb::SymbolContextItem resolve_scope)
Provide a SymbolContext for this StackFrame's current pc value.
lldb::ValueObjectSP FindVariable(ConstString name)
Attempt to reconstruct the ValueObject for a variable with a given name from within the current Stack...
bool Fail() const
Test for error condition.
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
bool Success() const
Test for success condition.
const char * GetData() const
Defines a list of symbol context objects.
uint32_t GetSize() const
Get accessor for a symbol context list size.
void Append(const SymbolContext &sc)
Append a new symbol context to the list.
Defines a symbol context baton that can be handed other debug core functions.
Block * GetFunctionBlock()
Find a block that defines the function represented by this symbol context.
Block * block
The Block for a given query.
lldb::ModuleSP module_sp
The Module for a given query.
lldb::SymbolType GetType() const
Address GetAddress() const
Symbol * ResolveReExportedSymbol(Target &target) const
PersistentExpressionState * GetPersistentExpressionStateForLanguage(lldb::LanguageType language)
const ModuleList & GetImages() const
Get accessor for the images for this process.
const ArchSpec & GetArchitecture() const
virtual lldb::StackFrameSP GetStackFrameAtIndex(uint32_t idx)
A TypeSystem implementation based on Clang.
CompilerType GetBasicType(lldb::BasicType type)
CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size) override
CompilerDeclContext CreateDeclContext(clang::DeclContext *ctx)
Creates a CompilerDeclContext from the given DeclContext with the current TypeSystemClang instance as...
static clang::CXXMethodDecl * DeclContextGetAsCXXMethodDecl(const CompilerDeclContext &dc)
uint32_t CountDeclLevels(clang::DeclContext *frame_decl_ctx, clang::DeclContext *child_decl_ctx, ConstString *child_name=nullptr, CompilerType *child_type=nullptr)
clang::CXXMethodDecl * AddMethodToCXXRecordType(lldb::opaque_compiler_type_t type, llvm::StringRef name, const char *mangled_name, const CompilerType &method_type, lldb::AccessType access, bool is_virtual, bool is_static, bool is_inline, bool is_explicit, bool is_attr_used, bool is_artificial)
clang::NamespaceDecl * GetUniqueNamespaceDeclaration(const char *name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, bool is_inline=false)
static clang::ObjCMethodDecl * DeclContextGetAsObjCMethodDecl(const CompilerDeclContext &dc)
static bool IsObjCClassType(const CompilerType &type)
clang::ASTContext & getASTContext()
Returns the clang::ASTContext instance managed by this TypeSystemClang.
CompilerType CreateFunctionType(const CompilerType &result_type, const CompilerType *args, unsigned num_args, bool is_variadic, unsigned type_quals, clang::CallingConv cc=clang::CC_C, clang::RefQualifierKind ref_qual=clang::RQ_None)
static bool IsObjCObjectPointerType(const CompilerType &type, CompilerType *target_type=nullptr)
Interface for representing a type system.
CompilerType GetForwardCompilerType()
CompilerType GetFullCompilerType()
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, const lldb::VariableSP &var_sp)
CompilerType GetCompilerType()
virtual lldb::ValueObjectSP AddressOf(Status &error)
const Scalar & GetScalar() const
@ HostAddress
A host address value (for memory in the process that < A is using liblldb).
@ FileAddress
A file address value.
@ LoadAddress
A load address value.
ValueType GetValueType() const
void SetCompilerType(const CompilerType &compiler_type)
void SetValueType(ValueType value_type)
ContextType GetContextType() const
lldb::VariableSP GetVariableAtIndex(size_t idx) const
lldb::VariableSP FindVariable(ConstString name, bool include_static_members=true)
#define LLDB_INVALID_ADDRESS
lldb::ValueObjectSP GetLambdaValueObject(StackFrame *frame)
Returns a ValueObject for the lambda class in the current frame.
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
TaggedASTType< 0 > TypeFromParser
@ eDiagnosticSeverityError
std::function< lldb::ValueObjectSP(ConstString, StackFrame *)> ValueObjectProviderTy
Functor that returns a ValueObjectSP for a variable given its name and the StackFrame of interest.
TaggedASTType< 1 > TypeFromUser
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
std::shared_ptr< lldb_private::ExpressionVariable > ExpressionVariableSP
@ eLanguageTypeC
Non-standardized C, such as K&R.
@ eSymbolTypeVariableType
@ eSymbolTypeObjCMetaClass
@ eSymbolTypeAdditional
When symbols take more than one entry, the extra entries get this type.
@ eSymbolTypeInstrumentation
std::shared_ptr< lldb_private::VariableList > VariableListSP
std::shared_ptr< lldb_private::Variable > VariableSP
std::shared_ptr< lldb_private::Target > TargetSP
std::shared_ptr< lldb_private::Module > ModuleSP
lldb::ByteOrder byte_order
The following values are valid if the variable is used by JIT code.
size_t m_size
The space required for the variable, in bytes.
lldb::offset_t m_alignment
The required alignment of the variable, in bytes.
lldb::offset_t m_offset
The offset of the variable in the struct, in bytes.
static clang::QualType GetQualType(const CompilerType &ct)
static std::string ToString(const clang::Type *t)
Returns a textual representation of the given type.
static std::string DumpDecl(const clang::Decl *d)
Returns a textual representation of the given Decl's AST.
Options used by Module::FindFunctions.
bool include_inlines
Include inlined functions.
bool include_symbols
Include the symbol table.
"lldb/Expression/ClangASTSource.h" Container for all objects relevant to a single name lookup
clang::NamedDecl * AddTypeDecl(const CompilerType &compiler_type)
Create a TypeDecl with the name being searched for and the provided type and register it in the right...
const clang::DeclarationName m_decl_name
The name being looked for.
bool m_found_function_with_type_info
clang::NamedDecl * AddFunDecl(const CompilerType &type, bool extern_c=false)
Create a FunDecl with the name being searched for and the provided type and register it in the right ...
clang::NamedDecl * AddGenericFunDecl()
Create a FunDecl with the name being searched for and generic type (i.e.
bool m_found_local_vars_nsp
const clang::DeclContext * m_decl_context
The DeclContext to put declarations into.
void AddNamedDecl(clang::NamedDecl *decl)
Add a NamedDecl to the list of results.
clang::NamedDecl * AddVarDecl(const CompilerType &type)
Create a VarDecl with the name being searched for and the provided type and register it in the right ...
Every register is described in detail including its name, alternate name (optional),...
lldb::Encoding encoding
Encoding of the register bits.
uint32_t byte_size
Size in bytes of the register.
const char * name
Name of this register, can't be NULL.
lldb::user_id_t GetID() const
Get accessor for the user ID.