LLDB  mainline
ClangExpressionDeclMap.cpp
Go to the documentation of this file.
1 //===-- ClangExpressionDeclMap.cpp ----------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 
11 #include "ClangASTSource.h"
12 #include "ClangExpressionUtil.h"
14 #include "ClangModulesDeclVendor.h"
16 #include "ClangUtil.h"
17 
18 #include "NameSearchContext.h"
20 #include "lldb/Core/Address.h"
21 #include "lldb/Core/Module.h"
22 #include "lldb/Core/ModuleSpec.h"
30 #include "lldb/Symbol/Function.h"
31 #include "lldb/Symbol/ObjectFile.h"
33 #include "lldb/Symbol/SymbolFile.h"
35 #include "lldb/Symbol/Type.h"
36 #include "lldb/Symbol/TypeList.h"
37 #include "lldb/Symbol/Variable.h"
40 #include "lldb/Target/Process.h"
42 #include "lldb/Target/StackFrame.h"
43 #include "lldb/Target/Target.h"
44 #include "lldb/Target/Thread.h"
45 #include "lldb/Utility/Endian.h"
46 #include "lldb/Utility/LLDBLog.h"
47 #include "lldb/Utility/Log.h"
49 #include "lldb/Utility/Status.h"
51 #include "lldb/lldb-private.h"
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"
58 
62 
63 using namespace lldb;
64 using namespace lldb_private;
65 using namespace clang;
66 
67 static const char *g_lldb_local_vars_namespace_cstr = "$__lldb_local_vars";
68 
69 namespace {
70 /// A lambda is represented by Clang as an artifical class whose
71 /// members are the lambda captures. If we capture a 'this' pointer,
72 /// the artifical class will contain a member variable named 'this'.
73 /// The function returns a ValueObject for the captured 'this' if such
74 /// member exists. If no 'this' was captured, return a nullptr.
75 lldb::ValueObjectSP GetCapturedThisValueObject(StackFrame *frame) {
76  assert(frame);
77 
78  if (auto thisValSP = frame->FindVariable(ConstString("this")))
79  if (auto thisThisValSP =
80  thisValSP->GetChildMemberWithName(ConstString("this"), true))
81  return thisThisValSP;
82 
83  return nullptr;
84 }
85 } // namespace
86 
87 ClangExpressionDeclMap::ClangExpressionDeclMap(
88  bool keep_result_in_memory,
90  const lldb::TargetSP &target,
91  const std::shared_ptr<ClangASTImporter> &importer, ValueObject *ctx_obj)
92  : ClangASTSource(target, importer), m_found_entities(), m_struct_members(),
93  m_keep_result_in_memory(keep_result_in_memory),
94  m_result_delegate(result_delegate), m_ctx_obj(ctx_obj), m_parser_vars(),
95  m_struct_vars() {
97 }
98 
100  // Note: The model is now that the parser's AST context and all associated
101  // data does not vanish until the expression has been executed. This means
102  // that valuable lookup data (like namespaces) doesn't vanish, but
103 
104  DidParse();
106 }
107 
109  Materializer *materializer) {
111  m_parser_vars->m_exe_ctx = exe_ctx;
112 
113  Target *target = exe_ctx.GetTargetPtr();
114  if (exe_ctx.GetFramePtr())
115  m_parser_vars->m_sym_ctx =
116  exe_ctx.GetFramePtr()->GetSymbolContext(lldb::eSymbolContextEverything);
117  else if (exe_ctx.GetThreadPtr() &&
118  exe_ctx.GetThreadPtr()->GetStackFrameAtIndex(0))
119  m_parser_vars->m_sym_ctx =
120  exe_ctx.GetThreadPtr()->GetStackFrameAtIndex(0)->GetSymbolContext(
121  lldb::eSymbolContextEverything);
122  else if (exe_ctx.GetProcessPtr()) {
123  m_parser_vars->m_sym_ctx.Clear(true);
124  m_parser_vars->m_sym_ctx.target_sp = exe_ctx.GetTargetSP();
125  } else if (target) {
126  m_parser_vars->m_sym_ctx.Clear(true);
127  m_parser_vars->m_sym_ctx.target_sp = exe_ctx.GetTargetSP();
128  }
129 
130  if (target) {
131  m_parser_vars->m_persistent_vars = llvm::cast<ClangPersistentVariables>(
133 
135  return false;
136  }
137 
138  m_parser_vars->m_target_info = GetTargetInfo();
139  m_parser_vars->m_materializer = materializer;
140 
141  return true;
142 }
143 
145  clang::ASTConsumer *code_gen) {
146  assert(m_parser_vars);
147  m_parser_vars->m_code_gen = code_gen;
148 }
149 
151  DiagnosticManager &diag_manager) {
152  assert(m_parser_vars);
153  m_parser_vars->m_diagnostics = &diag_manager;
154 }
155 
157  if (m_parser_vars && m_parser_vars->m_persistent_vars) {
158  for (size_t entity_index = 0, num_entities = m_found_entities.GetSize();
159  entity_index < num_entities; ++entity_index) {
160  ExpressionVariableSP var_sp(
161  m_found_entities.GetVariableAtIndex(entity_index));
162  if (var_sp)
163  llvm::cast<ClangExpressionVariable>(var_sp.get())
164  ->DisableParserVars(GetParserID());
165  }
166 
167  for (size_t pvar_index = 0,
168  num_pvars = m_parser_vars->m_persistent_vars->GetSize();
169  pvar_index < num_pvars; ++pvar_index) {
170  ExpressionVariableSP pvar_sp(
171  m_parser_vars->m_persistent_vars->GetVariableAtIndex(pvar_index));
172  if (ClangExpressionVariable *clang_var =
173  llvm::dyn_cast<ClangExpressionVariable>(pvar_sp.get()))
174  clang_var->DisableParserVars(GetParserID());
175  }
176 
178  }
179 }
180 
181 // Interface for IRForTarget
182 
184  assert(m_parser_vars.get());
185 
186  TargetInfo ret;
187 
188  ExecutionContext &exe_ctx = m_parser_vars->m_exe_ctx;
189 
190  Process *process = exe_ctx.GetProcessPtr();
191  if (process) {
192  ret.byte_order = process->GetByteOrder();
193  ret.address_byte_size = process->GetAddressByteSize();
194  } else {
195  Target *target = exe_ctx.GetTargetPtr();
196  if (target) {
197  ret.byte_order = target->GetArchitecture().GetByteOrder();
199  }
200  }
201 
202  return ret;
203 }
204 
206  TypeSystemClang &source,
207  TypeFromParser parser_type) {
208  assert(&target == GetScratchContext(*m_target).get());
209  assert((TypeSystem *)&source ==
210  parser_type.GetTypeSystem().GetSharedPointer().get());
211  assert(&source.getASTContext() == m_ast_context);
212 
213  return TypeFromUser(m_ast_importer_sp->DeportType(target, parser_type));
214 }
215 
217  ConstString name,
218  TypeFromParser parser_type,
219  bool is_result,
220  bool is_lvalue) {
221  assert(m_parser_vars.get());
222  auto ast = parser_type.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>();
223  if (ast == nullptr)
224  return false;
225 
226  // Check if we already declared a persistent variable with the same name.
227  if (lldb::ExpressionVariableSP conflicting_var =
228  m_parser_vars->m_persistent_vars->GetVariable(name)) {
229  std::string msg = llvm::formatv("redefinition of persistent variable '{0}'",
230  name).str();
231  m_parser_vars->m_diagnostics->AddDiagnostic(
234  return false;
235  }
236 
237  if (m_parser_vars->m_materializer && is_result) {
238  Status err;
239 
240  ExecutionContext &exe_ctx = m_parser_vars->m_exe_ctx;
241  Target *target = exe_ctx.GetTargetPtr();
242  if (target == nullptr)
243  return false;
244 
245  auto clang_ast_context = GetScratchContext(*target);
246  if (!clang_ast_context)
247  return false;
248 
249  TypeFromUser user_type = DeportType(*clang_ast_context, *ast, parser_type);
250 
251  uint32_t offset = m_parser_vars->m_materializer->AddResultVariable(
252  user_type, is_lvalue, m_keep_result_in_memory, m_result_delegate, err);
253 
255  exe_ctx.GetBestExecutionContextScope(), name, user_type,
256  m_parser_vars->m_target_info.byte_order,
257  m_parser_vars->m_target_info.address_byte_size);
258 
260 
262 
264  var->GetParserVars(GetParserID());
265 
266  parser_vars->m_named_decl = decl;
267 
268  var->EnableJITVars(GetParserID());
269 
271 
272  jit_vars->m_offset = offset;
273 
274  return true;
275  }
276 
278  ExecutionContext &exe_ctx = m_parser_vars->m_exe_ctx;
279  Target *target = exe_ctx.GetTargetPtr();
280  if (target == nullptr)
281  return false;
282 
283  auto context = GetScratchContext(*target);
284  if (!context)
285  return false;
286 
287  TypeFromUser user_type = DeportType(*context, *ast, parser_type);
288 
289  if (!user_type.GetOpaqueQualType()) {
290  LLDB_LOG(log, "Persistent variable's type wasn't copied successfully");
291  return false;
292  }
293 
294  if (!m_parser_vars->m_target_info.IsValid())
295  return false;
296 
297  if (!m_parser_vars->m_persistent_vars)
298  return false;
299 
300  ClangExpressionVariable *var = llvm::cast<ClangExpressionVariable>(
301  m_parser_vars->m_persistent_vars
302  ->CreatePersistentVariable(
303  exe_ctx.GetBestExecutionContextScope(), name, user_type,
304  m_parser_vars->m_target_info.byte_order,
305  m_parser_vars->m_target_info.address_byte_size)
306  .get());
307 
308  if (!var)
309  return false;
310 
311  var->m_frozen_sp->SetHasCompleteType();
312 
313  if (is_result)
315  else
316  var->m_flags |=
317  ClangExpressionVariable::EVKeepInTarget; // explicitly-declared
318  // persistent variables should
319  // persist
320 
321  if (is_lvalue) {
323  } else {
326  }
327 
330  }
331 
332  LLDB_LOG(log, "Created persistent variable with flags {0:x}", var->m_flags);
333 
335 
337  var->GetParserVars(GetParserID());
338 
339  parser_vars->m_named_decl = decl;
340 
341  return true;
342 }
343 
344 bool ClangExpressionDeclMap::AddValueToStruct(const NamedDecl *decl,
345  ConstString name,
346  llvm::Value *value, size_t size,
347  lldb::offset_t alignment) {
348  assert(m_struct_vars.get());
349  assert(m_parser_vars.get());
350 
351  bool is_persistent_variable = false;
352 
354 
355  m_struct_vars->m_struct_laid_out = false;
356 
358  GetParserID()))
359  return true;
360 
362  m_found_entities, decl, GetParserID()));
363 
364  if (!var && m_parser_vars->m_persistent_vars) {
366  *m_parser_vars->m_persistent_vars, decl, GetParserID());
367  is_persistent_variable = true;
368  }
369 
370  if (!var)
371  return false;
372 
373  LLDB_LOG(log, "Adding value for (NamedDecl*){0} [{1} - {2}] to the structure",
374  decl, name, var->GetName());
375 
376  // We know entity->m_parser_vars is valid because we used a parser variable
377  // to find it
378 
380  llvm::cast<ClangExpressionVariable>(var)->GetParserVars(GetParserID());
381 
382  parser_vars->m_llvm_value = value;
383 
384  if (ClangExpressionVariable::JITVars *jit_vars =
385  llvm::cast<ClangExpressionVariable>(var)->GetJITVars(GetParserID())) {
386  // We already laid this out; do not touch
387 
388  LLDB_LOG(log, "Already placed at {0:x}", jit_vars->m_offset);
389  }
390 
391  llvm::cast<ClangExpressionVariable>(var)->EnableJITVars(GetParserID());
392 
394  llvm::cast<ClangExpressionVariable>(var)->GetJITVars(GetParserID());
395 
396  jit_vars->m_alignment = alignment;
397  jit_vars->m_size = size;
398 
399  m_struct_members.AddVariable(var->shared_from_this());
400 
401  if (m_parser_vars->m_materializer) {
402  uint32_t offset = 0;
403 
404  Status err;
405 
406  if (is_persistent_variable) {
407  ExpressionVariableSP var_sp(var->shared_from_this());
408  offset = m_parser_vars->m_materializer->AddPersistentVariable(
409  var_sp, nullptr, err);
410  } else {
411  if (const lldb_private::Symbol *sym = parser_vars->m_lldb_sym)
412  offset = m_parser_vars->m_materializer->AddSymbol(*sym, err);
413  else if (const RegisterInfo *reg_info = var->GetRegisterInfo())
414  offset = m_parser_vars->m_materializer->AddRegister(*reg_info, err);
415  else if (parser_vars->m_lldb_var)
416  offset = m_parser_vars->m_materializer->AddVariable(
417  parser_vars->m_lldb_var, err);
418  else if (parser_vars->m_lldb_valobj_provider) {
419  offset = m_parser_vars->m_materializer->AddValueObject(
420  name, parser_vars->m_lldb_valobj_provider, err);
421  }
422  }
423 
424  if (!err.Success())
425  return false;
426 
427  LLDB_LOG(log, "Placed at {0:x}", offset);
428 
429  jit_vars->m_offset =
430  offset; // TODO DoStructLayout() should not change this.
431  }
432 
433  return true;
434 }
435 
437  assert(m_struct_vars.get());
438 
439  if (m_struct_vars->m_struct_laid_out)
440  return true;
441 
442  if (!m_parser_vars->m_materializer)
443  return false;
444 
445  m_struct_vars->m_struct_alignment =
446  m_parser_vars->m_materializer->GetStructAlignment();
447  m_struct_vars->m_struct_size =
448  m_parser_vars->m_materializer->GetStructByteSize();
449  m_struct_vars->m_struct_laid_out = true;
450  return true;
451 }
452 
453 bool ClangExpressionDeclMap::GetStructInfo(uint32_t &num_elements, size_t &size,
454  lldb::offset_t &alignment) {
455  assert(m_struct_vars.get());
456 
457  if (!m_struct_vars->m_struct_laid_out)
458  return false;
459 
460  num_elements = m_struct_members.GetSize();
461  size = m_struct_vars->m_struct_size;
462  alignment = m_struct_vars->m_struct_alignment;
463 
464  return true;
465 }
466 
467 bool ClangExpressionDeclMap::GetStructElement(const NamedDecl *&decl,
468  llvm::Value *&value,
469  lldb::offset_t &offset,
470  ConstString &name,
471  uint32_t index) {
472  assert(m_struct_vars.get());
473 
474  if (!m_struct_vars->m_struct_laid_out)
475  return false;
476 
477  if (index >= m_struct_members.GetSize())
478  return false;
479 
480  ExpressionVariableSP member_sp(m_struct_members.GetVariableAtIndex(index));
481 
482  if (!member_sp)
483  return false;
484 
486  llvm::cast<ClangExpressionVariable>(member_sp.get())
487  ->GetParserVars(GetParserID());
489  llvm::cast<ClangExpressionVariable>(member_sp.get())
490  ->GetJITVars(GetParserID());
491 
492  if (!parser_vars || !jit_vars || !member_sp->GetValueObject())
493  return false;
494 
495  decl = parser_vars->m_named_decl;
496  value = parser_vars->m_llvm_value;
497  offset = jit_vars->m_offset;
498  name = member_sp->GetName();
499 
500  return true;
501 }
502 
503 bool ClangExpressionDeclMap::GetFunctionInfo(const NamedDecl *decl,
504  uint64_t &ptr) {
506  m_found_entities, decl, GetParserID()));
507 
508  if (!entity)
509  return false;
510 
511  // We know m_parser_vars is valid since we searched for the variable by its
512  // NamedDecl
513 
515  entity->GetParserVars(GetParserID());
516 
517  ptr = parser_vars->m_lldb_value.GetScalar().ULongLong();
518 
519  return true;
520 }
521 
523  Process *process,
524  ConstString name,
525  lldb::SymbolType symbol_type,
526  lldb_private::Module *module) {
527  SymbolContextList sc_list;
528 
529  if (module)
530  module->FindSymbolsWithNameAndType(name, symbol_type, sc_list);
531  else
532  target.GetImages().FindSymbolsWithNameAndType(name, symbol_type, sc_list);
533 
534  const uint32_t num_matches = sc_list.GetSize();
535  addr_t symbol_load_addr = LLDB_INVALID_ADDRESS;
536 
537  for (uint32_t i = 0;
538  i < num_matches &&
539  (symbol_load_addr == 0 || symbol_load_addr == LLDB_INVALID_ADDRESS);
540  i++) {
541  SymbolContext sym_ctx;
542  sc_list.GetContextAtIndex(i, sym_ctx);
543 
544  const Address sym_address = sym_ctx.symbol->GetAddress();
545 
546  if (!sym_address.IsValid())
547  continue;
548 
549  switch (sym_ctx.symbol->GetType()) {
550  case eSymbolTypeCode:
552  symbol_load_addr = sym_address.GetCallableLoadAddress(&target);
553  break;
554 
555  case eSymbolTypeResolver:
556  symbol_load_addr = sym_address.GetCallableLoadAddress(&target, true);
557  break;
558 
559  case eSymbolTypeReExported: {
560  ConstString reexport_name = sym_ctx.symbol->GetReExportedSymbolName();
561  if (reexport_name) {
562  ModuleSP reexport_module_sp;
563  ModuleSpec reexport_module_spec;
564  reexport_module_spec.GetPlatformFileSpec() =
566  if (reexport_module_spec.GetPlatformFileSpec()) {
567  reexport_module_sp =
568  target.GetImages().FindFirstModule(reexport_module_spec);
569  if (!reexport_module_sp) {
570  reexport_module_spec.GetPlatformFileSpec().ClearDirectory();
571  reexport_module_sp =
572  target.GetImages().FindFirstModule(reexport_module_spec);
573  }
574  }
575  symbol_load_addr = GetSymbolAddress(
576  target, process, sym_ctx.symbol->GetReExportedSymbolName(),
577  symbol_type, reexport_module_sp.get());
578  }
579  } break;
580 
581  case eSymbolTypeData:
582  case eSymbolTypeRuntime:
583  case eSymbolTypeVariable:
584  case eSymbolTypeLocal:
585  case eSymbolTypeParam:
586  case eSymbolTypeInvalid:
587  case eSymbolTypeAbsolute:
593  case eSymbolTypeBlock:
598  case eSymbolTypeScopeEnd:
600  case eSymbolTypeCompiler:
605  case eSymbolTypeObjCIVar:
606  symbol_load_addr = sym_address.GetLoadAddress(&target);
607  break;
608  }
609  }
610 
611  if (symbol_load_addr == LLDB_INVALID_ADDRESS && process) {
612  ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process);
613 
614  if (runtime) {
615  symbol_load_addr = runtime->LookupRuntimeSymbol(name);
616  }
617  }
618 
619  return symbol_load_addr;
620 }
621 
623  lldb::SymbolType symbol_type) {
624  assert(m_parser_vars.get());
625 
626  if (!m_parser_vars->m_exe_ctx.GetTargetPtr())
627  return false;
628 
629  return GetSymbolAddress(m_parser_vars->m_exe_ctx.GetTargetRef(),
630  m_parser_vars->m_exe_ctx.GetProcessPtr(), name,
631  symbol_type);
632 }
633 
635  Target &target, ModuleSP &module, ConstString name,
636  const CompilerDeclContext &namespace_decl) {
637  VariableList vars;
638 
639  if (module && namespace_decl)
640  module->FindGlobalVariables(name, namespace_decl, -1, vars);
641  else
642  target.GetImages().FindGlobalVariables(name, -1, vars);
643 
644  if (vars.GetSize() == 0)
645  return VariableSP();
646  return vars.GetVariableAtIndex(0);
647 }
648 
650  StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
651  if (frame == nullptr)
652  return nullptr;
653 
654  SymbolContext sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction |
655  lldb::eSymbolContextBlock);
656  if (sym_ctx.block == nullptr)
657  return nullptr;
658 
659  CompilerDeclContext frame_decl_context = sym_ctx.block->GetDeclContext();
660  if (!frame_decl_context)
661  return nullptr;
662 
663  return llvm::dyn_cast_or_null<TypeSystemClang>(
664  frame_decl_context.GetTypeSystem());
665 }
666 
667 // Interface for ClangASTSource
668 
670  NameSearchContext &context) {
671  assert(m_ast_context);
672 
673  const ConstString name(context.m_decl_name.getAsString().c_str());
674 
676 
677  if (log) {
678  if (!context.m_decl_context)
679  LLDB_LOG(log,
680  "ClangExpressionDeclMap::FindExternalVisibleDecls for "
681  "'{0}' in a NULL DeclContext",
682  name);
683  else if (const NamedDecl *context_named_decl =
684  dyn_cast<NamedDecl>(context.m_decl_context))
685  LLDB_LOG(log,
686  "ClangExpressionDeclMap::FindExternalVisibleDecls for "
687  "'{0}' in '{1}'",
688  name, context_named_decl->getNameAsString());
689  else
690  LLDB_LOG(log,
691  "ClangExpressionDeclMap::FindExternalVisibleDecls for "
692  "'{0}' in a '{1}'",
693  name, context.m_decl_context->getDeclKindName());
694  }
695 
696  if (const NamespaceDecl *namespace_context =
697  dyn_cast<NamespaceDecl>(context.m_decl_context)) {
698  if (namespace_context->getName().str() ==
700  CompilerDeclContext compiler_decl_ctx =
702  const_cast<clang::DeclContext *>(context.m_decl_context));
703  FindExternalVisibleDecls(context, lldb::ModuleSP(), compiler_decl_ctx);
704  return;
705  }
706 
707  ClangASTImporter::NamespaceMapSP namespace_map =
708  m_ast_importer_sp->GetNamespaceMap(namespace_context);
709 
710  if (!namespace_map)
711  return;
712 
713  LLDB_LOGV(log, " CEDM::FEVD Inspecting (NamespaceMap*){0:x} ({1} entries)",
714  namespace_map.get(), namespace_map->size());
715 
716  for (ClangASTImporter::NamespaceMapItem &n : *namespace_map) {
717  LLDB_LOG(log, " CEDM::FEVD Searching namespace {0} in module {1}",
718  n.second.GetName(), n.first->GetFileSpec().GetFilename());
719 
720  FindExternalVisibleDecls(context, n.first, n.second);
721  }
722  } else if (isa<TranslationUnitDecl>(context.m_decl_context)) {
723  CompilerDeclContext namespace_decl;
724 
725  LLDB_LOG(log, " CEDM::FEVD Searching the root namespace");
726 
727  FindExternalVisibleDecls(context, lldb::ModuleSP(), namespace_decl);
728  }
729 
731 }
732 
734  FunctionDecl *copied_function_decl) {
735  if (copied_function_decl->getBody() && m_parser_vars->m_code_gen) {
736  clang::DeclGroupRef decl_group_ref(copied_function_decl);
737  m_parser_vars->m_code_gen->HandleTopLevelDecl(decl_group_ref);
738  }
739 }
740 
742  if (!m_parser_vars)
743  return nullptr;
744  Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
745  if (!target)
746  return nullptr;
747 
749 
750  if (!m_parser_vars->m_persistent_vars)
751  return nullptr;
752  return m_parser_vars->m_persistent_vars->GetPersistentDecl(name);
753 }
754 
756  const ConstString name) {
758 
759  NamedDecl *persistent_decl = GetPersistentDecl(name);
760 
761  if (!persistent_decl)
762  return;
763 
764  Decl *parser_persistent_decl = CopyDecl(persistent_decl);
765 
766  if (!parser_persistent_decl)
767  return;
768 
769  NamedDecl *parser_named_decl = dyn_cast<NamedDecl>(parser_persistent_decl);
770 
771  if (!parser_named_decl)
772  return;
773 
774  if (clang::FunctionDecl *parser_function_decl =
775  llvm::dyn_cast<clang::FunctionDecl>(parser_named_decl)) {
776  MaybeRegisterFunctionBody(parser_function_decl);
777  }
778 
779  LLDB_LOG(log, " CEDM::FEVD Found persistent decl {0}", name);
780 
781  context.AddNamedDecl(parser_named_decl);
782 }
783 
786 
787  StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
788  SymbolContext sym_ctx;
789  if (frame != nullptr)
790  sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction |
791  lldb::eSymbolContextBlock);
792 
793  if (m_ctx_obj) {
794  Status status;
795  lldb::ValueObjectSP ctx_obj_ptr = m_ctx_obj->AddressOf(status);
796  if (!ctx_obj_ptr || status.Fail())
797  return;
798 
800  return;
801  }
802 
803  // Clang is looking for the type of "this"
804 
805  if (frame == nullptr)
806  return;
807 
808  // Find the block that defines the function represented by "sym_ctx"
809  Block *function_block = sym_ctx.GetFunctionBlock();
810 
811  if (!function_block)
812  return;
813 
814  CompilerDeclContext function_decl_ctx = function_block->GetDeclContext();
815 
816  if (!function_decl_ctx)
817  return;
818 
819  clang::CXXMethodDecl *method_decl =
821 
822  if (method_decl) {
823  if (auto capturedThis = GetCapturedThisValueObject(frame)) {
824  // We're inside a lambda and we captured a 'this'.
825  // Import the outer class's AST instead of the
826  // (unnamed) lambda structure AST so unqualified
827  // member lookups are understood by the Clang parser.
828  //
829  // If we're in a lambda which didn't capture 'this',
830  // $__lldb_class will correspond to the lambda closure
831  // AST and references to captures will resolve like
832  // regular member varaiable accesses do.
833  TypeFromUser pointee_type =
834  capturedThis->GetCompilerType().GetPointeeType();
835 
836  LLDB_LOG(log,
837  " CEDM::FEVD Adding captured type ({0} for"
838  " $__lldb_class: {1}",
839  capturedThis->GetTypeName(), capturedThis->GetName());
840 
841  AddContextClassType(context, pointee_type);
842  return;
843  }
844 
845  clang::CXXRecordDecl *class_decl = method_decl->getParent();
846 
847  QualType class_qual_type(class_decl->getTypeForDecl(), 0);
848 
849  TypeFromUser class_user_type(
850  class_qual_type.getAsOpaquePtr(),
851  function_decl_ctx.GetTypeSystem()->weak_from_this());
852 
853  LLDB_LOG(log, " CEDM::FEVD Adding type for $__lldb_class: {0}",
854  class_qual_type.getAsString());
855 
856  AddContextClassType(context, class_user_type);
857  return;
858  }
859 
860  // This branch will get hit if we are executing code in the context of
861  // a function that claims to have an object pointer (through
862  // DW_AT_object_pointer?) but is not formally a method of the class.
863  // In that case, just look up the "this" variable in the current scope
864  // and use its type.
865  // FIXME: This code is formally correct, but clang doesn't currently
866  // emit DW_AT_object_pointer
867  // for C++ so it hasn't actually been tested.
868 
869  VariableList *vars = frame->GetVariableList(false, nullptr);
870 
871  lldb::VariableSP this_var = vars->FindVariable(ConstString("this"));
872 
873  if (this_var && this_var->IsInScope(frame) &&
874  this_var->LocationIsValidForFrame(frame)) {
875  Type *this_type = this_var->GetType();
876 
877  if (!this_type)
878  return;
879 
880  TypeFromUser pointee_type =
881  this_type->GetForwardCompilerType().GetPointeeType();
882 
883  LLDB_LOG(log, " FEVD Adding type for $__lldb_class: {0}",
884  ClangUtil::GetQualType(pointee_type).getAsString());
885 
886  AddContextClassType(context, pointee_type);
887  }
888 }
889 
892 
893  StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
894 
895  if (m_ctx_obj) {
896  Status status;
897  lldb::ValueObjectSP ctx_obj_ptr = m_ctx_obj->AddressOf(status);
898  if (!ctx_obj_ptr || status.Fail())
899  return;
900 
902  return;
903  }
904 
905  // Clang is looking for the type of "*self"
906 
907  if (!frame)
908  return;
909 
910  SymbolContext sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction |
911  lldb::eSymbolContextBlock);
912 
913  // Find the block that defines the function represented by "sym_ctx"
914  Block *function_block = sym_ctx.GetFunctionBlock();
915 
916  if (!function_block)
917  return;
918 
919  CompilerDeclContext function_decl_ctx = function_block->GetDeclContext();
920 
921  if (!function_decl_ctx)
922  return;
923 
924  clang::ObjCMethodDecl *method_decl =
926 
927  if (method_decl) {
928  ObjCInterfaceDecl *self_interface = method_decl->getClassInterface();
929 
930  if (!self_interface)
931  return;
932 
933  const clang::Type *interface_type = self_interface->getTypeForDecl();
934 
935  if (!interface_type)
936  return; // This is unlikely, but we have seen crashes where this
937  // occurred
938 
939  TypeFromUser class_user_type(
940  QualType(interface_type, 0).getAsOpaquePtr(),
941  function_decl_ctx.GetTypeSystem()->weak_from_this());
942 
943  LLDB_LOG(log, " FEVD[{0}] Adding type for $__lldb_objc_class: {1}",
944  ClangUtil::ToString(interface_type));
945 
946  AddOneType(context, class_user_type);
947  return;
948  }
949  // This branch will get hit if we are executing code in the context of
950  // a function that claims to have an object pointer (through
951  // DW_AT_object_pointer?) but is not formally a method of the class.
952  // In that case, just look up the "self" variable in the current scope
953  // and use its type.
954 
955  VariableList *vars = frame->GetVariableList(false, nullptr);
956 
957  lldb::VariableSP self_var = vars->FindVariable(ConstString("self"));
958 
959  if (!self_var)
960  return;
961  if (!self_var->IsInScope(frame))
962  return;
963  if (!self_var->LocationIsValidForFrame(frame))
964  return;
965 
966  Type *self_type = self_var->GetType();
967 
968  if (!self_type)
969  return;
970 
971  CompilerType self_clang_type = self_type->GetFullCompilerType();
972 
973  if (TypeSystemClang::IsObjCClassType(self_clang_type)) {
974  return;
975  }
976  if (!TypeSystemClang::IsObjCObjectPointerType(self_clang_type))
977  return;
978  self_clang_type = self_clang_type.GetPointeeType();
979 
980  if (!self_clang_type)
981  return;
982 
983  LLDB_LOG(log, " FEVD[{0}] Adding type for $__lldb_objc_class: {1}",
985 
986  TypeFromUser class_user_type(self_clang_type);
987 
988  AddOneType(context, class_user_type);
989 }
990 
992  SymbolContext &sym_ctx, NameSearchContext &name_context) {
993  if (sym_ctx.block == nullptr)
994  return;
995 
996  CompilerDeclContext frame_decl_context = sym_ctx.block->GetDeclContext();
997  if (!frame_decl_context)
998  return;
999 
1000  TypeSystemClang *frame_ast = llvm::dyn_cast_or_null<TypeSystemClang>(
1001  frame_decl_context.GetTypeSystem());
1002  if (!frame_ast)
1003  return;
1004 
1005  clang::NamespaceDecl *namespace_decl =
1008  if (!namespace_decl)
1009  return;
1010 
1011  name_context.AddNamedDecl(namespace_decl);
1012  clang::DeclContext *ctxt = clang::Decl::castToDeclContext(namespace_decl);
1013  ctxt->setHasExternalVisibleStorage(true);
1014  name_context.m_found_local_vars_nsp = true;
1015 }
1016 
1018  NameSearchContext &context, ConstString name) {
1020 
1021  if (!m_target)
1022  return;
1023 
1024  std::shared_ptr<ClangModulesDeclVendor> modules_decl_vendor =
1026  if (!modules_decl_vendor)
1027  return;
1028 
1029  bool append = false;
1030  uint32_t max_matches = 1;
1031  std::vector<clang::NamedDecl *> decls;
1032 
1033  if (!modules_decl_vendor->FindDecls(name, append, max_matches, decls))
1034  return;
1035 
1036  assert(!decls.empty() && "FindDecls returned true but no decls?");
1037  clang::NamedDecl *const decl_from_modules = decls[0];
1038 
1039  LLDB_LOG(log,
1040  " CAS::FEVD Matching decl found for "
1041  "\"{0}\" in the modules",
1042  name);
1043 
1044  clang::Decl *copied_decl = CopyDecl(decl_from_modules);
1045  if (!copied_decl) {
1046  LLDB_LOG(log, " CAS::FEVD - Couldn't export a "
1047  "declaration from the modules");
1048  return;
1049  }
1050 
1051  if (auto copied_function = dyn_cast<clang::FunctionDecl>(copied_decl)) {
1052  MaybeRegisterFunctionBody(copied_function);
1053 
1054  context.AddNamedDecl(copied_function);
1055 
1056  context.m_found_function_with_type_info = true;
1057  context.m_found_function = true;
1058  } else if (auto copied_var = dyn_cast<clang::VarDecl>(copied_decl)) {
1059  context.AddNamedDecl(copied_var);
1060  context.m_found_variable = true;
1061  }
1062 }
1063 
1065  NameSearchContext &context, ConstString name, SymbolContext &sym_ctx,
1066  const CompilerDeclContext &namespace_decl) {
1067  if (sym_ctx.block == nullptr)
1068  return false;
1069 
1070  CompilerDeclContext decl_context = sym_ctx.block->GetDeclContext();
1071  if (!decl_context)
1072  return false;
1073 
1074  // Make sure that the variables are parsed so that we have the
1075  // declarations.
1076  StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
1077  VariableListSP vars = frame->GetInScopeVariableList(true);
1078  for (size_t i = 0; i < vars->GetSize(); i++)
1079  vars->GetVariableAtIndex(i)->GetDecl();
1080 
1081  // Search for declarations matching the name. Do not include imported
1082  // decls in the search if we are looking for decls in the artificial
1083  // namespace $__lldb_local_vars.
1084  std::vector<CompilerDecl> found_decls =
1085  decl_context.FindDeclByName(name, namespace_decl.IsValid());
1086 
1087  VariableSP var;
1088  bool variable_found = false;
1089  for (CompilerDecl decl : found_decls) {
1090  for (size_t vi = 0, ve = vars->GetSize(); vi != ve; ++vi) {
1091  VariableSP candidate_var = vars->GetVariableAtIndex(vi);
1092  if (candidate_var->GetDecl() == decl) {
1093  var = candidate_var;
1094  break;
1095  }
1096  }
1097 
1098  if (var && !variable_found) {
1099  variable_found = true;
1100  ValueObjectSP valobj = ValueObjectVariable::Create(frame, var);
1101  AddOneVariable(context, var, valobj);
1102  context.m_found_variable = true;
1103  }
1104  }
1105 
1106  // We're in a local_var_lookup but haven't found any local variables
1107  // so far. When performing a variable lookup from within the context of
1108  // a lambda, we count the lambda captures as local variables. Thus,
1109  // see if we captured any variables with the requested 'name'.
1110  if (!variable_found) {
1111  auto find_capture = [](ConstString varname,
1112  StackFrame *frame) -> ValueObjectSP {
1113  if (auto lambda = ClangExpressionUtil::GetLambdaValueObject(frame)) {
1114  if (auto capture = lambda->GetChildMemberWithName(varname, true)) {
1115  return capture;
1116  }
1117  }
1118 
1119  return nullptr;
1120  };
1121 
1122  if (auto capture = find_capture(name, frame)) {
1123  variable_found = true;
1124  context.m_found_variable = true;
1125  AddOneVariable(context, std::move(capture), std::move(find_capture));
1126  }
1127  }
1128 
1129  return variable_found;
1130 }
1131 
1132 /// Structure to hold the info needed when comparing function
1133 /// declarations.
1134 namespace {
1135 struct FuncDeclInfo {
1136  ConstString m_name;
1137  CompilerType m_copied_type;
1138  uint32_t m_decl_lvl;
1139  SymbolContext m_sym_ctx;
1140 };
1141 } // namespace
1142 
1144  const SymbolContextList &sc_list,
1145  const CompilerDeclContext &frame_decl_context) {
1146  // First, symplify things by looping through the symbol contexts to
1147  // remove unwanted functions and separate out the functions we want to
1148  // compare and prune into a separate list. Cache the info needed about
1149  // the function declarations in a vector for efficiency.
1150  uint32_t num_indices = sc_list.GetSize();
1151  SymbolContextList sc_sym_list;
1152  std::vector<FuncDeclInfo> decl_infos;
1153  decl_infos.reserve(num_indices);
1154  clang::DeclContext *frame_decl_ctx =
1155  (clang::DeclContext *)frame_decl_context.GetOpaqueDeclContext();
1156  TypeSystemClang *ast = llvm::dyn_cast_or_null<TypeSystemClang>(
1157  frame_decl_context.GetTypeSystem());
1158 
1159  for (uint32_t index = 0; index < num_indices; ++index) {
1160  FuncDeclInfo fdi;
1161  SymbolContext sym_ctx;
1162  sc_list.GetContextAtIndex(index, sym_ctx);
1163 
1164  // We don't know enough about symbols to compare them, but we should
1165  // keep them in the list.
1166  Function *function = sym_ctx.function;
1167  if (!function) {
1168  sc_sym_list.Append(sym_ctx);
1169  continue;
1170  }
1171  // Filter out functions without declaration contexts, as well as
1172  // class/instance methods, since they'll be skipped in the code that
1173  // follows anyway.
1174  CompilerDeclContext func_decl_context = function->GetDeclContext();
1175  if (!func_decl_context ||
1176  func_decl_context.IsClassMethod(nullptr, nullptr, nullptr))
1177  continue;
1178  // We can only prune functions for which we can copy the type.
1179  CompilerType func_clang_type = function->GetType()->GetFullCompilerType();
1180  CompilerType copied_func_type = GuardedCopyType(func_clang_type);
1181  if (!copied_func_type) {
1182  sc_sym_list.Append(sym_ctx);
1183  continue;
1184  }
1185 
1186  fdi.m_sym_ctx = sym_ctx;
1187  fdi.m_name = function->GetName();
1188  fdi.m_copied_type = copied_func_type;
1189  fdi.m_decl_lvl = LLDB_INVALID_DECL_LEVEL;
1190  if (fdi.m_copied_type && func_decl_context) {
1191  // Call CountDeclLevels to get the number of parent scopes we have
1192  // to look through before we find the function declaration. When
1193  // comparing functions of the same type, the one with a lower count
1194  // will be closer to us in the lookup scope and shadows the other.
1195  clang::DeclContext *func_decl_ctx =
1196  (clang::DeclContext *)func_decl_context.GetOpaqueDeclContext();
1197  fdi.m_decl_lvl = ast->CountDeclLevels(frame_decl_ctx, func_decl_ctx,
1198  &fdi.m_name, &fdi.m_copied_type);
1199  }
1200  decl_infos.emplace_back(fdi);
1201  }
1202 
1203  // Loop through the functions in our cache looking for matching types,
1204  // then compare their scope levels to see which is closer.
1205  std::multimap<CompilerType, const FuncDeclInfo *> matches;
1206  for (const FuncDeclInfo &fdi : decl_infos) {
1207  const CompilerType t = fdi.m_copied_type;
1208  auto q = matches.find(t);
1209  if (q != matches.end()) {
1210  if (q->second->m_decl_lvl > fdi.m_decl_lvl)
1211  // This function is closer; remove the old set.
1212  matches.erase(t);
1213  else if (q->second->m_decl_lvl < fdi.m_decl_lvl)
1214  // The functions in our set are closer - skip this one.
1215  continue;
1216  }
1217  matches.insert(std::make_pair(t, &fdi));
1218  }
1219 
1220  // Loop through our matches and add their symbol contexts to our list.
1221  SymbolContextList sc_func_list;
1222  for (const auto &q : matches)
1223  sc_func_list.Append(q.second->m_sym_ctx);
1224 
1225  // Rejoin the lists with the functions in front.
1226  sc_func_list.Append(sc_sym_list);
1227  return sc_func_list;
1228 }
1229 
1231  NameSearchContext &context, lldb::ModuleSP module_sp, ConstString name,
1232  const CompilerDeclContext &namespace_decl) {
1233  if (!m_parser_vars)
1234  return;
1235 
1236  Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
1237 
1238  std::vector<clang::NamedDecl *> decls_from_modules;
1239 
1240  if (target) {
1241  if (std::shared_ptr<ClangModulesDeclVendor> decl_vendor =
1243  decl_vendor->FindDecls(name, false, UINT32_MAX, decls_from_modules);
1244  }
1245  }
1246 
1247  SymbolContextList sc_list;
1248  if (namespace_decl && module_sp) {
1249  ModuleFunctionSearchOptions function_options;
1250  function_options.include_inlines = false;
1251  function_options.include_symbols = false;
1252 
1253  module_sp->FindFunctions(name, namespace_decl, eFunctionNameTypeBase,
1254  function_options, sc_list);
1255  } else if (target && !namespace_decl) {
1256  ModuleFunctionSearchOptions function_options;
1257  function_options.include_inlines = false;
1258  function_options.include_symbols = true;
1259 
1260  // TODO Fix FindFunctions so that it doesn't return
1261  // instance methods for eFunctionNameTypeBase.
1262 
1263  target->GetImages().FindFunctions(
1264  name, eFunctionNameTypeFull | eFunctionNameTypeBase, function_options,
1265  sc_list);
1266  }
1267 
1268  // If we found more than one function, see if we can use the frame's decl
1269  // context to remove functions that are shadowed by other functions which
1270  // match in type but are nearer in scope.
1271  //
1272  // AddOneFunction will not add a function whose type has already been
1273  // added, so if there's another function in the list with a matching type,
1274  // check to see if their decl context is a parent of the current frame's or
1275  // was imported via a and using statement, and pick the best match
1276  // according to lookup rules.
1277  if (sc_list.GetSize() > 1) {
1278  // Collect some info about our frame's context.
1279  StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
1280  SymbolContext frame_sym_ctx;
1281  if (frame != nullptr)
1282  frame_sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction |
1283  lldb::eSymbolContextBlock);
1284  CompilerDeclContext frame_decl_context =
1285  frame_sym_ctx.block != nullptr ? frame_sym_ctx.block->GetDeclContext()
1286  : CompilerDeclContext();
1287 
1288  // We can't do this without a compiler decl context for our frame.
1289  if (frame_decl_context) {
1290  sc_list = SearchFunctionsInSymbolContexts(sc_list, frame_decl_context);
1291  }
1292  }
1293 
1294  if (sc_list.GetSize()) {
1295  Symbol *extern_symbol = nullptr;
1296  Symbol *non_extern_symbol = nullptr;
1297 
1298  for (uint32_t index = 0, num_indices = sc_list.GetSize();
1299  index < num_indices; ++index) {
1300  SymbolContext sym_ctx;
1301  sc_list.GetContextAtIndex(index, sym_ctx);
1302 
1303  if (sym_ctx.function) {
1304  CompilerDeclContext decl_ctx = sym_ctx.function->GetDeclContext();
1305 
1306  if (!decl_ctx)
1307  continue;
1308 
1309  // Filter out class/instance methods.
1310  if (decl_ctx.IsClassMethod(nullptr, nullptr, nullptr))
1311  continue;
1312 
1313  AddOneFunction(context, sym_ctx.function, nullptr);
1314  context.m_found_function_with_type_info = true;
1315  context.m_found_function = true;
1316  } else if (sym_ctx.symbol) {
1317  if (sym_ctx.symbol->GetType() == eSymbolTypeReExported && target) {
1318  sym_ctx.symbol = sym_ctx.symbol->ResolveReExportedSymbol(*target);
1319  if (sym_ctx.symbol == nullptr)
1320  continue;
1321  }
1322 
1323  if (sym_ctx.symbol->IsExternal())
1324  extern_symbol = sym_ctx.symbol;
1325  else
1326  non_extern_symbol = sym_ctx.symbol;
1327  }
1328  }
1329 
1330  if (!context.m_found_function_with_type_info) {
1331  for (clang::NamedDecl *decl : decls_from_modules) {
1332  if (llvm::isa<clang::FunctionDecl>(decl)) {
1333  clang::NamedDecl *copied_decl =
1334  llvm::cast_or_null<FunctionDecl>(CopyDecl(decl));
1335  if (copied_decl) {
1336  context.AddNamedDecl(copied_decl);
1337  context.m_found_function_with_type_info = true;
1338  }
1339  }
1340  }
1341  }
1342 
1343  if (!context.m_found_function_with_type_info) {
1344  if (extern_symbol) {
1345  AddOneFunction(context, nullptr, extern_symbol);
1346  context.m_found_function = true;
1347  } else if (non_extern_symbol) {
1348  AddOneFunction(context, nullptr, non_extern_symbol);
1349  context.m_found_function = true;
1350  }
1351  }
1352  }
1353 }
1354 
1356  NameSearchContext &context, lldb::ModuleSP module_sp,
1357  const CompilerDeclContext &namespace_decl) {
1358  assert(m_ast_context);
1359 
1361 
1362  const ConstString name(context.m_decl_name.getAsString().c_str());
1363  if (IgnoreName(name, false))
1364  return;
1365 
1366  // Only look for functions by name out in our symbols if the function doesn't
1367  // start with our phony prefix of '$'
1368 
1369  Target *target = nullptr;
1370  StackFrame *frame = nullptr;
1371  SymbolContext sym_ctx;
1372  if (m_parser_vars) {
1373  target = m_parser_vars->m_exe_ctx.GetTargetPtr();
1374  frame = m_parser_vars->m_exe_ctx.GetFramePtr();
1375  }
1376  if (frame != nullptr)
1377  sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction |
1378  lldb::eSymbolContextBlock);
1379 
1380  // Try the persistent decls, which take precedence over all else.
1381  if (!namespace_decl)
1382  SearchPersistenDecls(context, name);
1383 
1384  if (name.GetStringRef().startswith("$") && !namespace_decl) {
1385  if (name == "$__lldb_class") {
1386  LookUpLldbClass(context);
1387  return;
1388  }
1389 
1390  if (name == "$__lldb_objc_class") {
1391  LookUpLldbObjCClass(context);
1392  return;
1393  }
1394  if (name == g_lldb_local_vars_namespace_cstr) {
1395  LookupLocalVarNamespace(sym_ctx, context);
1396  return;
1397  }
1398 
1399  // any other $__lldb names should be weeded out now
1400  if (name.GetStringRef().startswith("$__lldb"))
1401  return;
1402 
1403  // No ParserVars means we can't do register or variable lookup.
1404  if (!m_parser_vars || !m_parser_vars->m_persistent_vars)
1405  return;
1406 
1407  ExpressionVariableSP pvar_sp(
1408  m_parser_vars->m_persistent_vars->GetVariable(name));
1409 
1410  if (pvar_sp) {
1411  AddOneVariable(context, pvar_sp);
1412  return;
1413  }
1414 
1415  assert(name.GetStringRef().startswith("$"));
1416  llvm::StringRef reg_name = name.GetStringRef().substr(1);
1417 
1418  if (m_parser_vars->m_exe_ctx.GetRegisterContext()) {
1419  const RegisterInfo *reg_info(
1420  m_parser_vars->m_exe_ctx.GetRegisterContext()->GetRegisterInfoByName(
1421  reg_name));
1422 
1423  if (reg_info) {
1424  LLDB_LOG(log, " CEDM::FEVD Found register {0}", reg_info->name);
1425 
1426  AddOneRegister(context, reg_info);
1427  }
1428  }
1429  return;
1430  }
1431 
1432  bool local_var_lookup = !namespace_decl || (namespace_decl.GetName() ==
1434  if (frame && local_var_lookup)
1435  if (LookupLocalVariable(context, name, sym_ctx, namespace_decl))
1436  return;
1437 
1438  if (target) {
1439  ValueObjectSP valobj;
1440  VariableSP var;
1441  var = FindGlobalVariable(*target, module_sp, name, namespace_decl);
1442 
1443  if (var) {
1444  valobj = ValueObjectVariable::Create(target, var);
1445  AddOneVariable(context, var, valobj);
1446  context.m_found_variable = true;
1447  return;
1448  }
1449  }
1450 
1451  LookupFunction(context, module_sp, name, namespace_decl);
1452 
1453  // Try the modules next.
1454  if (!context.m_found_function_with_type_info)
1455  LookupInModulesDeclVendor(context, name);
1456 
1457  if (target && !context.m_found_variable && !namespace_decl) {
1458  // We couldn't find a non-symbol variable for this. Now we'll hunt for a
1459  // generic data symbol, and -- if it is found -- treat it as a variable.
1460  Status error;
1461 
1462  const Symbol *data_symbol =
1463  m_parser_vars->m_sym_ctx.FindBestGlobalDataSymbol(name, error);
1464 
1465  if (!error.Success()) {
1466  const unsigned diag_id =
1467  m_ast_context->getDiagnostics().getCustomDiagID(
1469  m_ast_context->getDiagnostics().Report(diag_id) << error.AsCString();
1470  }
1471 
1472  if (data_symbol) {
1473  std::string warning("got name from symbols: ");
1474  warning.append(name.AsCString());
1475  const unsigned diag_id =
1476  m_ast_context->getDiagnostics().getCustomDiagID(
1477  clang::DiagnosticsEngine::Level::Warning, "%0");
1478  m_ast_context->getDiagnostics().Report(diag_id) << warning.c_str();
1479  AddOneGenericVariable(context, *data_symbol);
1480  context.m_found_variable = true;
1481  }
1482  }
1483 }
1484 
1486  lldb_private::Value &var_location,
1487  TypeFromUser *user_type,
1488  TypeFromParser *parser_type) {
1490 
1491  Type *var_type = var->GetType();
1492 
1493  if (!var_type) {
1494  LLDB_LOG(log, "Skipped a definition because it has no type");
1495  return false;
1496  }
1497 
1498  CompilerType var_clang_type = var_type->GetFullCompilerType();
1499 
1500  if (!var_clang_type) {
1501  LLDB_LOG(log, "Skipped a definition because it has no Clang type");
1502  return false;
1503  }
1504 
1505  auto ts = var_type->GetForwardCompilerType().GetTypeSystem();
1506  auto clang_ast = ts.dyn_cast_or_null<TypeSystemClang>();
1507 
1508  if (!clang_ast) {
1509  LLDB_LOG(log, "Skipped a definition because it has no Clang AST");
1510  return false;
1511  }
1512 
1513  DWARFExpressionList &var_location_list = var->LocationExpressionList();
1514 
1515  Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
1516  Status err;
1517 
1518  if (var->GetLocationIsConstantValueData()) {
1519  DataExtractor const_value_extractor;
1520  if (var_location_list.GetExpressionData(const_value_extractor)) {
1521  var_location = Value(const_value_extractor.GetDataStart(),
1522  const_value_extractor.GetByteSize());
1524  } else {
1525  LLDB_LOG(log, "Error evaluating constant variable: {0}", err.AsCString());
1526  return false;
1527  }
1528  }
1529 
1530  CompilerType type_to_use = GuardedCopyType(var_clang_type);
1531 
1532  if (!type_to_use) {
1533  LLDB_LOG(log,
1534  "Couldn't copy a variable's type into the parser's AST context");
1535 
1536  return false;
1537  }
1538 
1539  if (parser_type)
1540  *parser_type = TypeFromParser(type_to_use);
1541 
1542  if (var_location.GetContextType() == Value::ContextType::Invalid)
1543  var_location.SetCompilerType(type_to_use);
1544 
1545  if (var_location.GetValueType() == Value::ValueType::FileAddress) {
1546  SymbolContext var_sc;
1547  var->CalculateSymbolContext(&var_sc);
1548 
1549  if (!var_sc.module_sp)
1550  return false;
1551 
1552  Address so_addr(var_location.GetScalar().ULongLong(),
1553  var_sc.module_sp->GetSectionList());
1554 
1555  lldb::addr_t load_addr = so_addr.GetLoadAddress(target);
1556 
1557  if (load_addr != LLDB_INVALID_ADDRESS) {
1558  var_location.GetScalar() = load_addr;
1560  }
1561  }
1562 
1563  if (user_type)
1564  *user_type = TypeFromUser(var_clang_type);
1565 
1566  return true;
1567 }
1568 
1571  TypeFromParser const &pt,
1572  ValueObjectSP valobj) {
1573  clang::QualType parser_opaque_type =
1574  QualType::getFromOpaquePtr(pt.GetOpaqueQualType());
1575 
1576  if (parser_opaque_type.isNull())
1577  return nullptr;
1578 
1579  if (const clang::Type *parser_type = parser_opaque_type.getTypePtr()) {
1580  if (const TagType *tag_type = dyn_cast<TagType>(parser_type))
1581  CompleteType(tag_type->getDecl());
1582  if (const ObjCObjectPointerType *objc_object_ptr_type =
1583  dyn_cast<ObjCObjectPointerType>(parser_type))
1584  CompleteType(objc_object_ptr_type->getInterfaceDecl());
1585  }
1586 
1587  bool is_reference = pt.IsReferenceType();
1588 
1589  NamedDecl *var_decl = nullptr;
1590  if (is_reference)
1591  var_decl = context.AddVarDecl(pt);
1592  else
1593  var_decl = context.AddVarDecl(pt.GetLValueReferenceType());
1594 
1595  std::string decl_name(context.m_decl_name.getAsString());
1596  ConstString entity_name(decl_name.c_str());
1597  ClangExpressionVariable *entity(new ClangExpressionVariable(valobj));
1599 
1600  assert(entity);
1601  entity->EnableParserVars(GetParserID());
1603  entity->GetParserVars(GetParserID());
1604 
1605  parser_vars->m_named_decl = var_decl;
1606 
1607  if (is_reference)
1609 
1610  return parser_vars;
1611 }
1612 
1614  NameSearchContext &context, ValueObjectSP valobj,
1615  ValueObjectProviderTy valobj_provider) {
1616  assert(m_parser_vars.get());
1617  assert(valobj);
1618 
1620 
1621  Value var_location = valobj->GetValue();
1622 
1623  TypeFromUser user_type = valobj->GetCompilerType();
1624 
1625  auto clang_ast =
1627 
1628  if (!clang_ast) {
1629  LLDB_LOG(log, "Skipped a definition because it has no Clang AST");
1630  return;
1631  }
1632 
1633  TypeFromParser parser_type = GuardedCopyType(user_type);
1634 
1635  if (!parser_type) {
1636  LLDB_LOG(log,
1637  "Couldn't copy a variable's type into the parser's AST context");
1638 
1639  return;
1640  }
1641 
1642  if (var_location.GetContextType() == Value::ContextType::Invalid)
1643  var_location.SetCompilerType(parser_type);
1644 
1646  AddExpressionVariable(context, parser_type, valobj);
1647 
1648  if (!parser_vars)
1649  return;
1650 
1651  LLDB_LOG(log, " CEDM::FEVD Found variable {0}, returned\n{1} (original {2})",
1652  context.m_decl_name, ClangUtil::DumpDecl(parser_vars->m_named_decl),
1653  ClangUtil::ToString(user_type));
1654 
1655  parser_vars->m_llvm_value = nullptr;
1656  parser_vars->m_lldb_value = std::move(var_location);
1657  parser_vars->m_lldb_valobj_provider = std::move(valobj_provider);
1658 }
1659 
1661  VariableSP var,
1662  ValueObjectSP valobj) {
1663  assert(m_parser_vars.get());
1664 
1666 
1667  TypeFromUser ut;
1668  TypeFromParser pt;
1669  Value var_location;
1670 
1671  if (!GetVariableValue(var, var_location, &ut, &pt))
1672  return;
1673 
1675  AddExpressionVariable(context, pt, std::move(valobj));
1676 
1677  if (!parser_vars)
1678  return;
1679 
1680  LLDB_LOG(log, " CEDM::FEVD Found variable {0}, returned\n{1} (original {2})",
1681  context.m_decl_name, ClangUtil::DumpDecl(parser_vars->m_named_decl),
1682  ClangUtil::ToString(ut));
1683 
1684  parser_vars->m_llvm_value = nullptr;
1685  parser_vars->m_lldb_value = var_location;
1686  parser_vars->m_lldb_var = var;
1687 }
1688 
1690  ExpressionVariableSP &pvar_sp) {
1692 
1693  TypeFromUser user_type(
1694  llvm::cast<ClangExpressionVariable>(pvar_sp.get())->GetTypeFromUser());
1695 
1696  TypeFromParser parser_type(GuardedCopyType(user_type));
1697 
1698  if (!parser_type.GetOpaqueQualType()) {
1699  LLDB_LOG(log, " CEDM::FEVD Couldn't import type for pvar {0}",
1700  pvar_sp->GetName());
1701  return;
1702  }
1703 
1704  NamedDecl *var_decl =
1705  context.AddVarDecl(parser_type.GetLValueReferenceType());
1706 
1707  llvm::cast<ClangExpressionVariable>(pvar_sp.get())
1708  ->EnableParserVars(GetParserID());
1710  llvm::cast<ClangExpressionVariable>(pvar_sp.get())
1711  ->GetParserVars(GetParserID());
1712  parser_vars->m_named_decl = var_decl;
1713  parser_vars->m_llvm_value = nullptr;
1714  parser_vars->m_lldb_value.Clear();
1715 
1716  LLDB_LOG(log, " CEDM::FEVD Added pvar {0}, returned\n{1}",
1717  pvar_sp->GetName(), ClangUtil::DumpDecl(var_decl));
1718 }
1719 
1721  const Symbol &symbol) {
1722  assert(m_parser_vars.get());
1723 
1725 
1726  Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
1727 
1728  if (target == nullptr)
1729  return;
1730 
1731  auto scratch_ast_context = GetScratchContext(*target);
1732  if (!scratch_ast_context)
1733  return;
1734 
1735  TypeFromUser user_type(scratch_ast_context->GetBasicType(eBasicTypeVoid)
1736  .GetPointerType()
1737  .GetLValueReferenceType());
1739  .GetPointerType()
1741  NamedDecl *var_decl = context.AddVarDecl(parser_type);
1742 
1743  std::string decl_name(context.m_decl_name.getAsString());
1744  ConstString entity_name(decl_name.c_str());
1746  m_parser_vars->m_exe_ctx.GetBestExecutionContextScope(), entity_name,
1747  user_type, m_parser_vars->m_target_info.byte_order,
1748  m_parser_vars->m_target_info.address_byte_size));
1750 
1751  entity->EnableParserVars(GetParserID());
1753  entity->GetParserVars(GetParserID());
1754 
1755  const Address symbol_address = symbol.GetAddress();
1756  lldb::addr_t symbol_load_addr = symbol_address.GetLoadAddress(target);
1757 
1758  // parser_vars->m_lldb_value.SetContext(Value::ContextType::ClangType,
1759  // user_type.GetOpaqueQualType());
1760  parser_vars->m_lldb_value.SetCompilerType(user_type);
1761  parser_vars->m_lldb_value.GetScalar() = symbol_load_addr;
1763 
1764  parser_vars->m_named_decl = var_decl;
1765  parser_vars->m_llvm_value = nullptr;
1766  parser_vars->m_lldb_sym = &symbol;
1767 
1768  LLDB_LOG(log, " CEDM::FEVD Found variable {0}, returned\n{1}", decl_name,
1769  ClangUtil::DumpDecl(var_decl));
1770 }
1771 
1773  const RegisterInfo *reg_info) {
1775 
1776  CompilerType clang_type =
1778  reg_info->encoding, reg_info->byte_size * 8);
1779 
1780  if (!clang_type) {
1781  LLDB_LOG(log, " Tried to add a type for {0}, but couldn't get one",
1782  context.m_decl_name.getAsString());
1783  return;
1784  }
1785 
1786  TypeFromParser parser_clang_type(clang_type);
1787 
1788  NamedDecl *var_decl = context.AddVarDecl(parser_clang_type);
1789 
1791  m_parser_vars->m_exe_ctx.GetBestExecutionContextScope(),
1792  m_parser_vars->m_target_info.byte_order,
1793  m_parser_vars->m_target_info.address_byte_size));
1795 
1796  std::string decl_name(context.m_decl_name.getAsString());
1797  entity->SetName(ConstString(decl_name.c_str()));
1798  entity->SetRegisterInfo(reg_info);
1799  entity->EnableParserVars(GetParserID());
1801  entity->GetParserVars(GetParserID());
1802  parser_vars->m_named_decl = var_decl;
1803  parser_vars->m_llvm_value = nullptr;
1804  parser_vars->m_lldb_value.Clear();
1806 
1807  LLDB_LOG(log, " CEDM::FEVD Added register {0}, returned\n{1}",
1808  context.m_decl_name.getAsString(), ClangUtil::DumpDecl(var_decl));
1809 }
1810 
1812  Function *function,
1813  Symbol *symbol) {
1814  assert(m_parser_vars.get());
1815 
1817 
1818  NamedDecl *function_decl = nullptr;
1819  Address fun_address;
1820  CompilerType function_clang_type;
1821 
1822  bool is_indirect_function = false;
1823 
1824  if (function) {
1825  Type *function_type = function->GetType();
1826 
1827  const auto lang = function->GetCompileUnit()->GetLanguage();
1828  const auto name = function->GetMangled().GetMangledName().AsCString();
1829  const bool extern_c = (Language::LanguageIsC(lang) &&
1831  (Language::LanguageIsObjC(lang) &&
1833 
1834  if (!extern_c) {
1835  TypeSystem *type_system = function->GetDeclContext().GetTypeSystem();
1836  if (llvm::isa<TypeSystemClang>(type_system)) {
1837  clang::DeclContext *src_decl_context =
1838  (clang::DeclContext *)function->GetDeclContext()
1839  .GetOpaqueDeclContext();
1840  clang::FunctionDecl *src_function_decl =
1841  llvm::dyn_cast_or_null<clang::FunctionDecl>(src_decl_context);
1842  if (src_function_decl &&
1843  src_function_decl->getTemplateSpecializationInfo()) {
1844  clang::FunctionTemplateDecl *function_template =
1845  src_function_decl->getTemplateSpecializationInfo()->getTemplate();
1846  clang::FunctionTemplateDecl *copied_function_template =
1847  llvm::dyn_cast_or_null<clang::FunctionTemplateDecl>(
1848  CopyDecl(function_template));
1849  if (copied_function_template) {
1850  if (log) {
1851  StreamString ss;
1852 
1853  function->DumpSymbolContext(&ss);
1854 
1855  LLDB_LOG(log,
1856  " CEDM::FEVD Imported decl for function template"
1857  " {0} (description {1}), returned\n{2}",
1858  copied_function_template->getNameAsString(),
1859  ss.GetData(),
1860  ClangUtil::DumpDecl(copied_function_template));
1861  }
1862 
1863  context.AddNamedDecl(copied_function_template);
1864  }
1865  } else if (src_function_decl) {
1866  if (clang::FunctionDecl *copied_function_decl =
1867  llvm::dyn_cast_or_null<clang::FunctionDecl>(
1868  CopyDecl(src_function_decl))) {
1869  if (log) {
1870  StreamString ss;
1871 
1872  function->DumpSymbolContext(&ss);
1873 
1874  LLDB_LOG(log,
1875  " CEDM::FEVD Imported decl for function {0} "
1876  "(description {1}), returned\n{2}",
1877  copied_function_decl->getNameAsString(), ss.GetData(),
1878  ClangUtil::DumpDecl(copied_function_decl));
1879  }
1880 
1881  context.AddNamedDecl(copied_function_decl);
1882  return;
1883  } else {
1884  LLDB_LOG(log, " Failed to import the function decl for '{0}'",
1885  src_function_decl->getName());
1886  }
1887  }
1888  }
1889  }
1890 
1891  if (!function_type) {
1892  LLDB_LOG(log, " Skipped a function because it has no type");
1893  return;
1894  }
1895 
1896  function_clang_type = function_type->GetFullCompilerType();
1897 
1898  if (!function_clang_type) {
1899  LLDB_LOG(log, " Skipped a function because it has no Clang type");
1900  return;
1901  }
1902 
1903  fun_address = function->GetAddressRange().GetBaseAddress();
1904 
1905  CompilerType copied_function_type = GuardedCopyType(function_clang_type);
1906  if (copied_function_type) {
1907  function_decl = context.AddFunDecl(copied_function_type, extern_c);
1908 
1909  if (!function_decl) {
1910  LLDB_LOG(log, " Failed to create a function decl for '{0}' ({1:x})",
1911  function_type->GetName(), function_type->GetID());
1912 
1913  return;
1914  }
1915  } else {
1916  // We failed to copy the type we found
1917  LLDB_LOG(log,
1918  " Failed to import the function type '{0}' ({1:x})"
1919  " into the expression parser AST context",
1920  function_type->GetName(), function_type->GetID());
1921 
1922  return;
1923  }
1924  } else if (symbol) {
1925  fun_address = symbol->GetAddress();
1926  function_decl = context.AddGenericFunDecl();
1927  is_indirect_function = symbol->IsIndirect();
1928  } else {
1929  LLDB_LOG(log, " AddOneFunction called with no function and no symbol");
1930  return;
1931  }
1932 
1933  Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
1934 
1935  lldb::addr_t load_addr =
1936  fun_address.GetCallableLoadAddress(target, is_indirect_function);
1937 
1939  m_parser_vars->m_exe_ctx.GetBestExecutionContextScope(),
1940  m_parser_vars->m_target_info.byte_order,
1941  m_parser_vars->m_target_info.address_byte_size));
1943 
1944  std::string decl_name(context.m_decl_name.getAsString());
1945  entity->SetName(ConstString(decl_name.c_str()));
1946  entity->SetCompilerType(function_clang_type);
1947  entity->EnableParserVars(GetParserID());
1948 
1950  entity->GetParserVars(GetParserID());
1951 
1952  if (load_addr != LLDB_INVALID_ADDRESS) {
1954  parser_vars->m_lldb_value.GetScalar() = load_addr;
1955  } else {
1956  // We have to try finding a file address.
1957 
1958  lldb::addr_t file_addr = fun_address.GetFileAddress();
1959 
1961  parser_vars->m_lldb_value.GetScalar() = file_addr;
1962  }
1963 
1964  parser_vars->m_named_decl = function_decl;
1965  parser_vars->m_llvm_value = nullptr;
1966 
1967  if (log) {
1968  StreamString ss;
1969 
1970  fun_address.Dump(&ss,
1971  m_parser_vars->m_exe_ctx.GetBestExecutionContextScope(),
1973 
1974  LLDB_LOG(log,
1975  " CEDM::FEVD Found {0} function {1} (description {2}), "
1976  "returned\n{3}",
1977  (function ? "specific" : "generic"), decl_name, ss.GetData(),
1978  ClangUtil::DumpDecl(function_decl));
1979  }
1980 }
1981 
1983  const TypeFromUser &ut) {
1984  CompilerType copied_clang_type = GuardedCopyType(ut);
1985 
1987 
1988  if (!copied_clang_type) {
1989  LLDB_LOG(log,
1990  "ClangExpressionDeclMap::AddThisType - Couldn't import the type");
1991 
1992  return;
1993  }
1994 
1995  if (copied_clang_type.IsAggregateType() &&
1996  copied_clang_type.GetCompleteType()) {
1997  CompilerType void_clang_type =
1999  CompilerType void_ptr_clang_type = void_clang_type.GetPointerType();
2000 
2002  void_clang_type, &void_ptr_clang_type, 1, false, 0);
2003 
2004  const bool is_virtual = false;
2005  const bool is_static = false;
2006  const bool is_inline = false;
2007  const bool is_explicit = false;
2008  const bool is_attr_used = true;
2009  const bool is_artificial = false;
2010 
2011  CXXMethodDecl *method_decl = m_clang_ast_context->AddMethodToCXXRecordType(
2012  copied_clang_type.GetOpaqueQualType(), "$__lldb_expr", nullptr,
2013  method_type, lldb::eAccessPublic, is_virtual, is_static, is_inline,
2014  is_explicit, is_attr_used, is_artificial);
2015 
2016  LLDB_LOG(log,
2017  " CEDM::AddThisType Added function $__lldb_expr "
2018  "(description {0}) for this type\n{1}",
2019  ClangUtil::ToString(copied_clang_type),
2020  ClangUtil::DumpDecl(method_decl));
2021  }
2022 
2023  if (!copied_clang_type.IsValid())
2024  return;
2025 
2026  TypeSourceInfo *type_source_info = m_ast_context->getTrivialTypeSourceInfo(
2027  QualType::getFromOpaquePtr(copied_clang_type.GetOpaqueQualType()));
2028 
2029  if (!type_source_info)
2030  return;
2031 
2032  // Construct a typedef type because if "*this" is a templated type we can't
2033  // just return ClassTemplateSpecializationDecls in response to name queries.
2034  // Using a typedef makes this much more robust.
2035 
2036  TypedefDecl *typedef_decl = TypedefDecl::Create(
2037  *m_ast_context, m_ast_context->getTranslationUnitDecl(), SourceLocation(),
2038  SourceLocation(), context.m_decl_name.getAsIdentifierInfo(),
2039  type_source_info);
2040 
2041  if (!typedef_decl)
2042  return;
2043 
2044  context.AddNamedDecl(typedef_decl);
2045 }
2046 
2048  const TypeFromUser &ut) {
2049  CompilerType copied_clang_type = GuardedCopyType(ut);
2050 
2051  if (!copied_clang_type) {
2053 
2054  LLDB_LOG(log,
2055  "ClangExpressionDeclMap::AddOneType - Couldn't import the type");
2056 
2057  return;
2058  }
2059 
2060  context.AddTypeDecl(copied_clang_type);
2061 }
lldb_private::ExpressionVariableList::GetSize
size_t GetSize()
Implementation of methods in ExpressionVariableListBase.
Definition: ExpressionVariable.h:124
lldb_private::ClangExpressionDeclMap::LookUpLldbClass
void LookUpLldbClass(NameSearchContext &context)
Handles looking up $__lldb_class which requires special treatment.
Definition: ClangExpressionDeclMap.cpp:784
lldb::eSymbolTypeCompiler
@ eSymbolTypeCompiler
Definition: lldb-enumerations.h:650
lldb_private::NameSearchContext::AddNamedDecl
void AddNamedDecl(clang::NamedDecl *decl)
Add a NamedDecl to the list of results.
Definition: NameSearchContext.cpp:178
lldb_private::SymbolContext::block
Block * block
The Block for a given query.
Definition: SymbolContext.h:321
lldb_private::ClangExpressionDeclMap::AddOneVariable
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...
lldb_private::ExecutionContext
Definition: ExecutionContext.h:292
lldb::eSymbolTypeParam
@ eSymbolTypeParam
Definition: lldb-enumerations.h:641
lldb_private::ArchSpec::GetByteOrder
lldb::ByteOrder GetByteOrder() const
Returns the byte order for the architecture specification.
Definition: ArchSpec.cpp:741
lldb::eSymbolTypeObjCIVar
@ eSymbolTypeObjCIVar
Definition: lldb-enumerations.h:655
lldb_private::CompilerDeclContext::FindDeclByName
std::vector< CompilerDecl > FindDeclByName(ConstString name, const bool ignore_using_decls)
Definition: CompilerDeclContext.cpp:17
lldb-private-types.h
lldb_private::ClangExpressionDeclMap::GetStructInfo
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...
Definition: ClangExpressionDeclMap.cpp:453
lldb_private::ExpressionVariable::EVTypeIsReference
@ EVTypeIsReference
The original type of this variable is a reference, so materialize the value rather than the location.
Definition: ExpressionVariable.h:99
lldb_private::ClangASTSource::FindExternalVisibleDecls
virtual void FindExternalVisibleDecls(NameSearchContext &context)
The worker function for FindExternalVisibleDeclsByName.
Definition: ClangASTSource.cpp:519
lldb_private::StackFrame::GetVariableList
VariableList * GetVariableList(bool get_file_globals, Status *error_ptr)
Retrieve the list of variables that are in scope at this StackFrame's pc.
Definition: StackFrame.cpp:424
lldb_private::ModuleSpec::GetPlatformFileSpec
FileSpec & GetPlatformFileSpec()
Definition: ModuleSpec.h:65
lldb_private::ClangExpressionVariable::EnableJITVars
void EnableJITVars(uint64_t parser_id)
Make this variable usable for materializing for the JIT by allocating space for JIT-specific variable...
Definition: ClangExpressionVariable.h:182
lldb::eSymbolTypeHeaderFile
@ eSymbolTypeHeaderFile
Definition: lldb-enumerations.h:636
lldb_private::ClangASTSource::m_ast_context
clang::ASTContext * m_ast_context
The AST context requests are coming in for.
Definition: ClangASTSource.h:381
lldb_private::TypeSystemClang::getASTContext
clang::ASTContext & getASTContext()
Returns the clang::ASTContext instance managed by this TypeSystemClang.
Definition: TypeSystemClang.cpp:689
lldb_private::ClangExpressionVariable::ParserVars
The following values should not live beyond parsing.
Definition: ClangExpressionVariable.h:117
lldb_private::Address::IsValid
bool IsValid() const
Check if the object state is valid.
Definition: Address.h:345
lldb::eSymbolTypeCode
@ eSymbolTypeCode
Definition: lldb-enumerations.h:629
CPlusPlusLanguage.h
CompilerDecl.h
lldb_private::TypeSystemClang::CreateDeclContext
CompilerDeclContext CreateDeclContext(clang::DeclContext *ctx)
Creates a CompilerDeclContext from the given DeclContext with the current TypeSystemClang instance as...
Definition: TypeSystemClang.cpp:1202
ClangModulesDeclVendor.h
lldb_private::ClangASTSource::IgnoreName
bool IgnoreName(const ConstString name, bool ignore_all_dollar_names)
Returns true if a name should be ignored by name lookup.
Definition: ClangASTSource.cpp:579
CompileUnit.h
lldb::eSymbolTypeInstrumentation
@ eSymbolTypeInstrumentation
Definition: lldb-enumerations.h:651
ModuleSpec.h
lldb_private::ClangExpressionDeclMap::DisableParserVars
void DisableParserVars()
Deallocate parser-specific variables.
Definition: ClangExpressionDeclMap.h:352
lldb_private::ClangExpressionDeclMap::InstallCodeGenerator
void InstallCodeGenerator(clang::ASTConsumer *code_gen)
Definition: ClangExpressionDeclMap.cpp:144
lldb_private::ObjCLanguageRuntime
Definition: ObjCLanguageRuntime.h:36
lldb_private::Value::Clear
void Clear()
Definition: Value.cpp:608
lldb_private::Value
Definition: Value.h:38
lldb_private::Symbol
Definition: Symbol.h:20
lldb_private::Value::SetValueType
void SetValueType(ValueType value_type)
Definition: Value.h:89
lldb_private::ExecutionContext::GetProcessPtr
Process * GetProcessPtr() const
Returns a pointer to the process object.
Definition: ExecutionContext.cpp:206
lldb::eSymbolTypeInvalid
@ eSymbolTypeInvalid
Definition: lldb-enumerations.h:627
lldb_private::ClangExpressionDeclMap::GetVariableValue
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.
Definition: ClangExpressionDeclMap.cpp:1485
lldb::eSymbolTypeLineEntry
@ eSymbolTypeLineEntry
Definition: lldb-enumerations.h:644
lldb_private::ClangASTSource::m_target
const lldb::TargetSP m_target
The target to use in finding variables and types.
Definition: ClangASTSource.h:379
lldb_private::Value::ValueType::FileAddress
@ FileAddress
A file address value.
lldb_private::CompilerDeclContext::GetOpaqueDeclContext
void * GetOpaqueDeclContext() const
Definition: CompilerDeclContext.h:103
lldb_private::SymbolContextList::Append
void Append(const SymbolContext &sc)
Append a new symbol context to the list.
Definition: SymbolContext.cpp:1184
lldb_private::Value::GetValueType
ValueType GetValueType() const
Definition: Value.cpp:107
lldb_private::ClangUtil::ToString
static std::string ToString(const clang::Type *t)
Returns a textual representation of the given type.
Definition: ClangUtil.cpp:81
lldb_private::ClangExpressionDeclMap::m_result_delegate
Materializer::PersistentVariableDelegate * m_result_delegate
If non-NULL, used to report expression results to ClangUserExpression.
Definition: ClangExpressionDeclMap.h:302
lldb_private::ClangExpressionVariable
Definition: ClangExpressionVariable.h:60
lldb_private::NameSearchContext
Definition: NameSearchContext.h:26
lldb_private::ObjCLanguageRuntime::Get
static ObjCLanguageRuntime * Get(Process &process)
Definition: ObjCLanguageRuntime.h:215
lldb::eSymbolTypeCommonBlock
@ eSymbolTypeCommonBlock
Definition: lldb-enumerations.h:638
lldb::eSymbolTypeTrampoline
@ eSymbolTypeTrampoline
Definition: lldb-enumerations.h:632
lldb_private::Process
Definition: Process.h:338
lldb_private::TypeSystemClang::CreateFunctionType
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)
Definition: TypeSystemClang.cpp:2212
lldb_private::ExpressionVariable::EVIsLLDBAllocated
@ EVIsLLDBAllocated
This variable is resident in a location specifically allocated for it by LLDB in the target process.
Definition: ExpressionVariable.h:83
lldb_private::TypeSystemClang::GetBuiltinTypeForEncodingAndBitSize
CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size) override
Definition: TypeSystemClang.cpp:798
Module.h
lldb_private::ExpressionVariable::SetRegisterInfo
void SetRegisterInfo(const RegisterInfo *reg_info)
Definition: ExpressionVariable.h:50
lldb_private::ExpressionVariableList::AddNewlyConstructedVariable
lldb::ExpressionVariableSP AddNewlyConstructedVariable(ExpressionVariable *var)
Definition: ExpressionVariable.h:139
lldb_private::ClangExpressionDeclMap::SearchPersistenDecls
void SearchPersistenDecls(NameSearchContext &context, const ConstString name)
Searches the persistent decls of the target for entities with the given name.
Definition: ClangExpressionDeclMap.cpp:755
lldb_private::ClangExpressionVariable::EnableParserVars
void EnableParserVars(uint64_t parser_id)
Make this variable usable by the parser by allocating space for parser- specific variables.
Definition: ClangExpressionVariable.h:147
lldb_private::ExpressionVariable::GetRegisterInfo
RegisterInfo * GetRegisterInfo()
Definition: ExpressionVariable.h:46
lldb_private::VariableList::GetSize
size_t GetSize() const
Definition: VariableList.cpp:165
ClangExpressionUtil.h
lldb_private::VariableList::FindVariable
lldb::VariableSP FindVariable(ConstString name, bool include_static_members=true)
Definition: VariableList.cpp:72
lldb::eSymbolTypeScopeBegin
@ eSymbolTypeScopeBegin
Definition: lldb-enumerations.h:646
lldb_private::ClangExpressionDeclMap::EnableStructVars
void EnableStructVars()
Activate struct variables.
Definition: ClangExpressionDeclMap.h:373
lldb::eSymbolTypeData
@ eSymbolTypeData
Definition: lldb-enumerations.h:631
lldb_private::SymbolContextList
Definition: SymbolContext.h:379
lldb_private::CompilerDecl
Represents a generic declaration such as a function declaration.
Definition: CompilerDecl.h:28
lldb_private::SymbolContextList::GetContextAtIndex
bool GetContextAtIndex(size_t idx, SymbolContext &sc) const
Get accessor for a symbol context at index idx.
Definition: SymbolContext.cpp:1258
lldb_private::ClangExpressionDeclMap::InstallDiagnosticManager
void InstallDiagnosticManager(DiagnosticManager &diag_manager)
Definition: ClangExpressionDeclMap.cpp:150
lldb_private::Module
Definition: Module.h:87
lldb_private::ClangExpressionDeclMap::LookUpLldbObjCClass
void LookUpLldbObjCClass(NameSearchContext &context)
Handles looking up $__lldb_objc_class which requires special treatment.
Definition: ClangExpressionDeclMap.cpp:890
lldb_private::ExecutionContext::GetFramePtr
StackFrame * GetFramePtr() const
Returns a pointer to the frame object.
Definition: ExecutionContext.h:408
lldb_private::ConstString::AsCString
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:192
lldb_private::Value::ValueType::LoadAddress
@ LoadAddress
A load address value.
lldb_private::ClangASTSource::m_ast_importer_sp
std::shared_ptr< ClangASTImporter > m_ast_importer_sp
The target's AST importer.
Definition: ClangASTSource.h:387
lldb_private::CompilerType::GetOpaqueQualType
lldb::opaque_compiler_type_t GetOpaqueQualType() const
Definition: CompilerType.h:232
lldb::offset_t
uint64_t offset_t
Definition: lldb-types.h:87
RegisterValue.h
lldb_private::TypeSystemClang::IsObjCObjectPointerType
static bool IsObjCObjectPointerType(const CompilerType &type, CompilerType *target_type=nullptr)
Definition: TypeSystemClang.cpp:3777
lldb::eSymbolTypeRuntime
@ eSymbolTypeRuntime
Definition: lldb-enumerations.h:633
StackFrame.h
lldb_private::Symbol::GetReExportedSymbolName
ConstString GetReExportedSymbolName() const
Definition: Symbol.cpp:125
lldb_private::Type::GetName
ConstString GetName()
Definition: Type.cpp:303
lldb_private::StackFrame::FindVariable
lldb::ValueObjectSP FindVariable(ConstString name)
Attempt to reconstruct the ValueObject for a variable with a given name from within the current Stack...
Definition: StackFrame.cpp:1726
lldb_private::CompilerType::IsAggregateType
bool IsAggregateType() const
Definition: CompilerType.cpp:32
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::ModuleFunctionSearchOptions::include_symbols
bool include_symbols
Include the symbol table.
Definition: Module.h:67
lldb_private::ClangASTSource
Definition: ClangASTSource.h:33
lldb_private::ClangExpressionDeclMap::AddOneGenericVariable
void AddOneGenericVariable(NameSearchContext &context, const Symbol &symbol)
Use the NameSearchContext to generate a Decl for the given LLDB symbol (treated as a variable),...
Definition: ClangExpressionDeclMap.cpp:1720
lldb_private::ClangExpressionDeclMap::m_parser_vars
std::unique_ptr< ParserVars > m_parser_vars
Definition: ClangExpressionDeclMap.h:343
lldb_private::TypeSystemClang::DeclContextGetAsCXXMethodDecl
static clang::CXXMethodDecl * DeclContextGetAsCXXMethodDecl(const CompilerDeclContext &dc)
Definition: TypeSystemClang.cpp:9841
lldb_private::SymbolContext
Definition: SymbolContext.h:33
lldb_private::Target
Definition: Target.h:469
lldb_private::ExecutionContext::GetThreadPtr
Thread * GetThreadPtr() const
Returns a pointer to the thread object.
Definition: ExecutionContext.h:399
lldb_private::ClangExpressionDeclMap::EnableParserVars
void EnableParserVars()
Activate parser-specific variables.
Definition: ClangExpressionDeclMap.h:346
LLDB_LOGV
#define LLDB_LOGV(log,...)
Definition: Log.h:351
lldb_private::ClangASTSource::GuardedCopyType
CompilerType GuardedCopyType(const CompilerType &src_type)
A wrapper for TypeSystemClang::CopyType that sets a flag that indicates that we should not respond to...
Definition: ClangASTSource.cpp:1735
lldb_private::TypeFromUser
TaggedASTType< 1 > TypeFromUser
Definition: TaggedASTType.h:41
lldb_private::Target::GetImages
const ModuleList & GetImages() const
Get accessor for the images for this process.
Definition: Target.h:946
lldb_private::Language::LanguageIsCPlusPlus
static bool LanguageIsCPlusPlus(lldb::LanguageType language)
Definition: Language.cpp:250
lldb_private::VariableList
Definition: VariableList.h:18
g_lldb_local_vars_namespace_cstr
static const char * g_lldb_local_vars_namespace_cstr
Definition: ClangExpressionDeclMap.cpp:67
lldb_private::ModuleList::FindGlobalVariables
void FindGlobalVariables(ConstString name, size_t max_matches, VariableList &variable_list) const
Find global and static variables by name.
Definition: ModuleList.cpp:492
Process.h
ClangUtil.h
lldb_private::ModuleFunctionSearchOptions::include_inlines
bool include_inlines
Include inlined functions.
Definition: Module.h:69
lldb_private::Value::ContextType::Invalid
@ Invalid
Undefined.
lldb_private::VariableList::GetVariableAtIndex
lldb::VariableSP GetVariableAtIndex(size_t idx) const
Definition: VariableList.cpp:47
lldb_private::Value::SetCompilerType
void SetCompilerType(const CompilerType &compiler_type)
Definition: Value.cpp:252
lldb_private::ModuleList::FindSymbolsWithNameAndType
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list) const
Definition: ModuleList.cpp:509
lldb_private::ClangExpressionDeclMap::AddContextClassType
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...
Definition: ClangExpressionDeclMap.cpp:1982
Target.h
lldb_private::ClangExpressionDeclMap::DeportType
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...
Definition: ClangExpressionDeclMap.cpp:205
lldb_private::Value::GetScalar
const Scalar & GetScalar() const
Definition: Value.h:112
lldb_private::ExpressionVariable::EVNeedsAllocation
@ EVNeedsAllocation
Space for this variable has yet to be allocated in the target process.
Definition: ExpressionVariable.h:89
ClangASTSource.h
lldb_private::ClangExpressionVariable::JITVars::m_size
size_t m_size
The space required for the variable, in bytes.
Definition: ClangExpressionVariable.h:170
lldb_private::ClangASTImporter::NamespaceMapItem
std::pair< lldb::ModuleSP, CompilerDeclContext > NamespaceMapItem
Definition: ClangASTImporter.h:176
lldb_private::ClangUtil::GetQualType
static clang::QualType GetQualType(const CompilerType &ct)
Definition: ClangUtil.cpp:36
lldb_private::CompilerType::GetPointeeType
CompilerType GetPointeeType() const
If this type is a pointer type, return the type that the pointer points to, else return an invalid ty...
Definition: CompilerType.cpp:466
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::ExpressionVariable::m_frozen_sp
lldb::ValueObjectSP m_frozen_sp
Definition: ExpressionVariable.h:111
lldb_private::SymbolContext::symbol
Symbol * symbol
The Symbol for a given query.
Definition: SymbolContext.h:323
lldb::eSymbolTypeBlock
@ eSymbolTypeBlock
Definition: lldb-enumerations.h:639
lldb_private::Status::Success
bool Success() const
Test for success condition.
Definition: Status.cpp:287
lldb_private::eDiagnosticSeverityError
@ eDiagnosticSeverityError
Definition: DiagnosticManager.h:32
lldb_private::CompilerDeclContext::IsValid
bool IsValid() const
Definition: CompilerDeclContext.h:55
lldb_private::Function
Definition: Function.h:409
lldb_private::NameSearchContext::m_found_variable
bool m_found_variable
Definition: NameSearchContext.h:42
lldb_private::CompilerType::GetTypeSystem
TypeSystemSPWrapper GetTypeSystem() const
Accessors.
Definition: CompilerType.cpp:989
lldb_private::ClangExpressionDeclMap::~ClangExpressionDeclMap
~ClangExpressionDeclMap() override
Destructor.
Definition: ClangExpressionDeclMap.cpp:99
lldb_private::ClangExpressionDeclMap::m_found_entities
ExpressionVariableList m_found_entities
All entities that were looked up for the parser.
Definition: ClangExpressionDeclMap.h:295
lldb_private::ClangExpressionDeclMap::LookupLocalVarNamespace
void LookupLocalVarNamespace(SymbolContext &sym_ctx, NameSearchContext &name_context)
Handles looking up the synthetic namespace that contains our local variables for the current frame.
Definition: ClangExpressionDeclMap.cpp:991
lldb_private::ClangExpressionDeclMap::AddPersistentVariable
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.
Definition: ClangExpressionDeclMap.cpp:216
lldb::eSymbolTypeSourceFile
@ eSymbolTypeSourceFile
Definition: lldb-enumerations.h:635
NameSearchContext.h
lldb_private::ClangExpressionDeclMap::SearchFunctionsInSymbolContexts
SymbolContextList SearchFunctionsInSymbolContexts(const SymbolContextList &sc_list, const CompilerDeclContext &frame_decl_context)
Searches for functions in the given SymbolContextList.
Definition: ClangExpressionDeclMap.cpp:1143
lldb_private::TypeSystemClang::DeclContextGetAsObjCMethodDecl
static clang::ObjCMethodDecl * DeclContextGetAsObjCMethodDecl(const CompilerDeclContext &dc)
Definition: TypeSystemClang.cpp:9833
lldb_private::ClangExpressionDeclMap::GetPersistentDecl
virtual clang::NamedDecl * GetPersistentDecl(ConstString name)
Retrieves the declaration with the given name from the storage of persistent declarations.
Definition: ClangExpressionDeclMap.cpp:741
lldb_private::DataExtractor
Definition: DataExtractor.h:48
lldb_private::ConstString::GetStringRef
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
Definition: ConstString.h:201
lldb_private::Scalar::ULongLong
unsigned long long ULongLong(unsigned long long fail_value=0) const
Definition: Scalar.cpp:334
Log.h
lldb_private::ClangExpressionDeclMap::GetTargetInfo
TargetInfo GetTargetInfo()
Definition: ClangExpressionDeclMap.cpp:183
lldb::eSymbolTypeUndefined
@ eSymbolTypeUndefined
Definition: lldb-enumerations.h:652
lldb::eSymbolTypeObjectFile
@ eSymbolTypeObjectFile
Definition: lldb-enumerations.h:637
TypeSystemClang.h
lldb_private::Language::LanguageIsC
static bool LanguageIsC(lldb::LanguageType language)
Definition: Language.cpp:273
lldb_private::ClangExpressionDeclMap::TargetInfo
Definition: ClangExpressionDeclMap.h:251
lldb_private::ClangExpressionDeclMap::GetFunctionInfo
bool GetFunctionInfo(const clang::NamedDecl *decl, uint64_t &ptr)
[Used by IRForTarget] Get information about a function given its Decl.
Definition: ClangExpressionDeclMap.cpp:503
lldb_private::Address::GetCallableLoadAddress
lldb::addr_t GetCallableLoadAddress(Target *target, bool is_indirect=false) const
Get the load address as a callable code load address.
Definition: Address.cpp:336
lldb_private::Status::Fail
bool Fail() const
Test for error condition.
Definition: Status.cpp:181
lldb_private::StreamString::GetData
const char * GetData() const
Definition: StreamString.h:43
lldb_private::ClangASTSource::m_clang_ast_context
TypeSystemClang * m_clang_ast_context
The TypeSystemClang for m_ast_context.
Definition: ClangASTSource.h:383
lldb_private::TaggedASTType< 1 >
lldb_private::ClangExpressionVariable::GetParserVars
ParserVars * GetParserVars(uint64_t parser_id)
Access parser-specific variables.
Definition: ClangExpressionVariable.h:155
lldb_private::ClangExpressionDeclMap::GetTypeSystemClang
TypeSystemClang * GetTypeSystemClang()
Definition: ClangExpressionDeclMap.cpp:649
lldb_private::eDiagnosticOriginLLDB
@ eDiagnosticOriginLLDB
Definition: DiagnosticManager.h:25
lldb_private::ClangExpressionDeclMap::LookupLocalVariable
bool LookupLocalVariable(NameSearchContext &context, ConstString name, SymbolContext &sym_ctx, const CompilerDeclContext &namespace_decl)
Looks up a local variable.
Definition: ClangExpressionDeclMap.cpp:1064
lldb_private::SymbolContext::function
Function * function
The Function for a given query.
Definition: SymbolContext.h:320
lldb_private::Address::GetFileAddress
lldb::addr_t GetFileAddress() const
Get the file address.
Definition: Address.cpp:291
lldb_private::ClangExpressionVariable::JITVars
The following values are valid if the variable is used by JIT code.
Definition: ClangExpressionVariable.h:165
ClangPersistentVariables.h
lldb_private::ClangExpressionDeclMap::GetParserID
uint64_t GetParserID()
Get this parser's ID for use in extracting parser- and JIT-specific data from persistent variables.
Definition: ClangExpressionDeclMap.h:388
lldb_private::ClangExpressionVariable::GetJITVars
JITVars * GetJITVars(uint64_t parser_id)
Definition: ClangExpressionVariable.h:189
Type.h
lldb_private::TypeFromParser
TaggedASTType< 0 > TypeFromParser
Definition: TaggedASTType.h:40
lldb_private::ClangASTSource::CopyDecl
clang::Decl * CopyDecl(clang::Decl *src_decl)
Copies a single Decl into the parser's AST context.
Definition: ClangASTSource.cpp:1727
lldb_private::DataExtractor::GetDataStart
const uint8_t * GetDataStart() const
Get the data start pointer.
Definition: DataExtractor.h:422
lldb_private::ClangExpressionDeclMap::MaybeRegisterFunctionBody
void MaybeRegisterFunctionBody(clang::FunctionDecl *copied_function_decl)
Should be called on all copied functions.
Definition: ClangExpressionDeclMap.cpp:733
lldb_private::NameSearchContext::m_found_function
bool m_found_function
Definition: NameSearchContext.h:44
lldb_private::Process::GetAddressByteSize
uint32_t GetAddressByteSize() const
Definition: Process.cpp:3367
lldb_private::SymbolContextList::GetSize
uint32_t GetSize() const
Get accessor for a symbol context list size.
Definition: SymbolContext.cpp:1274
lldb_private::ConstString
Definition: ConstString.h:39
lldb_private::Language::LanguageIsObjC
static bool LanguageIsObjC(lldb::LanguageType language)
Definition: Language.cpp:263
lldb_private::StreamString
Definition: StreamString.h:23
lldb_private::ExpressionVariableList::AddVariable
size_t AddVariable(const lldb::ExpressionVariableSP &var_sp)
Definition: ExpressionVariable.h:133
lldb_private::ExpressionVariable::m_flags
FlagType m_flags
Definition: ExpressionVariable.h:108
lldb_private::ModuleList::FindFirstModule
lldb::ModuleSP FindFirstModule(const ModuleSpec &module_spec) const
Definition: ModuleList.cpp:623
lldb_private::ClangExpressionDeclMap::LookupFunction
void LookupFunction(NameSearchContext &context, lldb::ModuleSP module_sp, ConstString name, const CompilerDeclContext &namespace_decl)
Looks up a function.
Definition: ClangExpressionDeclMap.cpp:1230
lldb_private::Materializer::PersistentVariableDelegate
Definition: Materializer.h:70
lldb_private::Symbol::IsExternal
bool IsExternal() const
Definition: Symbol.h:180
lldb_private::ClangUtil::DumpDecl
static std::string DumpDecl(const clang::Decl *d)
Returns a textual representation of the given Decl's AST.
Definition: ClangUtil.cpp:68
lldb_private::SymbolContext::GetFunctionBlock
Block * GetFunctionBlock()
Find a block that defines the function represented by this symbol context.
Definition: SymbolContext.cpp:518
lldb_private::ClangExpressionDeclMap::m_ctx_obj
ValueObject * m_ctx_obj
If not empty, then expression is evaluated in context of this object.
Definition: ClangExpressionDeclMap.h:304
lldb_private::NameSearchContext::m_found_local_vars_nsp
bool m_found_local_vars_nsp
Definition: NameSearchContext.h:45
lldb::eBasicTypeVoid
@ eBasicTypeVoid
Definition: lldb-enumerations.h:756
lldb::eSymbolTypeObjCClass
@ eSymbolTypeObjCClass
Definition: lldb-enumerations.h:653
lldb_private::ClangExpressionDeclMap::AddOneType
void AddOneType(NameSearchContext &context, const TypeFromUser &type)
Use the NameSearchContext to generate a Decl for the given type.
Definition: ClangExpressionDeclMap.cpp:2047
lldb::eSymbolTypeAdditional
@ eSymbolTypeAdditional
When symbols take more than one entry, the extra entries get this type.
Definition: lldb-enumerations.h:648
lldb_private::ExpressionVariable::EVNeedsFreezeDry
@ EVNeedsFreezeDry
Copy from m_live_sp to m_frozen_sp during dematerialization.
Definition: ExpressionVariable.h:94
lldb_private::ClangExpressionDeclMap::DisableStructVars
void DisableStructVars()
Deallocate struct variables.
Definition: ClangExpressionDeclMap.h:379
lldb_private::TypeSystemClang::GetUniqueNamespaceDeclaration
clang::NamespaceDecl * GetUniqueNamespaceDeclaration(const char *name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, bool is_inline=false)
Definition: TypeSystemClang.cpp:1897
lldb_private::Target::GetPersistentExpressionStateForLanguage
PersistentExpressionState * GetPersistentExpressionStateForLanguage(lldb::LanguageType language)
Definition: Target.cpp:2397
lldb_private::ClangExpressionDeclMap::TargetInfo::byte_order
lldb::ByteOrder byte_order
Definition: ClangExpressionDeclMap.h:252
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::NameSearchContext::m_found_function_with_type_info
bool m_found_function_with_type_info
Definition: NameSearchContext.h:43
lldb_private::ScratchTypeSystemClang::GetForTarget
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.
Definition: TypeSystemClang.cpp:9953
lldb_private::Materializer
Definition: Materializer.h:23
CPPLanguageRuntime.h
lldb_private::CompilerDeclContext::GetName
ConstString GetName() const
Definition: CompilerDeclContext.cpp:25
Thread.h
lldb::SymbolType
SymbolType
Symbol types.
Definition: lldb-enumerations.h:625
Address.h
lldb::eSymbolTypeVariable
@ eSymbolTypeVariable
Definition: lldb-enumerations.h:642
lldb_private::TypeSystemClang::CountDeclLevels
uint32_t CountDeclLevels(clang::DeclContext *frame_decl_ctx, clang::DeclContext *child_decl_ctx, ConstString *child_name=nullptr, CompilerType *child_type=nullptr)
Definition: TypeSystemClang.cpp:9661
lldb::eSymbolTypeScopeEnd
@ eSymbolTypeScopeEnd
Definition: lldb-enumerations.h:647
VariableList.h
lldb_private::CompilerType::IsValid
bool IsValid() const
Definition: CompilerType.h:124
lldb_private::ClangExpressionVariable::JITVars::m_alignment
lldb::offset_t m_alignment
The required alignment of the variable, in bytes.
Definition: ClangExpressionVariable.h:168
lldb_private::CompilerDeclContext
Represents a generic declaration context in a program.
Definition: CompilerDeclContext.h:30
lldb_private::CompilerType::GetLValueReferenceType
CompilerType GetLValueReferenceType() const
Return a new CompilerType that is a L value reference to this type if this type is valid and the type...
Definition: CompilerType.cpp:482
lldb_private::ArchSpec::GetAddressByteSize
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
Definition: ArchSpec.cpp:694
ObjectFile.h
lldb_private::UserID::GetID
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition: UserID.h:47
lldb_private::ClangExpressionVariable::ParserVars::m_named_decl
const clang::NamedDecl * m_named_decl
The Decl corresponding to this variable.
Definition: ClangExpressionVariable.h:121
lldb_private::ModuleFunctionSearchOptions
Options used by Module::FindFunctions.
Definition: Module.h:65
lldb_private::NameSearchContext::AddGenericFunDecl
clang::NamedDecl * AddGenericFunDecl()
Create a FunDecl with the name being searched for and generic type (i.e.
Definition: NameSearchContext.cpp:130
lldb-private.h
lldb_private::CompilerType::GetCompleteType
bool GetCompleteType() const
Type Completion.
Definition: CompilerType.cpp:308
ValueObjectConstResult.h
lldb_private::ClangASTImporter::NamespaceMapSP
std::shared_ptr< NamespaceMap > NamespaceMapSP
Definition: ClangASTImporter.h:178
lldb_private::ClangExpressionVariable::ParserVars::m_lldb_value
lldb_private::Value m_lldb_value
The value found in LLDB for this variable.
Definition: ClangExpressionVariable.h:127
lldb::eAccessPublic
@ eAccessPublic
Definition: lldb-enumerations.h:516
TypeList.h
lldb_private::ClangExpressionDeclMap::DoStructLayout
bool DoStructLayout()
[Used by IRForTarget] Finalize the struct, laying out the position of each object in it.
Definition: ClangExpressionDeclMap.cpp:436
lldb_private::ClangExpressionVariable::FindVariableInList
static ClangExpressionVariable * FindVariableInList(ExpressionVariableList &list, const clang::NamedDecl *decl, uint64_t parser_id)
Utility functions for dealing with ExpressionVariableLists in Clang- specific ways.
Definition: ClangExpressionVariable.h:83
lldb_private::ClangASTSource::GetClangModulesDeclVendor
std::shared_ptr< ClangModulesDeclVendor > GetClangModulesDeclVendor()
Definition: ClangASTSource.cpp:1754
lldb_private::ModuleSpec
Definition: ModuleSpec.h:27
lldb_private::ClangExpressionDeclMap::TargetInfo::address_byte_size
size_t address_byte_size
Definition: ClangExpressionDeclMap.h:253
lldb_private::Target::GetArchitecture
const ArchSpec & GetArchitecture() const
Definition: Target.h:988
lldb_private::ClangASTSource::CompleteType
void CompleteType(clang::TagDecl *Tag) override
Complete a TagDecl.
lldb_private::NameSearchContext::AddTypeDecl
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...
Definition: NameSearchContext.cpp:144
Materializer.h
lldb_private::ClangExpressionDeclMap::m_struct_members
ExpressionVariableList m_struct_members
All entities that need to be placed in the struct.
Definition: ClangExpressionDeclMap.h:297
lldb_private::Status
Definition: Status.h:44
lldb_private::ValueObject
ValueObject:
Definition: ValueObject.h:105
lldb_private::Symbol::GetReExportedSymbolSharedLibrary
FileSpec GetReExportedSymbolSharedLibrary() const
Definition: Symbol.cpp:139
lldb_private::CompilerType::GetPointerType
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
Definition: CompilerType.cpp:474
lldb_private::NameSearchContext::AddFunDecl
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 ...
Definition: NameSearchContext.cpp:38
warning
static llvm::raw_ostream & warning(Stream &strm)
Definition: CommandReturnObject.cpp:23
lldb_private::OptionalClangModuleID
A Clang module ID.
Definition: TypeSystemClang.h:57
lldb_private::Address::DumpStyleResolvedDescription
@ DumpStyleResolvedDescription
Display the details about what an address resolves to.
Definition: Address.h:101
lldb_private::FileSpec::ClearDirectory
void ClearDirectory()
Clear the directory in this object.
Definition: FileSpec.cpp:359
lldb_private::Address::Dump
bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, DumpStyle fallback_style=DumpStyleInvalid, uint32_t addr_byte_size=UINT32_MAX, bool all_ranges=false) const
Dump a description of this object to a Stream.
Definition: Address.cpp:406
lldb_private::Block
Definition: Block.h:41
lldb_private::ClangExpressionDeclMap::FindGlobalVariable
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.
Definition: ClangExpressionDeclMap.cpp:634
uint32_t
lldb_private::ExecutionContext::GetBestExecutionContextScope
ExecutionContextScope * GetBestExecutionContextScope() const
Definition: ExecutionContext.cpp:214
lldb_private::ClangExpressionVariable::ParserVars::m_lldb_var
lldb::VariableSP m_lldb_var
The original variable for this variable.
Definition: ClangExpressionVariable.h:128
lldb_private::ExpressionVariable::EVKeepInTarget
@ EVKeepInTarget
Keep the allocation after the expression is complete rather than freeze drying its contents and freei...
Definition: ExpressionVariable.h:96
lldb_private::ClangExpressionDeclMap::AddExpressionVariable
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...
Definition: ClangExpressionDeclMap.cpp:1570
lldb_private::Block::GetDeclContext
CompilerDeclContext GetDeclContext()
Definition: Block.cpp:480
lldb_private::ClangExpressionDeclMap::LookupInModulesDeclVendor
void LookupInModulesDeclVendor(NameSearchContext &context, ConstString name)
Lookup entities in the ClangModulesDeclVendor.
Definition: ClangExpressionDeclMap.cpp:1017
lldb_private::ExpressionVariable::EVIsProgramReference
@ EVIsProgramReference
This variable is a reference to a (possibly invalid) area managed by the target program.
Definition: ExpressionVariable.h:86
lldb_private::Address
Definition: Address.h:59
lldb_private::Value::ValueType::HostAddress
@ HostAddress
A host address value (for memory in the process that < A is using liblldb).
lldb_private::ClangExpressionDeclMap::AddValueToStruct
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...
Definition: ClangExpressionDeclMap.cpp:344
lldb_private::Type
Definition: Type.h:68
lldb_private::ClangExpressionDeclMap::GetStructElement
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...
Definition: ClangExpressionDeclMap.cpp:467
lldb_private::Address::GetLoadAddress
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
Definition: Address.cpp:311
lldb_private::DiagnosticManager
Definition: DiagnosticManager.h:93
lldb_private::ClangExpressionDeclMap::GetScratchContext
lldb::TypeSystemClangSP GetScratchContext(Target &target)
Definition: ClangExpressionDeclMap.h:381
lldb_private::Type::GetForwardCompilerType
CompilerType GetForwardCompilerType()
Definition: Type.cpp:667
UINT32_MAX
#define UINT32_MAX
Definition: lldb-defines.h:19
lldb_private::Value::GetContextType
ContextType GetContextType() const
Definition: Value.h:87
lldb_private::ValueObject::GetCompilerType
CompilerType GetCompilerType()
Definition: ValueObject.h:352
lldb::eSymbolTypeObjCMetaClass
@ eSymbolTypeObjCMetaClass
Definition: lldb-enumerations.h:654
ObjCLanguageRuntime.h
lldb::eSymbolTypeVariableType
@ eSymbolTypeVariableType
Definition: lldb-enumerations.h:643
ClangExpressionDeclMap.h
lldb_private::SymbolContext::module_sp
lldb::ModuleSP module_sp
The Module for a given query.
Definition: SymbolContext.h:318
lldb_private::ClangExpressionDeclMap::AddOneFunction
void AddOneFunction(NameSearchContext &context, Function *fun, Symbol *sym)
Use the NameSearchContext to generate a Decl for the given function.
Definition: ClangExpressionDeclMap.cpp:1811
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:74
lldb_private::ExecutionContext::GetTargetSP
const lldb::TargetSP & GetTargetSP() const
Get accessor to get the target shared pointer.
Definition: ExecutionContext.h:454
LLDB_LOG
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition: Log.h:337
clang
Definition: ASTResultSynthesizer.h:15
lldb_private::CompilerDeclContext::GetTypeSystem
TypeSystem * GetTypeSystem() const
Definition: CompilerDeclContext.h:101
lldb_private::CompilerType
Generic representation of a type in a programming language.
Definition: CompilerType.h:36
Function.h
lldb_private::ClangExpressionDeclMap::GetSymbolAddress
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.
Definition: ClangExpressionDeclMap.cpp:522
lldb_private::NameSearchContext::AddVarDecl
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 ...
Definition: NameSearchContext.cpp:16
lldb_private::ModuleList::FindFunctions
void FindFunctions(ConstString name, lldb::FunctionNameType name_type_mask, const ModuleFunctionSearchOptions &options, SymbolContextList &sc_list) const
DiagnosticManager.h
Status.h
lldb::eSymbolTypeReExported
@ eSymbolTypeReExported
Definition: lldb-enumerations.h:656
SymbolContext.h
lldb_private::CPlusPlusLanguage::IsCPPMangledName
static bool IsCPPMangledName(llvm::StringRef name)
Definition: CPlusPlusLanguage.cpp:379
lldb::eLanguageTypeC
@ eLanguageTypeC
Non-standardized C, such as K&R.
Definition: lldb-enumerations.h:446
CompilerDeclContext.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::TypeSystem
Interface for representing a type system.
Definition: TypeSystem.h:76
Error
llvm::Error Error
Definition: UdtRecordCompleter.cpp:35
lldb_private::ExpressionVariableList::GetVariableAtIndex
lldb::ExpressionVariableSP GetVariableAtIndex(size_t index)
Definition: ExpressionVariable.h:126
lldb_private::TypeSystemClang::GetBasicType
CompilerType GetBasicType(lldb::BasicType type)
Definition: TypeSystemClang.cpp:933
lldb_private::DWARFExpressionList::GetExpressionData
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.
Definition: DWARFExpressionList.cpp:41
lldb::eSymbolTypeLineHeader
@ eSymbolTypeLineHeader
Definition: lldb-enumerations.h:645
lldb_private::TypeSystemClang
A TypeSystem implementation based on Clang.
Definition: TypeSystemClang.h:106
lldb_private::ClangExpressionVariable::ParserVars::m_llvm_value
llvm::Value * m_llvm_value
The IR value corresponding to this variable; usually a GlobalValue.
Definition: ClangExpressionVariable.h:123
lldb_private::CompilerType::TypeSystemSPWrapper::dyn_cast_or_null
std::shared_ptr< TypeSystemType > dyn_cast_or_null()
Return a shared_ptr<TypeSystemType> if dyn_cast succeeds.
Definition: CompilerType.h:68
lldb_private::ClangExpressionDeclMap::m_struct_vars
std::unique_ptr< StructVars > m_struct_vars
Definition: ClangExpressionDeclMap.h:370
ClangExpressionVariable.h
lldb_private::ClangExpressionDeclMap::FindExternalVisibleDecls
void FindExternalVisibleDecls(NameSearchContext &context) override
[Used by ClangASTSource] Find all entities matching a given name, using a NameSearchContext to make D...
Definition: ClangExpressionDeclMap.cpp:669
ValueObjectVariable.h
lldb_private::DWARFExpressionList
Definition: DWARFExpressionList.h:23
lldb_private::Module::FindSymbolsWithNameAndType
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list)
Definition: Module.cpp:1340
lldb::eSymbolTypeException
@ eSymbolTypeException
Definition: lldb-enumerations.h:634
lldb_private::Process::GetByteOrder
lldb::ByteOrder GetByteOrder() const
Definition: Process.cpp:3363
lldb_private::Log
Definition: Log.h:115
lldb_private::ClangExpressionVariable::ParserVars::m_lldb_valobj_provider
ValueObjectProviderTy m_lldb_valobj_provider
Callback that provides a ValueObject for the specified frame.
Definition: ClangExpressionVariable.h:137
lldb_private::TypeSystemClang::AddMethodToCXXRecordType
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)
Definition: TypeSystemClang.cpp:7685
lldb::eSymbolTypeResolver
@ eSymbolTypeResolver
Definition: lldb-enumerations.h:630
lldb_private::StackFrame::GetInScopeVariableList
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.
Definition: StackFrame.cpp:475
lldb_private::ValueObject::AddressOf
virtual lldb::ValueObjectSP AddressOf(Status &error)
Definition: ValueObject.cpp:2734
LLDB_INVALID_DECL_LEVEL
#define LLDB_INVALID_DECL_LEVEL
Definition: TypeSystemClang.h:909
lldb_private::Symbol::IsIndirect
bool IsIndirect() const
Definition: Symbol.cpp:175
lldb_private::ValueObjectVariable::Create
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, const lldb::VariableSP &var_sp)
Definition: ValueObjectVariable.cpp:52
lldb_private::Thread::GetStackFrameAtIndex
virtual lldb::StackFrameSP GetStackFrameAtIndex(uint32_t idx)
Definition: Thread.h:399
lldb_private::Function::GetDeclContext
CompilerDeclContext GetDeclContext()
Get the DeclContext for this function, if available.
Definition: Function.cpp:490
SymbolVendor.h
lldb::eSymbolTypeAbsolute
@ eSymbolTypeAbsolute
Definition: lldb-enumerations.h:628
Variable.h
lldb_private::GetLog
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:309
lldb_private::ClangExpressionDeclMap::AddOneRegister
void AddOneRegister(NameSearchContext &context, const RegisterInfo *reg_info)
Use the NameSearchContext to generate a Decl for the given register.
Definition: ClangExpressionDeclMap.cpp:1772
lldb_private::NameSearchContext::m_decl_context
const clang::DeclContext * m_decl_context
The DeclContext to put declarations into.
Definition: NameSearchContext.h:37
lldb_private::DataExtractor::GetByteSize
uint64_t GetByteSize() const
Get the number of bytes contained in this object.
Definition: DataExtractor.h:270
lldb_private::StackFrame
Definition: StackFrame.h:40
lldb_private::ExpressionVariable::SetName
void SetName(ConstString name)
Definition: ExpressionVariable.h:61
lldb_private::LLDBLog::Expressions
@ Expressions
lldb_private::Symbol::GetType
lldb::SymbolType GetType() const
Definition: Symbol.h:153
lldb_private::NameSearchContext::m_decl_name
const clang::DeclarationName m_decl_name
The name being looked for.
Definition: NameSearchContext.h:35
lldb::eSymbolTypeLocal
@ eSymbolTypeLocal
Definition: lldb-enumerations.h:640
lldb
Definition: SBAddress.h:15
Endian.h
RegisterContext.h
lldb_private::Type::GetFullCompilerType
CompilerType GetFullCompilerType()
Definition: Type.cpp:657
lldb_private::ClangExpressionDeclMap::WillParse
bool WillParse(ExecutionContext &exe_ctx, Materializer *materializer)
Enable the state needed for parsing and IR transformation.
Definition: ClangExpressionDeclMap.cpp:108
lldb_private::StackFrame::GetSymbolContext
const SymbolContext & GetSymbolContext(lldb::SymbolContextItem resolve_scope)
Provide a SymbolContext for this StackFrame's current pc value.
Definition: StackFrame.cpp:300
LLDBLog.h
SymbolFile.h
lldb_private::Symbol::ResolveReExportedSymbol
Symbol * ResolveReExportedSymbol(Target &target) const
Definition: Symbol.cpp:472
lldb_private::ClangExpressionDeclMap::DidParse
void DidParse()
Disable the state needed for parsing and IR transformation.
Definition: ClangExpressionDeclMap.cpp:156
lldb_private::ExecutionContext::GetTargetPtr
Target * GetTargetPtr() const
Returns a pointer to the target object.
Definition: ExecutionContext.cpp:198
lldb_private::ExpressionVariable::GetName
ConstString GetName()
Definition: ExpressionVariable.h:38
lldb_private::LanguageRuntime::LookupRuntimeSymbol
virtual lldb::addr_t LookupRuntimeSymbol(ConstString name)
Definition: LanguageRuntime.h:170
ExecutionContext.h
lldb_private::ClangExpressionDeclMap::m_keep_result_in_memory
bool m_keep_result_in_memory
True if result persistent variables generated by this expression should stay in memory.
Definition: ClangExpressionDeclMap.h:298
lldb_private::ClangExpressionVariable::ParserVars::m_lldb_sym
const lldb_private::Symbol * m_lldb_sym
The original symbol for this variable, if it was a symbol.
Definition: ClangExpressionVariable.h:129
lldb_private::TypeSystemClang::IsObjCClassType
static bool IsObjCClassType(const CompilerType &type)
Definition: TypeSystemClang.cpp:3520
lldb_private::ClangExpressionUtil::GetLambdaValueObject
lldb::ValueObjectSP GetLambdaValueObject(StackFrame *frame)
Returns a ValueObject for the lambda class in the current frame.
Definition: ClangExpressionUtil.cpp:17
lldb_private::Status::AsCString
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
Definition: Status.cpp:130
lldb_private::ClangExpressionVariable::JITVars::m_offset
lldb::offset_t m_offset
The offset of the variable in the struct, in bytes.
Definition: ClangExpressionVariable.h:171
lldb_private::ExpressionVariable::SetCompilerType
void SetCompilerType(const CompilerType &compiler_type)
Definition: ExpressionVariable.h:57
lldb_private::CompilerDeclContext::IsClassMethod
bool IsClassMethod(lldb::LanguageType *language_ptr, bool *is_instance_method_ptr, ConstString *language_object_name_ptr)
Checks if this decl context represents a method of a class.
Definition: CompilerDeclContext.cpp:37
lldb_private::Symbol::GetAddress
Address GetAddress() const
Definition: Symbol.h:73
lldb_private::ExpressionVariable::EVBareRegister
@ EVBareRegister
This variable is a direct reference to $pc or some other entity.
Definition: ExpressionVariable.h:102