File indexing completed on 2026-05-10 08:42:53
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLDB_SYMBOL_VARIABLE_H
0010 #define LLDB_SYMBOL_VARIABLE_H
0011
0012 #include "lldb/Core/Declaration.h"
0013 #include "lldb/Core/Mangled.h"
0014 #include "lldb/Expression/DWARFExpressionList.h"
0015 #include "lldb/Utility/CompletionRequest.h"
0016 #include "lldb/Utility/RangeMap.h"
0017 #include "lldb/Utility/UserID.h"
0018 #include "lldb/lldb-enumerations.h"
0019 #include "lldb/lldb-private.h"
0020 #include <memory>
0021 #include <vector>
0022
0023 namespace lldb_private {
0024
0025 class Variable : public UserID, public std::enable_shared_from_this<Variable> {
0026 public:
0027 typedef RangeVector<lldb::addr_t, lldb::addr_t> RangeList;
0028
0029
0030
0031
0032 Variable(lldb::user_id_t uid, const char *name, const char *mangled,
0033 const lldb::SymbolFileTypeSP &symfile_type_sp, lldb::ValueType scope,
0034 SymbolContextScope *owner_scope, const RangeList &scope_range,
0035 Declaration *decl, const DWARFExpressionList &location,
0036 bool external, bool artificial, bool location_is_constant_data,
0037 bool static_member = false);
0038
0039 virtual ~Variable();
0040
0041 void Dump(Stream *s, bool show_context) const;
0042
0043 bool DumpDeclaration(Stream *s, bool show_fullpaths, bool show_module);
0044
0045 const Declaration &GetDeclaration() const { return m_declaration; }
0046
0047 ConstString GetName() const;
0048
0049 ConstString GetUnqualifiedName() const;
0050
0051 SymbolContextScope *GetSymbolContextScope() const { return m_owner_scope; }
0052
0053
0054
0055
0056
0057
0058 bool NameMatches(ConstString name) const;
0059
0060 bool NameMatches(const RegularExpression ®ex) const;
0061
0062 Type *GetType();
0063
0064 lldb::LanguageType GetLanguage() const;
0065
0066 lldb::ValueType GetScope() const { return m_scope; }
0067
0068 const RangeList &GetScopeRange() const { return m_scope_range; }
0069
0070 bool IsExternal() const { return m_external; }
0071
0072 bool IsArtificial() const { return m_artificial; }
0073
0074 bool IsStaticMember() const { return m_static_member; }
0075
0076 DWARFExpressionList &LocationExpressionList() { return m_location_list; }
0077
0078 const DWARFExpressionList &LocationExpressionList() const {
0079 return m_location_list;
0080 }
0081
0082
0083
0084 bool DumpLocations(Stream *s, const Address &address);
0085
0086 size_t MemorySize() const;
0087
0088 void CalculateSymbolContext(SymbolContext *sc);
0089
0090 bool IsInScope(StackFrame *frame);
0091
0092 bool LocationIsValidForFrame(StackFrame *frame);
0093
0094 bool LocationIsValidForAddress(const Address &address);
0095
0096 bool GetLocationIsConstantValueData() const { return m_loc_is_const_data; }
0097
0098 void SetLocationIsConstantValueData(bool b) { m_loc_is_const_data = b; }
0099
0100 typedef size_t (*GetVariableCallback)(void *baton, const char *name,
0101 VariableList &var_list);
0102
0103 static Status GetValuesForVariableExpressionPath(
0104 llvm::StringRef variable_expr_path, ExecutionContextScope *scope,
0105 GetVariableCallback callback, void *baton, VariableList &variable_list,
0106 ValueObjectList &valobj_list);
0107
0108 static void AutoComplete(const ExecutionContext &exe_ctx,
0109 CompletionRequest &request);
0110
0111 CompilerDeclContext GetDeclContext();
0112
0113 CompilerDecl GetDecl();
0114
0115 protected:
0116
0117 ConstString m_name;
0118
0119 Mangled m_mangled;
0120
0121
0122 lldb::SymbolFileTypeSP m_symfile_type_sp;
0123 lldb::ValueType m_scope;
0124
0125 SymbolContextScope *m_owner_scope;
0126
0127
0128 RangeList m_scope_range;
0129
0130 Declaration m_declaration;
0131
0132
0133 DWARFExpressionList m_location_list;
0134
0135 unsigned m_external : 1;
0136
0137 unsigned m_artificial : 1;
0138
0139
0140 unsigned m_loc_is_const_data : 1;
0141
0142 unsigned m_static_member : 1;
0143
0144 private:
0145 Variable(const Variable &rhs) = delete;
0146 Variable &operator=(const Variable &rhs) = delete;
0147 };
0148
0149 }
0150
0151 #endif