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"
36
37#include "llvm/ADT/Twine.h"
38
39using namespace lldb;
40using namespace lldb_private;
41
42Variable::Variable(lldb::user_id_t uid, const char *name, const char *mangled,
43 const lldb::SymbolFileTypeSP &symfile_type_sp,
44 ValueType scope, SymbolContextScope *context,
45 const RangeList &scope_range, Declaration *decl_ptr,
46 const DWARFExpressionList &location_list, bool external,
47 bool artificial, bool location_is_constant_data,
48 bool static_member, std::optional<uint64_t> tag_offset)
49 : UserID(uid), m_name(name), m_mangled(ConstString(mangled)),
50 m_symfile_type_sp(symfile_type_sp), m_scope(scope),
51 m_owner_scope(context), m_scope_range(scope_range),
52 m_declaration(decl_ptr), m_location_list(location_list),
53 m_external(external), m_artificial(artificial),
54 m_loc_is_const_data(location_is_constant_data),
55 m_static_member(static_member), m_tag_offset(tag_offset) {
56#ifndef NDEBUG
58 .GetInjectVarLocListError())
59 m_location_list.Clear();
60#endif
61}
62
63Variable::~Variable() = default;
64
66 lldb::LanguageType lang = m_mangled.GuessLanguage();
68 return lang;
69
70 if (auto *func = m_owner_scope->CalculateSymbolContextFunction()) {
71 if ((lang = func->GetLanguage()) != lldb::eLanguageTypeUnknown)
72 return lang;
73 } else if (auto *comp_unit =
74 m_owner_scope->CalculateSymbolContextCompileUnit()) {
75 if ((lang = comp_unit->GetLanguage()) != lldb::eLanguageTypeUnknown)
76 return lang;
77 }
78
80}
81
83 ConstString name = m_mangled.GetName();
84 if (name)
85 return name;
86 return m_name;
87}
88
90
92 if (m_name == name)
93 return true;
94 SymbolContext variable_sc;
95 m_owner_scope->CalculateSymbolContext(&variable_sc);
96
97 return m_mangled.NameMatches(name);
98}
99bool Variable::NameMatches(const RegularExpression &regex) const {
100 if (regex.Execute(m_name.AsCString(nullptr)))
101 return true;
102 if (m_mangled)
103 return m_mangled.NameMatches(regex);
104 return false;
105}
106
109 return m_symfile_type_sp->GetType();
110 return nullptr;
111}
112
113void Variable::Dump(Stream *s, bool show_context) const {
114 s->Printf("%p: ", static_cast<const void *>(this));
115 s->Indent();
116 *s << "Variable" << (const UserID &)*this;
117
118 if (m_name)
119 *s << ", name = \"" << m_name << "\"";
120
121 if (m_symfile_type_sp) {
122 Type *type = m_symfile_type_sp->GetType();
123 if (type) {
124 s->Format(", type = {{{0:x-16}} {1} (", type->GetID(), type);
125 type->DumpTypeName(s);
126 s->PutChar(')');
127 }
128 }
129
130 if (m_scope != eValueTypeInvalid) {
131 s->PutCString(", scope = ");
132 switch (m_scope) {
134 s->PutCString(m_external ? "global" : "static");
135 break;
137 s->PutCString("parameter");
138 break;
140 s->PutCString("local");
141 break;
143 s->PutCString("thread local");
144 break;
145 default:
146 s->AsRawOstream() << "??? (" << m_scope << ')';
147 }
148 }
149
150 if (show_context && m_owner_scope != nullptr) {
151 s->PutCString(", context = ( ");
152 m_owner_scope->DumpSymbolContext(s);
153 s->PutCString(" )");
154 }
155
156 bool show_fullpaths = false;
157 m_declaration.Dump(s, show_fullpaths);
158
159 if (m_location_list.IsValid()) {
160 s->PutCString(", location = ");
161 ABISP abi;
162 if (m_owner_scope) {
163 ModuleSP module_sp(m_owner_scope->CalculateSymbolContextModule());
164 if (module_sp)
165 abi = ABI::FindPlugin(ProcessSP(), module_sp->GetArchitecture());
166 }
167 m_location_list.GetDescription(s, lldb::eDescriptionLevelBrief, abi.get());
168 }
169
170 if (m_external)
171 s->PutCString(", external");
172
173 if (m_artificial)
174 s->PutCString(", artificial");
175
176 s->EOL();
177}
178
179bool Variable::DumpDeclaration(Stream *s, bool show_fullpaths,
180 bool show_module) {
181 bool dumped_declaration_info = false;
182 if (m_owner_scope) {
183 SymbolContext sc;
184 m_owner_scope->CalculateSymbolContext(&sc);
185 sc.block = nullptr;
186 sc.line_entry.Clear();
187 bool show_inlined_frames = false;
188 const bool show_function_arguments = true;
189 const bool show_function_name = true;
190
191 dumped_declaration_info = sc.DumpStopContext(
192 s, nullptr, Address(), show_fullpaths, show_module, show_inlined_frames,
193 show_function_arguments, show_function_name);
194
195 if (sc.function)
196 s->PutChar(':');
197 }
198 if (m_declaration.DumpStopContext(s, false))
199 dumped_declaration_info = true;
200 return dumped_declaration_info;
201}
202
204 Type *type = GetType();
205 if (type)
207 return CompilerDeclContext();
208}
209
211 Type *type = GetType();
212 return type ? type->GetSymbolFile()->GetDeclForUID(GetID()) : CompilerDecl();
213}
214
216 if (m_owner_scope) {
217 m_owner_scope->CalculateSymbolContext(sc);
218 sc->variable = this;
219 } else
220 sc->Clear(false);
221}
222
224 if (frame) {
225 Function *function =
226 frame->GetSymbolContext(eSymbolContextFunction).function;
227 if (function) {
228 TargetSP target_sp(frame->CalculateTarget());
229
230 addr_t loclist_base_load_addr =
231 function->GetAddress().GetLoadAddress(target_sp.get());
232 if (loclist_base_load_addr == LLDB_INVALID_ADDRESS)
233 return false;
234 // It is a location list. We just need to tell if the location list
235 // contains the current address when converted to a load address
236 return m_location_list.ContainsAddress(
237 loclist_base_load_addr,
239 target_sp.get()));
240 }
241 }
242 return false;
243}
244
246 // Be sure to resolve the address to section offset prior to calling this
247 // function.
248 if (address.IsSectionOffset()) {
249 // We need to check if the address is valid for both scope range and value
250 // range.
251 // Empty scope range means block range.
252 bool valid_in_scope_range =
254 address.GetFileAddress()) != nullptr;
255 if (!valid_in_scope_range)
256 return false;
257 SymbolContext sc;
259 if (sc.module_sp == address.GetModule()) {
260 // Is the variable is described by a single location?
261 if (m_location_list.IsAlwaysValidSingleExpr()) {
262 // Yes it is, the location is valid.
263 return true;
264 }
265
266 if (sc.function) {
267 addr_t loclist_base_file_addr =
269 if (loclist_base_file_addr == LLDB_INVALID_ADDRESS)
270 return false;
271 // It is a location list. We just need to tell if the location list
272 // contains the current address when converted to a load address
273 return m_location_list.ContainsAddress(loclist_base_file_addr,
274 address.GetFileAddress());
275 }
276 }
277 }
278 return false;
279}
280
282 switch (m_scope) {
285 return frame != nullptr;
286
291 return true;
292
295 if (frame) {
296 // We don't have a location list, we just need to see if the block that
297 // this variable was defined in is currently
298 Block *deepest_frame_block =
299 frame->GetSymbolContext(eSymbolContextBlock).block;
300 Address frame_addr = frame->GetFrameCodeAddress();
301 if (deepest_frame_block)
302 return IsInScope(*deepest_frame_block, frame_addr);
303 }
304 break;
305
306 default:
307 break;
308 }
309 return false;
310}
311
312bool Variable::IsInScope(const Block &block, const Address &addr) {
313 SymbolContext variable_sc;
314 CalculateSymbolContext(&variable_sc);
315
316 // Check for static or global variable defined at the compile unit
317 // level that wasn't defined in a block
318 if (variable_sc.block == nullptr)
319 return true;
320
321 // Check if the variable is valid in the current block
322 if (variable_sc.block != &block && !variable_sc.block->Contains(&block))
323 return false;
324
325 // If no scope range is specified then it means that the scope is the
326 // same as the scope of the enclosing lexical block.
327 if (m_scope_range.IsEmpty())
328 return true;
329
330 return m_scope_range.FindEntryThatContains(addr.GetFileAddress()) != nullptr;
331}
332
334 llvm::StringRef variable_expr_path, ExecutionContextScope *scope,
335 GetVariableCallback callback, void *baton, VariableList &variable_list,
336 ValueObjectList &valobj_list) {
338 if (!callback || variable_expr_path.empty()) {
339 error = Status::FromErrorString("unknown error");
340 return error;
341 }
342
343 switch (variable_expr_path.front()) {
344 case '*':
346 variable_expr_path.drop_front(), scope, callback, baton, variable_list,
347 valobj_list);
348 if (error.Fail()) {
349 error = Status::FromErrorString("unknown error");
350 return error;
351 }
352 for (uint32_t i = 0; i < valobj_list.GetSize();) {
353 Status tmp_error;
354 ValueObjectSP valobj_sp(
355 valobj_list.GetValueObjectAtIndex(i)->Dereference(tmp_error));
356 if (tmp_error.Fail()) {
357 variable_list.RemoveVariableAtIndex(i);
358 valobj_list.RemoveValueObjectAtIndex(i);
359 } else {
360 valobj_list.SetValueObjectAtIndex(i, valobj_sp);
361 ++i;
362 }
363 }
364 return error;
365 case '&': {
367 variable_expr_path.drop_front(), scope, callback, baton, variable_list,
368 valobj_list);
369 if (error.Success()) {
370 for (uint32_t i = 0; i < valobj_list.GetSize();) {
371 Status tmp_error;
372 ValueObjectSP valobj_sp(
373 valobj_list.GetValueObjectAtIndex(i)->AddressOf(tmp_error));
374 if (tmp_error.Fail()) {
375 variable_list.RemoveVariableAtIndex(i);
376 valobj_list.RemoveValueObjectAtIndex(i);
377 } else {
378 valobj_list.SetValueObjectAtIndex(i, valobj_sp);
379 ++i;
380 }
381 }
382 } else {
383 error = Status::FromErrorString("unknown error");
384 }
385 return error;
386 } break;
387
388 default: {
389 static RegularExpression g_regex(
390 llvm::StringRef("^([A-Za-z_:][A-Za-z_0-9:]*)(.*)"));
391 llvm::SmallVector<llvm::StringRef, 2> matches;
392 variable_list.Clear();
393 if (!g_regex.Execute(variable_expr_path, &matches)) {
395 "unable to extract a variable name from '{0}'", variable_expr_path);
396 return error;
397 }
398 std::string variable_name = matches[1].str();
399 if (!callback(baton, variable_name.c_str(), variable_list)) {
400 error = Status::FromErrorString("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 '{0}' for variable '{1}'",
426 variable_sub_expr_path, var_sp->GetName().GetCString());
427 variable_list.RemoveVariableAtIndex(i);
428 continue;
429 }
430 } else {
431 // Just the name of a variable with no extras
432 valobj_sp = variable_valobj_sp;
433 }
434
435 valobj_list.Append(valobj_sp);
436 ++i;
437 }
438
439 if (variable_list.GetSize() > 0) {
440 error.Clear();
441 return error;
442 }
443 } break;
444 }
445 error = Status::FromErrorString("unknown error");
446 return error;
447}
448
449bool Variable::DumpLocations(Stream *s, const Address &address) {
450 SymbolContext sc;
452 ABISP abi;
453 if (m_owner_scope) {
454 ModuleSP module_sp(m_owner_scope->CalculateSymbolContextModule());
455 if (module_sp)
456 abi = ABI::FindPlugin(ProcessSP(), module_sp->GetArchitecture());
457 }
458
459 const addr_t file_addr = address.GetFileAddress();
460 if (sc.function) {
461 addr_t loclist_base_file_addr = sc.function->GetAddress().GetFileAddress();
462 if (loclist_base_file_addr == LLDB_INVALID_ADDRESS)
463 return false;
464 return m_location_list.DumpLocations(s, eDescriptionLevelBrief,
465 loclist_base_file_addr, file_addr,
466 abi.get());
467 }
468 return false;
469}
470
471static void PrivateAutoComplete(
472 StackFrame *frame, llvm::StringRef partial_path,
473 const llvm::Twine
474 &prefix_path, // Anything that has been resolved already will be in here
475 const CompilerType &compiler_type, CompletionRequest &request);
476
477/// Get the CompilerType of the current instance (this/self) for direct ivar
478/// completion. Returns an invalid CompilerType if the frame is not for an
479/// instance method.
481 VariableList &variable_list) {
482 SymbolContext sc =
483 frame.GetSymbolContext(eSymbolContextFunction | eSymbolContextBlock);
484 llvm::StringRef instance_name = sc.GetInstanceName();
485 if (instance_name.empty())
486 return {};
487 VariableSP var_sp = variable_list.FindVariable(ConstString(instance_name));
488 if (!var_sp)
489 return {};
490 Type *var_type = var_sp->GetType();
491 if (!var_type)
492 return {};
493 CompilerType compiler_type = var_type->GetForwardCompilerType();
494 if (compiler_type.IsPointerType())
495 compiler_type = compiler_type.GetPointeeType();
496 return compiler_type.GetCanonicalType();
497}
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, CompletionRequest &request) {
505
506 // We are in a type parsing child members
507 const uint32_t num_bases = compiler_type.GetNumDirectBaseClasses();
508
509 if (num_bases > 0) {
510 for (uint32_t i = 0; i < num_bases; ++i) {
511 CompilerType base_class_type =
512 compiler_type.GetDirectBaseClassAtIndex(i, nullptr);
513
514 PrivateAutoCompleteMembers(frame, partial_member_name, partial_path,
515 prefix_path,
516 base_class_type.GetCanonicalType(), request);
517 }
518 }
519
520 const uint32_t num_vbases = compiler_type.GetNumVirtualBaseClasses();
521
522 if (num_vbases > 0) {
523 for (uint32_t i = 0; i < num_vbases; ++i) {
524 CompilerType vbase_class_type =
525 compiler_type.GetVirtualBaseClassAtIndex(i, nullptr);
526
527 PrivateAutoCompleteMembers(frame, partial_member_name, partial_path,
528 prefix_path,
529 vbase_class_type.GetCanonicalType(), request);
530 }
531 }
532
533 // We are in a type parsing child members
534 const uint32_t num_fields = compiler_type.GetNumFields();
535
536 if (num_fields > 0) {
537 for (uint32_t i = 0; i < num_fields; ++i) {
538 std::string member_name;
539
540 CompilerType member_compiler_type = compiler_type.GetFieldAtIndex(
541 i, member_name, nullptr, nullptr, nullptr);
542
543 if (partial_member_name.empty()) {
544 request.AddCompletion((prefix_path + member_name).str());
545 } else if (llvm::StringRef(member_name)
546 .starts_with(partial_member_name)) {
547 if (member_name == partial_member_name) {
549 frame, partial_path,
550 prefix_path + member_name, // Anything that has been resolved
551 // already will be in here
552 member_compiler_type.GetCanonicalType(), request);
553 } else if (partial_path.empty()) {
554 request.AddCompletion((prefix_path + member_name).str());
555 }
556 }
557 }
558 }
559}
560
562 StackFrame *frame, llvm::StringRef partial_path,
563 const llvm::Twine
564 &prefix_path, // Anything that has been resolved already will be in here
565 const CompilerType &compiler_type, CompletionRequest &request) {
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 request.AddCompletion(prefix_path.str());
587 } break;
588
589 case eTypeClassClass:
590 case eTypeClassStruct:
591 case eTypeClassUnion:
592 if (prefix_path.str().back() != '.')
593 request.AddCompletion((prefix_path + ".").str());
594 break;
595
596 case eTypeClassObjCObject:
597 case eTypeClassObjCInterface:
598 break;
599 case eTypeClassObjCObjectPointer:
600 case eTypeClassPointer: {
601 bool omit_empty_base_classes = true;
602 if (llvm::expectedToOptional(
603 compiler_type.GetNumChildren(omit_empty_base_classes, nullptr))
604 .value_or(0))
605 request.AddCompletion((prefix_path + "->").str());
606 else {
607 request.AddCompletion(prefix_path.str());
608 }
609 } break;
610 }
611 } else {
612 if (frame) {
613 const bool get_file_globals = true;
614 const bool include_synthetic_vars = true;
615
616 VariableList *variable_list = frame->GetVariableList(
617 get_file_globals, include_synthetic_vars, nullptr);
618
619 if (variable_list) {
620 for (const VariableSP &var_sp : *variable_list)
621 request.AddCompletion(var_sp->GetName());
622
623 // Offer members of this/self so that direct ivar access can be
624 // completed (eg "frame variable member" for "this->member").
625 CompilerType instance_type = GetInstanceType(*frame, *variable_list);
626 if (instance_type.IsValid())
627 PrivateAutoCompleteMembers(frame, "", "", "", instance_type,
628 request);
629 }
630 }
631 }
632 } else {
633 const char ch = partial_path[0];
634 switch (ch) {
635 case '*':
636 if (prefix_path.str().empty()) {
637 PrivateAutoComplete(frame, partial_path.substr(1), "*", compiler_type,
638 request);
639 }
640 break;
641
642 case '&':
643 if (prefix_path.isTriviallyEmpty()) {
644 PrivateAutoComplete(frame, partial_path.substr(1), std::string("&"),
645 compiler_type, request);
646 }
647 break;
648
649 case '-':
650 if (partial_path.size() > 1 && partial_path[1] == '>' &&
651 !prefix_path.str().empty()) {
652 switch (type_class) {
653 case lldb::eTypeClassPointer: {
654 CompilerType pointee_type(compiler_type.GetPointeeType());
655 if (partial_path.size() > 2 && partial_path[2]) {
656 // If there is more after the "->", then search deeper
657 PrivateAutoComplete(frame, partial_path.substr(2),
658 prefix_path + "->",
659 pointee_type.GetCanonicalType(), request);
660 } else {
661 // Nothing after the "->", so list all members
663 frame, std::string(), std::string(), prefix_path + "->",
664 pointee_type.GetCanonicalType(), request);
665 }
666 } break;
667 default:
668 break;
669 }
670 }
671 break;
672
673 case '.':
674 if (compiler_type.IsValid()) {
675 switch (type_class) {
676 case lldb::eTypeClassUnion:
677 case lldb::eTypeClassStruct:
678 case lldb::eTypeClassClass:
679 if (partial_path.size() > 1 && partial_path[1]) {
680 // If there is more after the ".", then search deeper
681 PrivateAutoComplete(frame, partial_path.substr(1),
682 prefix_path + ".", compiler_type, request);
683
684 } else {
685 // Nothing after the ".", so list all members
686 PrivateAutoCompleteMembers(frame, std::string(), partial_path,
687 prefix_path + ".", compiler_type,
688 request);
689 }
690 break;
691 default:
692 break;
693 }
694 }
695 break;
696 default:
697 if (isalpha(ch) || ch == '_' || ch == '$') {
698 const size_t partial_path_len = partial_path.size();
699 size_t pos = 1;
700 while (pos < partial_path_len) {
701 const char curr_ch = partial_path[pos];
702 if (isalnum(curr_ch) || curr_ch == '_' || curr_ch == '$') {
703 ++pos;
704 continue;
705 }
706 break;
707 }
708
709 std::string token(std::string(partial_path), 0, pos);
710 remaining_partial_path = std::string(partial_path.substr(pos));
711
712 if (compiler_type.IsValid()) {
713 PrivateAutoCompleteMembers(frame, token, remaining_partial_path,
714 prefix_path, compiler_type, request);
715 } else if (frame) {
716 // We haven't found our variable yet
717 const bool get_file_globals = true;
718 const bool include_synthetic_vars = true;
719
720 VariableList *variable_list = frame->GetVariableList(
721 get_file_globals, include_synthetic_vars, nullptr);
722
723 if (!variable_list)
724 break;
725
726 for (VariableSP var_sp : *variable_list) {
727
728 if (!var_sp)
729 continue;
730
731 llvm::StringRef variable_name = var_sp->GetName().GetStringRef();
732 if (variable_name.starts_with(token)) {
733 if (variable_name == token) {
734 Type *variable_type = var_sp->GetType();
735 if (variable_type) {
736 CompilerType variable_compiler_type(
737 variable_type->GetForwardCompilerType());
739 frame, remaining_partial_path,
740 prefix_path + token, // Anything that has been resolved
741 // already will be in here
742 variable_compiler_type.GetCanonicalType(), request);
743 } else {
744 request.AddCompletion((prefix_path + variable_name).str());
745 }
746 } else if (remaining_partial_path.empty()) {
747 request.AddCompletion((prefix_path + variable_name).str());
748 }
749 }
750 }
751
752 // Try also completing the token as a member of this/self (direct ivar
753 // access).
754 CompilerType instance_type = GetInstanceType(*frame, *variable_list);
755 if (instance_type.IsValid())
756 PrivateAutoCompleteMembers(frame, token, remaining_partial_path,
757 prefix_path, instance_type, request);
758 }
759 }
760 break;
761 }
762 }
763}
764
766 CompletionRequest &request) {
767 CompilerType compiler_type;
768
770 "", compiler_type, request);
771}
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:499
static CompilerType GetInstanceType(StackFrame &frame, VariableList &variable_list)
Get the CompilerType of the current instance (this/self) for direct ivar completion.
Definition Variable.cpp:480
static void PrivateAutoComplete(StackFrame *frame, llvm::StringRef partial_path, const llvm::Twine &prefix_path, const CompilerType &compiler_type, CompletionRequest &request)
Definition Variable.cpp:561
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:376
const Address & GetAddress() const
Return the address of the function (its entry point).
Definition Function.h:429
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:179
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:281
static void AutoComplete(const ExecutionContext &exe_ctx, CompletionRequest &request)
Definition Variable.cpp:765
CompilerDeclContext GetDeclContext()
Definition Variable.cpp:203
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:245
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:89
static Status GetValuesForVariableExpressionPath(llvm::StringRef variable_expr_path, ExecutionContextScope *scope, GetVariableCallback callback, void *baton, VariableList &variable_list, ValueObjectList &valobj_list)
Definition Variable.cpp:333
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:91
void Dump(Stream *s, bool show_context) const
Definition Variable.cpp:113
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:82
CompilerDecl GetDecl()
Definition Variable.cpp:210
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:215
bool DumpLocations(Stream *s, const Address &address)
Definition Variable.cpp:449
lldb::LanguageType GetLanguage() const
Definition Variable.cpp:65
bool LocationIsValidForFrame(StackFrame *frame)
Definition Variable.cpp:223
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:42
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.
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:269
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