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