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 "ClangModulesDeclVendor.h"
14 #include "ClangUtil.h"
15 
17 #include "lldb/Core/Address.h"
18 #include "lldb/Core/Module.h"
19 #include "lldb/Core/ModuleSpec.h"
27 #include "lldb/Symbol/Function.h"
28 #include "lldb/Symbol/ObjectFile.h"
30 #include "lldb/Symbol/SymbolFile.h"
32 #include "lldb/Symbol/Type.h"
33 #include "lldb/Symbol/TypeList.h"
34 #include "lldb/Symbol/Variable.h"
37 #include "lldb/Target/Process.h"
39 #include "lldb/Target/StackFrame.h"
40 #include "lldb/Target/Target.h"
41 #include "lldb/Target/Thread.h"
42 #include "lldb/Utility/Endian.h"
43 #include "lldb/Utility/LLDBLog.h"
44 #include "lldb/Utility/Log.h"
46 #include "lldb/Utility/Status.h"
47 #include "lldb/lldb-private.h"
48 #include "clang/AST/ASTConsumer.h"
49 #include "clang/AST/ASTContext.h"
50 #include "clang/AST/ASTImporter.h"
51 #include "clang/AST/Decl.h"
52 #include "clang/AST/DeclarationName.h"
53 #include "clang/AST/RecursiveASTVisitor.h"
54 
58 
59 using namespace lldb;
60 using namespace lldb_private;
61 using namespace clang;
62 
63 static const char *g_lldb_local_vars_namespace_cstr = "$__lldb_local_vars";
64 
65 ClangExpressionDeclMap::ClangExpressionDeclMap(
66  bool keep_result_in_memory,
68  const lldb::TargetSP &target,
69  const std::shared_ptr<ClangASTImporter> &importer, ValueObject *ctx_obj)
70  : ClangASTSource(target, importer), m_found_entities(), m_struct_members(),
71  m_keep_result_in_memory(keep_result_in_memory),
72  m_result_delegate(result_delegate), m_ctx_obj(ctx_obj), m_parser_vars(),
73  m_struct_vars() {
75 }
76 
78  // Note: The model is now that the parser's AST context and all associated
79  // data does not vanish until the expression has been executed. This means
80  // that valuable lookup data (like namespaces) doesn't vanish, but
81 
82  DidParse();
84 }
85 
87  Materializer *materializer) {
89  m_parser_vars->m_exe_ctx = exe_ctx;
90 
91  Target *target = exe_ctx.GetTargetPtr();
92  if (exe_ctx.GetFramePtr())
93  m_parser_vars->m_sym_ctx =
94  exe_ctx.GetFramePtr()->GetSymbolContext(lldb::eSymbolContextEverything);
95  else if (exe_ctx.GetThreadPtr() &&
96  exe_ctx.GetThreadPtr()->GetStackFrameAtIndex(0))
97  m_parser_vars->m_sym_ctx =
98  exe_ctx.GetThreadPtr()->GetStackFrameAtIndex(0)->GetSymbolContext(
99  lldb::eSymbolContextEverything);
100  else if (exe_ctx.GetProcessPtr()) {
101  m_parser_vars->m_sym_ctx.Clear(true);
102  m_parser_vars->m_sym_ctx.target_sp = exe_ctx.GetTargetSP();
103  } else if (target) {
104  m_parser_vars->m_sym_ctx.Clear(true);
105  m_parser_vars->m_sym_ctx.target_sp = exe_ctx.GetTargetSP();
106  }
107 
108  if (target) {
109  m_parser_vars->m_persistent_vars = llvm::cast<ClangPersistentVariables>(
111 
113  return false;
114  }
115 
116  m_parser_vars->m_target_info = GetTargetInfo();
117  m_parser_vars->m_materializer = materializer;
118 
119  return true;
120 }
121 
123  clang::ASTConsumer *code_gen) {
124  assert(m_parser_vars);
125  m_parser_vars->m_code_gen = code_gen;
126 }
127 
129  DiagnosticManager &diag_manager) {
130  assert(m_parser_vars);
131  m_parser_vars->m_diagnostics = &diag_manager;
132 }
133 
135  if (m_parser_vars && m_parser_vars->m_persistent_vars) {
136  for (size_t entity_index = 0, num_entities = m_found_entities.GetSize();
137  entity_index < num_entities; ++entity_index) {
138  ExpressionVariableSP var_sp(
139  m_found_entities.GetVariableAtIndex(entity_index));
140  if (var_sp)
141  llvm::cast<ClangExpressionVariable>(var_sp.get())
142  ->DisableParserVars(GetParserID());
143  }
144 
145  for (size_t pvar_index = 0,
146  num_pvars = m_parser_vars->m_persistent_vars->GetSize();
147  pvar_index < num_pvars; ++pvar_index) {
148  ExpressionVariableSP pvar_sp(
149  m_parser_vars->m_persistent_vars->GetVariableAtIndex(pvar_index));
150  if (ClangExpressionVariable *clang_var =
151  llvm::dyn_cast<ClangExpressionVariable>(pvar_sp.get()))
152  clang_var->DisableParserVars(GetParserID());
153  }
154 
156  }
157 }
158 
159 // Interface for IRForTarget
160 
162  assert(m_parser_vars.get());
163 
164  TargetInfo ret;
165 
166  ExecutionContext &exe_ctx = m_parser_vars->m_exe_ctx;
167 
168  Process *process = exe_ctx.GetProcessPtr();
169  if (process) {
170  ret.byte_order = process->GetByteOrder();
171  ret.address_byte_size = process->GetAddressByteSize();
172  } else {
173  Target *target = exe_ctx.GetTargetPtr();
174  if (target) {
175  ret.byte_order = target->GetArchitecture().GetByteOrder();
177  }
178  }
179 
180  return ret;
181 }
182 
184  TypeSystemClang &source,
185  TypeFromParser parser_type) {
186  assert(&target == GetScratchContext(*m_target));
187  assert((TypeSystem *)&source == parser_type.GetTypeSystem());
188  assert(&source.getASTContext() == m_ast_context);
189 
190  return TypeFromUser(m_ast_importer_sp->DeportType(target, parser_type));
191 }
192 
194  ConstString name,
195  TypeFromParser parser_type,
196  bool is_result,
197  bool is_lvalue) {
198  assert(m_parser_vars.get());
199 
200  TypeSystemClang *ast =
201  llvm::dyn_cast_or_null<TypeSystemClang>(parser_type.GetTypeSystem());
202  if (ast == nullptr)
203  return false;
204 
205  // Check if we already declared a persistent variable with the same name.
206  if (lldb::ExpressionVariableSP conflicting_var =
207  m_parser_vars->m_persistent_vars->GetVariable(name)) {
208  std::string msg = llvm::formatv("redefinition of persistent variable '{0}'",
209  name).str();
210  m_parser_vars->m_diagnostics->AddDiagnostic(
213  return false;
214  }
215 
216  if (m_parser_vars->m_materializer && is_result) {
217  Status err;
218 
219  ExecutionContext &exe_ctx = m_parser_vars->m_exe_ctx;
220  Target *target = exe_ctx.GetTargetPtr();
221  if (target == nullptr)
222  return false;
223 
224  auto *clang_ast_context = GetScratchContext(*target);
225  if (!clang_ast_context)
226  return false;
227 
228  TypeFromUser user_type = DeportType(*clang_ast_context, *ast, parser_type);
229 
230  uint32_t offset = m_parser_vars->m_materializer->AddResultVariable(
231  user_type, is_lvalue, m_keep_result_in_memory, m_result_delegate, err);
232 
234  exe_ctx.GetBestExecutionContextScope(), name, user_type,
235  m_parser_vars->m_target_info.byte_order,
236  m_parser_vars->m_target_info.address_byte_size);
237 
239 
241 
243  var->GetParserVars(GetParserID());
244 
245  parser_vars->m_named_decl = decl;
246 
247  var->EnableJITVars(GetParserID());
248 
250 
251  jit_vars->m_offset = offset;
252 
253  return true;
254  }
255 
257  ExecutionContext &exe_ctx = m_parser_vars->m_exe_ctx;
258  Target *target = exe_ctx.GetTargetPtr();
259  if (target == nullptr)
260  return false;
261 
262  TypeSystemClang *context = GetScratchContext(*target);
263  if (!context)
264  return false;
265 
266  TypeFromUser user_type = DeportType(*context, *ast, parser_type);
267 
268  if (!user_type.GetOpaqueQualType()) {
269  LLDB_LOG(log, "Persistent variable's type wasn't copied successfully");
270  return false;
271  }
272 
273  if (!m_parser_vars->m_target_info.IsValid())
274  return false;
275 
276  if (!m_parser_vars->m_persistent_vars)
277  return false;
278 
279  ClangExpressionVariable *var = llvm::cast<ClangExpressionVariable>(
280  m_parser_vars->m_persistent_vars
281  ->CreatePersistentVariable(
282  exe_ctx.GetBestExecutionContextScope(), name, user_type,
283  m_parser_vars->m_target_info.byte_order,
284  m_parser_vars->m_target_info.address_byte_size)
285  .get());
286 
287  if (!var)
288  return false;
289 
290  var->m_frozen_sp->SetHasCompleteType();
291 
292  if (is_result)
294  else
295  var->m_flags |=
296  ClangExpressionVariable::EVKeepInTarget; // explicitly-declared
297  // persistent variables should
298  // persist
299 
300  if (is_lvalue) {
302  } else {
305  }
306 
309  }
310 
311  LLDB_LOG(log, "Created persistent variable with flags {0:x}", var->m_flags);
312 
314 
316  var->GetParserVars(GetParserID());
317 
318  parser_vars->m_named_decl = decl;
319 
320  return true;
321 }
322 
323 bool ClangExpressionDeclMap::AddValueToStruct(const NamedDecl *decl,
324  ConstString name,
325  llvm::Value *value, size_t size,
326  lldb::offset_t alignment) {
327  assert(m_struct_vars.get());
328  assert(m_parser_vars.get());
329 
330  bool is_persistent_variable = false;
331 
333 
334  m_struct_vars->m_struct_laid_out = false;
335 
337  GetParserID()))
338  return true;
339 
341  m_found_entities, decl, GetParserID()));
342 
343  if (!var && m_parser_vars->m_persistent_vars) {
345  *m_parser_vars->m_persistent_vars, decl, GetParserID());
346  is_persistent_variable = true;
347  }
348 
349  if (!var)
350  return false;
351 
352  LLDB_LOG(log, "Adding value for (NamedDecl*){0} [{1} - {2}] to the structure",
353  decl, name, var->GetName());
354 
355  // We know entity->m_parser_vars is valid because we used a parser variable
356  // to find it
357 
359  llvm::cast<ClangExpressionVariable>(var)->GetParserVars(GetParserID());
360 
361  parser_vars->m_llvm_value = value;
362 
363  if (ClangExpressionVariable::JITVars *jit_vars =
364  llvm::cast<ClangExpressionVariable>(var)->GetJITVars(GetParserID())) {
365  // We already laid this out; do not touch
366 
367  LLDB_LOG(log, "Already placed at {0:x}", jit_vars->m_offset);
368  }
369 
370  llvm::cast<ClangExpressionVariable>(var)->EnableJITVars(GetParserID());
371 
373  llvm::cast<ClangExpressionVariable>(var)->GetJITVars(GetParserID());
374 
375  jit_vars->m_alignment = alignment;
376  jit_vars->m_size = size;
377 
378  m_struct_members.AddVariable(var->shared_from_this());
379 
380  if (m_parser_vars->m_materializer) {
381  uint32_t offset = 0;
382 
383  Status err;
384 
385  if (is_persistent_variable) {
386  ExpressionVariableSP var_sp(var->shared_from_this());
387  offset = m_parser_vars->m_materializer->AddPersistentVariable(
388  var_sp, nullptr, err);
389  } else {
390  if (const lldb_private::Symbol *sym = parser_vars->m_lldb_sym)
391  offset = m_parser_vars->m_materializer->AddSymbol(*sym, err);
392  else if (const RegisterInfo *reg_info = var->GetRegisterInfo())
393  offset = m_parser_vars->m_materializer->AddRegister(*reg_info, err);
394  else if (parser_vars->m_lldb_var)
395  offset = m_parser_vars->m_materializer->AddVariable(
396  parser_vars->m_lldb_var, err);
397  }
398 
399  if (!err.Success())
400  return false;
401 
402  LLDB_LOG(log, "Placed at {0:x}", offset);
403 
404  jit_vars->m_offset =
405  offset; // TODO DoStructLayout() should not change this.
406  }
407 
408  return true;
409 }
410 
412  assert(m_struct_vars.get());
413 
414  if (m_struct_vars->m_struct_laid_out)
415  return true;
416 
417  if (!m_parser_vars->m_materializer)
418  return false;
419 
420  m_struct_vars->m_struct_alignment =
421  m_parser_vars->m_materializer->GetStructAlignment();
422  m_struct_vars->m_struct_size =
423  m_parser_vars->m_materializer->GetStructByteSize();
424  m_struct_vars->m_struct_laid_out = true;
425  return true;
426 }
427 
428 bool ClangExpressionDeclMap::GetStructInfo(uint32_t &num_elements, size_t &size,
429  lldb::offset_t &alignment) {
430  assert(m_struct_vars.get());
431 
432  if (!m_struct_vars->m_struct_laid_out)
433  return false;
434 
435  num_elements = m_struct_members.GetSize();
436  size = m_struct_vars->m_struct_size;
437  alignment = m_struct_vars->m_struct_alignment;
438 
439  return true;
440 }
441 
442 bool ClangExpressionDeclMap::GetStructElement(const NamedDecl *&decl,
443  llvm::Value *&value,
444  lldb::offset_t &offset,
445  ConstString &name,
446  uint32_t index) {
447  assert(m_struct_vars.get());
448 
449  if (!m_struct_vars->m_struct_laid_out)
450  return false;
451 
452  if (index >= m_struct_members.GetSize())
453  return false;
454 
455  ExpressionVariableSP member_sp(m_struct_members.GetVariableAtIndex(index));
456 
457  if (!member_sp)
458  return false;
459 
461  llvm::cast<ClangExpressionVariable>(member_sp.get())
462  ->GetParserVars(GetParserID());
464  llvm::cast<ClangExpressionVariable>(member_sp.get())
465  ->GetJITVars(GetParserID());
466 
467  if (!parser_vars || !jit_vars || !member_sp->GetValueObject())
468  return false;
469 
470  decl = parser_vars->m_named_decl;
471  value = parser_vars->m_llvm_value;
472  offset = jit_vars->m_offset;
473  name = member_sp->GetName();
474 
475  return true;
476 }
477 
478 bool ClangExpressionDeclMap::GetFunctionInfo(const NamedDecl *decl,
479  uint64_t &ptr) {
481  m_found_entities, decl, GetParserID()));
482 
483  if (!entity)
484  return false;
485 
486  // We know m_parser_vars is valid since we searched for the variable by its
487  // NamedDecl
488 
490  entity->GetParserVars(GetParserID());
491 
492  ptr = parser_vars->m_lldb_value.GetScalar().ULongLong();
493 
494  return true;
495 }
496 
498  Process *process,
499  ConstString name,
500  lldb::SymbolType symbol_type,
501  lldb_private::Module *module) {
502  SymbolContextList sc_list;
503 
504  if (module)
505  module->FindSymbolsWithNameAndType(name, symbol_type, sc_list);
506  else
507  target.GetImages().FindSymbolsWithNameAndType(name, symbol_type, sc_list);
508 
509  const uint32_t num_matches = sc_list.GetSize();
510  addr_t symbol_load_addr = LLDB_INVALID_ADDRESS;
511 
512  for (uint32_t i = 0;
513  i < num_matches &&
514  (symbol_load_addr == 0 || symbol_load_addr == LLDB_INVALID_ADDRESS);
515  i++) {
516  SymbolContext sym_ctx;
517  sc_list.GetContextAtIndex(i, sym_ctx);
518 
519  const Address sym_address = sym_ctx.symbol->GetAddress();
520 
521  if (!sym_address.IsValid())
522  continue;
523 
524  switch (sym_ctx.symbol->GetType()) {
525  case eSymbolTypeCode:
527  symbol_load_addr = sym_address.GetCallableLoadAddress(&target);
528  break;
529 
530  case eSymbolTypeResolver:
531  symbol_load_addr = sym_address.GetCallableLoadAddress(&target, true);
532  break;
533 
534  case eSymbolTypeReExported: {
535  ConstString reexport_name = sym_ctx.symbol->GetReExportedSymbolName();
536  if (reexport_name) {
537  ModuleSP reexport_module_sp;
538  ModuleSpec reexport_module_spec;
539  reexport_module_spec.GetPlatformFileSpec() =
541  if (reexport_module_spec.GetPlatformFileSpec()) {
542  reexport_module_sp =
543  target.GetImages().FindFirstModule(reexport_module_spec);
544  if (!reexport_module_sp) {
545  reexport_module_spec.GetPlatformFileSpec().GetDirectory().Clear();
546  reexport_module_sp =
547  target.GetImages().FindFirstModule(reexport_module_spec);
548  }
549  }
550  symbol_load_addr = GetSymbolAddress(
551  target, process, sym_ctx.symbol->GetReExportedSymbolName(),
552  symbol_type, reexport_module_sp.get());
553  }
554  } break;
555 
556  case eSymbolTypeData:
557  case eSymbolTypeRuntime:
558  case eSymbolTypeVariable:
559  case eSymbolTypeLocal:
560  case eSymbolTypeParam:
561  case eSymbolTypeInvalid:
562  case eSymbolTypeAbsolute:
568  case eSymbolTypeBlock:
573  case eSymbolTypeScopeEnd:
575  case eSymbolTypeCompiler:
580  case eSymbolTypeObjCIVar:
581  symbol_load_addr = sym_address.GetLoadAddress(&target);
582  break;
583  }
584  }
585 
586  if (symbol_load_addr == LLDB_INVALID_ADDRESS && process) {
587  ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process);
588 
589  if (runtime) {
590  symbol_load_addr = runtime->LookupRuntimeSymbol(name);
591  }
592  }
593 
594  return symbol_load_addr;
595 }
596 
598  lldb::SymbolType symbol_type) {
599  assert(m_parser_vars.get());
600 
601  if (!m_parser_vars->m_exe_ctx.GetTargetPtr())
602  return false;
603 
604  return GetSymbolAddress(m_parser_vars->m_exe_ctx.GetTargetRef(),
605  m_parser_vars->m_exe_ctx.GetProcessPtr(), name,
606  symbol_type);
607 }
608 
610  Target &target, ModuleSP &module, ConstString name,
611  const CompilerDeclContext &namespace_decl) {
612  VariableList vars;
613 
614  if (module && namespace_decl)
615  module->FindGlobalVariables(name, namespace_decl, -1, vars);
616  else
617  target.GetImages().FindGlobalVariables(name, -1, vars);
618 
619  if (vars.GetSize() == 0)
620  return VariableSP();
621  return vars.GetVariableAtIndex(0);
622 }
623 
625  StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
626  if (frame == nullptr)
627  return nullptr;
628 
629  SymbolContext sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction |
630  lldb::eSymbolContextBlock);
631  if (sym_ctx.block == nullptr)
632  return nullptr;
633 
634  CompilerDeclContext frame_decl_context = sym_ctx.block->GetDeclContext();
635  if (!frame_decl_context)
636  return nullptr;
637 
638  return llvm::dyn_cast_or_null<TypeSystemClang>(
639  frame_decl_context.GetTypeSystem());
640 }
641 
642 // Interface for ClangASTSource
643 
645  NameSearchContext &context) {
646  assert(m_ast_context);
647 
648  const ConstString name(context.m_decl_name.getAsString().c_str());
649 
651 
652  if (log) {
653  if (!context.m_decl_context)
654  LLDB_LOG(log,
655  "ClangExpressionDeclMap::FindExternalVisibleDecls for "
656  "'{0}' in a NULL DeclContext",
657  name);
658  else if (const NamedDecl *context_named_decl =
659  dyn_cast<NamedDecl>(context.m_decl_context))
660  LLDB_LOG(log,
661  "ClangExpressionDeclMap::FindExternalVisibleDecls for "
662  "'{0}' in '{1}'",
663  name, context_named_decl->getNameAsString());
664  else
665  LLDB_LOG(log,
666  "ClangExpressionDeclMap::FindExternalVisibleDecls for "
667  "'{0}' in a '{1}'",
668  name, context.m_decl_context->getDeclKindName());
669  }
670 
671  if (const NamespaceDecl *namespace_context =
672  dyn_cast<NamespaceDecl>(context.m_decl_context)) {
673  if (namespace_context->getName().str() ==
675  CompilerDeclContext compiler_decl_ctx =
677  const_cast<clang::DeclContext *>(context.m_decl_context));
678  FindExternalVisibleDecls(context, lldb::ModuleSP(), compiler_decl_ctx);
679  return;
680  }
681 
682  ClangASTImporter::NamespaceMapSP namespace_map =
683  m_ast_importer_sp->GetNamespaceMap(namespace_context);
684 
685  if (!namespace_map)
686  return;
687 
688  LLDB_LOGV(log, " CEDM::FEVD Inspecting (NamespaceMap*){0:x} ({1} entries)",
689  namespace_map.get(), namespace_map->size());
690 
691  for (ClangASTImporter::NamespaceMapItem &n : *namespace_map) {
692  LLDB_LOG(log, " CEDM::FEVD Searching namespace {0} in module {1}",
693  n.second.GetName(), n.first->GetFileSpec().GetFilename());
694 
695  FindExternalVisibleDecls(context, n.first, n.second);
696  }
697  } else if (isa<TranslationUnitDecl>(context.m_decl_context)) {
698  CompilerDeclContext namespace_decl;
699 
700  LLDB_LOG(log, " CEDM::FEVD Searching the root namespace");
701 
702  FindExternalVisibleDecls(context, lldb::ModuleSP(), namespace_decl);
703  }
704 
706 }
707 
709  FunctionDecl *copied_function_decl) {
710  if (copied_function_decl->getBody() && m_parser_vars->m_code_gen) {
711  clang::DeclGroupRef decl_group_ref(copied_function_decl);
712  m_parser_vars->m_code_gen->HandleTopLevelDecl(decl_group_ref);
713  }
714 }
715 
717  if (!m_parser_vars)
718  return nullptr;
719  Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
720  if (!target)
721  return nullptr;
722 
724 
725  if (!m_parser_vars->m_persistent_vars)
726  return nullptr;
727  return m_parser_vars->m_persistent_vars->GetPersistentDecl(name);
728 }
729 
731  const ConstString name) {
733 
734  NamedDecl *persistent_decl = GetPersistentDecl(name);
735 
736  if (!persistent_decl)
737  return;
738 
739  Decl *parser_persistent_decl = CopyDecl(persistent_decl);
740 
741  if (!parser_persistent_decl)
742  return;
743 
744  NamedDecl *parser_named_decl = dyn_cast<NamedDecl>(parser_persistent_decl);
745 
746  if (!parser_named_decl)
747  return;
748 
749  if (clang::FunctionDecl *parser_function_decl =
750  llvm::dyn_cast<clang::FunctionDecl>(parser_named_decl)) {
751  MaybeRegisterFunctionBody(parser_function_decl);
752  }
753 
754  LLDB_LOG(log, " CEDM::FEVD Found persistent decl {0}", name);
755 
756  context.AddNamedDecl(parser_named_decl);
757 }
758 
761 
762  StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
763  SymbolContext sym_ctx;
764  if (frame != nullptr)
765  sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction |
766  lldb::eSymbolContextBlock);
767 
768  if (m_ctx_obj) {
769  Status status;
770  lldb::ValueObjectSP ctx_obj_ptr = m_ctx_obj->AddressOf(status);
771  if (!ctx_obj_ptr || status.Fail())
772  return;
773 
775 
776  m_struct_vars->m_object_pointer_type =
777  TypeFromUser(ctx_obj_ptr->GetCompilerType());
778 
779  return;
780  }
781 
782  // Clang is looking for the type of "this"
783 
784  if (frame == nullptr)
785  return;
786 
787  // Find the block that defines the function represented by "sym_ctx"
788  Block *function_block = sym_ctx.GetFunctionBlock();
789 
790  if (!function_block)
791  return;
792 
793  CompilerDeclContext function_decl_ctx = function_block->GetDeclContext();
794 
795  if (!function_decl_ctx)
796  return;
797 
798  clang::CXXMethodDecl *method_decl =
800 
801  if (method_decl) {
802  clang::CXXRecordDecl *class_decl = method_decl->getParent();
803 
804  QualType class_qual_type(class_decl->getTypeForDecl(), 0);
805 
806  TypeFromUser class_user_type(class_qual_type.getAsOpaquePtr(),
807  function_decl_ctx.GetTypeSystem());
808 
809  LLDB_LOG(log, " CEDM::FEVD Adding type for $__lldb_class: {1}",
810  class_qual_type.getAsString());
811 
812  AddContextClassType(context, class_user_type);
813 
814  if (method_decl->isInstance()) {
815  // self is a pointer to the object
816 
817  QualType class_pointer_type =
818  method_decl->getASTContext().getPointerType(class_qual_type);
819 
820  TypeFromUser self_user_type(class_pointer_type.getAsOpaquePtr(),
821  function_decl_ctx.GetTypeSystem());
822 
823  m_struct_vars->m_object_pointer_type = self_user_type;
824  }
825  return;
826  }
827 
828  // This branch will get hit if we are executing code in the context of
829  // a function that claims to have an object pointer (through
830  // DW_AT_object_pointer?) but is not formally a method of the class.
831  // In that case, just look up the "this" variable in the current scope
832  // and use its type.
833  // FIXME: This code is formally correct, but clang doesn't currently
834  // emit DW_AT_object_pointer
835  // for C++ so it hasn't actually been tested.
836 
837  VariableList *vars = frame->GetVariableList(false);
838 
839  lldb::VariableSP this_var = vars->FindVariable(ConstString("this"));
840 
841  if (this_var && this_var->IsInScope(frame) &&
842  this_var->LocationIsValidForFrame(frame)) {
843  Type *this_type = this_var->GetType();
844 
845  if (!this_type)
846  return;
847 
848  TypeFromUser pointee_type =
849  this_type->GetForwardCompilerType().GetPointeeType();
850 
851  LLDB_LOG(log, " FEVD Adding type for $__lldb_class: {1}",
852  ClangUtil::GetQualType(pointee_type).getAsString());
853 
854  AddContextClassType(context, pointee_type);
855  TypeFromUser this_user_type(this_type->GetFullCompilerType());
856  m_struct_vars->m_object_pointer_type = this_user_type;
857  }
858 }
859 
862 
863  StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
864 
865  if (m_ctx_obj) {
866  Status status;
867  lldb::ValueObjectSP ctx_obj_ptr = m_ctx_obj->AddressOf(status);
868  if (!ctx_obj_ptr || status.Fail())
869  return;
870 
872 
873  m_struct_vars->m_object_pointer_type =
874  TypeFromUser(ctx_obj_ptr->GetCompilerType());
875 
876  return;
877  }
878 
879  // Clang is looking for the type of "*self"
880 
881  if (!frame)
882  return;
883 
884  SymbolContext sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction |
885  lldb::eSymbolContextBlock);
886 
887  // Find the block that defines the function represented by "sym_ctx"
888  Block *function_block = sym_ctx.GetFunctionBlock();
889 
890  if (!function_block)
891  return;
892 
893  CompilerDeclContext function_decl_ctx = function_block->GetDeclContext();
894 
895  if (!function_decl_ctx)
896  return;
897 
898  clang::ObjCMethodDecl *method_decl =
900 
901  if (method_decl) {
902  ObjCInterfaceDecl *self_interface = method_decl->getClassInterface();
903 
904  if (!self_interface)
905  return;
906 
907  const clang::Type *interface_type = self_interface->getTypeForDecl();
908 
909  if (!interface_type)
910  return; // This is unlikely, but we have seen crashes where this
911  // occurred
912 
913  TypeFromUser class_user_type(QualType(interface_type, 0).getAsOpaquePtr(),
914  function_decl_ctx.GetTypeSystem());
915 
916  LLDB_LOG(log, " FEVD[{0}] Adding type for $__lldb_objc_class: {1}",
917  ClangUtil::ToString(interface_type));
918 
919  AddOneType(context, class_user_type);
920 
921  if (method_decl->isInstanceMethod()) {
922  // self is a pointer to the object
923 
924  QualType class_pointer_type =
925  method_decl->getASTContext().getObjCObjectPointerType(
926  QualType(interface_type, 0));
927 
928  TypeFromUser self_user_type(class_pointer_type.getAsOpaquePtr(),
929  function_decl_ctx.GetTypeSystem());
930 
931  m_struct_vars->m_object_pointer_type = self_user_type;
932  } else {
933  // self is a Class pointer
934  QualType class_type = method_decl->getASTContext().getObjCClassType();
935 
936  TypeFromUser self_user_type(class_type.getAsOpaquePtr(),
937  function_decl_ctx.GetTypeSystem());
938 
939  m_struct_vars->m_object_pointer_type = self_user_type;
940  }
941 
942  return;
943  }
944  // This branch will get hit if we are executing code in the context of
945  // a function that claims to have an object pointer (through
946  // DW_AT_object_pointer?) but is not formally a method of the class.
947  // In that case, just look up the "self" variable in the current scope
948  // and use its type.
949 
950  VariableList *vars = frame->GetVariableList(false);
951 
952  lldb::VariableSP self_var = vars->FindVariable(ConstString("self"));
953 
954  if (!self_var)
955  return;
956  if (!self_var->IsInScope(frame))
957  return;
958  if (!self_var->LocationIsValidForFrame(frame))
959  return;
960 
961  Type *self_type = self_var->GetType();
962 
963  if (!self_type)
964  return;
965 
966  CompilerType self_clang_type = self_type->GetFullCompilerType();
967 
968  if (TypeSystemClang::IsObjCClassType(self_clang_type)) {
969  return;
970  }
971  if (!TypeSystemClang::IsObjCObjectPointerType(self_clang_type))
972  return;
973  self_clang_type = self_clang_type.GetPointeeType();
974 
975  if (!self_clang_type)
976  return;
977 
978  LLDB_LOG(log, " FEVD[{0}] Adding type for $__lldb_objc_class: {1}",
980 
981  TypeFromUser class_user_type(self_clang_type);
982 
983  AddOneType(context, class_user_type);
984 
985  TypeFromUser self_user_type(self_type->GetFullCompilerType());
986 
987  m_struct_vars->m_object_pointer_type = self_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  "\"{1}\" 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  return variable_found;
1105 }
1106 
1107 /// Structure to hold the info needed when comparing function
1108 /// declarations.
1109 namespace {
1110 struct FuncDeclInfo {
1111  ConstString m_name;
1112  CompilerType m_copied_type;
1113  uint32_t m_decl_lvl;
1114  SymbolContext m_sym_ctx;
1115 };
1116 } // namespace
1117 
1119  const SymbolContextList &sc_list,
1120  const CompilerDeclContext &frame_decl_context) {
1121  // First, symplify things by looping through the symbol contexts to
1122  // remove unwanted functions and separate out the functions we want to
1123  // compare and prune into a separate list. Cache the info needed about
1124  // the function declarations in a vector for efficiency.
1125  uint32_t num_indices = sc_list.GetSize();
1126  SymbolContextList sc_sym_list;
1127  std::vector<FuncDeclInfo> decl_infos;
1128  decl_infos.reserve(num_indices);
1129  clang::DeclContext *frame_decl_ctx =
1130  (clang::DeclContext *)frame_decl_context.GetOpaqueDeclContext();
1131  TypeSystemClang *ast = llvm::dyn_cast_or_null<TypeSystemClang>(
1132  frame_decl_context.GetTypeSystem());
1133 
1134  for (uint32_t index = 0; index < num_indices; ++index) {
1135  FuncDeclInfo fdi;
1136  SymbolContext sym_ctx;
1137  sc_list.GetContextAtIndex(index, sym_ctx);
1138 
1139  // We don't know enough about symbols to compare them, but we should
1140  // keep them in the list.
1141  Function *function = sym_ctx.function;
1142  if (!function) {
1143  sc_sym_list.Append(sym_ctx);
1144  continue;
1145  }
1146  // Filter out functions without declaration contexts, as well as
1147  // class/instance methods, since they'll be skipped in the code that
1148  // follows anyway.
1149  CompilerDeclContext func_decl_context = function->GetDeclContext();
1150  if (!func_decl_context ||
1151  func_decl_context.IsClassMethod(nullptr, nullptr, nullptr))
1152  continue;
1153  // We can only prune functions for which we can copy the type.
1154  CompilerType func_clang_type = function->GetType()->GetFullCompilerType();
1155  CompilerType copied_func_type = GuardedCopyType(func_clang_type);
1156  if (!copied_func_type) {
1157  sc_sym_list.Append(sym_ctx);
1158  continue;
1159  }
1160 
1161  fdi.m_sym_ctx = sym_ctx;
1162  fdi.m_name = function->GetName();
1163  fdi.m_copied_type = copied_func_type;
1164  fdi.m_decl_lvl = LLDB_INVALID_DECL_LEVEL;
1165  if (fdi.m_copied_type && func_decl_context) {
1166  // Call CountDeclLevels to get the number of parent scopes we have
1167  // to look through before we find the function declaration. When
1168  // comparing functions of the same type, the one with a lower count
1169  // will be closer to us in the lookup scope and shadows the other.
1170  clang::DeclContext *func_decl_ctx =
1171  (clang::DeclContext *)func_decl_context.GetOpaqueDeclContext();
1172  fdi.m_decl_lvl = ast->CountDeclLevels(frame_decl_ctx, func_decl_ctx,
1173  &fdi.m_name, &fdi.m_copied_type);
1174  }
1175  decl_infos.emplace_back(fdi);
1176  }
1177 
1178  // Loop through the functions in our cache looking for matching types,
1179  // then compare their scope levels to see which is closer.
1180  std::multimap<CompilerType, const FuncDeclInfo *> matches;
1181  for (const FuncDeclInfo &fdi : decl_infos) {
1182  const CompilerType t = fdi.m_copied_type;
1183  auto q = matches.find(t);
1184  if (q != matches.end()) {
1185  if (q->second->m_decl_lvl > fdi.m_decl_lvl)
1186  // This function is closer; remove the old set.
1187  matches.erase(t);
1188  else if (q->second->m_decl_lvl < fdi.m_decl_lvl)
1189  // The functions in our set are closer - skip this one.
1190  continue;
1191  }
1192  matches.insert(std::make_pair(t, &fdi));
1193  }
1194 
1195  // Loop through our matches and add their symbol contexts to our list.
1196  SymbolContextList sc_func_list;
1197  for (const auto &q : matches)
1198  sc_func_list.Append(q.second->m_sym_ctx);
1199 
1200  // Rejoin the lists with the functions in front.
1201  sc_func_list.Append(sc_sym_list);
1202  return sc_func_list;
1203 }
1204 
1206  NameSearchContext &context, lldb::ModuleSP module_sp, ConstString name,
1207  const CompilerDeclContext &namespace_decl) {
1208  if (!m_parser_vars)
1209  return;
1210 
1211  Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
1212 
1213  std::vector<clang::NamedDecl *> decls_from_modules;
1214 
1215  if (target) {
1216  if (std::shared_ptr<ClangModulesDeclVendor> decl_vendor =
1218  decl_vendor->FindDecls(name, false, UINT32_MAX, decls_from_modules);
1219  }
1220  }
1221 
1222  SymbolContextList sc_list;
1223  if (namespace_decl && module_sp) {
1224  ModuleFunctionSearchOptions function_options;
1225  function_options.include_inlines = false;
1226  function_options.include_symbols = false;
1227 
1228  module_sp->FindFunctions(name, namespace_decl, eFunctionNameTypeBase,
1229  function_options, sc_list);
1230  } else if (target && !namespace_decl) {
1231  ModuleFunctionSearchOptions function_options;
1232  function_options.include_inlines = false;
1233  function_options.include_symbols = true;
1234 
1235  // TODO Fix FindFunctions so that it doesn't return
1236  // instance methods for eFunctionNameTypeBase.
1237 
1238  target->GetImages().FindFunctions(
1239  name, eFunctionNameTypeFull | eFunctionNameTypeBase, function_options,
1240  sc_list);
1241  }
1242 
1243  // If we found more than one function, see if we can use the frame's decl
1244  // context to remove functions that are shadowed by other functions which
1245  // match in type but are nearer in scope.
1246  //
1247  // AddOneFunction will not add a function whose type has already been
1248  // added, so if there's another function in the list with a matching type,
1249  // check to see if their decl context is a parent of the current frame's or
1250  // was imported via a and using statement, and pick the best match
1251  // according to lookup rules.
1252  if (sc_list.GetSize() > 1) {
1253  // Collect some info about our frame's context.
1254  StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
1255  SymbolContext frame_sym_ctx;
1256  if (frame != nullptr)
1257  frame_sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction |
1258  lldb::eSymbolContextBlock);
1259  CompilerDeclContext frame_decl_context =
1260  frame_sym_ctx.block != nullptr ? frame_sym_ctx.block->GetDeclContext()
1261  : CompilerDeclContext();
1262 
1263  // We can't do this without a compiler decl context for our frame.
1264  if (frame_decl_context) {
1265  sc_list = SearchFunctionsInSymbolContexts(sc_list, frame_decl_context);
1266  }
1267  }
1268 
1269  if (sc_list.GetSize()) {
1270  Symbol *extern_symbol = nullptr;
1271  Symbol *non_extern_symbol = nullptr;
1272 
1273  for (uint32_t index = 0, num_indices = sc_list.GetSize();
1274  index < num_indices; ++index) {
1275  SymbolContext sym_ctx;
1276  sc_list.GetContextAtIndex(index, sym_ctx);
1277 
1278  if (sym_ctx.function) {
1279  CompilerDeclContext decl_ctx = sym_ctx.function->GetDeclContext();
1280 
1281  if (!decl_ctx)
1282  continue;
1283 
1284  // Filter out class/instance methods.
1285  if (decl_ctx.IsClassMethod(nullptr, nullptr, nullptr))
1286  continue;
1287 
1288  AddOneFunction(context, sym_ctx.function, nullptr);
1289  context.m_found_function_with_type_info = true;
1290  context.m_found_function = true;
1291  } else if (sym_ctx.symbol) {
1292  if (sym_ctx.symbol->GetType() == eSymbolTypeReExported && target) {
1293  sym_ctx.symbol = sym_ctx.symbol->ResolveReExportedSymbol(*target);
1294  if (sym_ctx.symbol == nullptr)
1295  continue;
1296  }
1297 
1298  if (sym_ctx.symbol->IsExternal())
1299  extern_symbol = sym_ctx.symbol;
1300  else
1301  non_extern_symbol = sym_ctx.symbol;
1302  }
1303  }
1304 
1305  if (!context.m_found_function_with_type_info) {
1306  for (clang::NamedDecl *decl : decls_from_modules) {
1307  if (llvm::isa<clang::FunctionDecl>(decl)) {
1308  clang::NamedDecl *copied_decl =
1309  llvm::cast_or_null<FunctionDecl>(CopyDecl(decl));
1310  if (copied_decl) {
1311  context.AddNamedDecl(copied_decl);
1312  context.m_found_function_with_type_info = true;
1313  }
1314  }
1315  }
1316  }
1317 
1318  if (!context.m_found_function_with_type_info) {
1319  if (extern_symbol) {
1320  AddOneFunction(context, nullptr, extern_symbol);
1321  context.m_found_function = true;
1322  } else if (non_extern_symbol) {
1323  AddOneFunction(context, nullptr, non_extern_symbol);
1324  context.m_found_function = true;
1325  }
1326  }
1327  }
1328 }
1329 
1331  NameSearchContext &context, lldb::ModuleSP module_sp,
1332  const CompilerDeclContext &namespace_decl) {
1333  assert(m_ast_context);
1334 
1336 
1337  const ConstString name(context.m_decl_name.getAsString().c_str());
1338  if (IgnoreName(name, false))
1339  return;
1340 
1341  // Only look for functions by name out in our symbols if the function doesn't
1342  // start with our phony prefix of '$'
1343 
1344  Target *target = nullptr;
1345  StackFrame *frame = nullptr;
1346  SymbolContext sym_ctx;
1347  if (m_parser_vars) {
1348  target = m_parser_vars->m_exe_ctx.GetTargetPtr();
1349  frame = m_parser_vars->m_exe_ctx.GetFramePtr();
1350  }
1351  if (frame != nullptr)
1352  sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction |
1353  lldb::eSymbolContextBlock);
1354 
1355  // Try the persistent decls, which take precedence over all else.
1356  if (!namespace_decl)
1357  SearchPersistenDecls(context, name);
1358 
1359  if (name.GetStringRef().startswith("$") && !namespace_decl) {
1360  if (name == "$__lldb_class") {
1361  LookUpLldbClass(context);
1362  return;
1363  }
1364 
1365  if (name == "$__lldb_objc_class") {
1366  LookUpLldbObjCClass(context);
1367  return;
1368  }
1369  if (name == g_lldb_local_vars_namespace_cstr) {
1370  LookupLocalVarNamespace(sym_ctx, context);
1371  return;
1372  }
1373 
1374  // any other $__lldb names should be weeded out now
1375  if (name.GetStringRef().startswith("$__lldb"))
1376  return;
1377 
1378  // No ParserVars means we can't do register or variable lookup.
1379  if (!m_parser_vars || !m_parser_vars->m_persistent_vars)
1380  return;
1381 
1382  ExpressionVariableSP pvar_sp(
1383  m_parser_vars->m_persistent_vars->GetVariable(name));
1384 
1385  if (pvar_sp) {
1386  AddOneVariable(context, pvar_sp);
1387  return;
1388  }
1389 
1390  assert(name.GetStringRef().startswith("$"));
1391  llvm::StringRef reg_name = name.GetStringRef().substr(1);
1392 
1393  if (m_parser_vars->m_exe_ctx.GetRegisterContext()) {
1394  const RegisterInfo *reg_info(
1395  m_parser_vars->m_exe_ctx.GetRegisterContext()->GetRegisterInfoByName(
1396  reg_name));
1397 
1398  if (reg_info) {
1399  LLDB_LOG(log, " CEDM::FEVD Found register {0}", reg_info->name);
1400 
1401  AddOneRegister(context, reg_info);
1402  }
1403  }
1404  return;
1405  }
1406 
1407  bool local_var_lookup = !namespace_decl || (namespace_decl.GetName() ==
1409  if (frame && local_var_lookup)
1410  if (LookupLocalVariable(context, name, sym_ctx, namespace_decl))
1411  return;
1412 
1413  if (target) {
1414  ValueObjectSP valobj;
1415  VariableSP var;
1416  var = FindGlobalVariable(*target, module_sp, name, namespace_decl);
1417 
1418  if (var) {
1419  valobj = ValueObjectVariable::Create(target, var);
1420  AddOneVariable(context, var, valobj);
1421  context.m_found_variable = true;
1422  return;
1423  }
1424  }
1425 
1426  LookupFunction(context, module_sp, name, namespace_decl);
1427 
1428  // Try the modules next.
1429  if (!context.m_found_function_with_type_info)
1430  LookupInModulesDeclVendor(context, name);
1431 
1432  if (target && !context.m_found_variable && !namespace_decl) {
1433  // We couldn't find a non-symbol variable for this. Now we'll hunt for a
1434  // generic data symbol, and -- if it is found -- treat it as a variable.
1435  Status error;
1436 
1437  const Symbol *data_symbol =
1438  m_parser_vars->m_sym_ctx.FindBestGlobalDataSymbol(name, error);
1439 
1440  if (!error.Success()) {
1441  const unsigned diag_id =
1442  m_ast_context->getDiagnostics().getCustomDiagID(
1444  m_ast_context->getDiagnostics().Report(diag_id) << error.AsCString();
1445  }
1446 
1447  if (data_symbol) {
1448  std::string warning("got name from symbols: ");
1449  warning.append(name.AsCString());
1450  const unsigned diag_id =
1451  m_ast_context->getDiagnostics().getCustomDiagID(
1452  clang::DiagnosticsEngine::Level::Warning, "%0");
1453  m_ast_context->getDiagnostics().Report(diag_id) << warning.c_str();
1454  AddOneGenericVariable(context, *data_symbol);
1455  context.m_found_variable = true;
1456  }
1457  }
1458 }
1459 
1461  lldb_private::Value &var_location,
1462  TypeFromUser *user_type,
1463  TypeFromParser *parser_type) {
1465 
1466  Type *var_type = var->GetType();
1467 
1468  if (!var_type) {
1469  LLDB_LOG(log, "Skipped a definition because it has no type");
1470  return false;
1471  }
1472 
1473  CompilerType var_clang_type = var_type->GetFullCompilerType();
1474 
1475  if (!var_clang_type) {
1476  LLDB_LOG(log, "Skipped a definition because it has no Clang type");
1477  return false;
1478  }
1479 
1480  TypeSystemClang *clang_ast = llvm::dyn_cast_or_null<TypeSystemClang>(
1481  var_type->GetForwardCompilerType().GetTypeSystem());
1482 
1483  if (!clang_ast) {
1484  LLDB_LOG(log, "Skipped a definition because it has no Clang AST");
1485  return false;
1486  }
1487 
1488  DWARFExpression &var_location_expr = var->LocationExpression();
1489 
1490  Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
1491  Status err;
1492 
1493  if (var->GetLocationIsConstantValueData()) {
1494  DataExtractor const_value_extractor;
1495 
1496  if (var_location_expr.GetExpressionData(const_value_extractor)) {
1497  var_location = Value(const_value_extractor.GetDataStart(),
1498  const_value_extractor.GetByteSize());
1500  } else {
1501  LLDB_LOG(log, "Error evaluating constant variable: {0}", err.AsCString());
1502  return false;
1503  }
1504  }
1505 
1506  CompilerType type_to_use = GuardedCopyType(var_clang_type);
1507 
1508  if (!type_to_use) {
1509  LLDB_LOG(log,
1510  "Couldn't copy a variable's type into the parser's AST context");
1511 
1512  return false;
1513  }
1514 
1515  if (parser_type)
1516  *parser_type = TypeFromParser(type_to_use);
1517 
1518  if (var_location.GetContextType() == Value::ContextType::Invalid)
1519  var_location.SetCompilerType(type_to_use);
1520 
1521  if (var_location.GetValueType() == Value::ValueType::FileAddress) {
1522  SymbolContext var_sc;
1523  var->CalculateSymbolContext(&var_sc);
1524 
1525  if (!var_sc.module_sp)
1526  return false;
1527 
1528  Address so_addr(var_location.GetScalar().ULongLong(),
1529  var_sc.module_sp->GetSectionList());
1530 
1531  lldb::addr_t load_addr = so_addr.GetLoadAddress(target);
1532 
1533  if (load_addr != LLDB_INVALID_ADDRESS) {
1534  var_location.GetScalar() = load_addr;
1536  }
1537  }
1538 
1539  if (user_type)
1540  *user_type = TypeFromUser(var_clang_type);
1541 
1542  return true;
1543 }
1544 
1546  VariableSP var,
1547  ValueObjectSP valobj) {
1548  assert(m_parser_vars.get());
1549 
1551 
1552  TypeFromUser ut;
1553  TypeFromParser pt;
1554  Value var_location;
1555 
1556  if (!GetVariableValue(var, var_location, &ut, &pt))
1557  return;
1558 
1559  clang::QualType parser_opaque_type =
1560  QualType::getFromOpaquePtr(pt.GetOpaqueQualType());
1561 
1562  if (parser_opaque_type.isNull())
1563  return;
1564 
1565  if (const clang::Type *parser_type = parser_opaque_type.getTypePtr()) {
1566  if (const TagType *tag_type = dyn_cast<TagType>(parser_type))
1567  CompleteType(tag_type->getDecl());
1568  if (const ObjCObjectPointerType *objc_object_ptr_type =
1569  dyn_cast<ObjCObjectPointerType>(parser_type))
1570  CompleteType(objc_object_ptr_type->getInterfaceDecl());
1571  }
1572 
1573  bool is_reference = pt.IsReferenceType();
1574 
1575  NamedDecl *var_decl = nullptr;
1576  if (is_reference)
1577  var_decl = context.AddVarDecl(pt);
1578  else
1579  var_decl = context.AddVarDecl(pt.GetLValueReferenceType());
1580 
1581  std::string decl_name(context.m_decl_name.getAsString());
1582  ConstString entity_name(decl_name.c_str());
1583  ClangExpressionVariable *entity(new ClangExpressionVariable(valobj));
1585 
1586  assert(entity);
1587  entity->EnableParserVars(GetParserID());
1589  entity->GetParserVars(GetParserID());
1590  parser_vars->m_named_decl = var_decl;
1591  parser_vars->m_llvm_value = nullptr;
1592  parser_vars->m_lldb_value = var_location;
1593  parser_vars->m_lldb_var = var;
1594 
1595  if (is_reference)
1596  entity->m_flags |= ClangExpressionVariable::EVTypeIsReference;
1597 
1598  LLDB_LOG(log, " CEDM::FEVD Found variable {1}, returned\n{2} (original {3})",
1599  decl_name, ClangUtil::DumpDecl(var_decl), ClangUtil::ToString(ut));
1600 }
1601 
1603  ExpressionVariableSP &pvar_sp) {
1605 
1606  TypeFromUser user_type(
1607  llvm::cast<ClangExpressionVariable>(pvar_sp.get())->GetTypeFromUser());
1608 
1609  TypeFromParser parser_type(GuardedCopyType(user_type));
1610 
1611  if (!parser_type.GetOpaqueQualType()) {
1612  LLDB_LOG(log, " CEDM::FEVD Couldn't import type for pvar {0}",
1613  pvar_sp->GetName());
1614  return;
1615  }
1616 
1617  NamedDecl *var_decl =
1618  context.AddVarDecl(parser_type.GetLValueReferenceType());
1619 
1620  llvm::cast<ClangExpressionVariable>(pvar_sp.get())
1621  ->EnableParserVars(GetParserID());
1623  llvm::cast<ClangExpressionVariable>(pvar_sp.get())
1624  ->GetParserVars(GetParserID());
1625  parser_vars->m_named_decl = var_decl;
1626  parser_vars->m_llvm_value = nullptr;
1627  parser_vars->m_lldb_value.Clear();
1628 
1629  LLDB_LOG(log, " CEDM::FEVD Added pvar {1}, returned\n{2}",
1630  pvar_sp->GetName(), ClangUtil::DumpDecl(var_decl));
1631 }
1632 
1634  const Symbol &symbol) {
1635  assert(m_parser_vars.get());
1636 
1638 
1639  Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
1640 
1641  if (target == nullptr)
1642  return;
1643 
1644  TypeSystemClang *scratch_ast_context = GetScratchContext(*target);
1645  if (!scratch_ast_context)
1646  return;
1647 
1648  TypeFromUser user_type(scratch_ast_context->GetBasicType(eBasicTypeVoid)
1649  .GetPointerType()
1652  .GetPointerType()
1654  NamedDecl *var_decl = context.AddVarDecl(parser_type);
1655 
1656  std::string decl_name(context.m_decl_name.getAsString());
1657  ConstString entity_name(decl_name.c_str());
1659  m_parser_vars->m_exe_ctx.GetBestExecutionContextScope(), entity_name,
1660  user_type, m_parser_vars->m_target_info.byte_order,
1661  m_parser_vars->m_target_info.address_byte_size));
1663 
1664  entity->EnableParserVars(GetParserID());
1666  entity->GetParserVars(GetParserID());
1667 
1668  const Address symbol_address = symbol.GetAddress();
1669  lldb::addr_t symbol_load_addr = symbol_address.GetLoadAddress(target);
1670 
1671  // parser_vars->m_lldb_value.SetContext(Value::ContextType::ClangType,
1672  // user_type.GetOpaqueQualType());
1673  parser_vars->m_lldb_value.SetCompilerType(user_type);
1674  parser_vars->m_lldb_value.GetScalar() = symbol_load_addr;
1676 
1677  parser_vars->m_named_decl = var_decl;
1678  parser_vars->m_llvm_value = nullptr;
1679  parser_vars->m_lldb_sym = &symbol;
1680 
1681  LLDB_LOG(log, " CEDM::FEVD Found variable {1}, returned\n{2}", decl_name,
1682  ClangUtil::DumpDecl(var_decl));
1683 }
1684 
1686  const RegisterInfo *reg_info) {
1688 
1689  CompilerType clang_type =
1691  reg_info->encoding, reg_info->byte_size * 8);
1692 
1693  if (!clang_type) {
1694  LLDB_LOG(log, " Tried to add a type for {0}, but couldn't get one",
1695  context.m_decl_name.getAsString());
1696  return;
1697  }
1698 
1699  TypeFromParser parser_clang_type(clang_type);
1700 
1701  NamedDecl *var_decl = context.AddVarDecl(parser_clang_type);
1702 
1704  m_parser_vars->m_exe_ctx.GetBestExecutionContextScope(),
1705  m_parser_vars->m_target_info.byte_order,
1706  m_parser_vars->m_target_info.address_byte_size));
1708 
1709  std::string decl_name(context.m_decl_name.getAsString());
1710  entity->SetName(ConstString(decl_name.c_str()));
1711  entity->SetRegisterInfo(reg_info);
1712  entity->EnableParserVars(GetParserID());
1714  entity->GetParserVars(GetParserID());
1715  parser_vars->m_named_decl = var_decl;
1716  parser_vars->m_llvm_value = nullptr;
1717  parser_vars->m_lldb_value.Clear();
1719 
1720  LLDB_LOG(log, " CEDM::FEVD Added register {1}, returned\n{2}",
1721  context.m_decl_name.getAsString(), ClangUtil::DumpDecl(var_decl));
1722 }
1723 
1725  Function *function,
1726  Symbol *symbol) {
1727  assert(m_parser_vars.get());
1728 
1730 
1731  NamedDecl *function_decl = nullptr;
1732  Address fun_address;
1733  CompilerType function_clang_type;
1734 
1735  bool is_indirect_function = false;
1736 
1737  if (function) {
1738  Type *function_type = function->GetType();
1739 
1740  const auto lang = function->GetCompileUnit()->GetLanguage();
1741  const auto name = function->GetMangled().GetMangledName().AsCString();
1742  const bool extern_c = (Language::LanguageIsC(lang) &&
1744  (Language::LanguageIsObjC(lang) &&
1746 
1747  if (!extern_c) {
1748  TypeSystem *type_system = function->GetDeclContext().GetTypeSystem();
1749  if (llvm::isa<TypeSystemClang>(type_system)) {
1750  clang::DeclContext *src_decl_context =
1751  (clang::DeclContext *)function->GetDeclContext()
1752  .GetOpaqueDeclContext();
1753  clang::FunctionDecl *src_function_decl =
1754  llvm::dyn_cast_or_null<clang::FunctionDecl>(src_decl_context);
1755  if (src_function_decl &&
1756  src_function_decl->getTemplateSpecializationInfo()) {
1757  clang::FunctionTemplateDecl *function_template =
1758  src_function_decl->getTemplateSpecializationInfo()->getTemplate();
1759  clang::FunctionTemplateDecl *copied_function_template =
1760  llvm::dyn_cast_or_null<clang::FunctionTemplateDecl>(
1761  CopyDecl(function_template));
1762  if (copied_function_template) {
1763  if (log) {
1764  StreamString ss;
1765 
1766  function->DumpSymbolContext(&ss);
1767 
1768  LLDB_LOG(log,
1769  " CEDM::FEVD Imported decl for function template"
1770  " {1} (description {2}), returned\n{3}",
1771  copied_function_template->getNameAsString(),
1772  ss.GetData(),
1773  ClangUtil::DumpDecl(copied_function_template));
1774  }
1775 
1776  context.AddNamedDecl(copied_function_template);
1777  }
1778  } else if (src_function_decl) {
1779  if (clang::FunctionDecl *copied_function_decl =
1780  llvm::dyn_cast_or_null<clang::FunctionDecl>(
1781  CopyDecl(src_function_decl))) {
1782  if (log) {
1783  StreamString ss;
1784 
1785  function->DumpSymbolContext(&ss);
1786 
1787  LLDB_LOG(log,
1788  " CEDM::FEVD Imported decl for function {1} "
1789  "(description {2}), returned\n{3}",
1790  copied_function_decl->getNameAsString(), ss.GetData(),
1791  ClangUtil::DumpDecl(copied_function_decl));
1792  }
1793 
1794  context.AddNamedDecl(copied_function_decl);
1795  return;
1796  } else {
1797  LLDB_LOG(log, " Failed to import the function decl for '{0}'",
1798  src_function_decl->getName());
1799  }
1800  }
1801  }
1802  }
1803 
1804  if (!function_type) {
1805  LLDB_LOG(log, " Skipped a function because it has no type");
1806  return;
1807  }
1808 
1809  function_clang_type = function_type->GetFullCompilerType();
1810 
1811  if (!function_clang_type) {
1812  LLDB_LOG(log, " Skipped a function because it has no Clang type");
1813  return;
1814  }
1815 
1816  fun_address = function->GetAddressRange().GetBaseAddress();
1817 
1818  CompilerType copied_function_type = GuardedCopyType(function_clang_type);
1819  if (copied_function_type) {
1820  function_decl = context.AddFunDecl(copied_function_type, extern_c);
1821 
1822  if (!function_decl) {
1823  LLDB_LOG(log, " Failed to create a function decl for '{0}' ({1:x})",
1824  function_type->GetName(), function_type->GetID());
1825 
1826  return;
1827  }
1828  } else {
1829  // We failed to copy the type we found
1830  LLDB_LOG(log,
1831  " Failed to import the function type '{0}' ({1:x})"
1832  " into the expression parser AST contenxt",
1833  function_type->GetName(), function_type->GetID());
1834 
1835  return;
1836  }
1837  } else if (symbol) {
1838  fun_address = symbol->GetAddress();
1839  function_decl = context.AddGenericFunDecl();
1840  is_indirect_function = symbol->IsIndirect();
1841  } else {
1842  LLDB_LOG(log, " AddOneFunction called with no function and no symbol");
1843  return;
1844  }
1845 
1846  Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
1847 
1848  lldb::addr_t load_addr =
1849  fun_address.GetCallableLoadAddress(target, is_indirect_function);
1850 
1852  m_parser_vars->m_exe_ctx.GetBestExecutionContextScope(),
1853  m_parser_vars->m_target_info.byte_order,
1854  m_parser_vars->m_target_info.address_byte_size));
1856 
1857  std::string decl_name(context.m_decl_name.getAsString());
1858  entity->SetName(ConstString(decl_name.c_str()));
1859  entity->SetCompilerType(function_clang_type);
1860  entity->EnableParserVars(GetParserID());
1861 
1863  entity->GetParserVars(GetParserID());
1864 
1865  if (load_addr != LLDB_INVALID_ADDRESS) {
1867  parser_vars->m_lldb_value.GetScalar() = load_addr;
1868  } else {
1869  // We have to try finding a file address.
1870 
1871  lldb::addr_t file_addr = fun_address.GetFileAddress();
1872 
1874  parser_vars->m_lldb_value.GetScalar() = file_addr;
1875  }
1876 
1877  parser_vars->m_named_decl = function_decl;
1878  parser_vars->m_llvm_value = nullptr;
1879 
1880  if (log) {
1881  StreamString ss;
1882 
1883  fun_address.Dump(&ss,
1884  m_parser_vars->m_exe_ctx.GetBestExecutionContextScope(),
1886 
1887  LLDB_LOG(log,
1888  " CEDM::FEVD Found {1} function {2} (description {3}), "
1889  "returned\n{4}",
1890  (function ? "specific" : "generic"), decl_name, ss.GetData(),
1891  ClangUtil::DumpDecl(function_decl));
1892  }
1893 }
1894 
1896  const TypeFromUser &ut) {
1897  CompilerType copied_clang_type = GuardedCopyType(ut);
1898 
1900 
1901  if (!copied_clang_type) {
1902  LLDB_LOG(log,
1903  "ClangExpressionDeclMap::AddThisType - Couldn't import the type");
1904 
1905  return;
1906  }
1907 
1908  if (copied_clang_type.IsAggregateType() &&
1909  copied_clang_type.GetCompleteType()) {
1910  CompilerType void_clang_type =
1912  CompilerType void_ptr_clang_type = void_clang_type.GetPointerType();
1913 
1915  void_clang_type, &void_ptr_clang_type, 1, false, 0);
1916 
1917  const bool is_virtual = false;
1918  const bool is_static = false;
1919  const bool is_inline = false;
1920  const bool is_explicit = false;
1921  const bool is_attr_used = true;
1922  const bool is_artificial = false;
1923 
1924  CXXMethodDecl *method_decl = m_clang_ast_context->AddMethodToCXXRecordType(
1925  copied_clang_type.GetOpaqueQualType(), "$__lldb_expr", nullptr,
1926  method_type, lldb::eAccessPublic, is_virtual, is_static, is_inline,
1927  is_explicit, is_attr_used, is_artificial);
1928 
1929  LLDB_LOG(log,
1930  " CEDM::AddThisType Added function $__lldb_expr "
1931  "(description {0}) for this type\n{1}",
1932  ClangUtil::ToString(copied_clang_type),
1933  ClangUtil::DumpDecl(method_decl));
1934  }
1935 
1936  if (!copied_clang_type.IsValid())
1937  return;
1938 
1939  TypeSourceInfo *type_source_info = m_ast_context->getTrivialTypeSourceInfo(
1940  QualType::getFromOpaquePtr(copied_clang_type.GetOpaqueQualType()));
1941 
1942  if (!type_source_info)
1943  return;
1944 
1945  // Construct a typedef type because if "*this" is a templated type we can't
1946  // just return ClassTemplateSpecializationDecls in response to name queries.
1947  // Using a typedef makes this much more robust.
1948 
1949  TypedefDecl *typedef_decl = TypedefDecl::Create(
1950  *m_ast_context, m_ast_context->getTranslationUnitDecl(), SourceLocation(),
1951  SourceLocation(), context.m_decl_name.getAsIdentifierInfo(),
1952  type_source_info);
1953 
1954  if (!typedef_decl)
1955  return;
1956 
1957  context.AddNamedDecl(typedef_decl);
1958 }
1959 
1961  const TypeFromUser &ut) {
1962  CompilerType copied_clang_type = GuardedCopyType(ut);
1963 
1964  if (!copied_clang_type) {
1966 
1967  LLDB_LOG(log,
1968  "ClangExpressionDeclMap::AddOneType - Couldn't import the type");
1969 
1970  return;
1971  }
1972 
1973  context.AddTypeDecl(copied_clang_type);
1974 }
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:759
lldb::eSymbolTypeCompiler
@ eSymbolTypeCompiler
Definition: lldb-enumerations.h:637
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:628
lldb_private::ArchSpec::GetByteOrder
lldb::ByteOrder GetByteOrder() const
Returns the byte order for the architecture specification.
Definition: ArchSpec.cpp:731
lldb::eSymbolTypeObjCIVar
@ eSymbolTypeObjCIVar
Definition: lldb-enumerations.h:642
lldb_private::CompilerDeclContext::FindDeclByName
std::vector< CompilerDecl > FindDeclByName(ConstString name, const bool ignore_using_decls)
Definition: CompilerDeclContext.cpp:17
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:428
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::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:176
lldb::eSymbolTypeHeaderFile
@ eSymbolTypeHeaderFile
Definition: lldb-enumerations.h:623
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:686
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:616
lldb_private::ClangExpressionDeclMap::GetScratchContext
TypeSystemClang * GetScratchContext(Target &target)
Definition: ClangExpressionDeclMap.h:382
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:1200
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:638
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:122
lldb_private::ObjCLanguageRuntime
Definition: ObjCLanguageRuntime.h:35
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)
Definition: TypeSystemClang.cpp:2172
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::StackFrame::GetVariableList
VariableList * GetVariableList(bool get_file_globals)
Retrieve the list of variables that are in scope at this StackFrame's pc.
Definition: StackFrame.cpp:423
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:614
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:1460
lldb::eSymbolTypeLineEntry
@ eSymbolTypeLineEntry
Definition: lldb-enumerations.h:631
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:1189
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:625
lldb::eSymbolTypeTrampoline
@ eSymbolTypeTrampoline
Definition: lldb-enumerations.h:619
lldb_private::Process
Definition: Process.h:338
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:795
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:730
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:141
lldb_private::ExpressionVariable::GetRegisterInfo
RegisterInfo * GetRegisterInfo()
Definition: ExpressionVariable.h:45
lldb_private::VariableList::GetSize
size_t GetSize() const
Definition: VariableList.cpp:165
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:633
lldb_private::ClangExpressionDeclMap::EnableStructVars
void EnableStructVars()
Activate struct variables.
Definition: ClangExpressionDeclMap.h:374
lldb::eSymbolTypeData
@ eSymbolTypeData
Definition: lldb-enumerations.h:618
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:1263
lldb_private::ClangExpressionDeclMap::InstallDiagnosticManager
void InstallDiagnosticManager(DiagnosticManager &diag_manager)
Definition: ClangExpressionDeclMap.cpp:128
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:860
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:193
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:620
StackFrame.h
lldb_private::Symbol::GetReExportedSymbolName
ConstString GetReExportedSymbolName() const
Definition: Symbol.cpp:126
lldb_private::Type::GetName
ConstString GetName()
Definition: Type.cpp:302
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:1633
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:9709
lldb_private::SymbolContext
Definition: SymbolContext.h:33
lldb_private::Target
Definition: Target.h:464
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:277
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:1738
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:938
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:63
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:487
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:504
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:1895
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:183
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:164
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:626
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:77
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:193
lldb::eSymbolTypeSourceFile
@ eSymbolTypeSourceFile
Definition: lldb-enumerations.h:622
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:1118
lldb_private::TypeSystemClang::DeclContextGetAsObjCMethodDecl
static clang::ObjCMethodDecl * DeclContextGetAsObjCMethodDecl(const CompilerDeclContext &dc)
Definition: TypeSystemClang.cpp:9701
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:716
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:202
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:161
lldb::eSymbolTypeUndefined
@ eSymbolTypeUndefined
Definition: lldb-enumerations.h:639
lldb::eSymbolTypeObjectFile
@ eSymbolTypeObjectFile
Definition: lldb-enumerations.h:624
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:478
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:149
lldb_private::ClangExpressionDeclMap::GetTypeSystemClang
TypeSystemClang * GetTypeSystemClang()
Definition: ClangExpressionDeclMap.cpp:624
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:159
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:389
lldb_private::ClangExpressionVariable::GetJITVars
JITVars * GetJITVars(uint64_t parser_id)
Definition: ClangExpressionVariable.h:183
Type.h
lldb_private::DWARFExpression
Definition: DWARFExpression.h:36
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:1730
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:708
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:3332
lldb_private::SymbolContextList::GetSize
uint32_t GetSize() const
Get accessor for a symbol context list size.
Definition: SymbolContext.cpp:1279
lldb_private::ConstString
Definition: ConstString.h:40
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:618
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:1205
lldb_private::Materializer::PersistentVariableDelegate
Definition: Materializer.h:70
lldb_private::Symbol::IsExternal
bool IsExternal() const
Definition: Symbol.h:170
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:521
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:743
lldb::eSymbolTypeObjCClass
@ eSymbolTypeObjCClass
Definition: lldb-enumerations.h:640
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:1960
lldb::eSymbolTypeAdditional
@ eSymbolTypeAdditional
When symbols take more than one entry, the extra entries get this type.
Definition: lldb-enumerations.h:635
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:380
lldb_private::TypeSystemClang::GetUniqueNamespaceDeclaration
clang::NamespaceDecl * GetUniqueNamespaceDeclaration(const char *name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, bool is_inline=false)
Definition: TypeSystemClang.cpp:1857
lldb_private::Target::GetPersistentExpressionStateForLanguage
PersistentExpressionState * GetPersistentExpressionStateForLanguage(lldb::LanguageType language)
Definition: Target.cpp:2339
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:612
Address.h
lldb::eSymbolTypeVariable
@ eSymbolTypeVariable
Definition: lldb-enumerations.h:629
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:9529
lldb::eSymbolTypeScopeEnd
@ eSymbolTypeScopeEnd
Definition: lldb-enumerations.h:634
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:162
lldb_private::DWARFExpression::GetExpressionData
bool GetExpressionData(DataExtractor &data) const
Definition: DWARFExpression.h:204
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:684
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:411
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::ConstString::Clear
void Clear()
Clear this object's state.
Definition: ConstString.h:232
lldb_private::ClangASTSource::GetClangModulesDeclVendor
std::shared_ptr< ClangModulesDeclVendor > GetClangModulesDeclVendor()
Definition: ClangASTSource.cpp:1757
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:980
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:140
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:56
lldb_private::Address::DumpStyleResolvedDescription
@ DumpStyleResolvedDescription
Display the details about what an address resolves to.
Definition: Address.h:101
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:609
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::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:323
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:442
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:641
ObjCLanguageRuntime.h
lldb::eSymbolTypeVariableType
@ eSymbolTypeVariableType
Definition: lldb-enumerations.h:630
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:9797
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:1724
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:263
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:497
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:643
SymbolContext.h
lldb_private::CPlusPlusLanguage::IsCPPMangledName
static bool IsCPPMangledName(llvm::StringRef name)
Definition: CPlusPlusLanguage.cpp:306
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:71
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:930
lldb::eSymbolTypeLineHeader
@ eSymbolTypeLineHeader
Definition: lldb-enumerations.h:632
lldb_private::TypeSystemClang
A TypeSystem implementation based on Clang.
Definition: TypeSystemClang.h:105
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::FileSpec::GetDirectory
ConstString & GetDirectory()
Directory string get accessor.
Definition: FileSpec.cpp:334
lldb_private::ClangExpressionDeclMap::m_struct_vars
std::unique_ptr< StructVars > m_struct_vars
Definition: ClangExpressionDeclMap.h:371
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:644
ValueObjectVariable.h
lldb_private::Module::FindSymbolsWithNameAndType
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list)
Definition: Module.cpp:1378
lldb::eSymbolTypeException
@ eSymbolTypeException
Definition: lldb-enumerations.h:621
lldb_private::Process::GetByteOrder
lldb::ByteOrder GetByteOrder() const
Definition: Process.cpp:3328
lldb_private::Log
Definition: Log.h:48
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:7560
lldb::eSymbolTypeResolver
@ eSymbolTypeResolver
Definition: lldb-enumerations.h:617
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:462
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:826
lldb_private::Symbol::IsIndirect
bool IsIndirect() const
Definition: Symbol.cpp:176
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:398
lldb_private::Function::GetDeclContext
CompilerDeclContext GetDeclContext()
Get the DeclContext for this function, if available.
Definition: Function.cpp:492
SymbolVendor.h
lldb::eSymbolTypeAbsolute
@ eSymbolTypeAbsolute
Definition: lldb-enumerations.h:615
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:235
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:1685
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:143
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:627
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:86
lldb_private::StackFrame::GetSymbolContext
const SymbolContext & GetSymbolContext(lldb::SymbolContextItem resolve_scope)
Provide a SymbolContext for this StackFrame's current pc value.
Definition: StackFrame.cpp:299
LLDBLog.h
SymbolFile.h
lldb_private::Symbol::ResolveReExportedSymbol
Symbol * ResolveReExportedSymbol(Target &target) const
Definition: Symbol.cpp:473
lldb_private::ClangExpressionDeclMap::DidParse
void DidParse()
Disable the state needed for parsing and IR transformation.
Definition: ClangExpressionDeclMap.cpp:134
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::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:165
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