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"
24#include "lldb/Target/Process.h"
27#include "lldb/Target/Target.h"
28#include "lldb/Target/Thread.h"
30#include "lldb/Utility/Log.h"
32#include "lldb/Utility/Stream.h"
35
36#include "llvm/ADT/Twine.h"
37
38using namespace lldb;
39using namespace lldb_private;
40
41Variable::Variable(lldb::user_id_t uid, const char *name, const char *mangled,
42 const lldb::SymbolFileTypeSP &symfile_type_sp,
43 ValueType scope, SymbolContextScope *context,
44 const RangeList &scope_range, Declaration *decl_ptr,
45 const DWARFExpressionList &location_list, bool external,
46 bool artificial, bool location_is_constant_data,
47 bool static_member)
48 : UserID(uid), m_name(name), m_mangled(ConstString(mangled)),
49 m_symfile_type_sp(symfile_type_sp), m_scope(scope),
50 m_owner_scope(context), m_scope_range(scope_range),
51 m_declaration(decl_ptr), m_location_list(location_list),
52 m_external(external), m_artificial(artificial),
53 m_loc_is_const_data(location_is_constant_data),
54 m_static_member(static_member) {
55#ifndef NDEBUG
57 .GetInjectVarLocListError())
58 m_location_list.Clear();
59#endif
60}
61
62Variable::~Variable() = default;
63
65 lldb::LanguageType lang = m_mangled.GuessLanguage();
67 return lang;
68
69 if (auto *func = m_owner_scope->CalculateSymbolContextFunction()) {
70 if ((lang = func->GetLanguage()) != lldb::eLanguageTypeUnknown)
71 return lang;
72 } else if (auto *comp_unit =
73 m_owner_scope->CalculateSymbolContextCompileUnit()) {
74 if ((lang = comp_unit->GetLanguage()) != lldb::eLanguageTypeUnknown)
75 return lang;
76 }
77
79}
80
82 ConstString name = m_mangled.GetName();
83 if (name)
84 return name;
85 return m_name;
86}
87
89
91 if (m_name == name)
92 return true;
93 SymbolContext variable_sc;
94 m_owner_scope->CalculateSymbolContext(&variable_sc);
95
96 return m_mangled.NameMatches(name);
97}
98bool Variable::NameMatches(const RegularExpression &regex) const {
99 if (regex.Execute(m_name.AsCString()))
100 return true;
101 if (m_mangled)
102 return m_mangled.NameMatches(regex);
103 return false;
104}
105
108 return m_symfile_type_sp->GetType();
109 return nullptr;
110}
111
112void Variable::Dump(Stream *s, bool show_context) const {
113 s->Printf("%p: ", static_cast<const void *>(this));
114 s->Indent();
115 *s << "Variable" << (const UserID &)*this;
116
117 if (m_name)
118 *s << ", name = \"" << m_name << "\"";
119
120 if (m_symfile_type_sp) {
121 Type *type = m_symfile_type_sp->GetType();
122 if (type) {
123 s->Format(", type = {{{0:x-16}} {1} (", type->GetID(), type);
124 type->DumpTypeName(s);
125 s->PutChar(')');
126 }
127 }
128
129 if (m_scope != eValueTypeInvalid) {
130 s->PutCString(", scope = ");
131 switch (m_scope) {
133 s->PutCString(m_external ? "global" : "static");
134 break;
136 s->PutCString("parameter");
137 break;
139 s->PutCString("local");
140 break;
142 s->PutCString("thread local");
143 break;
144 default:
145 s->AsRawOstream() << "??? (" << m_scope << ')';
146 }
147 }
148
149 if (show_context && m_owner_scope != nullptr) {
150 s->PutCString(", context = ( ");
151 m_owner_scope->DumpSymbolContext(s);
152 s->PutCString(" )");
153 }
154
155 bool show_fullpaths = false;
156 m_declaration.Dump(s, show_fullpaths);
157
158 if (m_location_list.IsValid()) {
159 s->PutCString(", location = ");
160 ABISP abi;
161 if (m_owner_scope) {
162 ModuleSP module_sp(m_owner_scope->CalculateSymbolContextModule());
163 if (module_sp)
164 abi = ABI::FindPlugin(ProcessSP(), module_sp->GetArchitecture());
165 }
166 m_location_list.GetDescription(s, lldb::eDescriptionLevelBrief, abi.get());
167 }
168
169 if (m_external)
170 s->PutCString(", external");
171
172 if (m_artificial)
173 s->PutCString(", artificial");
174
175 s->EOL();
176}
177
178bool Variable::DumpDeclaration(Stream *s, bool show_fullpaths,
179 bool show_module) {
180 bool dumped_declaration_info = false;
181 if (m_owner_scope) {
182 SymbolContext sc;
183 m_owner_scope->CalculateSymbolContext(&sc);
184 sc.block = nullptr;
185 sc.line_entry.Clear();
186 bool show_inlined_frames = false;
187 const bool show_function_arguments = true;
188 const bool show_function_name = true;
189
190 dumped_declaration_info = sc.DumpStopContext(
191 s, nullptr, Address(), show_fullpaths, show_module, show_inlined_frames,
192 show_function_arguments, show_function_name);
193
194 if (sc.function)
195 s->PutChar(':');
196 }
197 if (m_declaration.DumpStopContext(s, false))
198 dumped_declaration_info = true;
199 return dumped_declaration_info;
200}
201
202size_t Variable::MemorySize() const { return sizeof(Variable); }
203
205 Type *type = GetType();
206 if (type)
208 return CompilerDeclContext();
209}
210
212 Type *type = GetType();
213 return type ? type->GetSymbolFile()->GetDeclForUID(GetID()) : CompilerDecl();
214}
215
217 if (m_owner_scope) {
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 switch (m_scope) {
286 return frame != nullptr;
287
292 return true;
293
296 if (frame) {
297 // We don't have a location list, we just need to see if the block that
298 // this variable was defined in is currently
299 Block *deepest_frame_block =
300 frame->GetSymbolContext(eSymbolContextBlock).block;
301 Address frame_addr = frame->GetFrameCodeAddress();
302 if (deepest_frame_block)
303 return IsInScope(*deepest_frame_block, frame_addr);
304 }
305 break;
306
307 default:
308 break;
309 }
310 return false;
311}
312
313bool Variable::IsInScope(const Block &block, const Address &addr) {
314 SymbolContext variable_sc;
315 CalculateSymbolContext(&variable_sc);
316
317 // Check for static or global variable defined at the compile unit
318 // level that wasn't defined in a block
319 if (variable_sc.block == nullptr)
320 return true;
321
322 // Check if the variable is valid in the current block
323 if (variable_sc.block != &block && !variable_sc.block->Contains(&block))
324 return false;
325
326 // If no scope range is specified then it means that the scope is the
327 // same as the scope of the enclosing lexical block.
328 if (m_scope_range.IsEmpty())
329 return true;
330
331 return m_scope_range.FindEntryThatContains(addr.GetFileAddress()) != nullptr;
332}
333
335 llvm::StringRef variable_expr_path, ExecutionContextScope *scope,
336 GetVariableCallback callback, void *baton, VariableList &variable_list,
337 ValueObjectList &valobj_list) {
339 if (!callback || variable_expr_path.empty()) {
340 error = Status::FromErrorString("unknown error");
341 return error;
342 }
343
344 switch (variable_expr_path.front()) {
345 case '*':
347 variable_expr_path.drop_front(), scope, callback, baton, variable_list,
348 valobj_list);
349 if (error.Fail()) {
350 error = Status::FromErrorString("unknown error");
351 return error;
352 }
353 for (uint32_t i = 0; i < valobj_list.GetSize();) {
354 Status tmp_error;
355 ValueObjectSP valobj_sp(
356 valobj_list.GetValueObjectAtIndex(i)->Dereference(tmp_error));
357 if (tmp_error.Fail()) {
358 variable_list.RemoveVariableAtIndex(i);
359 valobj_list.RemoveValueObjectAtIndex(i);
360 } else {
361 valobj_list.SetValueObjectAtIndex(i, valobj_sp);
362 ++i;
363 }
364 }
365 return error;
366 case '&': {
368 variable_expr_path.drop_front(), scope, callback, baton, variable_list,
369 valobj_list);
370 if (error.Success()) {
371 for (uint32_t i = 0; i < valobj_list.GetSize();) {
372 Status tmp_error;
373 ValueObjectSP valobj_sp(
374 valobj_list.GetValueObjectAtIndex(i)->AddressOf(tmp_error));
375 if (tmp_error.Fail()) {
376 variable_list.RemoveVariableAtIndex(i);
377 valobj_list.RemoveValueObjectAtIndex(i);
378 } else {
379 valobj_list.SetValueObjectAtIndex(i, valobj_sp);
380 ++i;
381 }
382 }
383 } else {
384 error = Status::FromErrorString("unknown error");
385 }
386 return error;
387 } break;
388
389 default: {
390 static RegularExpression g_regex(
391 llvm::StringRef("^([A-Za-z_:][A-Za-z_0-9:]*)(.*)"));
392 llvm::SmallVector<llvm::StringRef, 2> matches;
393 variable_list.Clear();
394 if (!g_regex.Execute(variable_expr_path, &matches)) {
396 "unable to extract a variable name from '{0}'", variable_expr_path);
397 return error;
398 }
399 std::string variable_name = matches[1].str();
400 if (!callback(baton, variable_name.c_str(), variable_list)) {
401 error = Status::FromErrorString("unknown error");
402 return error;
403 }
404 uint32_t i = 0;
405 while (i < variable_list.GetSize()) {
406 VariableSP var_sp(variable_list.GetVariableAtIndex(i));
407 ValueObjectSP valobj_sp;
408 if (!var_sp) {
409 variable_list.RemoveVariableAtIndex(i);
410 continue;
411 }
412 ValueObjectSP variable_valobj_sp(
413 ValueObjectVariable::Create(scope, var_sp));
414 if (!variable_valobj_sp) {
415 variable_list.RemoveVariableAtIndex(i);
416 continue;
417 }
418
419 llvm::StringRef variable_sub_expr_path =
420 variable_expr_path.drop_front(variable_name.size());
421 if (!variable_sub_expr_path.empty()) {
422 valobj_sp = variable_valobj_sp->GetValueForExpressionPath(
423 variable_sub_expr_path);
424 if (!valobj_sp) {
426 "invalid expression path '{0}' for variable '{1}'",
427 variable_sub_expr_path, var_sp->GetName().GetCString());
428 variable_list.RemoveVariableAtIndex(i);
429 continue;
430 }
431 } else {
432 // Just the name of a variable with no extras
433 valobj_sp = variable_valobj_sp;
434 }
435
436 valobj_list.Append(valobj_sp);
437 ++i;
438 }
439
440 if (variable_list.GetSize() > 0) {
441 error.Clear();
442 return error;
443 }
444 } break;
445 }
446 error = Status::FromErrorString("unknown error");
447 return error;
448}
449
450bool Variable::DumpLocations(Stream *s, const Address &address) {
451 SymbolContext sc;
453 ABISP abi;
454 if (m_owner_scope) {
455 ModuleSP module_sp(m_owner_scope->CalculateSymbolContextModule());
456 if (module_sp)
457 abi = ABI::FindPlugin(ProcessSP(), module_sp->GetArchitecture());
458 }
459
460 const addr_t file_addr = address.GetFileAddress();
461 if (sc.function) {
462 addr_t loclist_base_file_addr = sc.function->GetAddress().GetFileAddress();
463 if (loclist_base_file_addr == LLDB_INVALID_ADDRESS)
464 return false;
465 return m_location_list.DumpLocations(s, eDescriptionLevelBrief,
466 loclist_base_file_addr, file_addr,
467 abi.get());
468 }
469 return false;
470}
471
472static void PrivateAutoComplete(
473 StackFrame *frame, llvm::StringRef partial_path,
474 const llvm::Twine
475 &prefix_path, // Anything that has been resolved already will be in here
476 const CompilerType &compiler_type, CompletionRequest &request);
477
479 StackFrame *frame, const std::string &partial_member_name,
480 llvm::StringRef partial_path,
481 const llvm::Twine
482 &prefix_path, // Anything that has been resolved already will be in here
483 const CompilerType &compiler_type, CompletionRequest &request) {
484
485 // We are in a type parsing child members
486 const uint32_t num_bases = compiler_type.GetNumDirectBaseClasses();
487
488 if (num_bases > 0) {
489 for (uint32_t i = 0; i < num_bases; ++i) {
490 CompilerType base_class_type =
491 compiler_type.GetDirectBaseClassAtIndex(i, nullptr);
492
493 PrivateAutoCompleteMembers(frame, partial_member_name, partial_path,
494 prefix_path,
495 base_class_type.GetCanonicalType(), request);
496 }
497 }
498
499 const uint32_t num_vbases = compiler_type.GetNumVirtualBaseClasses();
500
501 if (num_vbases > 0) {
502 for (uint32_t i = 0; i < num_vbases; ++i) {
503 CompilerType vbase_class_type =
504 compiler_type.GetVirtualBaseClassAtIndex(i, nullptr);
505
506 PrivateAutoCompleteMembers(frame, partial_member_name, partial_path,
507 prefix_path,
508 vbase_class_type.GetCanonicalType(), request);
509 }
510 }
511
512 // We are in a type parsing child members
513 const uint32_t num_fields = compiler_type.GetNumFields();
514
515 if (num_fields > 0) {
516 for (uint32_t i = 0; i < num_fields; ++i) {
517 std::string member_name;
518
519 CompilerType member_compiler_type = compiler_type.GetFieldAtIndex(
520 i, member_name, nullptr, nullptr, nullptr);
521
522 if (partial_member_name.empty()) {
523 request.AddCompletion((prefix_path + member_name).str());
524 } else if (llvm::StringRef(member_name)
525 .starts_with(partial_member_name)) {
526 if (member_name == partial_member_name) {
528 frame, partial_path,
529 prefix_path + member_name, // Anything that has been resolved
530 // already will be in here
531 member_compiler_type.GetCanonicalType(), request);
532 } else if (partial_path.empty()) {
533 request.AddCompletion((prefix_path + member_name).str());
534 }
535 }
536 }
537 }
538}
539
541 StackFrame *frame, llvm::StringRef partial_path,
542 const llvm::Twine
543 &prefix_path, // Anything that has been resolved already will be in here
544 const CompilerType &compiler_type, CompletionRequest &request) {
545 // printf ("\nPrivateAutoComplete()\n\tprefix_path = '%s'\n\tpartial_path =
546 // '%s'\n", prefix_path.c_str(), partial_path.c_str());
547 std::string remaining_partial_path;
548
549 const lldb::TypeClass type_class = compiler_type.GetTypeClass();
550 if (partial_path.empty()) {
551 if (compiler_type.IsValid()) {
552 switch (type_class) {
553 default:
554 case eTypeClassArray:
555 case eTypeClassBlockPointer:
556 case eTypeClassBuiltin:
557 case eTypeClassComplexFloat:
558 case eTypeClassComplexInteger:
559 case eTypeClassEnumeration:
560 case eTypeClassFunction:
561 case eTypeClassMemberPointer:
562 case eTypeClassReference:
563 case eTypeClassTypedef:
564 case eTypeClassVector: {
565 request.AddCompletion(prefix_path.str());
566 } break;
567
568 case eTypeClassClass:
569 case eTypeClassStruct:
570 case eTypeClassUnion:
571 if (prefix_path.str().back() != '.')
572 request.AddCompletion((prefix_path + ".").str());
573 break;
574
575 case eTypeClassObjCObject:
576 case eTypeClassObjCInterface:
577 break;
578 case eTypeClassObjCObjectPointer:
579 case eTypeClassPointer: {
580 bool omit_empty_base_classes = true;
581 if (llvm::expectedToStdOptional(
582 compiler_type.GetNumChildren(omit_empty_base_classes, nullptr))
583 .value_or(0))
584 request.AddCompletion((prefix_path + "->").str());
585 else {
586 request.AddCompletion(prefix_path.str());
587 }
588 } break;
589 }
590 } else {
591 if (frame) {
592 const bool get_file_globals = true;
593
594 VariableList *variable_list = frame->GetVariableList(get_file_globals,
595 nullptr);
596
597 if (variable_list) {
598 for (const VariableSP &var_sp : *variable_list)
599 request.AddCompletion(var_sp->GetName().AsCString());
600 }
601 }
602 }
603 } else {
604 const char ch = partial_path[0];
605 switch (ch) {
606 case '*':
607 if (prefix_path.str().empty()) {
608 PrivateAutoComplete(frame, partial_path.substr(1), "*", compiler_type,
609 request);
610 }
611 break;
612
613 case '&':
614 if (prefix_path.isTriviallyEmpty()) {
615 PrivateAutoComplete(frame, partial_path.substr(1), std::string("&"),
616 compiler_type, request);
617 }
618 break;
619
620 case '-':
621 if (partial_path.size() > 1 && partial_path[1] == '>' &&
622 !prefix_path.str().empty()) {
623 switch (type_class) {
624 case lldb::eTypeClassPointer: {
625 CompilerType pointee_type(compiler_type.GetPointeeType());
626 if (partial_path.size() > 2 && partial_path[2]) {
627 // If there is more after the "->", then search deeper
628 PrivateAutoComplete(frame, partial_path.substr(2),
629 prefix_path + "->",
630 pointee_type.GetCanonicalType(), request);
631 } else {
632 // Nothing after the "->", so list all members
634 frame, std::string(), std::string(), prefix_path + "->",
635 pointee_type.GetCanonicalType(), request);
636 }
637 } break;
638 default:
639 break;
640 }
641 }
642 break;
643
644 case '.':
645 if (compiler_type.IsValid()) {
646 switch (type_class) {
647 case lldb::eTypeClassUnion:
648 case lldb::eTypeClassStruct:
649 case lldb::eTypeClassClass:
650 if (partial_path.size() > 1 && partial_path[1]) {
651 // If there is more after the ".", then search deeper
652 PrivateAutoComplete(frame, partial_path.substr(1),
653 prefix_path + ".", compiler_type, request);
654
655 } else {
656 // Nothing after the ".", so list all members
657 PrivateAutoCompleteMembers(frame, std::string(), partial_path,
658 prefix_path + ".", compiler_type,
659 request);
660 }
661 break;
662 default:
663 break;
664 }
665 }
666 break;
667 default:
668 if (isalpha(ch) || ch == '_' || ch == '$') {
669 const size_t partial_path_len = partial_path.size();
670 size_t pos = 1;
671 while (pos < partial_path_len) {
672 const char curr_ch = partial_path[pos];
673 if (isalnum(curr_ch) || curr_ch == '_' || curr_ch == '$') {
674 ++pos;
675 continue;
676 }
677 break;
678 }
679
680 std::string token(std::string(partial_path), 0, pos);
681 remaining_partial_path = std::string(partial_path.substr(pos));
682
683 if (compiler_type.IsValid()) {
684 PrivateAutoCompleteMembers(frame, token, remaining_partial_path,
685 prefix_path, compiler_type, request);
686 } else if (frame) {
687 // We haven't found our variable yet
688 const bool get_file_globals = true;
689
690 VariableList *variable_list =
691 frame->GetVariableList(get_file_globals, nullptr);
692
693 if (!variable_list)
694 break;
695
696 for (VariableSP var_sp : *variable_list) {
697
698 if (!var_sp)
699 continue;
700
701 llvm::StringRef variable_name = var_sp->GetName().GetStringRef();
702 if (variable_name.starts_with(token)) {
703 if (variable_name == token) {
704 Type *variable_type = var_sp->GetType();
705 if (variable_type) {
706 CompilerType variable_compiler_type(
707 variable_type->GetForwardCompilerType());
709 frame, remaining_partial_path,
710 prefix_path + token, // Anything that has been resolved
711 // already will be in here
712 variable_compiler_type.GetCanonicalType(), request);
713 } else {
714 request.AddCompletion((prefix_path + variable_name).str());
715 }
716 } else if (remaining_partial_path.empty()) {
717 request.AddCompletion((prefix_path + variable_name).str());
718 }
719 }
720 }
721 }
722 }
723 break;
724 }
725 }
726}
727
729 CompletionRequest &request) {
730 CompilerType compiler_type;
731
733 "", compiler_type, request);
734}
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:478
static void PrivateAutoComplete(StackFrame *frame, llvm::StringRef partial_path, const llvm::Twine &prefix_path, const CompilerType &compiler_type, CompletionRequest &request)
Definition Variable.cpp:540
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
"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:400
const Address & GetAddress() const
Return the address of the function (its entry point).
Definition Function.h:453
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 VariableList * GetVariableList(bool get_file_globals, Status *error_ptr)
Retrieve the list of variables whose scope either:
virtual Address GetFrameCodeAddressForSymbolication()
Get the current code Address suitable for symbolication, may not be the same as GetFrameCodeAddress()...
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:294
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)
Definition Stream.h:364
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
Definition Stream.h:406
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:65
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.
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:782
SymbolFile * GetSymbolFile()
Definition Type.h:476
void DumpTypeName(Stream *s)
Definition Type.cpp:451
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)
bool DumpDeclaration(Stream *s, bool show_fullpaths, bool show_module)
Definition Variable.cpp:178
const RangeList & GetScopeRange() const
Definition Variable.h:68
unsigned m_static_member
Non-zero if variable is static member of a class or struct.
Definition Variable.h:145
bool IsInScope(StackFrame *frame)
Definition Variable.cpp:282
static void AutoComplete(const ExecutionContext &exe_ctx, CompletionRequest &request)
Definition Variable.cpp:728
CompilerDeclContext GetDeclContext()
Definition Variable.cpp:204
unsigned m_artificial
Non-zero if the variable is not explicitly declared in source.
Definition Variable.h:140
unsigned m_external
Visible outside the containing compile unit?
Definition Variable.h:138
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:143
lldb::SymbolFileTypeSP m_symfile_type_sp
The type pointer of the variable (int, struct, class, etc) global, parameter, local.
Definition Variable.h:125
RangeList m_scope_range
The list of ranges inside the owner's scope where this variable is valid.
Definition Variable.h:131
ConstString GetUnqualifiedName() const
Definition Variable.cpp:88
static Status GetValuesForVariableExpressionPath(llvm::StringRef variable_expr_path, ExecutionContextScope *scope, GetVariableCallback callback, void *baton, VariableList &variable_list, ValueObjectList &valobj_list)
Definition Variable.cpp:334
Mangled m_mangled
The mangled name of the variable.
Definition Variable.h:122
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:90
void Dump(Stream *s, bool show_context) const
Definition Variable.cpp:112
lldb::ValueType m_scope
Definition Variable.h:126
SymbolContextScope * m_owner_scope
The symbol file scope that this variable was defined in.
Definition Variable.h:128
ConstString GetName() const
Definition Variable.cpp:81
CompilerDecl GetDecl()
Definition Variable.cpp:211
ConstString m_name
The basename of the variable (no namespaces).
Definition Variable.h:120
RangeVector< lldb::addr_t, lldb::addr_t > RangeList
Definition Variable.h:27
Declaration m_declaration
Declaration location for this item.
Definition Variable.h:133
void CalculateSymbolContext(SymbolContext *sc)
Definition Variable.cpp:216
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)
Constructors and Destructors.
Definition Variable.cpp:41
bool DumpLocations(Stream *s, const Address &address)
Definition Variable.cpp:450
lldb::LanguageType GetLanguage() const
Definition Variable.cpp:64
size_t MemorySize() const
Definition Variable.cpp:202
bool LocationIsValidForFrame(StackFrame *frame)
Definition Variable.cpp:224
size_t(* GetVariableCallback)(void *baton, const char *name, VariableList &var_list)
Definition Variable.h:103
DWARFExpressionList m_location_list
The location of this variable that can be fed to DWARFExpression::Evaluate().
Definition Variable.h:136
#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
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
@ 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
void Clear()
Clear the object's state.
Definition LineEntry.cpp:22
static TestingProperties & GetGlobalTestingProperties()
Definition Debugger.cpp:227
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