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