38#include "llvm/ADT/Twine.h"
48 bool artificial,
bool location_is_constant_data,
49 bool static_member, std::optional<uint64_t> tag_offset)
59 .GetInjectVarLocListError())
71 if (
auto *func =
m_owner_scope->CalculateSymbolContextFunction()) {
74 }
else if (
auto *comp_unit =
122 s->
Printf(
"%p: ",
static_cast<const void *
>(
this));
124 *s <<
"Variable" << (
const UserID &)*
this;
127 *s <<
", name = \"" <<
m_name <<
"\"";
132 s->
Format(
", type = {{{0:x-16}} {1} (", type->
GetID(), type);
164 bool show_fullpaths =
false;
189 bool dumped_declaration_info =
false;
195 bool show_inlined_frames =
false;
196 const bool show_function_arguments =
true;
197 const bool show_function_name =
true;
200 s,
nullptr,
Address(), show_fullpaths, show_module, show_inlined_frames,
201 show_function_arguments, show_function_name);
207 dumped_declaration_info =
true;
208 return dumped_declaration_info;
238 addr_t loclist_base_load_addr =
245 loclist_base_load_addr,
260 bool valid_in_scope_range =
263 if (!valid_in_scope_range)
275 addr_t loclist_base_file_addr =
297 return frame !=
nullptr;
310 Block *deepest_frame_block =
313 if (deepest_frame_block)
314 return IsInScope(*deepest_frame_block, frame_addr);
330 if (variable_sc.
block ==
nullptr)
350 if (!callback || variable_expr_path.empty()) {
355 switch (variable_expr_path.front()) {
358 variable_expr_path.drop_front(), scope, callback, baton, variable_list,
364 for (uint32_t i = 0; i < valobj_list.
GetSize();) {
368 if (tmp_error.
Fail()) {
379 variable_expr_path.drop_front(), scope, callback, baton, variable_list,
381 if (
error.Success()) {
382 for (uint32_t i = 0; i < valobj_list.
GetSize();) {
386 if (tmp_error.
Fail()) {
402 llvm::StringRef(
"^([A-Za-z_:][A-Za-z_0-9:]*)(.*)"));
403 llvm::SmallVector<llvm::StringRef, 2> matches;
404 variable_list.
Clear();
405 if (!g_regex.
Execute(variable_expr_path, &matches)) {
407 "unable to extract a variable name from '{0}'", variable_expr_path);
410 std::string variable_name = matches[1].str();
411 if (!callback(baton, variable_name.c_str(), variable_list)) {
416 while (i < variable_list.
GetSize()) {
425 if (!variable_valobj_sp) {
430 llvm::StringRef variable_sub_expr_path =
431 variable_expr_path.drop_front(variable_name.size());
432 if (!variable_sub_expr_path.empty()) {
433 valobj_sp = variable_valobj_sp->GetValueForExpressionPath(
434 variable_sub_expr_path);
437 "invalid expression path '{0}' for variable '{1}'",
438 variable_sub_expr_path, var_sp->GetName().GetCString());
444 valobj_sp = variable_valobj_sp;
447 valobj_list.
Append(valobj_sp);
451 if (variable_list.
GetSize() > 0) {
477 loclist_base_file_addr, file_addr,
484 StackFrame *frame, llvm::StringRef partial_path,
497 if (instance_name.empty())
502 Type *var_type = var_sp->GetType();
512 StackFrame *frame,
const std::string &partial_member_name,
513 llvm::StringRef partial_path,
522 for (uint32_t i = 0; i < num_bases; ++i) {
534 if (num_vbases > 0) {
535 for (uint32_t i = 0; i < num_vbases; ++i) {
546 const uint32_t num_fields = compiler_type.
GetNumFields();
548 if (num_fields > 0) {
549 for (uint32_t i = 0; i < num_fields; ++i) {
550 std::string member_name;
553 i, member_name,
nullptr,
nullptr,
nullptr);
555 if (partial_member_name.empty()) {
557 }
else if (llvm::StringRef(member_name)
558 .starts_with(partial_member_name)) {
559 if (member_name == partial_member_name) {
562 prefix_path + member_name,
565 }
else if (partial_path.empty()) {
574 StackFrame *frame, llvm::StringRef partial_path,
580 std::string remaining_partial_path;
582 const lldb::TypeClass type_class = compiler_type.
GetTypeClass();
583 if (partial_path.empty()) {
585 switch (type_class) {
587 case eTypeClassArray:
588 case eTypeClassBlockPointer:
589 case eTypeClassBuiltin:
590 case eTypeClassComplexFloat:
591 case eTypeClassComplexInteger:
592 case eTypeClassEnumeration:
593 case eTypeClassFunction:
594 case eTypeClassMemberPointer:
595 case eTypeClassReference:
596 case eTypeClassTypedef:
597 case eTypeClassVector: {
601 case eTypeClassClass:
602 case eTypeClassStruct:
603 case eTypeClassUnion:
604 if (prefix_path.str().back() !=
'.')
608 case eTypeClassObjCObject:
609 case eTypeClassObjCInterface:
611 case eTypeClassObjCObjectPointer:
612 case eTypeClassPointer: {
613 bool omit_empty_base_classes =
true;
614 if (llvm::expectedToOptional(
625 const bool get_file_globals =
true;
626 const bool include_synthetic_vars =
true;
629 get_file_globals, include_synthetic_vars,
nullptr);
632 for (
const VariableSP &var_sp : *variable_list)
645 const char ch = partial_path[0];
648 if (prefix_path.str().empty()) {
655 if (prefix_path.isTriviallyEmpty()) {
657 compiler_type, request);
662 if (partial_path.size() > 1 && partial_path[1] ==
'>' &&
663 !prefix_path.str().empty()) {
664 switch (type_class) {
665 case lldb::eTypeClassPointer: {
667 if (partial_path.size() > 2 && partial_path[2]) {
675 frame, std::string(), std::string(), prefix_path +
"->",
687 switch (type_class) {
688 case lldb::eTypeClassUnion:
689 case lldb::eTypeClassStruct:
690 case lldb::eTypeClassClass:
691 if (partial_path.size() > 1 && partial_path[1]) {
694 prefix_path +
".", compiler_type, request);
699 prefix_path +
".", compiler_type,
709 if (isalpha(ch) || ch ==
'_' || ch ==
'$') {
710 const size_t partial_path_len = partial_path.size();
712 while (pos < partial_path_len) {
713 const char curr_ch = partial_path[pos];
714 if (isalnum(curr_ch) || curr_ch ==
'_' || curr_ch ==
'$') {
721 std::string token(std::string(partial_path), 0, pos);
722 remaining_partial_path = std::string(partial_path.substr(pos));
726 prefix_path, compiler_type, request);
729 const bool get_file_globals =
true;
730 const bool include_synthetic_vars =
true;
733 get_file_globals, include_synthetic_vars,
nullptr);
743 llvm::StringRef variable_name = var_sp->GetName().GetStringRef();
744 if (variable_name.starts_with(token)) {
745 if (variable_name == token) {
746 Type *variable_type = var_sp->GetType();
751 frame, remaining_partial_path,
758 }
else if (remaining_partial_path.empty()) {
769 prefix_path, instance_type, request);
782 "", compiler_type, request);
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)
static CompilerType GetInstanceType(StackFrame &frame, VariableList &variable_list)
Get the CompilerType of the current instance (this/self) for direct ivar completion.
static void PrivateAutoComplete(StackFrame *frame, llvm::StringRef partial_path, const llvm::Twine &prefix_path, const CompilerType &compiler_type, CompletionRequest &request)
static lldb::ABISP FindPlugin(lldb::ProcessSP process_sp, const ArchSpec &arch)
A section + offset based address class.
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
lldb::ModuleSP GetModule() const
Get accessor for the module for this address.
lldb::addr_t GetFileAddress() const
Get the file address.
bool IsSectionOffset() const
Check if an address is section offset.
A class that describes a single lexical block.
bool Contains(lldb::addr_t range_offset) const
Check if an offset is in one of the block offset ranges.
Represents a generic declaration context in a program.
Represents a generic declaration such as a function declaration.
Generic representation of a type in a programming language.
CompilerType GetVirtualBaseClassAtIndex(size_t idx, uint32_t *bit_offset_ptr) const
CompilerType GetFieldAtIndex(size_t idx, std::string &name, uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) const
lldb::TypeClass GetTypeClass() const
uint32_t GetNumVirtualBaseClasses() const
uint32_t GetNumFields() const
uint32_t GetNumDirectBaseClasses() const
CompilerType GetDirectBaseClassAtIndex(size_t idx, uint32_t *bit_offset_ptr) const
CompilerType GetPointeeType() const
If this type is a pointer type, return the type that the pointer points to, else return an invalid ty...
llvm::Expected< uint32_t > GetNumChildren(bool omit_empty_base_classes, const ExecutionContext *exe_ctx) const
CompilerType GetCanonicalType() const
bool IsPointerType(CompilerType *pointee_type=nullptr) const
"lldb/Utility/ArgCompletionRequest.h"
void AddCompletion(llvm::StringRef completion, llvm::StringRef description="", CompletionMode mode=CompletionMode::Normal)
Adds a possible completion string.
llvm::StringRef GetCursorArgumentPrefix() const
A uniqued constant string class.
"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.
"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.
const Address & GetAddress() const
Return the address of the function (its entry point).
const Entry * FindEntryThatContains(B addr) const
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.
virtual Address GetFrameCodeAddressForSymbolication()
Get the current code Address suitable for symbolication, may not be the same as GetFrameCodeAddress()...
virtual VariableList * GetVariableList(bool get_file_globals, bool include_synthetic_vars, Status *error_ptr)
Retrieve the list of variables whose scope either:
virtual const SymbolContext & GetSymbolContext(lldb::SymbolContextItem resolve_scope)
Provide a SymbolContext for this StackFrame's current pc value.
virtual const Address & GetFrameCodeAddress()
Get an Address for the current pc value in this StackFrame.
lldb::TargetSP CalculateTarget() override
static Status FromErrorString(const char *str)
bool Fail() const
Test for error condition.
static Status static Status FromErrorStringWithFormatv(const char *format, Args &&...args)
A stream class that can stream formatted output to a file.
void Format(const char *format, Args &&... args)
Forwards the arguments to llvm::formatv and writes to the stream.
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
size_t EOL()
Output and End of Line character to the stream.
"lldb/Symbol/SymbolContextScope.h" Inherit from this if your object is part of a symbol context and c...
Defines a symbol context baton that can be handed other debug core functions.
Function * function
The Function for a given query.
llvm::StringRef GetInstanceName()
Determines the name of the instance for this decl context.
Block * block
The Block for a given query.
lldb::ModuleSP module_sp
The Module for a given query.
bool DumpStopContext(Stream *s, ExecutionContextScope *exe_scope, const Address &so_addr, bool show_fullpaths, bool show_module, bool show_inlined_frames, bool show_function_arguments, bool show_function_name, bool show_function_display_name=false, std::optional< Stream::HighlightSettings > settings=std::nullopt) const
Dump the stop context in this object to a Stream.
void Clear(bool clear_target)
Clear the object's state.
Variable * variable
The global variable matching the given query.
LineEntry line_entry
The LineEntry for a given query.
virtual CompilerDeclContext GetDeclContextContainingUID(lldb::user_id_t uid)
virtual CompilerDecl GetDeclForUID(lldb::user_id_t uid)
virtual lldb::TypeSP GetTypeEnclosingVariableUID(lldb::user_id_t uid)
Get the semantically innermost non-function type that encloses the provided variable.
CompilerType GetForwardCompilerType()
SymbolFile * GetSymbolFile()
void DumpTypeName(Stream *s)
A collection of ValueObject values that.
void SetValueObjectAtIndex(size_t idx, const lldb::ValueObjectSP &valobj_sp)
void Append(const lldb::ValueObjectSP &val_obj_sp)
lldb::ValueObjectSP GetValueObjectAtIndex(size_t idx)
lldb::ValueObjectSP RemoveValueObjectAtIndex(size_t idx)
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, const lldb::VariableSP &var_sp)
lldb::VariableSP GetVariableAtIndex(size_t idx) const
lldb::VariableSP RemoveVariableAtIndex(size_t idx)
lldb::VariableSP FindVariable(ConstString name, bool include_static_members=true) const
bool DumpDeclaration(Stream *s, bool show_fullpaths, bool show_module)
const RangeList & GetScopeRange() const
unsigned m_static_member
Non-zero if variable is static member of a class or struct.
bool IsInScope(StackFrame *frame)
static void AutoComplete(const ExecutionContext &exe_ctx, CompletionRequest &request)
CompilerDeclContext GetDeclContext()
unsigned m_artificial
Non-zero if the variable is not explicitly declared in source.
unsigned m_external
Visible outside the containing compile unit?
bool LocationIsValidForAddress(const Address &address)
unsigned m_loc_is_const_data
The m_location expression contains the constant variable value data, not a DWARF location.
lldb::SymbolFileTypeSP m_symfile_type_sp
The type pointer of the variable (int, struct, class, etc) global, parameter, local.
RangeList m_scope_range
The list of ranges inside the owner's scope where this variable is valid.
ConstString GetUnqualifiedName() const
static Status GetValuesForVariableExpressionPath(llvm::StringRef variable_expr_path, ExecutionContextScope *scope, GetVariableCallback callback, void *baton, VariableList &variable_list, ValueObjectList &valobj_list)
Mangled m_mangled
The mangled name of the variable.
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...
void Dump(Stream *s, bool show_context) const
std::optional< uint64_t > m_tag_offset
The value of DW_AT_LLVM_tag_offset if present.
SymbolContextScope * m_owner_scope
The symbol file scope that this variable was defined in.
ConstString GetName() const
ConstString m_name
The basename of the variable (no namespaces).
RangeVector< lldb::addr_t, lldb::addr_t > RangeList
Declaration m_declaration
Declaration location for this item.
void CalculateSymbolContext(SymbolContext *sc)
lldb::TypeSP GetEnclosingType()
bool DumpLocations(Stream *s, const Address &address)
lldb::LanguageType GetLanguage() const
bool LocationIsValidForFrame(StackFrame *frame)
Variable(lldb::user_id_t uid, const char *name, const char *mangled, const lldb::SymbolFileTypeSP &symfile_type_sp, lldb::ValueType scope, SymbolContextScope *owner_scope, const RangeList &scope_range, Declaration *decl, const DWARFExpressionList &location, bool external, bool artificial, bool location_is_constant_data, bool static_member=false, std::optional< uint64_t > tag_offset=std::nullopt)
Constructors and Destructors.
size_t(* GetVariableCallback)(void *baton, const char *name, VariableList &var_list)
DWARFExpressionList m_location_list
The location of this variable that can be fed to DWARFExpression::Evaluate().
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
constexpr bool IsSyntheticValueType(lldb::ValueType vt)
Return true if vt represents a synthetic value, false if not.
std::shared_ptr< lldb_private::ABI > ABISP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
std::shared_ptr< lldb_private::Type > TypeSP
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::SymbolFileType > SymbolFileTypeSP
std::shared_ptr< lldb_private::Variable > VariableSP
@ eValueTypeVariableGlobal
globals variable
@ eValueTypeConstResult
constant result variables
@ eValueTypeVariableLocal
function local variables
@ eValueTypeVariableArgument
function argument variables
@ eValueTypeRegister
stack frame register value
@ eValueTypeVariableStatic
static variable
@ eValueTypeRegisterSet
A collection of stack frame register values.
@ eValueTypeVariableThreadLocal
thread local storage variable
std::shared_ptr< lldb_private::Target > TargetSP
std::shared_ptr< lldb_private::Module > ModuleSP
void Clear()
Clear the object's state.
static TestingProperties & GetGlobalTestingProperties()
UserID(lldb::user_id_t uid=LLDB_INVALID_UID)
Construct with optional user ID.
lldb::user_id_t GetID() const
Get accessor for the user ID.