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
115 Type *type = GetType();
116 if (type)
118 return nullptr;
119}
120
121void Variable::Dump(Stream *s, bool show_context) const {
122 s->Printf("%p: ", static_cast<const void *>(this));
123 s->Indent();
124 *s << "Variable" << (const UserID &)*this;
125
126 if (m_name)
127 *s << ", name = \"" << m_name << "\"";
128
129 if (m_symfile_type_sp) {
130 Type *type = m_symfile_type_sp->GetType();
131 if (type) {
132 s->Format(", type = {{{0:x-16}} {1} (", type->GetID(), type);
133 type->DumpTypeName(s);
134 s->PutChar(')');
135 }
136 }
137
138 if (m_scope != eValueTypeInvalid) {
139 s->PutCString(", scope = ");
140 switch (m_scope) {
142 s->PutCString(m_external ? "global" : "static");
143 break;
145 s->PutCString("parameter");
146 break;
148 s->PutCString("local");
149 break;
151 s->PutCString("thread local");
152 break;
153 default:
154 s->AsRawOstream() << "??? (" << m_scope << ')';
155 }
156 }
157
158 if (show_context && m_owner_scope != nullptr) {
159 s->PutCString(", context = ( ");
160 m_owner_scope->DumpSymbolContext(s);
161 s->PutCString(" )");
162 }
163
164 bool show_fullpaths = false;
165 m_declaration.Dump(s, show_fullpaths);
166
167 if (m_location_list.IsValid()) {
168 s->PutCString(", location = ");
169 ABISP abi;
170 if (m_owner_scope) {
171 ModuleSP module_sp(m_owner_scope->CalculateSymbolContextModule());
172 if (module_sp)
173 abi = ABI::FindPlugin(ProcessSP(), module_sp->GetArchitecture());
174 }
175 m_location_list.GetDescription(s, lldb::eDescriptionLevelBrief, abi.get());
176 }
177
178 if (m_external)
179 s->PutCString(", external");
180
181 if (m_artificial)
182 s->PutCString(", artificial");
183
184 s->EOL();
185}
186
187bool Variable::DumpDeclaration(Stream *s, bool show_fullpaths,
188 bool show_module) {
189 bool dumped_declaration_info = false;
190 if (m_owner_scope) {
191 SymbolContext sc;
192 m_owner_scope->CalculateSymbolContext(&sc);
193 sc.block = nullptr;
194 sc.line_entry.Clear();
195 bool show_inlined_frames = false;
196 const bool show_function_arguments = true;
197 const bool show_function_name = true;
198
199 dumped_declaration_info = sc.DumpStopContext(
200 s, nullptr, Address(), show_fullpaths, show_module, show_inlined_frames,
201 show_function_arguments, show_function_name);
202
203 if (sc.function)
204 s->PutChar(':');
205 }
206 if (m_declaration.DumpStopContext(s, false))
207 dumped_declaration_info = true;
208 return dumped_declaration_info;
209}
210
212 Type *type = GetType();
213 if (type)
215 return CompilerDeclContext();
216}
217
219 Type *type = GetType();
220 return type ? type->GetSymbolFile()->GetDeclForUID(GetID()) : CompilerDecl();
221}
222
224 if (m_owner_scope) {
225 m_owner_scope->CalculateSymbolContext(sc);
226 sc->variable = this;
227 } else
228 sc->Clear(false);
229}
230
232 if (frame) {
233 Function *function =
234 frame->GetSymbolContext(eSymbolContextFunction).function;
235 if (function) {
236 TargetSP target_sp(frame->CalculateTarget());
237
238 addr_t loclist_base_load_addr =
239 function->GetAddress().GetLoadAddress(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
244 return m_location_list.ContainsAddress(
245 loclist_base_load_addr,
247 target_sp.get()));
248 }
249 }
250 return false;
251}
252
254 // Be sure to resolve the address to section offset prior to calling this
255 // function.
256 if (address.IsSectionOffset()) {
257 // We need to check if the address is valid for both scope range and value
258 // range.
259 // Empty scope range means block range.
260 bool valid_in_scope_range =
262 address.GetFileAddress()) != nullptr;
263 if (!valid_in_scope_range)
264 return false;
265 SymbolContext sc;
267 if (sc.module_sp == address.GetModule()) {
268 // Is the variable is described by a single location?
269 if (m_location_list.IsAlwaysValidSingleExpr()) {
270 // Yes it is, the location is valid.
271 return true;
272 }
273
274 if (sc.function) {
275 addr_t loclist_base_file_addr =
277 if (loclist_base_file_addr == LLDB_INVALID_ADDRESS)
278 return false;
279 // It is a location list. We just need to tell if the location list
280 // contains the current address when converted to a load address
281 return m_location_list.ContainsAddress(loclist_base_file_addr,
282 address.GetFileAddress());
283 }
284 }
285 }
286 return false;
287}
288
290 // Synthetic values are always in scope.
292 return true;
293
294 switch (m_scope) {
297 return frame != nullptr;
298
303 return true;
304
307 if (frame) {
308 // We don't have a location list, we just need to see if the block that
309 // this variable was defined in is currently
310 Block *deepest_frame_block =
311 frame->GetSymbolContext(eSymbolContextBlock).block;
312 Address frame_addr = frame->GetFrameCodeAddress();
313 if (deepest_frame_block)
314 return IsInScope(*deepest_frame_block, frame_addr);
315 }
316 break;
317
318 default:
319 break;
320 }
321 return false;
322}
323
324bool Variable::IsInScope(const Block &block, const Address &addr) {
325 SymbolContext variable_sc;
326 CalculateSymbolContext(&variable_sc);
327
328 // Check for static or global variable defined at the compile unit
329 // level that wasn't defined in a block
330 if (variable_sc.block == nullptr)
331 return true;
332
333 // Check if the variable is valid in the current block
334 if (variable_sc.block != &block && !variable_sc.block->Contains(&block))
335 return false;
336
337 // If no scope range is specified then it means that the scope is the
338 // same as the scope of the enclosing lexical block.
339 if (m_scope_range.IsEmpty())
340 return true;
341
342 return m_scope_range.FindEntryThatContains(addr.GetFileAddress()) != nullptr;
343}
344
346 llvm::StringRef variable_expr_path, ExecutionContextScope *scope,
347 GetVariableCallback callback, void *baton, VariableList &variable_list,
348 ValueObjectList &valobj_list) {
350 if (!callback || variable_expr_path.empty()) {
351 error = Status::FromErrorString("unknown error");
352 return error;
353 }
354
355 switch (variable_expr_path.front()) {
356 case '*':
358 variable_expr_path.drop_front(), scope, callback, baton, variable_list,
359 valobj_list);
360 if (error.Fail()) {
361 error = Status::FromErrorString("unknown error");
362 return error;
363 }
364 for (uint32_t i = 0; i < valobj_list.GetSize();) {
365 Status tmp_error;
366 ValueObjectSP valobj_sp(
367 valobj_list.GetValueObjectAtIndex(i)->Dereference(tmp_error));
368 if (tmp_error.Fail()) {
369 variable_list.RemoveVariableAtIndex(i);
370 valobj_list.RemoveValueObjectAtIndex(i);
371 } else {
372 valobj_list.SetValueObjectAtIndex(i, valobj_sp);
373 ++i;
374 }
375 }
376 return error;
377 case '&': {
379 variable_expr_path.drop_front(), scope, callback, baton, variable_list,
380 valobj_list);
381 if (error.Success()) {
382 for (uint32_t i = 0; i < valobj_list.GetSize();) {
383 Status tmp_error;
384 ValueObjectSP valobj_sp(
385 valobj_list.GetValueObjectAtIndex(i)->AddressOf(tmp_error));
386 if (tmp_error.Fail()) {
387 variable_list.RemoveVariableAtIndex(i);
388 valobj_list.RemoveValueObjectAtIndex(i);
389 } else {
390 valobj_list.SetValueObjectAtIndex(i, valobj_sp);
391 ++i;
392 }
393 }
394 } else {
395 error = Status::FromErrorString("unknown error");
396 }
397 return error;
398 } break;
399
400 default: {
401 static RegularExpression g_regex(
402 llvm::StringRef("^([A-Za-z_:][A-Za-z_0-9:]*)(.*)"));
403 llvm::SmallVector<llvm::StringRef, 2> matches;
404 variable_list.Clear();
405 if (!g_regex.Execute(variable_expr_path, &matches)) {
407 "unable to extract a variable name from '{0}'", variable_expr_path);
408 return error;
409 }
410 std::string variable_name = matches[1].str();
411 if (!callback(baton, variable_name.c_str(), variable_list)) {
412 error = Status::FromErrorString("unknown error");
413 return error;
414 }
415 uint32_t i = 0;
416 while (i < variable_list.GetSize()) {
417 VariableSP var_sp(variable_list.GetVariableAtIndex(i));
418 ValueObjectSP valobj_sp;
419 if (!var_sp) {
420 variable_list.RemoveVariableAtIndex(i);
421 continue;
422 }
423 ValueObjectSP variable_valobj_sp(
424 ValueObjectVariable::Create(scope, var_sp));
425 if (!variable_valobj_sp) {
426 variable_list.RemoveVariableAtIndex(i);
427 continue;
428 }
429
430 llvm::StringRef variable_sub_expr_path =
431 variable_expr_path.drop_front(variable_name.size());
432 if (!variable_sub_expr_path.empty()) {
433 valobj_sp = variable_valobj_sp->GetValueForExpressionPath(
434 variable_sub_expr_path);
435 if (!valobj_sp) {
437 "invalid expression path '{0}' for variable '{1}'",
438 variable_sub_expr_path, var_sp->GetName().GetCString());
439 variable_list.RemoveVariableAtIndex(i);
440 continue;
441 }
442 } else {
443 // Just the name of a variable with no extras
444 valobj_sp = variable_valobj_sp;
445 }
446
447 valobj_list.Append(valobj_sp);
448 ++i;
449 }
450
451 if (variable_list.GetSize() > 0) {
452 error.Clear();
453 return error;
454 }
455 } break;
456 }
457 error = Status::FromErrorString("unknown error");
458 return error;
459}
460
461bool Variable::DumpLocations(Stream *s, const Address &address) {
462 SymbolContext sc;
464 ABISP abi;
465 if (m_owner_scope) {
466 ModuleSP module_sp(m_owner_scope->CalculateSymbolContextModule());
467 if (module_sp)
468 abi = ABI::FindPlugin(ProcessSP(), module_sp->GetArchitecture());
469 }
470
471 const addr_t file_addr = address.GetFileAddress();
472 if (sc.function) {
473 addr_t loclist_base_file_addr = sc.function->GetAddress().GetFileAddress();
474 if (loclist_base_file_addr == LLDB_INVALID_ADDRESS)
475 return false;
476 return m_location_list.DumpLocations(s, eDescriptionLevelBrief,
477 loclist_base_file_addr, file_addr,
478 abi.get());
479 }
480 return false;
481}
482
483static void PrivateAutoComplete(
484 StackFrame *frame, llvm::StringRef partial_path,
485 const llvm::Twine
486 &prefix_path, // Anything that has been resolved already will be in here
487 const CompilerType &compiler_type, CompletionRequest &request);
488
489/// Get the CompilerType of the current instance (this/self) for direct ivar
490/// completion. Returns an invalid CompilerType if the frame is not for an
491/// instance method.
493 VariableList &variable_list) {
494 SymbolContext sc =
495 frame.GetSymbolContext(eSymbolContextFunction | eSymbolContextBlock);
496 llvm::StringRef instance_name = sc.GetInstanceName();
497 if (instance_name.empty())
498 return {};
499 VariableSP var_sp = variable_list.FindVariable(ConstString(instance_name));
500 if (!var_sp)
501 return {};
502 Type *var_type = var_sp->GetType();
503 if (!var_type)
504 return {};
505 CompilerType compiler_type = var_type->GetForwardCompilerType();
506 if (compiler_type.IsPointerType())
507 compiler_type = compiler_type.GetPointeeType();
508 return compiler_type.GetCanonicalType();
509}
510
512 StackFrame *frame, const std::string &partial_member_name,
513 llvm::StringRef partial_path,
514 const llvm::Twine
515 &prefix_path, // Anything that has been resolved already will be in here
516 const CompilerType &compiler_type, CompletionRequest &request) {
517
518 // We are in a type parsing child members
519 const uint32_t num_bases = compiler_type.GetNumDirectBaseClasses();
520
521 if (num_bases > 0) {
522 for (uint32_t i = 0; i < num_bases; ++i) {
523 CompilerType base_class_type =
524 compiler_type.GetDirectBaseClassAtIndex(i, nullptr);
525
526 PrivateAutoCompleteMembers(frame, partial_member_name, partial_path,
527 prefix_path,
528 base_class_type.GetCanonicalType(), request);
529 }
530 }
531
532 const uint32_t num_vbases = compiler_type.GetNumVirtualBaseClasses();
533
534 if (num_vbases > 0) {
535 for (uint32_t i = 0; i < num_vbases; ++i) {
536 CompilerType vbase_class_type =
537 compiler_type.GetVirtualBaseClassAtIndex(i, nullptr);
538
539 PrivateAutoCompleteMembers(frame, partial_member_name, partial_path,
540 prefix_path,
541 vbase_class_type.GetCanonicalType(), request);
542 }
543 }
544
545 // We are in a type parsing child members
546 const uint32_t num_fields = compiler_type.GetNumFields();
547
548 if (num_fields > 0) {
549 for (uint32_t i = 0; i < num_fields; ++i) {
550 std::string member_name;
551
552 CompilerType member_compiler_type = compiler_type.GetFieldAtIndex(
553 i, member_name, nullptr, nullptr, nullptr);
554
555 if (partial_member_name.empty()) {
556 request.AddCompletion((prefix_path + member_name).str());
557 } else if (llvm::StringRef(member_name)
558 .starts_with(partial_member_name)) {
559 if (member_name == partial_member_name) {
561 frame, partial_path,
562 prefix_path + member_name, // Anything that has been resolved
563 // already will be in here
564 member_compiler_type.GetCanonicalType(), request);
565 } else if (partial_path.empty()) {
566 request.AddCompletion((prefix_path + member_name).str());
567 }
568 }
569 }
570 }
571}
572
574 StackFrame *frame, llvm::StringRef partial_path,
575 const llvm::Twine
576 &prefix_path, // Anything that has been resolved already will be in here
577 const CompilerType &compiler_type, CompletionRequest &request) {
578 // printf ("\nPrivateAutoComplete()\n\tprefix_path = '%s'\n\tpartial_path =
579 // '%s'\n", prefix_path.c_str(), partial_path.c_str());
580 std::string remaining_partial_path;
581
582 const lldb::TypeClass type_class = compiler_type.GetTypeClass();
583 if (partial_path.empty()) {
584 if (compiler_type.IsValid()) {
585 switch (type_class) {
586 default:
587 case eTypeClassArray:
588 case eTypeClassBlockPointer:
589 case eTypeClassBuiltin:
590 case eTypeClassComplexFloat:
591 case eTypeClassComplexInteger:
592 case eTypeClassEnumeration:
593 case eTypeClassFunction:
594 case eTypeClassMemberPointer:
595 case eTypeClassReference:
596 case eTypeClassTypedef:
597 case eTypeClassVector: {
598 request.AddCompletion(prefix_path.str());
599 } break;
600
601 case eTypeClassClass:
602 case eTypeClassStruct:
603 case eTypeClassUnion:
604 if (prefix_path.str().back() != '.')
605 request.AddCompletion((prefix_path + ".").str());
606 break;
607
608 case eTypeClassObjCObject:
609 case eTypeClassObjCInterface:
610 break;
611 case eTypeClassObjCObjectPointer:
612 case eTypeClassPointer: {
613 bool omit_empty_base_classes = true;
614 if (llvm::expectedToOptional(
615 compiler_type.GetNumChildren(omit_empty_base_classes, nullptr))
616 .value_or(0))
617 request.AddCompletion((prefix_path + "->").str());
618 else {
619 request.AddCompletion(prefix_path.str());
620 }
621 } break;
622 }
623 } else {
624 if (frame) {
625 const bool get_file_globals = true;
626 const bool include_synthetic_vars = true;
627
628 VariableList *variable_list = frame->GetVariableList(
629 get_file_globals, include_synthetic_vars, nullptr);
630
631 if (variable_list) {
632 for (const VariableSP &var_sp : *variable_list)
633 request.AddCompletion(var_sp->GetName());
634
635 // Offer members of this/self so that direct ivar access can be
636 // completed (eg "frame variable member" for "this->member").
637 CompilerType instance_type = GetInstanceType(*frame, *variable_list);
638 if (instance_type.IsValid())
639 PrivateAutoCompleteMembers(frame, "", "", "", instance_type,
640 request);
641 }
642 }
643 }
644 } else {
645 const char ch = partial_path[0];
646 switch (ch) {
647 case '*':
648 if (prefix_path.str().empty()) {
649 PrivateAutoComplete(frame, partial_path.substr(1), "*", compiler_type,
650 request);
651 }
652 break;
653
654 case '&':
655 if (prefix_path.isTriviallyEmpty()) {
656 PrivateAutoComplete(frame, partial_path.substr(1), std::string("&"),
657 compiler_type, request);
658 }
659 break;
660
661 case '-':
662 if (partial_path.size() > 1 && partial_path[1] == '>' &&
663 !prefix_path.str().empty()) {
664 switch (type_class) {
665 case lldb::eTypeClassPointer: {
666 CompilerType pointee_type(compiler_type.GetPointeeType());
667 if (partial_path.size() > 2 && partial_path[2]) {
668 // If there is more after the "->", then search deeper
669 PrivateAutoComplete(frame, partial_path.substr(2),
670 prefix_path + "->",
671 pointee_type.GetCanonicalType(), request);
672 } else {
673 // Nothing after the "->", so list all members
675 frame, std::string(), std::string(), prefix_path + "->",
676 pointee_type.GetCanonicalType(), request);
677 }
678 } break;
679 default:
680 break;
681 }
682 }
683 break;
684
685 case '.':
686 if (compiler_type.IsValid()) {
687 switch (type_class) {
688 case lldb::eTypeClassUnion:
689 case lldb::eTypeClassStruct:
690 case lldb::eTypeClassClass:
691 if (partial_path.size() > 1 && partial_path[1]) {
692 // If there is more after the ".", then search deeper
693 PrivateAutoComplete(frame, partial_path.substr(1),
694 prefix_path + ".", compiler_type, request);
695
696 } else {
697 // Nothing after the ".", so list all members
698 PrivateAutoCompleteMembers(frame, std::string(), partial_path,
699 prefix_path + ".", compiler_type,
700 request);
701 }
702 break;
703 default:
704 break;
705 }
706 }
707 break;
708 default:
709 if (isalpha(ch) || ch == '_' || ch == '$') {
710 const size_t partial_path_len = partial_path.size();
711 size_t pos = 1;
712 while (pos < partial_path_len) {
713 const char curr_ch = partial_path[pos];
714 if (isalnum(curr_ch) || curr_ch == '_' || curr_ch == '$') {
715 ++pos;
716 continue;
717 }
718 break;
719 }
720
721 std::string token(std::string(partial_path), 0, pos);
722 remaining_partial_path = std::string(partial_path.substr(pos));
723
724 if (compiler_type.IsValid()) {
725 PrivateAutoCompleteMembers(frame, token, remaining_partial_path,
726 prefix_path, compiler_type, request);
727 } else if (frame) {
728 // We haven't found our variable yet
729 const bool get_file_globals = true;
730 const bool include_synthetic_vars = true;
731
732 VariableList *variable_list = frame->GetVariableList(
733 get_file_globals, include_synthetic_vars, nullptr);
734
735 if (!variable_list)
736 break;
737
738 for (VariableSP var_sp : *variable_list) {
739
740 if (!var_sp)
741 continue;
742
743 llvm::StringRef variable_name = var_sp->GetName().GetStringRef();
744 if (variable_name.starts_with(token)) {
745 if (variable_name == token) {
746 Type *variable_type = var_sp->GetType();
747 if (variable_type) {
748 CompilerType variable_compiler_type(
749 variable_type->GetForwardCompilerType());
751 frame, remaining_partial_path,
752 prefix_path + token, // Anything that has been resolved
753 // already will be in here
754 variable_compiler_type.GetCanonicalType(), request);
755 } else {
756 request.AddCompletion((prefix_path + variable_name).str());
757 }
758 } else if (remaining_partial_path.empty()) {
759 request.AddCompletion((prefix_path + variable_name).str());
760 }
761 }
762 }
763
764 // Try also completing the token as a member of this/self (direct ivar
765 // access).
766 CompilerType instance_type = GetInstanceType(*frame, *variable_list);
767 if (instance_type.IsValid())
768 PrivateAutoCompleteMembers(frame, token, remaining_partial_path,
769 prefix_path, instance_type, request);
770 }
771 }
772 break;
773 }
774 }
775}
776
778 CompletionRequest &request) {
779 CompilerType compiler_type;
780
782 "", compiler_type, request);
783}
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:511
static CompilerType GetInstanceType(StackFrame &frame, VariableList &variable_list)
Get the CompilerType of the current instance (this/self) for direct ivar completion.
Definition Variable.cpp:492
static void PrivateAutoComplete(StackFrame *frame, llvm::StringRef partial_path, const llvm::Twine &prefix_path, const CompilerType &compiler_type, CompletionRequest &request)
Definition Variable.cpp:573
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:303
lldb::ModuleSP GetModule() const
Get accessor for the module for this address.
Definition Address.cpp:275
lldb::addr_t GetFileAddress() const
Get the file address.
Definition Address.cpp:283
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
virtual lldb::TypeSP GetTypeEnclosingVariableUID(lldb::user_id_t uid)
Get the semantically innermost non-function type that encloses the provided variable.
Definition SymbolFile.h:542
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:187
const RangeList & GetScopeRange() const
Definition Variable.h:71
unsigned m_static_member
Non-zero if variable is static member of a class or struct.
Definition Variable.h:150
bool IsInScope(StackFrame *frame)
Definition Variable.cpp:289
static void AutoComplete(const ExecutionContext &exe_ctx, CompletionRequest &request)
Definition Variable.cpp:777
CompilerDeclContext GetDeclContext()
Definition Variable.cpp:211
unsigned m_artificial
Non-zero if the variable is not explicitly declared in source.
Definition Variable.h:145
unsigned m_external
Visible outside the containing compile unit?
Definition Variable.h:143
bool LocationIsValidForAddress(const Address &address)
Definition Variable.cpp:253
unsigned m_loc_is_const_data
The m_location expression contains the constant variable value data, not a DWARF location.
Definition Variable.h:148
lldb::SymbolFileTypeSP m_symfile_type_sp
The type pointer of the variable (int, struct, class, etc) global, parameter, local.
Definition Variable.h:130
RangeList m_scope_range
The list of ranges inside the owner's scope where this variable is valid.
Definition Variable.h:136
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:345
Mangled m_mangled
The mangled name of the variable.
Definition Variable.h:127
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:121
std::optional< uint64_t > m_tag_offset
The value of DW_AT_LLVM_tag_offset if present.
Definition Variable.h:152
lldb::ValueType m_scope
Definition Variable.h:131
SymbolContextScope * m_owner_scope
The symbol file scope that this variable was defined in.
Definition Variable.h:133
ConstString GetName() const
Definition Variable.cpp:83
CompilerDecl GetDecl()
Definition Variable.cpp:218
ConstString m_name
The basename of the variable (no namespaces).
Definition Variable.h:125
RangeVector< lldb::addr_t, lldb::addr_t > RangeList
Definition Variable.h:27
Declaration m_declaration
Declaration location for this item.
Definition Variable.h:138
void CalculateSymbolContext(SymbolContext *sc)
Definition Variable.cpp:223
lldb::TypeSP GetEnclosingType()
Definition Variable.cpp:114
bool DumpLocations(Stream *s, const Address &address)
Definition Variable.cpp:461
lldb::LanguageType GetLanguage() const
Definition Variable.cpp:66
bool LocationIsValidForFrame(StackFrame *frame)
Definition Variable.cpp:231
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:108
DWARFExpressionList m_location_list
The location of this variable that can be fed to DWARFExpression::Evaluate().
Definition Variable.h:141
#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::Type > TypeSP
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:83
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