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));
209  assert((TypeSystem *)&source == parser_type.GetTypeSystem());
210  assert(&source.getASTContext() == m_ast_context);
211 
212  return TypeFromUser(m_ast_importer_sp->DeportType(target, parser_type));
213 }
214 
216  ConstString name,
217  TypeFromParser parser_type,
218  bool is_result,
219  bool is_lvalue) {
220  assert(m_parser_vars.get());
221 
222  TypeSystemClang *ast =
223  llvm::dyn_cast_or_null<TypeSystemClang>(parser_type.GetTypeSystem());
224  if (ast == nullptr)
225  return false;
226 
227  // Check if we already declared a persistent variable with the same name.
228  if (lldb::ExpressionVariableSP conflicting_var =
229  m_parser_vars->m_persistent_vars->GetVariable(name)) {
230  std::string msg = llvm::formatv("redefinition of persistent variable '{0}'",
231  name).str();
232  m_parser_vars->m_diagnostics->AddDiagnostic(
235  return false;
236  }
237 
238  if (m_parser_vars->m_materializer && is_result) {
239  Status err;
240 
241  ExecutionContext &exe_ctx = m_parser_vars->m_exe_ctx;
242  Target *target = exe_ctx.GetTargetPtr();
243  if (target == nullptr)
244  return false;
245 
246  auto *clang_ast_context = GetScratchContext(*target);
247  if (!clang_ast_context)
248  return false;
249 
250  TypeFromUser user_type = DeportType(*clang_ast_context, *ast, parser_type);
251 
252  uint32_t offset = m_parser_vars->m_materializer->AddResultVariable(
253  user_type, is_lvalue, m_keep_result_in_memory, m_result_delegate, err);
254 
256  exe_ctx.GetBestExecutionContextScope(), name, user_type,
257  m_parser_vars->m_target_info.byte_order,
258  m_parser_vars->m_target_info.address_byte_size);
259 
261 
263 
265  var->GetParserVars(GetParserID());
266 
267  parser_vars->m_named_decl = decl;
268 
269  var->EnableJITVars(GetParserID());
270 
272 
273  jit_vars->m_offset = offset;
274 
275  return true;
276  }
277 
279  ExecutionContext &exe_ctx = m_parser_vars->m_exe_ctx;
280  Target *target = exe_ctx.GetTargetPtr();
281  if (target == nullptr)
282  return false;
283 
284  TypeSystemClang *context = GetScratchContext(*target);
285  if (!context)
286  return false;
287 
288  TypeFromUser user_type = DeportType(*context, *ast, parser_type);
289 
290  if (!user_type.GetOpaqueQualType()) {
291  LLDB_LOG(log, "Persistent variable's type wasn't copied successfully");
292  return false;
293  }
294 
295  if (!m_parser_vars->m_target_info.IsValid())
296  return false;
297 
298  if (!m_parser_vars->m_persistent_vars)
299  return false;
300 
301  ClangExpressionVariable *var = llvm::cast<ClangExpressionVariable>(
302  m_parser_vars->m_persistent_vars
303  ->CreatePersistentVariable(
304  exe_ctx.GetBestExecutionContextScope(), name, user_type,
305  m_parser_vars->m_target_info.byte_order,
306  m_parser_vars->m_target_info.address_byte_size)
307  .get());
308 
309  if (!var)
310  return false;
311 
312  var->m_frozen_sp->SetHasCompleteType();
313 
314  if (is_result)
316  else
317  var->m_flags |=
318  ClangExpressionVariable::EVKeepInTarget; // explicitly-declared
319  // persistent variables should
320  // persist
321 
322  if (is_lvalue) {
324  } else {
327  }
328 
331  }
332 
333  LLDB_LOG(log, "Created persistent variable with flags {0:x}", var->m_flags);
334 
336 
338  var->GetParserVars(GetParserID());
339 
340  parser_vars->m_named_decl = decl;
341 
342  return true;
343 }
344 
345 bool ClangExpressionDeclMap::AddValueToStruct(const NamedDecl *decl,
346  ConstString name,
347  llvm::Value *value, size_t size,
348  lldb::offset_t alignment) {
349  assert(m_struct_vars.get());
350  assert(m_parser_vars.get());
351 
352  bool is_persistent_variable = false;
353 
355 
356  m_struct_vars->m_struct_laid_out = false;
357 
359  GetParserID()))
360  return true;
361 
363  m_found_entities, decl, GetParserID()));
364 
365  if (!var && m_parser_vars->m_persistent_vars) {
367  *m_parser_vars->m_persistent_vars, decl, GetParserID());
368  is_persistent_variable = true;
369  }
370 
371  if (!var)
372  return false;
373 
374  LLDB_LOG(log, "Adding value for (NamedDecl*){0} [{1} - {2}] to the structure",
375  decl, name, var->GetName());
376 
377  // We know entity->m_parser_vars is valid because we used a parser variable
378  // to find it
379 
381  llvm::cast<ClangExpressionVariable>(var)->GetParserVars(GetParserID());
382 
383  parser_vars->m_llvm_value = value;
384 
385  if (ClangExpressionVariable::JITVars *jit_vars =
386  llvm::cast<ClangExpressionVariable>(var)->GetJITVars(GetParserID())) {
387  // We already laid this out; do not touch
388 
389  LLDB_LOG(log, "Already placed at {0:x}", jit_vars->m_offset);
390  }
391 
392  llvm::cast<ClangExpressionVariable>(var)->EnableJITVars(GetParserID());
393 
395  llvm::cast<ClangExpressionVariable>(var)->GetJITVars(GetParserID());
396 
397  jit_vars->m_alignment = alignment;
398  jit_vars->m_size = size;
399 
400  m_struct_members.AddVariable(var->shared_from_this());
401 
402  if (m_parser_vars->m_materializer) {
403  uint32_t offset = 0;
404 
405  Status err;
406 
407  if (is_persistent_variable) {
408  ExpressionVariableSP var_sp(var->shared_from_this());
409  offset = m_parser_vars->m_materializer->AddPersistentVariable(
410  var_sp, nullptr, err);
411  } else {
412  if (const lldb_private::Symbol *sym = parser_vars->m_lldb_sym)
413  offset = m_parser_vars->m_materializer->AddSymbol(*sym, err);
414  else if (const RegisterInfo *reg_info = var->GetRegisterInfo())
415  offset = m_parser_vars->m_materializer->AddRegister(*reg_info, err);
416  else if (parser_vars->m_lldb_var)
417  offset = m_parser_vars->m_materializer->AddVariable(
418  parser_vars->m_lldb_var, err);
419  else if (parser_vars->m_lldb_valobj_provider) {
420  offset = m_parser_vars->m_materializer->AddValueObject(
421  name, parser_vars->m_lldb_valobj_provider, err);
422  }
423  }
424 
425  if (!err.Success())
426  return false;
427 
428  LLDB_LOG(log, "Placed at {0:x}", offset);
429 
430  jit_vars->m_offset =
431  offset; // TODO DoStructLayout() should not change this.
432  }
433 
434  return true;
435 }
436 
438  assert(m_struct_vars.get());
439 
440  if (m_struct_vars->m_struct_laid_out)
441  return true;
442 
443  if (!m_parser_vars->m_materializer)
444  return false;
445 
446  m_struct_vars->m_struct_alignment =
447  m_parser_vars->m_materializer->GetStructAlignment();
448  m_struct_vars->m_struct_size =
449  m_parser_vars->m_materializer->GetStructByteSize();
450  m_struct_vars->m_struct_laid_out = true;
451  return true;
452 }
453 
454 bool ClangExpressionDeclMap::GetStructInfo(uint32_t &num_elements, size_t &size,
455  lldb::offset_t &alignment) {
456  assert(m_struct_vars.get());
457 
458  if (!m_struct_vars->m_struct_laid_out)
459  return false;
460 
461  num_elements = m_struct_members.GetSize();
462  size = m_struct_vars->m_struct_size;
463  alignment = m_struct_vars->m_struct_alignment;
464 
465  return true;
466 }
467 
468 bool ClangExpressionDeclMap::GetStructElement(const NamedDecl *&decl,
469  llvm::Value *&value,
470  lldb::offset_t &offset,
471  ConstString &name,
472  uint32_t index) {
473  assert(m_struct_vars.get());
474 
475  if (!m_struct_vars->m_struct_laid_out)
476  return false;
477 
478  if (index >= m_struct_members.GetSize())
479  return false;
480 
481  ExpressionVariableSP member_sp(m_struct_members.GetVariableAtIndex(index));
482 
483  if (!member_sp)
484  return false;
485 
487  llvm::cast<ClangExpressionVariable>(member_sp.get())
488  ->GetParserVars(GetParserID());
490  llvm::cast<ClangExpressionVariable>(member_sp.get())
491  ->GetJITVars(GetParserID());
492 
493  if (!parser_vars || !jit_vars || !member_sp->GetValueObject())
494  return false;
495 
496  decl = parser_vars->m_named_decl;
497  value = parser_vars->m_llvm_value;
498  offset = jit_vars->m_offset;
499  name = member_sp->GetName();
500 
501  return true;
502 }
503 
504 bool ClangExpressionDeclMap::GetFunctionInfo(const NamedDecl *decl,
505  uint64_t &ptr) {
507  m_found_entities, decl, GetParserID()));
508 
509  if (!entity)
510  return false;
511 
512  // We know m_parser_vars is valid since we searched for the variable by its
513  // NamedDecl
514 
516  entity->GetParserVars(GetParserID());
517 
518  ptr = parser_vars->m_lldb_value.GetScalar().ULongLong();
519 
520  return true;
521 }
522 
524  Process *process,
525  ConstString name,
526  lldb::SymbolType symbol_type,
527  lldb_private::Module *module) {
528  SymbolContextList sc_list;
529 
530  if (module)
531  module->FindSymbolsWithNameAndType(name, symbol_type, sc_list);
532  else
533  target.GetImages().FindSymbolsWithNameAndType(name, symbol_type, sc_list);
534 
535  const uint32_t num_matches = sc_list.GetSize();
536  addr_t symbol_load_addr = LLDB_INVALID_ADDRESS;
537 
538  for (uint32_t i = 0;
539  i < num_matches &&
540  (symbol_load_addr == 0 || symbol_load_addr == LLDB_INVALID_ADDRESS);
541  i++) {
542  SymbolContext sym_ctx;
543  sc_list.GetContextAtIndex(i, sym_ctx);
544 
545  const Address sym_address = sym_ctx.symbol->GetAddress();
546 
547  if (!sym_address.IsValid())
548  continue;
549 
550  switch (sym_ctx.symbol->GetType()) {
551  case eSymbolTypeCode:
553  symbol_load_addr = sym_address.GetCallableLoadAddress(&target);
554  break;
555 
556  case eSymbolTypeResolver:
557  symbol_load_addr = sym_address.GetCallableLoadAddress(&target, true);
558  break;
559 
560  case eSymbolTypeReExported: {
561  ConstString reexport_name = sym_ctx.symbol->GetReExportedSymbolName();
562  if (reexport_name) {
563  ModuleSP reexport_module_sp;
564  ModuleSpec reexport_module_spec;
565  reexport_module_spec.GetPlatformFileSpec() =
567  if (reexport_module_spec.GetPlatformFileSpec()) {
568  reexport_module_sp =
569  target.GetImages().FindFirstModule(reexport_module_spec);
570  if (!reexport_module_sp) {
571  reexport_module_spec.GetPlatformFileSpec().ClearDirectory();
572  reexport_module_sp =
573  target.GetImages().FindFirstModule(reexport_module_spec);
574  }
575  }
576  symbol_load_addr = GetSymbolAddress(
577  target, process, sym_ctx.symbol->GetReExportedSymbolName(),
578  symbol_type, reexport_module_sp.get());
579  }
580  } break;
581 
582  case eSymbolTypeData:
583  case eSymbolTypeRuntime:
584  case eSymbolTypeVariable:
585  case eSymbolTypeLocal:
586  case eSymbolTypeParam:
587  case eSymbolTypeInvalid:
588  case eSymbolTypeAbsolute:
594  case eSymbolTypeBlock:
599  case eSymbolTypeScopeEnd:
601  case eSymbolTypeCompiler:
606  case eSymbolTypeObjCIVar:
607  symbol_load_addr = sym_address.GetLoadAddress(&target);
608  break;
609  }
610  }
611 
612  if (symbol_load_addr == LLDB_INVALID_ADDRESS && process) {
613  ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process);
614 
615  if (runtime) {
616  symbol_load_addr = runtime->LookupRuntimeSymbol(name);
617  }
618  }
619 
620  return symbol_load_addr;
621 }
622 
624  lldb::SymbolType symbol_type) {
625  assert(m_parser_vars.get());
626 
627  if (!m_parser_vars->m_exe_ctx.GetTargetPtr())
628  return false;
629 
630  return GetSymbolAddress(m_parser_vars->m_exe_ctx.GetTargetRef(),
631  m_parser_vars->m_exe_ctx.GetProcessPtr(), name,
632  symbol_type);
633 }
634 
636  Target &target, ModuleSP &module, ConstString name,
637  const CompilerDeclContext &namespace_decl) {
638  VariableList vars;
639 
640  if (module && namespace_decl)
641  module->FindGlobalVariables(name, namespace_decl, -1, vars);
642  else
643  target.GetImages().FindGlobalVariables(name, -1, vars);
644 
645  if (vars.GetSize() == 0)
646  return VariableSP();
647  return vars.GetVariableAtIndex(0);
648 }
649 
651  StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
652  if (frame == nullptr)
653  return nullptr;
654 
655  SymbolContext sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction |
656  lldb::eSymbolContextBlock);
657  if (sym_ctx.block == nullptr)
658  return nullptr;
659 
660  CompilerDeclContext frame_decl_context = sym_ctx.block->GetDeclContext();
661  if (!frame_decl_context)
662  return nullptr;
663 
664  return llvm::dyn_cast_or_null<TypeSystemClang>(
665  frame_decl_context.GetTypeSystem());
666 }
667 
668 // Interface for ClangASTSource
669 
671  NameSearchContext &context) {
672  assert(m_ast_context);
673 
674  const ConstString name(context.m_decl_name.getAsString().c_str());
675 
677 
678  if (log) {
679  if (!context.m_decl_context)
680  LLDB_LOG(log,
681  "ClangExpressionDeclMap::FindExternalVisibleDecls for "
682  "'{0}' in a NULL DeclContext",
683  name);
684  else if (const NamedDecl *context_named_decl =
685  dyn_cast<NamedDecl>(context.m_decl_context))
686  LLDB_LOG(log,
687  "ClangExpressionDeclMap::FindExternalVisibleDecls for "
688  "'{0}' in '{1}'",
689  name, context_named_decl->getNameAsString());
690  else
691  LLDB_LOG(log,
692  "ClangExpressionDeclMap::FindExternalVisibleDecls for "
693  "'{0}' in a '{1}'",
694  name, context.m_decl_context->getDeclKindName());
695  }
696 
697  if (const NamespaceDecl *namespace_context =
698  dyn_cast<NamespaceDecl>(context.m_decl_context)) {
699  if (namespace_context->getName().str() ==
701  CompilerDeclContext compiler_decl_ctx =
703  const_cast<clang::DeclContext *>(context.m_decl_context));
704  FindExternalVisibleDecls(context, lldb::ModuleSP(), compiler_decl_ctx);
705  return;
706  }
707 
708  ClangASTImporter::NamespaceMapSP namespace_map =
709  m_ast_importer_sp->GetNamespaceMap(namespace_context);
710 
711  if (!namespace_map)
712  return;
713 
714  LLDB_LOGV(log, " CEDM::FEVD Inspecting (NamespaceMap*){0:x} ({1} entries)",
715  namespace_map.get(), namespace_map->size());
716 
717  for (ClangASTImporter::NamespaceMapItem &n : *namespace_map) {
718  LLDB_LOG(log, " CEDM::FEVD Searching namespace {0} in module {1}",
719  n.second.GetName(), n.first->GetFileSpec().GetFilename());
720 
721  FindExternalVisibleDecls(context, n.first, n.second);
722  }
723  } else if (isa<TranslationUnitDecl>(context.m_decl_context)) {
724  CompilerDeclContext namespace_decl;
725 
726  LLDB_LOG(log, " CEDM::FEVD Searching the root namespace");
727 
728  FindExternalVisibleDecls(context, lldb::ModuleSP(), namespace_decl);
729  }
730 
732 }
733 
735  FunctionDecl *copied_function_decl) {
736  if (copied_function_decl->getBody() && m_parser_vars->m_code_gen) {
737  clang::DeclGroupRef decl_group_ref(copied_function_decl);
738  m_parser_vars->m_code_gen->HandleTopLevelDecl(decl_group_ref);
739  }
740 }
741 
743  if (!m_parser_vars)
744  return nullptr;
745  Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
746  if (!target)
747  return nullptr;
748 
750 
751  if (!m_parser_vars->m_persistent_vars)
752  return nullptr;
753  return m_parser_vars->m_persistent_vars->GetPersistentDecl(name);
754 }
755 
757  const ConstString name) {
759 
760  NamedDecl *persistent_decl = GetPersistentDecl(name);
761 
762  if (!persistent_decl)
763  return;
764 
765  Decl *parser_persistent_decl = CopyDecl(persistent_decl);
766 
767  if (!parser_persistent_decl)
768  return;
769 
770  NamedDecl *parser_named_decl = dyn_cast<NamedDecl>(parser_persistent_decl);
771 
772  if (!parser_named_decl)
773  return;
774 
775  if (clang::FunctionDecl *parser_function_decl =
776  llvm::dyn_cast<clang::FunctionDecl>(parser_named_decl)) {
777  MaybeRegisterFunctionBody(parser_function_decl);
778  }
779 
780  LLDB_LOG(log, " CEDM::FEVD Found persistent decl {0}", name);
781 
782  context.AddNamedDecl(parser_named_decl);
783 }
784 
787 
788  StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
789  SymbolContext sym_ctx;
790  if (frame != nullptr)
791  sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction |
792  lldb::eSymbolContextBlock);
793 
794  if (m_ctx_obj) {
795  Status status;
796  lldb::ValueObjectSP ctx_obj_ptr = m_ctx_obj->AddressOf(status);
797  if (!ctx_obj_ptr || status.Fail())
798  return;
799 
801  return;
802  }
803 
804  // Clang is looking for the type of "this"
805 
806  if (frame == nullptr)
807  return;
808 
809  // Find the block that defines the function represented by "sym_ctx"
810  Block *function_block = sym_ctx.GetFunctionBlock();
811 
812  if (!function_block)
813  return;
814 
815  CompilerDeclContext function_decl_ctx = function_block->GetDeclContext();
816 
817  if (!function_decl_ctx)
818  return;
819 
820  clang::CXXMethodDecl *method_decl =
822 
823  if (method_decl) {
824  if (auto capturedThis = GetCapturedThisValueObject(frame)) {
825  // We're inside a lambda and we captured a 'this'.
826  // Import the outer class's AST instead of the
827  // (unnamed) lambda structure AST so unqualified
828  // member lookups are understood by the Clang parser.
829  //
830  // If we're in a lambda which didn't capture 'this',
831  // $__lldb_class will correspond to the lambda closure
832  // AST and references to captures will resolve like
833  // regular member varaiable accesses do.
834  TypeFromUser pointee_type =
835  capturedThis->GetCompilerType().GetPointeeType();
836 
837  LLDB_LOG(log,
838  " CEDM::FEVD Adding captured type ({0} for"
839  " $__lldb_class: {1}",
840  capturedThis->GetTypeName(), capturedThis->GetName());
841 
842  AddContextClassType(context, pointee_type);
843  return;
844  }
845 
846  clang::CXXRecordDecl *class_decl = method_decl->getParent();
847 
848  QualType class_qual_type(class_decl->getTypeForDecl(), 0);
849 
850  TypeFromUser class_user_type(class_qual_type.getAsOpaquePtr(),
851  function_decl_ctx.GetTypeSystem());
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(QualType(interface_type, 0).getAsOpaquePtr(),
940  function_decl_ctx.GetTypeSystem());
941 
942  LLDB_LOG(log, " FEVD[{0}] Adding type for $__lldb_objc_class: {1}",
943  ClangUtil::ToString(interface_type));
944 
945  AddOneType(context, class_user_type);
946  return;
947  }
948  // This branch will get hit if we are executing code in the context of
949  // a function that claims to have an object pointer (through
950  // DW_AT_object_pointer?) but is not formally a method of the class.
951  // In that case, just look up the "self" variable in the current scope
952  // and use its type.
953 
954  VariableList *vars = frame->GetVariableList(false, nullptr);
955 
956  lldb::VariableSP self_var = vars->FindVariable(ConstString("self"));
957 
958  if (!self_var)
959  return;
960  if (!self_var->IsInScope(frame))
961  return;
962  if (!self_var->LocationIsValidForFrame(frame))
963  return;
964 
965  Type *self_type = self_var->GetType();
966 
967  if (!self_type)
968  return;
969 
970  CompilerType self_clang_type = self_type->GetFullCompilerType();
971 
972  if (TypeSystemClang::IsObjCClassType(self_clang_type)) {
973  return;
974  }
975  if (!TypeSystemClang::IsObjCObjectPointerType(self_clang_type))
976  return;
977  self_clang_type = self_clang_type.GetPointeeType();
978 
979  if (!self_clang_type)
980  return;
981 
982  LLDB_LOG(log, " FEVD[{0}] Adding type for $__lldb_objc_class: {1}",
984 
985  TypeFromUser class_user_type(self_clang_type);
986 
987  AddOneType(context, class_user_type);
988 }
989 
991  SymbolContext &sym_ctx, NameSearchContext &name_context) {
992  if (sym_ctx.block == nullptr)
993  return;
994 
995  CompilerDeclContext frame_decl_context = sym_ctx.block->GetDeclContext();
996  if (!frame_decl_context)
997  return;
998 
999  TypeSystemClang *frame_ast = llvm::dyn_cast_or_null<TypeSystemClang>(
1000  frame_decl_context.GetTypeSystem());
1001  if (!frame_ast)
1002  return;
1003 
1004  clang::NamespaceDecl *namespace_decl =
1007  if (!namespace_decl)
1008  return;
1009 
1010  name_context.AddNamedDecl(namespace_decl);
1011  clang::DeclContext *ctxt = clang::Decl::castToDeclContext(namespace_decl);
1012  ctxt->setHasExternalVisibleStorage(true);
1013  name_context.m_found_local_vars_nsp = true;
1014 }
1015 
1017  NameSearchContext &context, ConstString name) {
1019 
1020  if (!m_target)
1021  return;
1022 
1023  std::shared_ptr<ClangModulesDeclVendor> modules_decl_vendor =
1025  if (!modules_decl_vendor)
1026  return;
1027 
1028  bool append = false;
1029  uint32_t max_matches = 1;
1030  std::vector<clang::NamedDecl *> decls;
1031 
1032  if (!modules_decl_vendor->FindDecls(name, append, max_matches, decls))
1033  return;
1034 
1035  assert(!decls.empty() && "FindDecls returned true but no decls?");
1036  clang::NamedDecl *const decl_from_modules = decls[0];
1037 
1038  LLDB_LOG(log,
1039  " CAS::FEVD Matching decl found for "
1040  "\"{0}\" in the modules",
1041  name);
1042 
1043  clang::Decl *copied_decl = CopyDecl(decl_from_modules);
1044  if (!copied_decl) {
1045  LLDB_LOG(log, " CAS::FEVD - Couldn't export a "
1046  "declaration from the modules");
1047  return;
1048  }
1049 
1050  if (auto copied_function = dyn_cast<clang::FunctionDecl>(copied_decl)) {
1051  MaybeRegisterFunctionBody(copied_function);
1052 
1053  context.AddNamedDecl(copied_function);
1054 
1055  context.m_found_function_with_type_info = true;
1056  context.m_found_function = true;
1057  } else if (auto copied_var = dyn_cast<clang::VarDecl>(copied_decl)) {
1058  context.AddNamedDecl(copied_var);
1059  context.m_found_variable = true;
1060  }
1061 }
1062 
1064  NameSearchContext &context, ConstString name, SymbolContext &sym_ctx,
1065  const CompilerDeclContext &namespace_decl) {
1066  if (sym_ctx.block == nullptr)
1067  return false;
1068 
1069  CompilerDeclContext decl_context = sym_ctx.block->GetDeclContext();
1070  if (!decl_context)
1071  return false;
1072 
1073  // Make sure that the variables are parsed so that we have the
1074  // declarations.
1075  StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
1076  VariableListSP vars = frame->GetInScopeVariableList(true);
1077  for (size_t i = 0; i < vars->GetSize(); i++)
1078  vars->GetVariableAtIndex(i)->GetDecl();
1079 
1080  // Search for declarations matching the name. Do not include imported
1081  // decls in the search if we are looking for decls in the artificial
1082  // namespace $__lldb_local_vars.
1083  std::vector<CompilerDecl> found_decls =
1084  decl_context.FindDeclByName(name, namespace_decl.IsValid());
1085 
1086  VariableSP var;
1087  bool variable_found = false;
1088  for (CompilerDecl decl : found_decls) {
1089  for (size_t vi = 0, ve = vars->GetSize(); vi != ve; ++vi) {
1090  VariableSP candidate_var = vars->GetVariableAtIndex(vi);
1091  if (candidate_var->GetDecl() == decl) {
1092  var = candidate_var;
1093  break;
1094  }
1095  }
1096 
1097  if (var && !variable_found) {
1098  variable_found = true;
1099  ValueObjectSP valobj = ValueObjectVariable::Create(frame, var);
1100  AddOneVariable(context, var, valobj);
1101  context.m_found_variable = true;
1102  }
1103  }
1104 
1105  // We're in a local_var_lookup but haven't found any local variables
1106  // so far. When performing a variable lookup from within the context of
1107  // a lambda, we count the lambda captures as local variables. Thus,
1108  // see if we captured any variables with the requested 'name'.
1109  if (!variable_found) {
1110  auto find_capture = [](ConstString varname,
1111  StackFrame *frame) -> ValueObjectSP {
1112  if (auto lambda = ClangExpressionUtil::GetLambdaValueObject(frame)) {
1113  if (auto capture = lambda->GetChildMemberWithName(varname, true)) {
1114  return capture;
1115  }
1116  }
1117 
1118  return nullptr;
1119  };
1120 
1121  if (auto capture = find_capture(name, frame)) {
1122  variable_found = true;
1123  context.m_found_variable = true;
1124  AddOneVariable(context, std::move(capture), std::move(find_capture));
1125  }
1126  }
1127 
1128  return variable_found;
1129 }
1130 
1131 /// Structure to hold the info needed when comparing function
1132 /// declarations.
1133 namespace {
1134 struct FuncDeclInfo {
1135  ConstString m_name;
1136  CompilerType m_copied_type;
1137  uint32_t m_decl_lvl;
1138  SymbolContext m_sym_ctx;
1139 };
1140 } // namespace
1141 
1143  const SymbolContextList &sc_list,
1144  const CompilerDeclContext &frame_decl_context) {
1145  // First, symplify things by looping through the symbol contexts to
1146  // remove unwanted functions and separate out the functions we want to
1147  // compare and prune into a separate list. Cache the info needed about
1148  // the function declarations in a vector for efficiency.
1149  uint32_t num_indices = sc_list.GetSize();
1150  SymbolContextList sc_sym_list;
1151  std::vector<FuncDeclInfo> decl_infos;
1152  decl_infos.reserve(num_indices);
1153  clang::DeclContext *frame_decl_ctx =
1154  (clang::DeclContext *)frame_decl_context.GetOpaqueDeclContext();
1155  TypeSystemClang *ast = llvm::dyn_cast_or_null<TypeSystemClang>(
1156  frame_decl_context.GetTypeSystem());
1157 
1158  for (uint32_t index = 0; index < num_indices; ++index) {
1159  FuncDeclInfo fdi;
1160  SymbolContext sym_ctx;
1161  sc_list.GetContextAtIndex(index, sym_ctx);
1162 
1163  // We don't know enough about symbols to compare them, but we should
1164  // keep them in the list.
1165  Function *function = sym_ctx.function;
1166  if (!function) {
1167  sc_sym_list.Append(sym_ctx);
1168  continue;
1169  }
1170  // Filter out functions without declaration contexts, as well as
1171  // class/instance methods, since they'll be skipped in the code that
1172  // follows anyway.
1173  CompilerDeclContext func_decl_context = function->GetDeclContext();
1174  if (!func_decl_context ||
1175  func_decl_context.IsClassMethod(nullptr, nullptr, nullptr))
1176  continue;
1177  // We can only prune functions for which we can copy the type.
1178  CompilerType func_clang_type = function->GetType()->GetFullCompilerType();
1179  CompilerType copied_func_type = GuardedCopyType(func_clang_type);
1180  if (!copied_func_type) {
1181  sc_sym_list.Append(sym_ctx);
1182  continue;
1183  }
1184 
1185  fdi.m_sym_ctx = sym_ctx;
1186  fdi.m_name = function->GetName();
1187  fdi.m_copied_type = copied_func_type;
1188  fdi.m_decl_lvl = LLDB_INVALID_DECL_LEVEL;
1189  if (fdi.m_copied_type && func_decl_context) {
1190  // Call CountDeclLevels to get the number of parent scopes we have
1191  // to look through before we find the function declaration. When
1192  // comparing functions of the same type, the one with a lower count
1193  // will be closer to us in the lookup scope and shadows the other.
1194  clang::DeclContext *func_decl_ctx =
1195  (clang::DeclContext *)func_decl_context.GetOpaqueDeclContext();
1196  fdi.m_decl_lvl = ast->CountDeclLevels(frame_decl_ctx, func_decl_ctx,
1197  &fdi.m_name, &fdi.m_copied_type);
1198  }
1199  decl_infos.emplace_back(fdi);
1200  }
1201 
1202  // Loop through the functions in our cache looking for matching types,
1203  // then compare their scope levels to see which is closer.
1204  std::multimap<CompilerType, const FuncDeclInfo *> matches;
1205  for (const FuncDeclInfo &fdi : decl_infos) {
1206  const CompilerType t = fdi.m_copied_type;
1207  auto q = matches.find(t);
1208  if (q != matches.end()) {
1209  if (q->second->m_decl_lvl > fdi.m_decl_lvl)
1210  // This function is closer; remove the old set.
1211  matches.erase(t);
1212  else if (q->second->m_decl_lvl < fdi.m_decl_lvl)
1213  // The functions in our set are closer - skip this one.
1214  continue;
1215  }
1216  matches.insert(std::make_pair(t, &fdi));
1217  }
1218 
1219  // Loop through our matches and add their symbol contexts to our list.
1220  SymbolContextList sc_func_list;
1221  for (const auto &q : matches)
1222  sc_func_list.Append(q.second->m_sym_ctx);
1223 
1224  // Rejoin the lists with the functions in front.
1225  sc_func_list.Append(sc_sym_list);
1226  return sc_func_list;
1227 }
1228 
1230  NameSearchContext &context, lldb::ModuleSP module_sp, ConstString name,
1231  const CompilerDeclContext &namespace_decl) {
1232  if (!m_parser_vars)
1233  return;
1234 
1235  Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
1236 
1237  std::vector<clang::NamedDecl *> decls_from_modules;
1238 
1239  if (target) {
1240  if (std::shared_ptr<ClangModulesDeclVendor> decl_vendor =
1242  decl_vendor->FindDecls(name, false, UINT32_MAX, decls_from_modules);
1243  }
1244  }
1245 
1246  SymbolContextList sc_list;
1247  if (namespace_decl && module_sp) {
1248  ModuleFunctionSearchOptions function_options;
1249  function_options.include_inlines = false;
1250  function_options.include_symbols = false;
1251 
1252  module_sp->FindFunctions(name, namespace_decl, eFunctionNameTypeBase,
1253  function_options, sc_list);
1254  } else if (target && !namespace_decl) {
1255  ModuleFunctionSearchOptions function_options;
1256  function_options.include_inlines = false;
1257  function_options.include_symbols = true;
1258 
1259  // TODO Fix FindFunctions so that it doesn't return
1260  // instance methods for eFunctionNameTypeBase.
1261 
1262  target->GetImages().FindFunctions(
1263  name, eFunctionNameTypeFull | eFunctionNameTypeBase, function_options,
1264  sc_list);
1265  }
1266 
1267  // If we found more than one function, see if we can use the frame's decl
1268  // context to remove functions that are shadowed by other functions which
1269  // match in type but are nearer in scope.
1270  //
1271  // AddOneFunction will not add a function whose type has already been
1272  // added, so if there's another function in the list with a matching type,
1273  // check to see if their decl context is a parent of the current frame's or
1274  // was imported via a and using statement, and pick the best match
1275  // according to lookup rules.
1276  if (sc_list.GetSize() > 1) {
1277  // Collect some info about our frame's context.
1278  StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
1279  SymbolContext frame_sym_ctx;
1280  if (frame != nullptr)
1281  frame_sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction |
1282  lldb::eSymbolContextBlock);
1283  CompilerDeclContext frame_decl_context =
1284  frame_sym_ctx.block != nullptr ? frame_sym_ctx.block->GetDeclContext()
1285  : CompilerDeclContext();
1286 
1287  // We can't do this without a compiler decl context for our frame.
1288  if (frame_decl_context) {
1289  sc_list = SearchFunctionsInSymbolContexts(sc_list, frame_decl_context);
1290  }
1291  }
1292 
1293  if (sc_list.GetSize()) {
1294  Symbol *extern_symbol = nullptr;
1295  Symbol *non_extern_symbol = nullptr;
1296 
1297  for (uint32_t index = 0, num_indices = sc_list.GetSize();
1298  index < num_indices; ++index) {
1299  SymbolContext sym_ctx;
1300  sc_list.GetContextAtIndex(index, sym_ctx);
1301 
1302  if (sym_ctx.function) {
1303  CompilerDeclContext decl_ctx = sym_ctx.function->GetDeclContext();
1304 
1305  if (!decl_ctx)
1306  continue;
1307 
1308  // Filter out class/instance methods.
1309  if (decl_ctx.IsClassMethod(nullptr, nullptr, nullptr))
1310  continue;
1311 
1312  AddOneFunction(context, sym_ctx.function, nullptr);
1313  context.m_found_function_with_type_info = true;
1314  context.m_found_function = true;
1315  } else if (sym_ctx.symbol) {
1316  if (sym_ctx.symbol->GetType() == eSymbolTypeReExported && target) {
1317  sym_ctx.symbol = sym_ctx.symbol->ResolveReExportedSymbol(*target);
1318  if (sym_ctx.symbol == nullptr)
1319  continue;
1320  }
1321 
1322  if (sym_ctx.symbol->IsExternal())
1323  extern_symbol = sym_ctx.symbol;
1324  else
1325  non_extern_symbol = sym_ctx.symbol;
1326  }
1327  }
1328 
1329  if (!context.m_found_function_with_type_info) {
1330  for (clang::NamedDecl *decl : decls_from_modules) {
1331  if (llvm::isa<clang::FunctionDecl>(decl)) {
1332  clang::NamedDecl *copied_decl =
1333  llvm::cast_or_null<FunctionDecl>(CopyDecl(decl));
1334  if (copied_decl) {
1335  context.AddNamedDecl(copied_decl);
1336  context.m_found_function_with_type_info = true;
1337  }
1338  }
1339  }
1340  }
1341 
1342  if (!context.m_found_function_with_type_info) {
1343  if (extern_symbol) {
1344  AddOneFunction(context, nullptr, extern_symbol);
1345  context.m_found_function = true;
1346  } else if (non_extern_symbol) {
1347  AddOneFunction(context, nullptr, non_extern_symbol);
1348  context.m_found_function = true;
1349  }
1350  }
1351  }
1352 }
1353 
1355  NameSearchContext &context, lldb::ModuleSP module_sp,
1356  const CompilerDeclContext &namespace_decl) {
1357  assert(m_ast_context);
1358 
1360 
1361  const ConstString name(context.m_decl_name.getAsString().c_str());
1362  if (IgnoreName(name, false))
1363  return;
1364 
1365  // Only look for functions by name out in our symbols if the function doesn't
1366  // start with our phony prefix of '$'
1367 
1368  Target *target = nullptr;
1369  StackFrame *frame = nullptr;
1370  SymbolContext sym_ctx;
1371  if (m_parser_vars) {
1372  target = m_parser_vars->m_exe_ctx.GetTargetPtr();
1373  frame = m_parser_vars->m_exe_ctx.GetFramePtr();
1374  }
1375  if (frame != nullptr)
1376  sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction |
1377  lldb::eSymbolContextBlock);
1378 
1379  // Try the persistent decls, which take precedence over all else.
1380  if (!namespace_decl)
1381  SearchPersistenDecls(context, name);
1382 
1383  if (name.GetStringRef().startswith("$") && !namespace_decl) {
1384  if (name == "$__lldb_class") {
1385  LookUpLldbClass(context);
1386  return;
1387  }
1388 
1389  if (name == "$__lldb_objc_class") {
1390  LookUpLldbObjCClass(context);
1391  return;
1392  }
1393  if (name == g_lldb_local_vars_namespace_cstr) {
1394  LookupLocalVarNamespace(sym_ctx, context);
1395  return;
1396  }
1397 
1398  // any other $__lldb names should be weeded out now
1399  if (name.GetStringRef().startswith("$__lldb"))
1400  return;
1401 
1402  // No ParserVars means we can't do register or variable lookup.
1403  if (!m_parser_vars || !m_parser_vars->m_persistent_vars)
1404  return;
1405 
1406  ExpressionVariableSP pvar_sp(
1407  m_parser_vars->m_persistent_vars->GetVariable(name));
1408 
1409  if (pvar_sp) {
1410  AddOneVariable(context, pvar_sp);
1411  return;
1412  }
1413 
1414  assert(name.GetStringRef().startswith("$"));
1415  llvm::StringRef reg_name = name.GetStringRef().substr(1);
1416 
1417  if (m_parser_vars->m_exe_ctx.GetRegisterContext()) {
1418  const RegisterInfo *reg_info(
1419  m_parser_vars->m_exe_ctx.GetRegisterContext()->GetRegisterInfoByName(
1420  reg_name));
1421 
1422  if (reg_info) {
1423  LLDB_LOG(log, " CEDM::FEVD Found register {0}", reg_info->name);
1424 
1425  AddOneRegister(context, reg_info);
1426  }
1427  }
1428  return;
1429  }
1430 
1431  bool local_var_lookup = !namespace_decl || (namespace_decl.GetName() ==
1433  if (frame && local_var_lookup)
1434  if (LookupLocalVariable(context, name, sym_ctx, namespace_decl))
1435  return;
1436 
1437  if (target) {
1438  ValueObjectSP valobj;
1439  VariableSP var;
1440  var = FindGlobalVariable(*target, module_sp, name, namespace_decl);
1441 
1442  if (var) {
1443  valobj = ValueObjectVariable::Create(target, var);
1444  AddOneVariable(context, var, valobj);
1445  context.m_found_variable = true;
1446  return;
1447  }
1448  }
1449 
1450  LookupFunction(context, module_sp, name, namespace_decl);
1451 
1452  // Try the modules next.
1453  if (!context.m_found_function_with_type_info)
1454  LookupInModulesDeclVendor(context, name);
1455 
1456  if (target && !context.m_found_variable && !namespace_decl) {
1457  // We couldn't find a non-symbol variable for this. Now we'll hunt for a
1458  // generic data symbol, and -- if it is found -- treat it as a variable.
1459  Status error;
1460 
1461  const Symbol *data_symbol =
1462  m_parser_vars->m_sym_ctx.FindBestGlobalDataSymbol(name, error);
1463 
1464  if (!error.Success()) {
1465  const unsigned diag_id =
1466  m_ast_context->getDiagnostics().getCustomDiagID(
1468  m_ast_context->getDiagnostics().Report(diag_id) << error.AsCString();
1469  }
1470 
1471  if (data_symbol) {
1472  std::string warning("got name from symbols: ");
1473  warning.append(name.AsCString());
1474  const unsigned diag_id =
1475  m_ast_context->getDiagnostics().getCustomDiagID(
1476  clang::DiagnosticsEngine::Level::Warning, "%0");
1477  m_ast_context->getDiagnostics().Report(diag_id) << warning.c_str();
1478  AddOneGenericVariable(context, *data_symbol);
1479  context.m_found_variable = true;
1480  }
1481  }
1482 }
1483 
1485  lldb_private::Value &var_location,
1486  TypeFromUser *user_type,
1487  TypeFromParser *parser_type) {
1489 
1490  Type *var_type = var->GetType();
1491 
1492  if (!var_type) {
1493  LLDB_LOG(log, "Skipped a definition because it has no type");
1494  return false;
1495  }
1496 
1497  CompilerType var_clang_type = var_type->GetFullCompilerType();
1498 
1499  if (!var_clang_type) {
1500  LLDB_LOG(log, "Skipped a definition because it has no Clang type");
1501  return false;
1502  }
1503 
1504  TypeSystemClang *clang_ast = llvm::dyn_cast_or_null<TypeSystemClang>(
1505  var_type->GetForwardCompilerType().GetTypeSystem());
1506 
1507  if (!clang_ast) {
1508  LLDB_LOG(log, "Skipped a definition because it has no Clang AST");
1509  return false;
1510  }
1511 
1512  DWARFExpressionList &var_location_list = var->LocationExpressionList();
1513 
1514  Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
1515  Status err;
1516 
1517  if (var->GetLocationIsConstantValueData()) {
1518  DataExtractor const_value_extractor;
1519  if (var_location_list.GetExpressionData(const_value_extractor)) {
1520  var_location = Value(const_value_extractor.GetDataStart(),
1521  const_value_extractor.GetByteSize());
1523  } else {
1524  LLDB_LOG(log, "Error evaluating constant variable: {0}", err.AsCString());
1525  return false;
1526  }
1527  }
1528 
1529  CompilerType type_to_use = GuardedCopyType(var_clang_type);
1530 
1531  if (!type_to_use) {
1532  LLDB_LOG(log,
1533  "Couldn't copy a variable's type into the parser's AST context");
1534 
1535  return false;
1536  }
1537 
1538  if (parser_type)
1539  *parser_type = TypeFromParser(type_to_use);
1540 
1541  if (var_location.GetContextType() == Value::ContextType::Invalid)
1542  var_location.SetCompilerType(type_to_use);
1543 
1544  if (var_location.GetValueType() == Value::ValueType::FileAddress) {
1545  SymbolContext var_sc;
1546  var->CalculateSymbolContext(&var_sc);
1547 
1548  if (!var_sc.module_sp)
1549  return false;
1550 
1551  Address so_addr(var_location.GetScalar().ULongLong(),
1552  var_sc.module_sp->GetSectionList());
1553 
1554  lldb::addr_t load_addr = so_addr.GetLoadAddress(target);
1555 
1556  if (load_addr != LLDB_INVALID_ADDRESS) {
1557  var_location.GetScalar() = load_addr;
1559  }
1560  }
1561 
1562  if (user_type)
1563  *user_type = TypeFromUser(var_clang_type);
1564 
1565  return true;
1566 }
1567 
1570  TypeFromParser const &pt,
1571  ValueObjectSP valobj) {
1572  clang::QualType parser_opaque_type =
1573  QualType::getFromOpaquePtr(pt.GetOpaqueQualType());
1574 
1575  if (parser_opaque_type.isNull())
1576  return nullptr;
1577 
1578  if (const clang::Type *parser_type = parser_opaque_type.getTypePtr()) {
1579  if (const TagType *tag_type = dyn_cast<TagType>(parser_type))
1580  CompleteType(tag_type->getDecl());
1581  if (const ObjCObjectPointerType *objc_object_ptr_type =
1582  dyn_cast<ObjCObjectPointerType>(parser_type))
1583  CompleteType(objc_object_ptr_type->getInterfaceDecl());
1584  }
1585 
1586  bool is_reference = pt.IsReferenceType();
1587 
1588  NamedDecl *var_decl = nullptr;
1589  if (is_reference)
1590  var_decl = context.AddVarDecl(pt);
1591  else
1592  var_decl = context.AddVarDecl(pt.GetLValueReferenceType());
1593 
1594  std::string decl_name(context.m_decl_name.getAsString());
1595  ConstString entity_name(decl_name.c_str());
1596  ClangExpressionVariable *entity(new ClangExpressionVariable(valobj));
1598 
1599  assert(entity);
1600  entity->EnableParserVars(GetParserID());
1602  entity->GetParserVars(GetParserID());
1603 
1604  parser_vars->m_named_decl = var_decl;
1605 
1606  if (is_reference)
1608 
1609  return parser_vars;
1610 }
1611 
1613  NameSearchContext &context, ValueObjectSP valobj,
1614  ValueObjectProviderTy valobj_provider) {
1615  assert(m_parser_vars.get());
1616  assert(valobj);
1617 
1619 
1620  Value var_location = valobj->GetValue();
1621 
1622  TypeFromUser user_type = valobj->GetCompilerType();
1623 
1624  TypeSystemClang *clang_ast =
1625  llvm::dyn_cast_or_null<TypeSystemClang>(user_type.GetTypeSystem());
1626 
1627  if (!clang_ast) {
1628  LLDB_LOG(log, "Skipped a definition because it has no Clang AST");
1629  return;
1630  }
1631 
1632  TypeFromParser parser_type = GuardedCopyType(user_type);
1633 
1634  if (!parser_type) {
1635  LLDB_LOG(log,
1636  "Couldn't copy a variable's type into the parser's AST context");
1637 
1638  return;
1639  }
1640 
1641  if (var_location.GetContextType() == Value::ContextType::Invalid)
1642  var_location.SetCompilerType(parser_type);
1643 
1645  AddExpressionVariable(context, parser_type, valobj);
1646 
1647  if (!parser_vars)
1648  return;
1649 
1650  LLDB_LOG(log, " CEDM::FEVD Found variable {0}, returned\n{1} (original {2})",
1651  context.m_decl_name, ClangUtil::DumpDecl(parser_vars->m_named_decl),
1652  ClangUtil::ToString(user_type));
1653 
1654  parser_vars->m_llvm_value = nullptr;
1655  parser_vars->m_lldb_value = std::move(var_location);
1656  parser_vars->m_lldb_valobj_provider = std::move(valobj_provider);
1657 }
1658 
1660  VariableSP var,
1661  ValueObjectSP valobj) {
1662  assert(m_parser_vars.get());
1663 
1665 
1666  TypeFromUser ut;
1667  TypeFromParser pt;
1668  Value var_location;
1669 
1670  if (!GetVariableValue(var, var_location, &ut, &pt))
1671  return;
1672 
1674  AddExpressionVariable(context, pt, std::move(valobj));
1675 
1676  if (!parser_vars)
1677  return;
1678 
1679  LLDB_LOG(log, " CEDM::FEVD Found variable {0}, returned\n{1} (original {2})",
1680  context.m_decl_name, ClangUtil::DumpDecl(parser_vars->m_named_decl),
1681  ClangUtil::ToString(ut));
1682 
1683  parser_vars->m_llvm_value = nullptr;
1684  parser_vars->m_lldb_value = var_location;
1685  parser_vars->m_lldb_var = var;
1686 }
1687 
1689  ExpressionVariableSP &pvar_sp) {
1691 
1692  TypeFromUser user_type(
1693  llvm::cast<ClangExpressionVariable>(pvar_sp.get())->GetTypeFromUser());
1694 
1695  TypeFromParser parser_type(GuardedCopyType(user_type));
1696 
1697  if (!parser_type.GetOpaqueQualType()) {
1698  LLDB_LOG(log, " CEDM::FEVD Couldn't import type for pvar {0}",
1699  pvar_sp->GetName());
1700  return;
1701  }
1702 
1703  NamedDecl *var_decl =
1704  context.AddVarDecl(parser_type.GetLValueReferenceType());
1705 
1706  llvm::cast<ClangExpressionVariable>(pvar_sp.get())
1707  ->EnableParserVars(GetParserID());
1709  llvm::cast<ClangExpressionVariable>(pvar_sp.get())
1710  ->GetParserVars(GetParserID());
1711  parser_vars->m_named_decl = var_decl;
1712  parser_vars->m_llvm_value = nullptr;
1713  parser_vars->m_lldb_value.Clear();
1714 
1715  LLDB_LOG(log, " CEDM::FEVD Added pvar {0}, returned\n{1}",
1716  pvar_sp->GetName(), ClangUtil::DumpDecl(var_decl));
1717 }
1718 
1720  const Symbol &symbol) {
1721  assert(m_parser_vars.get());
1722 
1724 
1725  Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
1726 
1727  if (target == nullptr)
1728  return;
1729 
1730  TypeSystemClang *scratch_ast_context = GetScratchContext(*target);
1731  if (!scratch_ast_context)
1732  return;
1733 
1734  TypeFromUser user_type(scratch_ast_context->GetBasicType(eBasicTypeVoid)
1735  .GetPointerType()
1738  .GetPointerType()
1740  NamedDecl *var_decl = context.AddVarDecl(parser_type);
1741 
1742  std::string decl_name(context.m_decl_name.getAsString());
1743  ConstString entity_name(decl_name.c_str());
1745  m_parser_vars->m_exe_ctx.GetBestExecutionContextScope(), entity_name,
1746  user_type, m_parser_vars->m_target_info.byte_order,
1747  m_parser_vars->m_target_info.address_byte_size));
1749 
1750  entity->EnableParserVars(GetParserID());
1752  entity->GetParserVars(GetParserID());
1753 
1754  const Address symbol_address = symbol.GetAddress();
1755  lldb::addr_t symbol_load_addr = symbol_address.GetLoadAddress(target);
1756 
1757  // parser_vars->m_lldb_value.SetContext(Value::ContextType::ClangType,
1758  // user_type.GetOpaqueQualType());
1759  parser_vars->m_lldb_value.SetCompilerType(user_type);
1760  parser_vars->m_lldb_value.GetScalar() = symbol_load_addr;
1762 
1763  parser_vars->m_named_decl = var_decl;
1764  parser_vars->m_llvm_value = nullptr;
1765  parser_vars->m_lldb_sym = &symbol;
1766 
1767  LLDB_LOG(log, " CEDM::FEVD Found variable {0}, returned\n{1}", decl_name,
1768  ClangUtil::DumpDecl(var_decl));
1769 }
1770 
1772  const RegisterInfo *reg_info) {
1774 
1775  CompilerType clang_type =
1777  reg_info->encoding, reg_info->byte_size * 8);
1778 
1779  if (!clang_type) {
1780  LLDB_LOG(log, " Tried to add a type for {0}, but couldn't get one",
1781  context.m_decl_name.getAsString());
1782  return;
1783  }
1784 
1785  TypeFromParser parser_clang_type(clang_type);
1786 
1787  NamedDecl *var_decl = context.AddVarDecl(parser_clang_type);
1788 
1790  m_parser_vars->m_exe_ctx.GetBestExecutionContextScope(),
1791  m_parser_vars->m_target_info.byte_order,
1792  m_parser_vars->m_target_info.address_byte_size));
1794 
1795  std::string decl_name(context.m_decl_name.getAsString());
1796  entity->SetName(ConstString(decl_name.c_str()));
1797  entity->SetRegisterInfo(reg_info);
1798  entity->EnableParserVars(GetParserID());
1800  entity->GetParserVars(GetParserID());
1801  parser_vars->m_named_decl = var_decl;
1802  parser_vars->m_llvm_value = nullptr;
1803  parser_vars->m_lldb_value.Clear();
1805 
1806  LLDB_LOG(log, " CEDM::FEVD Added register {0}, returned\n{1}",
1807  context.m_decl_name.getAsString(), ClangUtil::DumpDecl(var_decl));
1808 }
1809 
1811  Function *function,
1812  Symbol *symbol) {
1813  assert(m_parser_vars.get());
1814 
1816 
1817  NamedDecl *function_decl = nullptr;
1818  Address fun_address;
1819  CompilerType function_clang_type;
1820 
1821  bool is_indirect_function = false;
1822 
1823  if (function) {
1824  Type *function_type = function->GetType();
1825 
1826  const auto lang = function->GetCompileUnit()->GetLanguage();
1827  const auto name = function->GetMangled().GetMangledName().AsCString();
1828  const bool extern_c = (Language::LanguageIsC(lang) &&
1830  (Language::LanguageIsObjC(lang) &&
1832 
1833  if (!extern_c) {
1834  TypeSystem *type_system = function->GetDeclContext().GetTypeSystem();
1835  if (llvm::isa<TypeSystemClang>(type_system)) {
1836  clang::DeclContext *src_decl_context =
1837  (clang::DeclContext *)function->GetDeclContext()
1838  .GetOpaqueDeclContext();
1839  clang::FunctionDecl *src_function_decl =
1840  llvm::dyn_cast_or_null<clang::FunctionDecl>(src_decl_context);
1841  if (src_function_decl &&
1842  src_function_decl->getTemplateSpecializationInfo()) {
1843  clang::FunctionTemplateDecl *function_template =
1844  src_function_decl->getTemplateSpecializationInfo()->getTemplate();
1845  clang::FunctionTemplateDecl *copied_function_template =
1846  llvm::dyn_cast_or_null<clang::FunctionTemplateDecl>(
1847  CopyDecl(function_template));
1848  if (copied_function_template) {
1849  if (log) {
1850  StreamString ss;
1851 
1852  function->DumpSymbolContext(&ss);
1853 
1854  LLDB_LOG(log,
1855  " CEDM::FEVD Imported decl for function template"
1856  " {0} (description {1}), returned\n{2}",
1857  copied_function_template->getNameAsString(),
1858  ss.GetData(),
1859  ClangUtil::DumpDecl(copied_function_template));
1860  }
1861 
1862  context.AddNamedDecl(copied_function_template);
1863  }
1864  } else if (src_function_decl) {
1865  if (clang::FunctionDecl *copied_function_decl =
1866  llvm::dyn_cast_or_null<clang::FunctionDecl>(
1867  CopyDecl(src_function_decl))) {
1868  if (log) {
1869  StreamString ss;
1870 
1871  function->DumpSymbolContext(&ss);
1872 
1873  LLDB_LOG(log,
1874  " CEDM::FEVD Imported decl for function {0} "
1875  "(description {1}), returned\n{2}",
1876  copied_function_decl->getNameAsString(), ss.GetData(),
1877  ClangUtil::DumpDecl(copied_function_decl));
1878  }
1879 
1880  context.AddNamedDecl(copied_function_decl);
1881  return;
1882  } else {
1883  LLDB_LOG(log, " Failed to import the function decl for '{0}'",
1884  src_function_decl->getName());
1885  }
1886  }
1887  }
1888  }
1889 
1890  if (!function_type) {
1891  LLDB_LOG(log, " Skipped a function because it has no type");
1892  return;
1893  }
1894 
1895  function_clang_type = function_type->GetFullCompilerType();
1896 
1897  if (!function_clang_type) {
1898  LLDB_LOG(log, " Skipped a function because it has no Clang type");
1899  return;
1900  }
1901 
1902  fun_address = function->GetAddressRange().GetBaseAddress();
1903 
1904  CompilerType copied_function_type = GuardedCopyType(function_clang_type);
1905  if (copied_function_type) {
1906  function_decl = context.AddFunDecl(copied_function_type, extern_c);
1907 
1908  if (!function_decl) {
1909  LLDB_LOG(log, " Failed to create a function decl for '{0}' ({1:x})",
1910  function_type->GetName(), function_type->GetID());
1911 
1912  return;
1913  }
1914  } else {
1915  // We failed to copy the type we found
1916  LLDB_LOG(log,
1917  " Failed to import the function type '{0}' ({1:x})"
1918  " into the expression parser AST context",
1919  function_type->GetName(), function_type->GetID());
1920 
1921  return;
1922  }
1923  } else if (symbol) {
1924  fun_address = symbol->GetAddress();
1925  function_decl = context.AddGenericFunDecl();
1926  is_indirect_function = symbol->IsIndirect();
1927  } else {
1928  LLDB_LOG(log, " AddOneFunction called with no function and no symbol");
1929  return;
1930  }
1931 
1932  Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
1933 
1934  lldb::addr_t load_addr =
1935  fun_address.GetCallableLoadAddress(target, is_indirect_function);
1936 
1938  m_parser_vars->m_exe_ctx.GetBestExecutionContextScope(),
1939  m_parser_vars->m_target_info.byte_order,
1940  m_parser_vars->m_target_info.address_byte_size));
1942 
1943  std::string decl_name(context.m_decl_name.getAsString());
1944  entity->SetName(ConstString(decl_name.c_str()));
1945  entity->SetCompilerType(function_clang_type);
1946  entity->EnableParserVars(GetParserID());
1947 
1949  entity->GetParserVars(GetParserID());
1950 
1951  if (load_addr != LLDB_INVALID_ADDRESS) {
1953  parser_vars->m_lldb_value.GetScalar() = load_addr;
1954  } else {
1955  // We have to try finding a file address.
1956 
1957  lldb::addr_t file_addr = fun_address.GetFileAddress();
1958 
1960  parser_vars->m_lldb_value.GetScalar() = file_addr;
1961  }
1962 
1963  parser_vars->m_named_decl = function_decl;
1964  parser_vars->m_llvm_value = nullptr;
1965 
1966  if (log) {
1967  StreamString ss;
1968 
1969  fun_address.Dump(&ss,
1970  m_parser_vars->m_exe_ctx.GetBestExecutionContextScope(),
1972 
1973  LLDB_LOG(log,
1974  " CEDM::FEVD Found {0} function {1} (description {2}), "
1975  "returned\n{3}",
1976  (function ? "specific" : "generic"), decl_name, ss.GetData(),
1977  ClangUtil::DumpDecl(function_decl));
1978  }
1979 }
1980 
1982  const TypeFromUser &ut) {
1983  CompilerType copied_clang_type = GuardedCopyType(ut);
1984 
1986 
1987  if (!copied_clang_type) {
1988  LLDB_LOG(log,
1989  "ClangExpressionDeclMap::AddThisType - Couldn't import the type");
1990 
1991  return;
1992  }
1993 
1994  if (copied_clang_type.IsAggregateType() &&
1995  copied_clang_type.GetCompleteType()) {
1996  CompilerType void_clang_type =
1998  CompilerType void_ptr_clang_type = void_clang_type.GetPointerType();
1999 
2001  void_clang_type, &void_ptr_clang_type, 1, false, 0);
2002 
2003  const bool is_virtual = false;
2004  const bool is_static = false;
2005  const bool is_inline = false;
2006  const bool is_explicit = false;
2007  const bool is_attr_used = true;
2008  const bool is_artificial = false;
2009 
2010  CXXMethodDecl *method_decl = m_clang_ast_context->AddMethodToCXXRecordType(
2011  copied_clang_type.GetOpaqueQualType(), "$__lldb_expr", nullptr,
2012  method_type, lldb::eAccessPublic, is_virtual, is_static, is_inline,
2013  is_explicit, is_attr_used, is_artificial);
2014 
2015  LLDB_LOG(log,
2016  " CEDM::AddThisType Added function $__lldb_expr "
2017  "(description {0}) for this type\n{1}",
2018  ClangUtil::ToString(copied_clang_type),
2019  ClangUtil::DumpDecl(method_decl));
2020  }
2021 
2022  if (!copied_clang_type.IsValid())
2023  return;
2024 
2025  TypeSourceInfo *type_source_info = m_ast_context->getTrivialTypeSourceInfo(
2026  QualType::getFromOpaquePtr(copied_clang_type.GetOpaqueQualType()));
2027 
2028  if (!type_source_info)
2029  return;
2030 
2031  // Construct a typedef type because if "*this" is a templated type we can't
2032  // just return ClassTemplateSpecializationDecls in response to name queries.
2033  // Using a typedef makes this much more robust.
2034 
2035  TypedefDecl *typedef_decl = TypedefDecl::Create(
2036  *m_ast_context, m_ast_context->getTranslationUnitDecl(), SourceLocation(),
2037  SourceLocation(), context.m_decl_name.getAsIdentifierInfo(),
2038  type_source_info);
2039 
2040  if (!typedef_decl)
2041  return;
2042 
2043  context.AddNamedDecl(typedef_decl);
2044 }
2045 
2047  const TypeFromUser &ut) {
2048  CompilerType copied_clang_type = GuardedCopyType(ut);
2049 
2050  if (!copied_clang_type) {
2052 
2053  LLDB_LOG(log,
2054  "ClangExpressionDeclMap::AddOneType - Couldn't import the type");
2055 
2056  return;
2057  }
2058 
2059  context.AddTypeDecl(copied_clang_type);
2060 }
lldb_private::ExpressionVariableList::GetSize
size_t GetSize()
Implementation of methods in ExpressionVariableListBase.
Definition: ExpressionVariable.h:123
lldb_private::ClangExpressionDeclMap::LookUpLldbClass
void LookUpLldbClass(NameSearchContext &context)
Handles looking up $__lldb_class which requires special treatment.
Definition: ClangExpressionDeclMap.cpp:785
lldb::eSymbolTypeCompiler
@ eSymbolTypeCompiler
Definition: lldb-enumerations.h:643
lldb_private::NameSearchContext::AddNamedDecl
void AddNamedDecl(clang::NamedDecl *decl)
Add a NamedDecl to the list of results.
Definition: NameSearchContext.cpp:180
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:634
lldb_private::ArchSpec::GetByteOrder
lldb::ByteOrder GetByteOrder() const
Returns the byte order for the architecture specification.
Definition: ArchSpec.cpp:729
lldb::eSymbolTypeObjCIVar
@ eSymbolTypeObjCIVar
Definition: lldb-enumerations.h:648
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:454
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:98
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:629
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:687
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:622
lldb_private::ClangExpressionDeclMap::GetScratchContext
TypeSystemClang * GetScratchContext(Target &target)
Definition: ClangExpressionDeclMap.h:380
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:1201
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:644
ModuleSpec.h
lldb_private::ClangExpressionDeclMap::DisableParserVars
void DisableParserVars()
Deallocate parser-specific variables.
Definition: ClangExpressionDeclMap.h:351
lldb_private::ClangExpressionDeclMap::InstallCodeGenerator
void InstallCodeGenerator(clang::ASTConsumer *code_gen)
Definition: ClangExpressionDeclMap.cpp:144
lldb_private::ObjCLanguageRuntime
Definition: ObjCLanguageRuntime.h:35
lldb_private::Value::Clear
void Clear()
Definition: Value.cpp:607
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:620
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:1484
lldb::eSymbolTypeLineEntry
@ eSymbolTypeLineEntry
Definition: lldb-enumerations.h:637
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:106
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:301
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:214
lldb::eSymbolTypeCommonBlock
@ eSymbolTypeCommonBlock
Definition: lldb-enumerations.h:631
lldb::eSymbolTypeTrampoline
@ eSymbolTypeTrampoline
Definition: lldb-enumerations.h:625
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:2172
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:82
lldb_private::TypeSystemClang::GetBuiltinTypeForEncodingAndBitSize
CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size) override
Definition: TypeSystemClang.cpp:796
Module.h
lldb_private::ExpressionVariable::SetRegisterInfo
void SetRegisterInfo(const RegisterInfo *reg_info)
Definition: ExpressionVariable.h:49
lldb_private::ExpressionVariableList::AddNewlyConstructedVariable
lldb::ExpressionVariableSP AddNewlyConstructedVariable(ExpressionVariable *var)
Definition: ExpressionVariable.h:138
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:756
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:45
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:639
lldb_private::ClangExpressionDeclMap::EnableStructVars
void EnableStructVars()
Activate struct variables.
Definition: ClangExpressionDeclMap.h:372
lldb::eSymbolTypeData
@ eSymbolTypeData
Definition: lldb-enumerations.h:624
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:85
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:173
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:3730
lldb::eSymbolTypeRuntime
@ eSymbolTypeRuntime
Definition: lldb-enumerations.h:626
StackFrame.h
lldb_private::Symbol::GetReExportedSymbolName
ConstString GetReExportedSymbolName() const
Definition: Symbol.cpp:125
lldb_private::Type::GetName
ConstString GetName()
Definition: Type.cpp:302
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:1724
lldb_private::CompilerType::IsAggregateType
bool IsAggregateType() const
Definition: CompilerType.cpp:31
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:65
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:1719
lldb_private::ClangExpressionDeclMap::m_parser_vars
std::unique_ptr< ParserVars > m_parser_vars
Definition: ClangExpressionDeclMap.h:342
lldb_private::TypeSystemClang::DeclContextGetAsCXXMethodDecl
static clang::CXXMethodDecl * DeclContextGetAsCXXMethodDecl(const CompilerDeclContext &dc)
Definition: TypeSystemClang.cpp:9763
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:345
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:40
lldb_private::Target::GetImages
const ModuleList & GetImages() const
Get accessor for the images for this process.
Definition: Target.h:947
lldb_private::Language::LanguageIsCPlusPlus
static bool LanguageIsCPlusPlus(lldb::LanguageType language)
Definition: Language.cpp:239
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:67
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:251
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:1981
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:88
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:400
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:110
lldb_private::SymbolContext::symbol
Symbol * symbol
The Symbol for a given query.
Definition: SymbolContext.h:323
lldb::eSymbolTypeBlock
@ eSymbolTypeBlock
Definition: lldb-enumerations.h:632
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::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:294
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:990
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:215
lldb::eSymbolTypeSourceFile
@ eSymbolTypeSourceFile
Definition: lldb-enumerations.h:628
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:1142
lldb_private::TypeSystemClang::DeclContextGetAsObjCMethodDecl
static clang::ObjCMethodDecl * DeclContextGetAsObjCMethodDecl(const CompilerDeclContext &dc)
Definition: TypeSystemClang.cpp:9755
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:742
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:645
lldb::eSymbolTypeObjectFile
@ eSymbolTypeObjectFile
Definition: lldb-enumerations.h:630
TypeSystemClang.h
lldb_private::Language::LanguageIsC
static bool LanguageIsC(lldb::LanguageType language)
Definition: Language.cpp:262
lldb_private::ClangExpressionDeclMap::TargetInfo
Definition: ClangExpressionDeclMap.h:250
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:504
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:650
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:1063
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:387
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:39
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:734
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:3366
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:252
lldb_private::StreamString
Definition: StreamString.h:23
lldb_private::ExpressionVariableList::AddVariable
size_t AddVariable(const lldb::ExpressionVariableSP &var_sp)
Definition: ExpressionVariable.h:132
lldb_private::ExpressionVariable::m_flags
FlagType m_flags
Definition: ExpressionVariable.h:107
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:1229
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:303
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:749
lldb::eSymbolTypeObjCClass
@ eSymbolTypeObjCClass
Definition: lldb-enumerations.h:646
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:2046
lldb::eSymbolTypeAdditional
@ eSymbolTypeAdditional
When symbols take more than one entry, the extra entries get this type.
Definition: lldb-enumerations.h:641
lldb_private::ExpressionVariable::EVNeedsFreezeDry
@ EVNeedsFreezeDry
Copy from m_live_sp to m_frozen_sp during dematerialization.
Definition: ExpressionVariable.h:93
lldb_private::ClangExpressionDeclMap::DisableStructVars
void DisableStructVars()
Deallocate struct variables.
Definition: ClangExpressionDeclMap.h:378
lldb_private::TypeSystemClang::GetUniqueNamespaceDeclaration
clang::NamespaceDecl * GetUniqueNamespaceDeclaration(const char *name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, bool is_inline=false)
Definition: TypeSystemClang.cpp:1858
lldb_private::Target::GetPersistentExpressionStateForLanguage
PersistentExpressionState * GetPersistentExpressionStateForLanguage(lldb::LanguageType language)
Definition: Target.cpp:2353
lldb_private::ClangExpressionDeclMap::TargetInfo::byte_order
lldb::ByteOrder byte_order
Definition: ClangExpressionDeclMap.h:251
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::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:618
Address.h
lldb::eSymbolTypeVariable
@ eSymbolTypeVariable
Definition: lldb-enumerations.h:635
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:9583
lldb::eSymbolTypeScopeEnd
@ eSymbolTypeScopeEnd
Definition: lldb-enumerations.h:640
VariableList.h
lldb_private::CompilerType::IsValid
bool IsValid() const
Definition: CompilerType.h:72
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:414
lldb_private::ArchSpec::GetAddressByteSize
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
Definition: ArchSpec.cpp:682
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:63
lldb_private::NameSearchContext::AddGenericFunDecl
clang::NamedDecl * AddGenericFunDecl()
Create a FunDecl with the name being searched for and generic type (i.e.
Definition: NameSearchContext.cpp:132
lldb-private.h
lldb_private::CompilerType::GetCompleteType
bool GetCompleteType() const
Type Completion.
Definition: CompilerType.cpp:264
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:509
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:437
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:252
lldb_private::Target::GetArchitecture
const ArchSpec & GetArchitecture() const
Definition: Target.h:989
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:146
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:296
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:407
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:39
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:357
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:635
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:95
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:1569
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:1016
lldb_private::ExpressionVariable::EVIsProgramReference
@ EVIsProgramReference
This variable is a reference to a (possibly invalid) area managed by the target program.
Definition: ExpressionVariable.h:85
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:345
lldb_private::CompilerType::GetTypeSystem
TypeSystem * GetTypeSystem() const
Accessors.
Definition: CompilerType.h:162
lldb_private::Type
Definition: Type.h:66
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:468
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::Type::GetForwardCompilerType
CompilerType GetForwardCompilerType()
Definition: Type.cpp:655
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:647
ObjCLanguageRuntime.h
lldb::eSymbolTypeVariableType
@ eSymbolTypeVariableType
Definition: lldb-enumerations.h:636
ClangExpressionDeclMap.h
lldb_private::SymbolContext::module_sp
lldb::ModuleSP module_sp
The Module for a given query.
Definition: SymbolContext.h:318
lldb_private::ScratchTypeSystemClang::GetForTarget
static TypeSystemClang * GetForTarget(Target &target, llvm::Optional< IsolatedASTKind > ast_kind=DefaultAST, bool create_on_demand=true)
Returns the scratch TypeSystemClang for the given target.
Definition: TypeSystemClang.cpp:9851
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:1810
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:33
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:523
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:649
SymbolContext.h
lldb_private::CPlusPlusLanguage::IsCPPMangledName
static bool IsCPPMangledName(llvm::StringRef name)
Definition: CPlusPlusLanguage.cpp:307
lldb::eLanguageTypeC
@ eLanguageTypeC
Non-standardized C, such as K&R.
Definition: lldb-enumerations.h:439
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:74
Error
llvm::Error Error
Definition: UdtRecordCompleter.cpp:30
lldb_private::ExpressionVariableList::GetVariableAtIndex
lldb::ExpressionVariableSP GetVariableAtIndex(size_t index)
Definition: ExpressionVariable.h:125
lldb_private::TypeSystemClang::GetBasicType
CompilerType GetBasicType(lldb::BasicType type)
Definition: TypeSystemClang.cpp:931
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:638
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::ClangExpressionDeclMap::m_struct_vars
std::unique_ptr< StructVars > m_struct_vars
Definition: ClangExpressionDeclMap.h:369
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:670
ValueObjectVariable.h
lldb_private::DWARFExpressionList
Definition: DWARFExpressionList.h:24
lldb_private::Module::FindSymbolsWithNameAndType
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list)
Definition: Module.cpp:1371
lldb::eSymbolTypeException
@ eSymbolTypeException
Definition: lldb-enumerations.h:627
lldb_private::Process::GetByteOrder
lldb::ByteOrder GetByteOrder() const
Definition: Process.cpp:3362
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:7606
lldb::eSymbolTypeResolver
@ eSymbolTypeResolver
Definition: lldb-enumerations.h:623
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:2722
LLDB_INVALID_DECL_LEVEL
#define LLDB_INVALID_DECL_LEVEL
Definition: TypeSystemClang.h:830
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:51
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:621
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:1771
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:60
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:633
lldb
Definition: SBAddress.h:15
Endian.h
RegisterContext.h
lldb_private::Type::GetFullCompilerType
CompilerType GetFullCompilerType()
Definition: Type.cpp:645
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:37
lldb_private::LanguageRuntime::LookupRuntimeSymbol
virtual lldb::addr_t LookupRuntimeSymbol(ConstString name)
Definition: LanguageRuntime.h:169
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:297
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:3474
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:56
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:101