LLDB  mainline
Variable.cpp
Go to the documentation of this file.
1 //===-- Variable.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 
9 #include "lldb/Symbol/Variable.h"
10 
11 #include "lldb/Core/Module.h"
12 #include "lldb/Core/ValueObject.h"
14 #include "lldb/Symbol/Block.h"
18 #include "lldb/Symbol/Function.h"
20 #include "lldb/Symbol/SymbolFile.h"
21 #include "lldb/Symbol/Type.h"
22 #include "lldb/Symbol/TypeSystem.h"
24 #include "lldb/Target/ABI.h"
25 #include "lldb/Target/Process.h"
27 #include "lldb/Target/StackFrame.h"
28 #include "lldb/Target/Target.h"
29 #include "lldb/Target/Thread.h"
31 #include "lldb/Utility/Stream.h"
32 
33 #include "llvm/ADT/Twine.h"
34 
35 using namespace lldb;
36 using namespace lldb_private;
37 
38 Variable::Variable(lldb::user_id_t uid, const char *name, const char *mangled,
39  const lldb::SymbolFileTypeSP &symfile_type_sp,
40  ValueType scope, SymbolContextScope *context,
41  const RangeList &scope_range, Declaration *decl_ptr,
42  const DWARFExpression &location, bool external,
43  bool artificial, bool location_is_constant_data,
44  bool static_member)
45  : UserID(uid), m_name(name), m_mangled(ConstString(mangled)),
46  m_symfile_type_sp(symfile_type_sp), m_scope(scope),
47  m_owner_scope(context), m_scope_range(scope_range),
48  m_declaration(decl_ptr), m_location(location), m_external(external),
49  m_artificial(artificial), m_loc_is_const_data(location_is_constant_data),
50  m_static_member(static_member) {}
51 
52 Variable::~Variable() = default;
53 
55  lldb::LanguageType lang = m_mangled.GuessLanguage();
56  if (lang != lldb::eLanguageTypeUnknown)
57  return lang;
58 
59  if (auto *func = m_owner_scope->CalculateSymbolContextFunction()) {
60  if ((lang = func->GetLanguage()) != lldb::eLanguageTypeUnknown)
61  return lang;
62  } else if (auto *comp_unit =
64  if ((lang = comp_unit->GetLanguage()) != lldb::eLanguageTypeUnknown)
65  return lang;
66  }
67 
69 }
70 
72  ConstString name = m_mangled.GetName();
73  if (name)
74  return name;
75  return m_name;
76 }
77 
79 
81  if (m_name == name)
82  return true;
83  SymbolContext variable_sc;
85 
86  return m_mangled.NameMatches(name);
87 }
88 bool Variable::NameMatches(const RegularExpression &regex) const {
89  if (regex.Execute(m_name.AsCString()))
90  return true;
91  if (m_mangled)
92  return m_mangled.NameMatches(regex);
93  return false;
94 }
95 
98  return m_symfile_type_sp->GetType();
99  return nullptr;
100 }
101 
102 void Variable::Dump(Stream *s, bool show_context) const {
103  s->Printf("%p: ", static_cast<const void *>(this));
104  s->Indent();
105  *s << "Variable" << (const UserID &)*this;
106 
107  if (m_name)
108  *s << ", name = \"" << m_name << "\"";
109 
110  if (m_symfile_type_sp) {
111  Type *type = m_symfile_type_sp->GetType();
112  if (type) {
113  s->Format(", type = {{{0:x-16}} {1} (", type->GetID(), type);
114  type->DumpTypeName(s);
115  s->PutChar(')');
116  }
117  }
118 
119  if (m_scope != eValueTypeInvalid) {
120  s->PutCString(", scope = ");
121  switch (m_scope) {
123  s->PutCString(m_external ? "global" : "static");
124  break;
126  s->PutCString("parameter");
127  break;
129  s->PutCString("local");
130  break;
132  s->PutCString("thread local");
133  break;
134  default:
135  s->AsRawOstream() << "??? (" << m_scope << ')';
136  }
137  }
138 
139  if (show_context && m_owner_scope != nullptr) {
140  s->PutCString(", context = ( ");
142  s->PutCString(" )");
143  }
144 
145  bool show_fullpaths = false;
146  m_declaration.Dump(s, show_fullpaths);
147 
148  if (m_location.IsValid()) {
149  s->PutCString(", location = ");
150  lldb::addr_t loclist_base_addr = LLDB_INVALID_ADDRESS;
151  if (m_location.IsLocationList()) {
152  SymbolContext variable_sc;
153  m_owner_scope->CalculateSymbolContext(&variable_sc);
154  if (variable_sc.function)
155  loclist_base_addr = variable_sc.function->GetAddressRange()
156  .GetBaseAddress()
157  .GetFileAddress();
158  }
159  ABISP abi;
160  if (m_owner_scope) {
161  ModuleSP module_sp(m_owner_scope->CalculateSymbolContextModule());
162  if (module_sp)
163  abi = ABI::FindPlugin(ProcessSP(), module_sp->GetArchitecture());
164  }
166  loclist_base_addr, abi.get());
167  }
168 
169  if (m_external)
170  s->PutCString(", external");
171 
172  if (m_artificial)
173  s->PutCString(", artificial");
174 
175  s->EOL();
176 }
177 
178 bool Variable::DumpDeclaration(Stream *s, bool show_fullpaths,
179  bool show_module) {
180  bool dumped_declaration_info = false;
181  if (m_owner_scope) {
182  SymbolContext sc;
184  sc.block = nullptr;
185  sc.line_entry.Clear();
186  bool show_inlined_frames = false;
187  const bool show_function_arguments = true;
188  const bool show_function_name = true;
189 
190  dumped_declaration_info = sc.DumpStopContext(
191  s, nullptr, Address(), show_fullpaths, show_module, show_inlined_frames,
192  show_function_arguments, show_function_name);
193 
194  if (sc.function)
195  s->PutChar(':');
196  }
197  if (m_declaration.DumpStopContext(s, false))
198  dumped_declaration_info = true;
199  return dumped_declaration_info;
200 }
201 
202 size_t Variable::MemorySize() const { return sizeof(Variable); }
203 
205  Type *type = GetType();
206  if (type)
208  return CompilerDeclContext();
209 }
210 
212  Type *type = GetType();
213  return type ? type->GetSymbolFile()->GetDeclForUID(GetID()) : CompilerDecl();
214 }
215 
217  if (m_owner_scope) {
219  sc->variable = this;
220  } else
221  sc->Clear(false);
222 }
223 
225  // Is the variable is described by a single location?
226  if (!m_location.IsLocationList()) {
227  // Yes it is, the location is valid.
228  return true;
229  }
230 
231  if (frame) {
232  Function *function =
233  frame->GetSymbolContext(eSymbolContextFunction).function;
234  if (function) {
235  TargetSP target_sp(frame->CalculateTarget());
236 
237  addr_t loclist_base_load_addr =
238  function->GetAddressRange().GetBaseAddress().GetLoadAddress(
239  target_sp.get());
240  if (loclist_base_load_addr == LLDB_INVALID_ADDRESS)
241  return false;
242  // It is a location list. We just need to tell if the location list
243  // contains the current address when converted to a load address
245  loclist_base_load_addr,
246  frame->GetFrameCodeAddress().GetLoadAddress(target_sp.get()));
247  }
248  }
249  return false;
250 }
251 
253  // Be sure to resolve the address to section offset prior to calling this
254  // function.
255  if (address.IsSectionOffset()) {
256  SymbolContext sc;
258  if (sc.module_sp == address.GetModule()) {
259  // Is the variable is described by a single location?
260  if (!m_location.IsLocationList()) {
261  // Yes it is, the location is valid.
262  return true;
263  }
264 
265  if (sc.function) {
266  addr_t loclist_base_file_addr =
268  if (loclist_base_file_addr == LLDB_INVALID_ADDRESS)
269  return false;
270  // It is a location list. We just need to tell if the location list
271  // contains the current address when converted to a load address
272  return m_location.LocationListContainsAddress(loclist_base_file_addr,
273  address.GetFileAddress());
274  }
275  }
276  }
277  return false;
278 }
279 
281  switch (m_scope) {
282  case eValueTypeRegister:
284  return frame != nullptr;
285 
290  return true;
291 
294  if (frame) {
295  // We don't have a location list, we just need to see if the block that
296  // this variable was defined in is currently
297  Block *deepest_frame_block =
298  frame->GetSymbolContext(eSymbolContextBlock).block;
299  if (deepest_frame_block) {
300  SymbolContext variable_sc;
301  CalculateSymbolContext(&variable_sc);
302 
303  // Check for static or global variable defined at the compile unit
304  // level that wasn't defined in a block
305  if (variable_sc.block == nullptr)
306  return true;
307 
308  // Check if the variable is valid in the current block
309  if (variable_sc.block != deepest_frame_block &&
310  !variable_sc.block->Contains(deepest_frame_block))
311  return false;
312 
313  // If no scope range is specified then it means that the scope is the
314  // same as the scope of the enclosing lexical block.
315  if (m_scope_range.IsEmpty())
316  return true;
317 
318  addr_t file_address = frame->GetFrameCodeAddress().GetFileAddress();
319  return m_scope_range.FindEntryThatContains(file_address) != nullptr;
320  }
321  }
322  break;
323 
324  default:
325  break;
326  }
327  return false;
328 }
329 
331  llvm::StringRef variable_expr_path, ExecutionContextScope *scope,
332  GetVariableCallback callback, void *baton, VariableList &variable_list,
333  ValueObjectList &valobj_list) {
334  Status error;
335  if (!callback || variable_expr_path.empty()) {
336  error.SetErrorString("unknown error");
337  return error;
338  }
339 
340  switch (variable_expr_path.front()) {
341  case '*':
343  variable_expr_path.drop_front(), scope, callback, baton, variable_list,
344  valobj_list);
345  if (error.Fail()) {
346  error.SetErrorString("unknown error");
347  return error;
348  }
349  for (uint32_t i = 0; i < valobj_list.GetSize();) {
350  Status tmp_error;
351  ValueObjectSP valobj_sp(
352  valobj_list.GetValueObjectAtIndex(i)->Dereference(tmp_error));
353  if (tmp_error.Fail()) {
354  variable_list.RemoveVariableAtIndex(i);
355  valobj_list.RemoveValueObjectAtIndex(i);
356  } else {
357  valobj_list.SetValueObjectAtIndex(i, valobj_sp);
358  ++i;
359  }
360  }
361  return error;
362  case '&': {
364  variable_expr_path.drop_front(), scope, callback, baton, variable_list,
365  valobj_list);
366  if (error.Success()) {
367  for (uint32_t i = 0; i < valobj_list.GetSize();) {
368  Status tmp_error;
369  ValueObjectSP valobj_sp(
370  valobj_list.GetValueObjectAtIndex(i)->AddressOf(tmp_error));
371  if (tmp_error.Fail()) {
372  variable_list.RemoveVariableAtIndex(i);
373  valobj_list.RemoveValueObjectAtIndex(i);
374  } else {
375  valobj_list.SetValueObjectAtIndex(i, valobj_sp);
376  ++i;
377  }
378  }
379  } else {
380  error.SetErrorString("unknown error");
381  }
382  return error;
383  } break;
384 
385  default: {
386  static RegularExpression g_regex(
387  llvm::StringRef("^([A-Za-z_:][A-Za-z_0-9:]*)(.*)"));
388  llvm::SmallVector<llvm::StringRef, 2> matches;
389  variable_list.Clear();
390  if (!g_regex.Execute(variable_expr_path, &matches)) {
391  error.SetErrorStringWithFormat(
392  "unable to extract a variable name from '%s'",
393  variable_expr_path.str().c_str());
394  return error;
395  }
396  std::string variable_name = matches[1].str();
397  if (!callback(baton, variable_name.c_str(), variable_list)) {
398  error.SetErrorString("unknown error");
399  return error;
400  }
401  uint32_t i = 0;
402  while (i < variable_list.GetSize()) {
403  VariableSP var_sp(variable_list.GetVariableAtIndex(i));
404  ValueObjectSP valobj_sp;
405  if (!var_sp) {
406  variable_list.RemoveVariableAtIndex(i);
407  continue;
408  }
409  ValueObjectSP variable_valobj_sp(
410  ValueObjectVariable::Create(scope, var_sp));
411  if (!variable_valobj_sp) {
412  variable_list.RemoveVariableAtIndex(i);
413  continue;
414  }
415 
416  llvm::StringRef variable_sub_expr_path =
417  variable_expr_path.drop_front(variable_name.size());
418  if (!variable_sub_expr_path.empty()) {
419  valobj_sp = variable_valobj_sp->GetValueForExpressionPath(
420  variable_sub_expr_path);
421  if (!valobj_sp) {
422  error.SetErrorStringWithFormat(
423  "invalid expression path '%s' for variable '%s'",
424  variable_sub_expr_path.str().c_str(),
425  var_sp->GetName().GetCString());
426  variable_list.RemoveVariableAtIndex(i);
427  continue;
428  }
429  } else {
430  // Just the name of a variable with no extras
431  valobj_sp = variable_valobj_sp;
432  }
433 
434  valobj_list.Append(valobj_sp);
435  ++i;
436  }
437 
438  if (variable_list.GetSize() > 0) {
439  error.Clear();
440  return error;
441  }
442  } break;
443  }
444  error.SetErrorString("unknown error");
445  return error;
446 }
447 
449  // Be sure to resolve the address to section offset prior to calling this
450  // function.
451  if (address.IsSectionOffset()) {
452  SymbolContext sc;
454  if (sc.module_sp == address.GetModule()) {
455  ABISP abi;
456  if (m_owner_scope) {
457  ModuleSP module_sp(m_owner_scope->CalculateSymbolContextModule());
458  if (module_sp)
459  abi = ABI::FindPlugin(ProcessSP(), module_sp->GetArchitecture());
460  }
461 
462  const addr_t file_addr = address.GetFileAddress();
463  if (sc.function) {
464  if (sc.function->GetAddressRange().ContainsFileAddress(address)) {
465  addr_t loclist_base_file_addr =
467  if (loclist_base_file_addr == LLDB_INVALID_ADDRESS)
468  return false;
470  loclist_base_file_addr,
471  file_addr, abi.get());
472  }
473  }
475  LLDB_INVALID_ADDRESS, file_addr,
476  abi.get());
477  }
478  }
479  return false;
480 }
481 
482 static void PrivateAutoComplete(
483  StackFrame *frame, llvm::StringRef partial_path,
484  const llvm::Twine
485  &prefix_path, // Anything that has been resolved already will be in here
486  const CompilerType &compiler_type, CompletionRequest &request);
487 
489  StackFrame *frame, const std::string &partial_member_name,
490  llvm::StringRef partial_path,
491  const llvm::Twine
492  &prefix_path, // Anything that has been resolved already will be in here
493  const CompilerType &compiler_type, CompletionRequest &request) {
494 
495  // We are in a type parsing child members
496  const uint32_t num_bases = compiler_type.GetNumDirectBaseClasses();
497 
498  if (num_bases > 0) {
499  for (uint32_t i = 0; i < num_bases; ++i) {
500  CompilerType base_class_type =
501  compiler_type.GetDirectBaseClassAtIndex(i, nullptr);
502 
503  PrivateAutoCompleteMembers(frame, partial_member_name, partial_path,
504  prefix_path,
505  base_class_type.GetCanonicalType(), request);
506  }
507  }
508 
509  const uint32_t num_vbases = compiler_type.GetNumVirtualBaseClasses();
510 
511  if (num_vbases > 0) {
512  for (uint32_t i = 0; i < num_vbases; ++i) {
513  CompilerType vbase_class_type =
514  compiler_type.GetVirtualBaseClassAtIndex(i, nullptr);
515 
516  PrivateAutoCompleteMembers(frame, partial_member_name, partial_path,
517  prefix_path,
518  vbase_class_type.GetCanonicalType(), request);
519  }
520  }
521 
522  // We are in a type parsing child members
523  const uint32_t num_fields = compiler_type.GetNumFields();
524 
525  if (num_fields > 0) {
526  for (uint32_t i = 0; i < num_fields; ++i) {
527  std::string member_name;
528 
529  CompilerType member_compiler_type = compiler_type.GetFieldAtIndex(
530  i, member_name, nullptr, nullptr, nullptr);
531 
532  if (partial_member_name.empty() ||
533  llvm::StringRef(member_name).startswith(partial_member_name)) {
534  if (member_name == partial_member_name) {
536  frame, partial_path,
537  prefix_path + member_name, // Anything that has been resolved
538  // already will be in here
539  member_compiler_type.GetCanonicalType(), request);
540  } else {
541  request.AddCompletion((prefix_path + member_name).str());
542  }
543  }
544  }
545  }
546 }
547 
549  StackFrame *frame, llvm::StringRef partial_path,
550  const llvm::Twine
551  &prefix_path, // Anything that has been resolved already will be in here
552  const CompilerType &compiler_type, CompletionRequest &request) {
553  // printf ("\nPrivateAutoComplete()\n\tprefix_path = '%s'\n\tpartial_path =
554  // '%s'\n", prefix_path.c_str(), partial_path.c_str());
555  std::string remaining_partial_path;
556 
557  const lldb::TypeClass type_class = compiler_type.GetTypeClass();
558  if (partial_path.empty()) {
559  if (compiler_type.IsValid()) {
560  switch (type_class) {
561  default:
562  case eTypeClassArray:
563  case eTypeClassBlockPointer:
564  case eTypeClassBuiltin:
565  case eTypeClassComplexFloat:
566  case eTypeClassComplexInteger:
567  case eTypeClassEnumeration:
568  case eTypeClassFunction:
569  case eTypeClassMemberPointer:
570  case eTypeClassReference:
571  case eTypeClassTypedef:
572  case eTypeClassVector: {
573  request.AddCompletion(prefix_path.str());
574  } break;
575 
576  case eTypeClassClass:
577  case eTypeClassStruct:
578  case eTypeClassUnion:
579  if (prefix_path.str().back() != '.')
580  request.AddCompletion((prefix_path + ".").str());
581  break;
582 
583  case eTypeClassObjCObject:
584  case eTypeClassObjCInterface:
585  break;
586  case eTypeClassObjCObjectPointer:
587  case eTypeClassPointer: {
588  bool omit_empty_base_classes = true;
589  if (compiler_type.GetNumChildren(omit_empty_base_classes, nullptr) > 0)
590  request.AddCompletion((prefix_path + "->").str());
591  else {
592  request.AddCompletion(prefix_path.str());
593  }
594  } break;
595  }
596  } else {
597  if (frame) {
598  const bool get_file_globals = true;
599 
600  VariableList *variable_list = frame->GetVariableList(get_file_globals);
601 
602  if (variable_list) {
603  for (const VariableSP &var_sp : *variable_list)
604  request.AddCompletion(var_sp->GetName().AsCString());
605  }
606  }
607  }
608  } else {
609  const char ch = partial_path[0];
610  switch (ch) {
611  case '*':
612  if (prefix_path.str().empty()) {
613  PrivateAutoComplete(frame, partial_path.substr(1), "*", compiler_type,
614  request);
615  }
616  break;
617 
618  case '&':
619  if (prefix_path.isTriviallyEmpty()) {
620  PrivateAutoComplete(frame, partial_path.substr(1), std::string("&"),
621  compiler_type, request);
622  }
623  break;
624 
625  case '-':
626  if (partial_path.size() > 1 && partial_path[1] == '>' &&
627  !prefix_path.str().empty()) {
628  switch (type_class) {
629  case lldb::eTypeClassPointer: {
630  CompilerType pointee_type(compiler_type.GetPointeeType());
631  if (partial_path.size() > 2 && partial_path[2]) {
632  // If there is more after the "->", then search deeper
633  PrivateAutoComplete(frame, partial_path.substr(2),
634  prefix_path + "->",
635  pointee_type.GetCanonicalType(), request);
636  } else {
637  // Nothing after the "->", so list all members
639  frame, std::string(), std::string(), prefix_path + "->",
640  pointee_type.GetCanonicalType(), request);
641  }
642  } break;
643  default:
644  break;
645  }
646  }
647  break;
648 
649  case '.':
650  if (compiler_type.IsValid()) {
651  switch (type_class) {
652  case lldb::eTypeClassUnion:
653  case lldb::eTypeClassStruct:
654  case lldb::eTypeClassClass:
655  if (partial_path.size() > 1 && partial_path[1]) {
656  // If there is more after the ".", then search deeper
657  PrivateAutoComplete(frame, partial_path.substr(1),
658  prefix_path + ".", compiler_type, request);
659 
660  } else {
661  // Nothing after the ".", so list all members
662  PrivateAutoCompleteMembers(frame, std::string(), partial_path,
663  prefix_path + ".", compiler_type,
664  request);
665  }
666  break;
667  default:
668  break;
669  }
670  }
671  break;
672  default:
673  if (isalpha(ch) || ch == '_' || ch == '$') {
674  const size_t partial_path_len = partial_path.size();
675  size_t pos = 1;
676  while (pos < partial_path_len) {
677  const char curr_ch = partial_path[pos];
678  if (isalnum(curr_ch) || curr_ch == '_' || curr_ch == '$') {
679  ++pos;
680  continue;
681  }
682  break;
683  }
684 
685  std::string token(std::string(partial_path), 0, pos);
686  remaining_partial_path = std::string(partial_path.substr(pos));
687 
688  if (compiler_type.IsValid()) {
689  PrivateAutoCompleteMembers(frame, token, remaining_partial_path,
690  prefix_path, compiler_type, request);
691  } else if (frame) {
692  // We haven't found our variable yet
693  const bool get_file_globals = true;
694 
695  VariableList *variable_list =
696  frame->GetVariableList(get_file_globals);
697 
698  if (!variable_list)
699  break;
700 
701  for (VariableSP var_sp : *variable_list) {
702 
703  if (!var_sp)
704  continue;
705 
706  llvm::StringRef variable_name = var_sp->GetName().GetStringRef();
707  if (variable_name.startswith(token)) {
708  if (variable_name == token) {
709  Type *variable_type = var_sp->GetType();
710  if (variable_type) {
711  CompilerType variable_compiler_type(
712  variable_type->GetForwardCompilerType());
714  frame, remaining_partial_path,
715  prefix_path + token, // Anything that has been resolved
716  // already will be in here
717  variable_compiler_type.GetCanonicalType(), request);
718  } else {
719  request.AddCompletion((prefix_path + variable_name).str());
720  }
721  } else if (remaining_partial_path.empty()) {
722  request.AddCompletion((prefix_path + variable_name).str());
723  }
724  }
725  }
726  }
727  }
728  break;
729  }
730  }
731 }
732 
734  CompletionRequest &request) {
735  CompilerType compiler_type;
736 
738  "", compiler_type, request);
739 }
lldb_private::StackFrame::CalculateTarget
lldb::TargetSP CalculateTarget() override
Definition: StackFrame.cpp:1732
lldb_private::Variable::DumpDeclaration
bool DumpDeclaration(Stream *s, bool show_fullpaths, bool show_module)
Definition: Variable.cpp:178
RegularExpression.h
lldb_private::Variable::m_owner_scope
SymbolContextScope * m_owner_scope
The symbol file scope that this variable was defined in.
Definition: Variable.h:121
lldb_private::AddressRange::GetBaseAddress
Address & GetBaseAddress()
Get accessor for the base address of the range.
Definition: AddressRange.h:209
Block.h
lldb_private::Stream::Format
void Format(const char *format, Args &&... args)
Definition: Stream.h:309
lldb_private::ValueObjectList
A collection of ValueObject values that.
Definition: ValueObjectList.h:23
lldb_private::SymbolContext::block
Block * block
The Block for a given query.
Definition: SymbolContext.h:321
lldb_private::SymbolFile::GetDeclForUID
virtual CompilerDecl GetDeclForUID(lldb::user_id_t uid)
Definition: SymbolFile.h:201
lldb_private::ExecutionContext
Definition: ExecutionContext.h:292
lldb_private::DWARFExpression::GetDescription
void GetDescription(Stream *s, lldb::DescriptionLevel level, lldb::addr_t location_list_base_addr, ABI *abi) const
Print the description of the expression to a stream.
Definition: DWARFExpression.cpp:128
lldb::eValueTypeVariableGlobal
@ eValueTypeVariableGlobal
globals variable
Definition: lldb-enumerations.h:317
lldb_private::RegularExpression
Definition: RegularExpression.h:18
CompilerDecl.h
lldb_private::Variable::m_scope
lldb::ValueType m_scope
Definition: Variable.h:119
CompileUnit.h
lldb_private::Function::GetAddressRange
const AddressRange & GetAddressRange()
Definition: Function.h:461
lldb_private::SymbolContextScope::CalculateSymbolContextModule
virtual lldb::ModuleSP CalculateSymbolContextModule()
Definition: SymbolContextScope.h:78
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:422
lldb_private::VariableList::Clear
void Clear()
Definition: VariableList.cpp:45
lldb_private::ValueObjectList::GetValueObjectAtIndex
lldb::ValueObjectSP GetValueObjectAtIndex(size_t idx)
Definition: ValueObjectList.cpp:39
lldb_private::CompilerType::GetNumVirtualBaseClasses
uint32_t GetNumVirtualBaseClasses() const
Definition: CompilerType.cpp:559
lldb_private::SymbolContextScope::CalculateSymbolContextFunction
virtual Function * CalculateSymbolContextFunction()
Definition: SymbolContextScope.h:84
lldb_private::StackFrame::GetFrameCodeAddress
const Address & GetFrameCodeAddress()
Get an Address for the current pc value in this StackFrame.
Definition: StackFrame.cpp:188
lldb_private::UserID
Definition: UserID.h:31
lldb_private::Variable::m_symfile_type_sp
lldb::SymbolFileTypeSP m_symfile_type_sp
The type pointer of the variable (int, struct, class, etc) global, parameter, local.
Definition: Variable.h:118
lldb_private::Variable::MemorySize
size_t MemorySize() const
Definition: Variable.cpp:202
Module.h
lldb_private::ValueObjectList::RemoveValueObjectAtIndex
lldb::ValueObjectSP RemoveValueObjectAtIndex(size_t idx)
Definition: ValueObjectList.cpp:46
lldb_private::VariableList::GetSize
size_t GetSize() const
Definition: VariableList.cpp:165
lldb::LanguageType
LanguageType
Programming language type.
Definition: lldb-enumerations.h:436
lldb_private::CompilerDecl
Represents a generic declaration such as a function declaration.
Definition: CompilerDecl.h:28
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
StackFrame.h
lldb::eValueTypeRegisterSet
@ eValueTypeRegisterSet
A collection of stack frame register values.
Definition: lldb-enumerations.h:322
lldb_private::CompilerType::GetTypeClass
lldb::TypeClass GetTypeClass() const
Definition: CompilerType.cpp:305
lldb_private::Stream
Definition: Stream.h:28
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::CompilerType::GetVirtualBaseClassAtIndex
CompilerType GetVirtualBaseClassAtIndex(size_t idx, uint32_t *bit_offset_ptr) const
Definition: CompilerType.cpp:575
lldb_private::Variable::GetName
ConstString GetName() const
Definition: Variable.cpp:71
lldb_private::SymbolContext
Definition: SymbolContext.h:33
lldb_private::CompilerType::GetNumDirectBaseClasses
uint32_t GetNumDirectBaseClasses() const
Definition: CompilerType.cpp:553
ABI.h
lldb_private::VariableList
Definition: VariableList.h:18
Process.h
lldb_private::VariableList::GetVariableAtIndex
lldb::VariableSP GetVariableAtIndex(size_t idx) const
Definition: VariableList.cpp:47
lldb_private::Variable::m_name
ConstString m_name
The basename of the variable (no namespaces).
Definition: Variable.h:113
Target.h
lldb_private::DWARFExpression::DumpLocationForAddress
bool DumpLocationForAddress(Stream *s, lldb::DescriptionLevel level, lldb::addr_t func_load_addr, lldb::addr_t address, ABI *abi)
Definition: DWARFExpression.cpp:621
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
lldb_private::Declaration::Dump
void Dump(Stream *s, bool show_fullpaths) const
Dump a description of this object to a Stream.
Definition: Declaration.cpp:14
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::Function
Definition: Function.h:413
lldb_private::Variable::IsInScope
bool IsInScope(StackFrame *frame)
Definition: Variable.cpp:280
lldb_private::SymbolContext::DumpStopContext
bool DumpStopContext(Stream *s, ExecutionContextScope *exe_scope, const Address &so_addr, bool show_fullpaths, bool show_module, bool show_inlined_frames, bool show_function_arguments, bool show_function_name) const
Dump the stop context in this object to a Stream.
Definition: SymbolContext.cpp:67
lldb_private::Stream::Indent
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
Definition: Stream.cpp:130
PrivateAutoComplete
static void PrivateAutoComplete(StackFrame *frame, llvm::StringRef partial_path, const llvm::Twine &prefix_path, const CompilerType &compiler_type, CompletionRequest &request)
Definition: Variable.cpp:548
lldb_private::ExecutionContextScope
Definition: ExecutionContextScope.h:32
lldb_private::SymbolContextScope::CalculateSymbolContextCompileUnit
virtual CompileUnit * CalculateSymbolContextCompileUnit()
Definition: SymbolContextScope.h:82
lldb_private::ValueObjectList::GetSize
size_t GetSize() const
Definition: ValueObjectList.cpp:35
lldb_private::Declaration::DumpStopContext
bool DumpStopContext(Stream *s, bool show_fullpaths) const
Definition: Declaration.cpp:35
lldb_private::ValueObjectList::SetValueObjectAtIndex
void SetValueObjectAtIndex(size_t idx, const lldb::ValueObjectSP &valobj_sp)
Definition: ValueObjectList.cpp:55
lldb_private::Status::Fail
bool Fail() const
Test for error condition.
Definition: Status.cpp:182
lldb_private::SymbolContextScope::CalculateSymbolContext
virtual void CalculateSymbolContext(SymbolContext *sc)=0
Reconstruct the object's symbol context into sc.
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:290
Type.h
lldb_private::DWARFExpression
Definition: DWARFExpression.h:35
lldb_private::Variable::GetLanguage
lldb::LanguageType GetLanguage() const
Definition: Variable.cpp:54
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::Type::DumpTypeName
void DumpTypeName(Stream *s)
Definition: Type.cpp:307
lldb_private::Variable::GetValuesForVariableExpressionPath
static Status GetValuesForVariableExpressionPath(llvm::StringRef variable_expr_path, ExecutionContextScope *scope, GetVariableCallback callback, void *baton, VariableList &variable_list, ValueObjectList &valobj_list)
Definition: Variable.cpp:330
lldb_private::Type::GetSymbolFile
SymbolFile * GetSymbolFile()
Definition: Type.h:127
lldb_private::Variable::m_external
unsigned m_external
Visible outside the containing compile unit?
Definition: Variable.h:131
lldb_private::SymbolContext::variable
Variable * variable
The global variable matching the given query.
Definition: SymbolContext.h:324
lldb_private::Variable::m_scope_range
RangeList m_scope_range
The list of ranges inside the owner's scope where this variable is valid.
Definition: Variable.h:124
lldb_private::CompletionRequest::GetCursorArgumentPrefix
llvm::StringRef GetCursorArgumentPrefix() const
Definition: CompletionRequest.h:217
lldb::eValueTypeVariableArgument
@ eValueTypeVariableArgument
function argument variables
Definition: lldb-enumerations.h:319
lldb_private::CompilerType::GetNumFields
uint32_t GetNumFields() const
Definition: CompilerType.cpp:537
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::RangeVector::IsEmpty
bool IsEmpty() const
Definition: RangeMap.h:250
Thread.h
TypeSystem.h
lldb_private::Stream::PutChar
size_t PutChar(char ch)
Definition: Stream.cpp:104
lldb_private::Variable::NameMatches
bool NameMatches(ConstString name) const
Since a variable can have a basename "i" and also a mangled named "_ZN12_GLOBAL__N_11iE" and a demang...
Definition: Variable.cpp:80
lldb_private::DWARFExpression::IsLocationList
bool IsLocationList() const
Return true if a location list was provided.
Definition: DWARFExpression.cpp:105
lldb_private::RangeVector< lldb::addr_t, lldb::addr_t >
lldb_private::Variable::GetDeclContext
CompilerDeclContext GetDeclContext()
Definition: Variable.cpp:204
VariableList.h
lldb_private::CompilerType::IsValid
bool IsValid() const
Definition: CompilerType.h:72
lldb_private::CompilerDeclContext
Represents a generic declaration context in a program.
Definition: CompilerDeclContext.h:30
ValueObject.h
lldb_private::SymbolContextScope
Definition: SymbolContextScope.h:64
lldb_private::UserID::GetID
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition: UserID.h:47
lldb_private::Variable::AutoComplete
static void AutoComplete(const ExecutionContext &exe_ctx, CompletionRequest &request)
Definition: Variable.cpp:733
lldb_private::CompilerType::GetNumChildren
uint32_t GetNumChildren(bool omit_empty_base_classes, const ExecutionContext *exe_ctx) const
Definition: CompilerType.cpp:515
lldb_private::AddressRange::ContainsFileAddress
bool ContainsFileAddress(const Address &so_addr) const
Check if a section offset address is contained in this range.
Definition: AddressRange.cpp:71
lldb_private::Variable::GetDecl
CompilerDecl GetDecl()
Definition: Variable.cpp:211
lldb_private::VariableList::RemoveVariableAtIndex
lldb::VariableSP RemoveVariableAtIndex(size_t idx)
Definition: VariableList.cpp:54
lldb::eValueTypeVariableLocal
@ eValueTypeVariableLocal
function local variables
Definition: lldb-enumerations.h:320
lldb_private::Status
Definition: Status.h:44
lldb::ValueType
ValueType
Definition: lldb-enumerations.h:315
lldb_private::Block
Definition: Block.h:41
lldb::eLanguageTypeUnknown
@ eLanguageTypeUnknown
Unknown or invalid language value.
Definition: lldb-enumerations.h:437
PrivateAutoCompleteMembers
static void PrivateAutoCompleteMembers(StackFrame *frame, const std::string &partial_member_name, llvm::StringRef partial_path, const llvm::Twine &prefix_path, const CompilerType &compiler_type, CompletionRequest &request)
Definition: Variable.cpp:488
uint32_t
lldb_private::Block::Contains
bool Contains(lldb::addr_t range_offset) const
Check if an offset is in one of the block offset ranges.
Definition: Block.cpp:169
lldb_private::CompilerType::GetDirectBaseClassAtIndex
CompilerType GetDirectBaseClassAtIndex(size_t idx, uint32_t *bit_offset_ptr) const
Definition: CompilerType.cpp:566
lldb_private::SymbolFile::GetDeclContextContainingUID
virtual CompilerDeclContext GetDeclContextContainingUID(lldb::user_id_t uid)
Definition: SymbolFile.h:207
lldb_private::Address
Definition: Address.h:59
lldb_private::Stream::EOL
size_t EOL()
Output and End of Line character to the stream.
Definition: Stream.cpp:128
lldb_private::CompilerType::GetCanonicalType
CompilerType GetCanonicalType() const
Definition: CompilerType.cpp:341
lldb_private::Type
Definition: Type.h:66
lldb_private::Address::GetLoadAddress
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
Definition: Address.cpp:310
lldb_private::Type::GetForwardCompilerType
CompilerType GetForwardCompilerType()
Definition: Type.cpp:656
lldb_private::Stream::AsRawOstream
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
Definition: Stream.h:357
lldb_private::Variable::LocationIsValidForAddress
bool LocationIsValidForAddress(const Address &address)
Definition: Variable.cpp:252
lldb_private::Variable::m_location
DWARFExpression m_location
The location of this variable that can be fed to DWARFExpression::Evaluate().
Definition: Variable.h:129
lldb_private::SymbolContext::module_sp
lldb::ModuleSP module_sp
The Module for a given query.
Definition: SymbolContext.h:318
lldb_private::Variable::~Variable
virtual ~Variable()
lldb_private::Variable::CalculateSymbolContext
void CalculateSymbolContext(SymbolContext *sc)
Definition: Variable.cpp:216
lldb_private::ABI::FindPlugin
static lldb::ABISP FindPlugin(lldb::ProcessSP process_sp, const ArchSpec &arch)
Definition: ABI.cpp:26
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:86
lldb_private::ValueObjectList::Append
void Append(const lldb::ValueObjectSP &val_obj_sp)
lldb_private::CompilerType
Generic representation of a type in a programming language.
Definition: CompilerType.h:33
Function.h
lldb_private::Stream::Printf
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
lldb_private::Variable::m_mangled
Mangled m_mangled
The mangled name of the variable.
Definition: Variable.h:115
lldb_private::Variable::DumpLocationForAddress
bool DumpLocationForAddress(Stream *s, const Address &address)
Definition: Variable.cpp:448
lldb::user_id_t
uint64_t user_id_t
Definition: lldb-types.h:84
SymbolContext.h
lldb_private::LineEntry::Clear
void Clear()
Clear the object's state.
Definition: LineEntry.cpp:33
lldb_private::SymbolContext::Clear
void Clear(bool clear_target)
Clear the object's state.
Definition: SymbolContext.cpp:55
lldb::eValueTypeVariableThreadLocal
@ eValueTypeVariableThreadLocal
thread local storage variable
Definition: lldb-enumerations.h:324
CompilerDeclContext.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb::eValueTypeInvalid
@ eValueTypeInvalid
Definition: lldb-enumerations.h:316
lldb::eValueTypeConstResult
@ eValueTypeConstResult
constant result variables
Definition: lldb-enumerations.h:323
lldb_private::RegularExpression::Execute
bool Execute(llvm::StringRef string, llvm::SmallVectorImpl< llvm::StringRef > *matches=nullptr) const
Execute a regular expression match using the compiled regular expression that is already in this obje...
Definition: RegularExpression.cpp:23
lldb_private::CompletionRequest::AddCompletion
void AddCompletion(llvm::StringRef completion, llvm::StringRef description="", CompletionMode mode=CompletionMode::Normal)
Adds a possible completion string.
Definition: CompletionRequest.h:167
lldb_private::Address::IsSectionOffset
bool IsSectionOffset() const
Check if an address is section offset.
Definition: Address.h:323
lldb_private::SymbolContextScope::DumpSymbolContext
virtual void DumpSymbolContext(Stream *s)=0
Dump the object's symbol context to the stream s.
lldb_private::Variable::GetType
Type * GetType()
Definition: Variable.cpp:96
lldb_private::RangeVector::FindEntryThatContains
const Entry * FindEntryThatContains(B addr) const
Definition: RangeMap.h:295
ValueObjectVariable.h
lldb_private::Address::GetModule
lldb::ModuleSP GetModule() const
Get accessor for the module for this address.
Definition: Address.cpp:282
lldb_private::DWARFExpression::LocationListContainsAddress
bool LocationListContainsAddress(lldb::addr_t func_load_addr, lldb::addr_t addr) const
Search for a load address in the location list.
Definition: DWARFExpression.cpp:610
Stream.h
lldb::eValueTypeRegister
@ eValueTypeRegister
stack frame register value
Definition: lldb-enumerations.h:321
lldb_private::CompilerType::GetFieldAtIndex
CompilerType GetFieldAtIndex(size_t idx, std::string &name, uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) const
Definition: CompilerType.cpp:543
lldb::eValueTypeVariableStatic
@ eValueTypeVariableStatic
static variable
Definition: lldb-enumerations.h:318
lldb_private::Variable::LocationIsValidForFrame
bool LocationIsValidForFrame(StackFrame *frame)
Definition: Variable.cpp:224
lldb_private::Stream::PutCString
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:63
lldb_private::ValueObjectVariable::Create
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, const lldb::VariableSP &var_sp)
Definition: ValueObjectVariable.cpp:51
lldb_private::SymbolContext::line_entry
LineEntry line_entry
The LineEntry for a given query.
Definition: SymbolContext.h:322
Variable.h
lldb_private::Declaration
Definition: Declaration.h:24
lldb_private::StackFrame
Definition: StackFrame.h:40
lldb_private::DWARFExpression::IsValid
bool IsValid() const
Return true if the location expression contains data.
Definition: DWARFExpression.cpp:72
lldb_private::Variable::GetUnqualifiedName
ConstString GetUnqualifiedName() const
Definition: Variable.cpp:78
lldb_private::Variable::m_artificial
unsigned m_artificial
Non-zero if the variable is not explicitly declared in source.
Definition: Variable.h:133
lldb
Definition: SBAddress.h:15
RegisterContext.h
lldb_private::Variable::m_declaration
Declaration m_declaration
Declaration location for this item.
Definition: Variable.h:126
lldb_private::StackFrame::GetSymbolContext
const SymbolContext & GetSymbolContext(lldb::SymbolContextItem resolve_scope)
Provide a SymbolContext for this StackFrame's current pc value.
Definition: StackFrame.cpp:298
SymbolFile.h
lldb::eDescriptionLevelBrief
@ eDescriptionLevelBrief
Definition: lldb-enumerations.h:208
lldb_private::CompletionRequest
Definition: CompletionRequest.h:100
lldb_private::Variable::Dump
void Dump(Stream *s, bool show_context) const
Definition: Variable.cpp:102
lldb_private::Variable::Variable
Variable(lldb::user_id_t uid, const char *name, const char *mangled, const lldb::SymbolFileTypeSP &symfile_type_sp, lldb::ValueType scope, SymbolContextScope *owner_scope, const RangeList &scope_range, Declaration *decl, const DWARFExpression &location, bool external, bool artificial, bool location_is_constant_data, bool static_member=false)
Constructors and Destructors.
Definition: Variable.cpp:38