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"
14#include "lldb/Symbol/Block.h"
21#include "lldb/Symbol/Type.h"
24#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/Stream.h"
32
33#include "llvm/ADT/Twine.h"
34
35using namespace lldb;
36using namespace lldb_private;
37
38Variable::Variable(lldb::user_id_t uid, const char *name, const char *mangled,
39 const lldb::SymbolFileTypeSP &symfile_type_sp,
40 ValueType scope, SymbolContextScope *context,
41 const RangeList &scope_range, Declaration *decl_ptr,
42 const DWARFExpressionList &location_list, bool external,
43 bool artificial, bool location_is_constant_data,
44 bool static_member)
45 : UserID(uid), m_name(name), m_mangled(ConstString(mangled)),
46 m_symfile_type_sp(symfile_type_sp), m_scope(scope),
47 m_owner_scope(context), m_scope_range(scope_range),
48 m_declaration(decl_ptr), m_location_list(location_list), m_external(external),
49 m_artificial(artificial), m_loc_is_const_data(location_is_constant_data),
50 m_static_member(static_member) {}
51
52Variable::~Variable() = default;
53
57 return lang;
58
60 if ((lang = func->GetLanguage()) != lldb::eLanguageTypeUnknown)
61 return lang;
62 } else if (auto *comp_unit =
64 if ((lang = comp_unit->GetLanguage()) != lldb::eLanguageTypeUnknown)
65 return lang;
66 }
67
69}
70
73 if (name)
74 return name;
75 return m_name;
76}
77
79
81 if (m_name == name)
82 return true;
83 SymbolContext variable_sc;
85
86 return m_mangled.NameMatches(name);
87}
88bool Variable::NameMatches(const RegularExpression &regex) const {
89 if (regex.Execute(m_name.AsCString()))
90 return true;
91 if (m_mangled)
92 return m_mangled.NameMatches(regex);
93 return false;
94}
95
98 return m_symfile_type_sp->GetType();
99 return nullptr;
100}
101
102void Variable::Dump(Stream *s, bool show_context) const {
103 s->Printf("%p: ", static_cast<const void *>(this));
104 s->Indent();
105 *s << "Variable" << (const UserID &)*this;
106
107 if (m_name)
108 *s << ", name = \"" << m_name << "\"";
109
110 if (m_symfile_type_sp) {
111 Type *type = m_symfile_type_sp->GetType();
112 if (type) {
113 s->Format(", type = {{{0:x-16}} {1} (", type->GetID(), type);
114 type->DumpTypeName(s);
115 s->PutChar(')');
116 }
117 }
118
119 if (m_scope != eValueTypeInvalid) {
120 s->PutCString(", scope = ");
121 switch (m_scope) {
123 s->PutCString(m_external ? "global" : "static");
124 break;
126 s->PutCString("parameter");
127 break;
129 s->PutCString("local");
130 break;
132 s->PutCString("thread local");
133 break;
134 default:
135 s->AsRawOstream() << "??? (" << m_scope << ')';
136 }
137 }
138
139 if (show_context && m_owner_scope != nullptr) {
140 s->PutCString(", context = ( ");
142 s->PutCString(" )");
143 }
144
145 bool show_fullpaths = false;
146 m_declaration.Dump(s, show_fullpaths);
147
148 if (m_location_list.IsValid()) {
149 s->PutCString(", location = ");
150 ABISP abi;
151 if (m_owner_scope) {
153 if (module_sp)
154 abi = ABI::FindPlugin(ProcessSP(), module_sp->GetArchitecture());
155 }
157 }
158
159 if (m_external)
160 s->PutCString(", external");
161
162 if (m_artificial)
163 s->PutCString(", artificial");
164
165 s->EOL();
166}
167
168bool Variable::DumpDeclaration(Stream *s, bool show_fullpaths,
169 bool show_module) {
170 bool dumped_declaration_info = false;
171 if (m_owner_scope) {
172 SymbolContext sc;
174 sc.block = nullptr;
175 sc.line_entry.Clear();
176 bool show_inlined_frames = false;
177 const bool show_function_arguments = true;
178 const bool show_function_name = true;
179
180 dumped_declaration_info = sc.DumpStopContext(
181 s, nullptr, Address(), show_fullpaths, show_module, show_inlined_frames,
182 show_function_arguments, show_function_name);
183
184 if (sc.function)
185 s->PutChar(':');
186 }
187 if (m_declaration.DumpStopContext(s, false))
188 dumped_declaration_info = true;
189 return dumped_declaration_info;
190}
191
192size_t Variable::MemorySize() const { return sizeof(Variable); }
193
195 Type *type = GetType();
196 if (type)
198 return CompilerDeclContext();
199}
200
202 Type *type = GetType();
203 return type ? type->GetSymbolFile()->GetDeclForUID(GetID()) : CompilerDecl();
204}
205
207 if (m_owner_scope) {
209 sc->variable = this;
210 } else
211 sc->Clear(false);
212}
213
215 if (frame) {
216 Function *function =
217 frame->GetSymbolContext(eSymbolContextFunction).function;
218 if (function) {
219 TargetSP target_sp(frame->CalculateTarget());
220
221 addr_t loclist_base_load_addr =
223 target_sp.get());
224 if (loclist_base_load_addr == LLDB_INVALID_ADDRESS)
225 return false;
226 // It is a location list. We just need to tell if the location list
227 // contains the current address when converted to a load address
229 loclist_base_load_addr,
231 target_sp.get()));
232 }
233 }
234 return false;
235}
236
238 // Be sure to resolve the address to section offset prior to calling this
239 // function.
240 if (address.IsSectionOffset()) {
241 // We need to check if the address is valid for both scope range and value
242 // range.
243 // Empty scope range means block range.
244 bool valid_in_scope_range =
246 address.GetFileAddress()) != nullptr;
247 if (!valid_in_scope_range)
248 return false;
249 SymbolContext sc;
251 if (sc.module_sp == address.GetModule()) {
252 // Is the variable is described by a single location?
254 // Yes it is, the location is valid.
255 return true;
256 }
257
258 if (sc.function) {
259 addr_t loclist_base_file_addr =
261 if (loclist_base_file_addr == LLDB_INVALID_ADDRESS)
262 return false;
263 // It is a location list. We just need to tell if the location list
264 // contains the current address when converted to a load address
265 return m_location_list.ContainsAddress(loclist_base_file_addr,
266 address.GetFileAddress());
267 }
268 }
269 }
270 return false;
271}
272
274 switch (m_scope) {
277 return frame != nullptr;
278
283 return true;
284
287 if (frame) {
288 // We don't have a location list, we just need to see if the block that
289 // this variable was defined in is currently
290 Block *deepest_frame_block =
291 frame->GetSymbolContext(eSymbolContextBlock).block;
292 if (deepest_frame_block) {
293 SymbolContext variable_sc;
294 CalculateSymbolContext(&variable_sc);
295
296 // Check for static or global variable defined at the compile unit
297 // level that wasn't defined in a block
298 if (variable_sc.block == nullptr)
299 return true;
300
301 // Check if the variable is valid in the current block
302 if (variable_sc.block != deepest_frame_block &&
303 !variable_sc.block->Contains(deepest_frame_block))
304 return false;
305
306 // If no scope range is specified then it means that the scope is the
307 // same as the scope of the enclosing lexical block.
309 return true;
310
311 addr_t file_address = frame->GetFrameCodeAddress().GetFileAddress();
312 return m_scope_range.FindEntryThatContains(file_address) != nullptr;
313 }
314 }
315 break;
316
317 default:
318 break;
319 }
320 return false;
321}
322
324 llvm::StringRef variable_expr_path, ExecutionContextScope *scope,
325 GetVariableCallback callback, void *baton, VariableList &variable_list,
326 ValueObjectList &valobj_list) {
328 if (!callback || variable_expr_path.empty()) {
329 error.SetErrorString("unknown error");
330 return error;
331 }
332
333 switch (variable_expr_path.front()) {
334 case '*':
336 variable_expr_path.drop_front(), scope, callback, baton, variable_list,
337 valobj_list);
338 if (error.Fail()) {
339 error.SetErrorString("unknown error");
340 return error;
341 }
342 for (uint32_t i = 0; i < valobj_list.GetSize();) {
343 Status tmp_error;
344 ValueObjectSP valobj_sp(
345 valobj_list.GetValueObjectAtIndex(i)->Dereference(tmp_error));
346 if (tmp_error.Fail()) {
347 variable_list.RemoveVariableAtIndex(i);
348 valobj_list.RemoveValueObjectAtIndex(i);
349 } else {
350 valobj_list.SetValueObjectAtIndex(i, valobj_sp);
351 ++i;
352 }
353 }
354 return error;
355 case '&': {
357 variable_expr_path.drop_front(), scope, callback, baton, variable_list,
358 valobj_list);
359 if (error.Success()) {
360 for (uint32_t i = 0; i < valobj_list.GetSize();) {
361 Status tmp_error;
362 ValueObjectSP valobj_sp(
363 valobj_list.GetValueObjectAtIndex(i)->AddressOf(tmp_error));
364 if (tmp_error.Fail()) {
365 variable_list.RemoveVariableAtIndex(i);
366 valobj_list.RemoveValueObjectAtIndex(i);
367 } else {
368 valobj_list.SetValueObjectAtIndex(i, valobj_sp);
369 ++i;
370 }
371 }
372 } else {
373 error.SetErrorString("unknown error");
374 }
375 return error;
376 } break;
377
378 default: {
379 static RegularExpression g_regex(
380 llvm::StringRef("^([A-Za-z_:][A-Za-z_0-9:]*)(.*)"));
381 llvm::SmallVector<llvm::StringRef, 2> matches;
382 variable_list.Clear();
383 if (!g_regex.Execute(variable_expr_path, &matches)) {
384 error.SetErrorStringWithFormatv(
385 "unable to extract a variable name from '{0}'", variable_expr_path);
386 return error;
387 }
388 std::string variable_name = matches[1].str();
389 if (!callback(baton, variable_name.c_str(), variable_list)) {
390 error.SetErrorString("unknown error");
391 return error;
392 }
393 uint32_t i = 0;
394 while (i < variable_list.GetSize()) {
395 VariableSP var_sp(variable_list.GetVariableAtIndex(i));
396 ValueObjectSP valobj_sp;
397 if (!var_sp) {
398 variable_list.RemoveVariableAtIndex(i);
399 continue;
400 }
401 ValueObjectSP variable_valobj_sp(
402 ValueObjectVariable::Create(scope, var_sp));
403 if (!variable_valobj_sp) {
404 variable_list.RemoveVariableAtIndex(i);
405 continue;
406 }
407
408 llvm::StringRef variable_sub_expr_path =
409 variable_expr_path.drop_front(variable_name.size());
410 if (!variable_sub_expr_path.empty()) {
411 valobj_sp = variable_valobj_sp->GetValueForExpressionPath(
412 variable_sub_expr_path);
413 if (!valobj_sp) {
414 error.SetErrorStringWithFormatv(
415 "invalid expression path '{0}' for variable '{1}'",
416 variable_sub_expr_path, var_sp->GetName().GetCString());
417 variable_list.RemoveVariableAtIndex(i);
418 continue;
419 }
420 } else {
421 // Just the name of a variable with no extras
422 valobj_sp = variable_valobj_sp;
423 }
424
425 valobj_list.Append(valobj_sp);
426 ++i;
427 }
428
429 if (variable_list.GetSize() > 0) {
430 error.Clear();
431 return error;
432 }
433 } break;
434 }
435 error.SetErrorString("unknown error");
436 return error;
437}
438
439bool Variable::DumpLocations(Stream *s, const Address &address) {
440 SymbolContext sc;
442 ABISP abi;
443 if (m_owner_scope) {
445 if (module_sp)
446 abi = ABI::FindPlugin(ProcessSP(), module_sp->GetArchitecture());
447 }
448
449 const addr_t file_addr = address.GetFileAddress();
450 if (sc.function) {
451 addr_t loclist_base_file_addr =
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 llvm::StringRef(member_name).starts_with(partial_member_name)) {
514 if (member_name == partial_member_name) {
516 frame, partial_path,
517 prefix_path + member_name, // Anything that has been resolved
518 // already will be in here
519 member_compiler_type.GetCanonicalType(), request);
520 } else {
521 request.AddCompletion((prefix_path + member_name).str());
522 }
523 }
524 }
525 }
526}
527
529 StackFrame *frame, llvm::StringRef partial_path,
530 const llvm::Twine
531 &prefix_path, // Anything that has been resolved already will be in here
532 const CompilerType &compiler_type, CompletionRequest &request) {
533 // printf ("\nPrivateAutoComplete()\n\tprefix_path = '%s'\n\tpartial_path =
534 // '%s'\n", prefix_path.c_str(), partial_path.c_str());
535 std::string remaining_partial_path;
536
537 const lldb::TypeClass type_class = compiler_type.GetTypeClass();
538 if (partial_path.empty()) {
539 if (compiler_type.IsValid()) {
540 switch (type_class) {
541 default:
542 case eTypeClassArray:
543 case eTypeClassBlockPointer:
544 case eTypeClassBuiltin:
545 case eTypeClassComplexFloat:
546 case eTypeClassComplexInteger:
547 case eTypeClassEnumeration:
548 case eTypeClassFunction:
549 case eTypeClassMemberPointer:
550 case eTypeClassReference:
551 case eTypeClassTypedef:
552 case eTypeClassVector: {
553 request.AddCompletion(prefix_path.str());
554 } break;
555
556 case eTypeClassClass:
557 case eTypeClassStruct:
558 case eTypeClassUnion:
559 if (prefix_path.str().back() != '.')
560 request.AddCompletion((prefix_path + ".").str());
561 break;
562
563 case eTypeClassObjCObject:
564 case eTypeClassObjCInterface:
565 break;
566 case eTypeClassObjCObjectPointer:
567 case eTypeClassPointer: {
568 bool omit_empty_base_classes = true;
569 if (compiler_type.GetNumChildren(omit_empty_base_classes, nullptr) > 0)
570 request.AddCompletion((prefix_path + "->").str());
571 else {
572 request.AddCompletion(prefix_path.str());
573 }
574 } break;
575 }
576 } else {
577 if (frame) {
578 const bool get_file_globals = true;
579
580 VariableList *variable_list = frame->GetVariableList(get_file_globals,
581 nullptr);
582
583 if (variable_list) {
584 for (const VariableSP &var_sp : *variable_list)
585 request.AddCompletion(var_sp->GetName().AsCString());
586 }
587 }
588 }
589 } else {
590 const char ch = partial_path[0];
591 switch (ch) {
592 case '*':
593 if (prefix_path.str().empty()) {
594 PrivateAutoComplete(frame, partial_path.substr(1), "*", compiler_type,
595 request);
596 }
597 break;
598
599 case '&':
600 if (prefix_path.isTriviallyEmpty()) {
601 PrivateAutoComplete(frame, partial_path.substr(1), std::string("&"),
602 compiler_type, request);
603 }
604 break;
605
606 case '-':
607 if (partial_path.size() > 1 && partial_path[1] == '>' &&
608 !prefix_path.str().empty()) {
609 switch (type_class) {
610 case lldb::eTypeClassPointer: {
611 CompilerType pointee_type(compiler_type.GetPointeeType());
612 if (partial_path.size() > 2 && partial_path[2]) {
613 // If there is more after the "->", then search deeper
614 PrivateAutoComplete(frame, partial_path.substr(2),
615 prefix_path + "->",
616 pointee_type.GetCanonicalType(), request);
617 } else {
618 // Nothing after the "->", so list all members
620 frame, std::string(), std::string(), prefix_path + "->",
621 pointee_type.GetCanonicalType(), request);
622 }
623 } break;
624 default:
625 break;
626 }
627 }
628 break;
629
630 case '.':
631 if (compiler_type.IsValid()) {
632 switch (type_class) {
633 case lldb::eTypeClassUnion:
634 case lldb::eTypeClassStruct:
635 case lldb::eTypeClassClass:
636 if (partial_path.size() > 1 && partial_path[1]) {
637 // If there is more after the ".", then search deeper
638 PrivateAutoComplete(frame, partial_path.substr(1),
639 prefix_path + ".", compiler_type, request);
640
641 } else {
642 // Nothing after the ".", so list all members
643 PrivateAutoCompleteMembers(frame, std::string(), partial_path,
644 prefix_path + ".", compiler_type,
645 request);
646 }
647 break;
648 default:
649 break;
650 }
651 }
652 break;
653 default:
654 if (isalpha(ch) || ch == '_' || ch == '$') {
655 const size_t partial_path_len = partial_path.size();
656 size_t pos = 1;
657 while (pos < partial_path_len) {
658 const char curr_ch = partial_path[pos];
659 if (isalnum(curr_ch) || curr_ch == '_' || curr_ch == '$') {
660 ++pos;
661 continue;
662 }
663 break;
664 }
665
666 std::string token(std::string(partial_path), 0, pos);
667 remaining_partial_path = std::string(partial_path.substr(pos));
668
669 if (compiler_type.IsValid()) {
670 PrivateAutoCompleteMembers(frame, token, remaining_partial_path,
671 prefix_path, compiler_type, request);
672 } else if (frame) {
673 // We haven't found our variable yet
674 const bool get_file_globals = true;
675
676 VariableList *variable_list =
677 frame->GetVariableList(get_file_globals, nullptr);
678
679 if (!variable_list)
680 break;
681
682 for (VariableSP var_sp : *variable_list) {
683
684 if (!var_sp)
685 continue;
686
687 llvm::StringRef variable_name = var_sp->GetName().GetStringRef();
688 if (variable_name.starts_with(token)) {
689 if (variable_name == token) {
690 Type *variable_type = var_sp->GetType();
691 if (variable_type) {
692 CompilerType variable_compiler_type(
693 variable_type->GetForwardCompilerType());
695 frame, remaining_partial_path,
696 prefix_path + token, // Anything that has been resolved
697 // already will be in here
698 variable_compiler_type.GetCanonicalType(), request);
699 } else {
700 request.AddCompletion((prefix_path + variable_name).str());
701 }
702 } else if (remaining_partial_path.empty()) {
703 request.AddCompletion((prefix_path + variable_name).str());
704 }
705 }
706 }
707 }
708 }
709 break;
710 }
711 }
712}
713
715 CompletionRequest &request) {
716 CompilerType compiler_type;
717
719 "", compiler_type, request);
720}
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:528
static lldb::ABISP FindPlugin(lldb::ProcessSP process_sp, const ArchSpec &arch)
Definition: ABI.cpp:27
Address & GetBaseAddress()
Get accessor for the base address of the range.
Definition: AddressRange.h:209
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:180
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
uint32_t GetNumChildren(bool omit_empty_base_classes, const ExecutionContext *exe_ctx) 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...
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 seperated 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 AddressRange & GetAddressRange()
Definition: Function.h:447
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:379
ConstString GetName(NamePreference preference=ePreferDemangled) const
Best name get accessor.
Definition: Mangled.cpp:323
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:42
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:424
Address GetFrameCodeAddressForSymbolication()
Get the current code Address suitable for symbolication, may not be the same as GetFrameCodeAddress()...
Definition: StackFrame.cpp:222
const SymbolContext & GetSymbolContext(lldb::SymbolContextItem resolve_scope)
Provide a SymbolContext for this StackFrame's current pc value.
Definition: StackFrame.cpp:300
const Address & GetFrameCodeAddress()
Get an Address for the current pc value in this StackFrame.
Definition: StackFrame.cpp:190
lldb::TargetSP CalculateTarget() override
An error handling class.
Definition: Status.h:44
bool Fail() const
Test for error condition.
Definition: Status.cpp:181
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.
void Clear(bool clear_target)
Clear the object's state.
Variable * variable
The global variable matching the 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, std::optional< Stream::HighlightSettings > settings=std::nullopt) const
Dump the stop context in this object to a Stream.
LineEntry line_entry
The LineEntry for a given query.
virtual CompilerDeclContext GetDeclContextContainingUID(lldb::user_id_t uid)
Definition: SymbolFile.h:232
virtual CompilerDecl GetDeclForUID(lldb::user_id_t uid)
Definition: SymbolFile.h:228
CompilerType GetForwardCompilerType()
Definition: Type.cpp:751
SymbolFile * GetSymbolFile()
Definition: Type.h:434
void DumpTypeName(Stream *s)
Definition: Type.cpp:438
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:168
const RangeList & GetScopeRange() const
Definition: Variable.h:68
bool IsInScope(StackFrame *frame)
Definition: Variable.cpp:273
static void AutoComplete(const ExecutionContext &exe_ctx, CompletionRequest &request)
Definition: Variable.cpp:714
CompilerDeclContext GetDeclContext()
Definition: Variable.cpp:194
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:237
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:78
static Status GetValuesForVariableExpressionPath(llvm::StringRef variable_expr_path, ExecutionContextScope *scope, GetVariableCallback callback, void *baton, VariableList &variable_list, ValueObjectList &valobj_list)
Definition: Variable.cpp:323
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:80
void Dump(Stream *s, bool show_context) const
Definition: Variable.cpp:102
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:71
CompilerDecl GetDecl()
Definition: Variable.cpp:201
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:206
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:38
bool DumpLocations(Stream *s, const Address &address)
Definition: Variable.cpp:439
lldb::LanguageType GetLanguage() const
Definition: Variable.cpp:54
size_t MemorySize() const
Definition: Variable.cpp:192
bool LocationIsValidForFrame(StackFrame *frame)
Definition: Variable.cpp:214
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: SBAttachInfo.h:14
Definition: SBAddress.h:15
std::shared_ptr< lldb_private::ABI > ABISP
Definition: lldb-forward.h:310
@ eDescriptionLevelBrief
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
Definition: lldb-forward.h:472
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
std::shared_ptr< lldb_private::Process > ProcessSP
Definition: lldb-forward.h:381
std::shared_ptr< lldb_private::SymbolFileType > SymbolFileTypeSP
Definition: lldb-forward.h:429
std::shared_ptr< lldb_private::Variable > VariableSP
Definition: lldb-forward.h:474
uint64_t user_id_t
Definition: lldb-types.h:80
uint64_t addr_t
Definition: lldb-types.h:79
std::shared_ptr< lldb_private::Target > TargetSP
Definition: lldb-forward.h:436
std::shared_ptr< lldb_private::Module > ModuleSP
Definition: lldb-forward.h:365
@ 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:20
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