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