]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Symbol/Variable.h
Import CK as of commit 0f017230ccc86929f56bf44ef2dca93d7df8076b.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Symbol / Variable.h
1 //===-- Variable.h -----------------------------------------------*- C++-*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef liblldb_Variable_h_
11 #define liblldb_Variable_h_
12
13 #include <memory>
14 #include <vector>
15
16 #include "lldb/Core/Mangled.h"
17 #include "lldb/Core/RangeMap.h"
18 #include "lldb/Expression/DWARFExpression.h"
19 #include "lldb/Symbol/Declaration.h"
20 #include "lldb/Utility/UserID.h"
21 #include "lldb/lldb-enumerations.h"
22 #include "lldb/lldb-private.h"
23
24 namespace lldb_private {
25
26 class Variable : public UserID, public std::enable_shared_from_this<Variable> {
27 public:
28   typedef RangeVector<lldb::addr_t, lldb::addr_t> RangeList;
29
30   //------------------------------------------------------------------
31   // Constructors and Destructors
32   //------------------------------------------------------------------
33   Variable(lldb::user_id_t uid, const char *name,
34            const char
35                *mangled, // The mangled or fully qualified name of the variable.
36            const lldb::SymbolFileTypeSP &symfile_type_sp,
37            lldb::ValueType scope, SymbolContextScope *owner_scope,
38            const RangeList &scope_range, Declaration *decl,
39            const DWARFExpression &location, bool external, bool artificial,
40            bool static_member = false);
41
42   virtual ~Variable();
43
44   void Dump(Stream *s, bool show_context) const;
45
46   bool DumpDeclaration(Stream *s, bool show_fullpaths, bool show_module);
47
48   const Declaration &GetDeclaration() const { return m_declaration; }
49
50   ConstString GetName() const;
51
52   ConstString GetUnqualifiedName() const;
53
54   SymbolContextScope *GetSymbolContextScope() const { return m_owner_scope; }
55
56   // Since a variable can have a basename "i" and also a mangled
57   // named "_ZN12_GLOBAL__N_11iE" and a demangled mangled name
58   // "(anonymous namespace)::i", this function will allow a generic match
59   // function that can be called by commands and expression parsers to make
60   // sure we match anything we come across.
61   bool NameMatches(const ConstString &name) const;
62
63   bool NameMatches(const RegularExpression &regex) const;
64
65   Type *GetType();
66
67   lldb::LanguageType GetLanguage() const;
68
69   lldb::ValueType GetScope() const { return m_scope; }
70
71   bool IsExternal() const { return m_external; }
72
73   bool IsArtificial() const { return m_artificial; }
74
75   bool IsStaticMember() const { return m_static_member; }
76
77   DWARFExpression &LocationExpression() { return m_location; }
78
79   const DWARFExpression &LocationExpression() const { return m_location; }
80
81   bool DumpLocationForAddress(Stream *s, const Address &address);
82
83   size_t MemorySize() const;
84
85   void CalculateSymbolContext(SymbolContext *sc);
86
87   bool IsInScope(StackFrame *frame);
88
89   bool LocationIsValidForFrame(StackFrame *frame);
90
91   bool LocationIsValidForAddress(const Address &address);
92
93   bool GetLocationIsConstantValueData() const { return m_loc_is_const_data; }
94
95   void SetLocationIsConstantValueData(bool b) { m_loc_is_const_data = b; }
96
97   typedef size_t (*GetVariableCallback)(void *baton, const char *name,
98                                         VariableList &var_list);
99
100   static Status GetValuesForVariableExpressionPath(
101       llvm::StringRef variable_expr_path, ExecutionContextScope *scope,
102       GetVariableCallback callback, void *baton, VariableList &variable_list,
103       ValueObjectList &valobj_list);
104
105   static size_t AutoComplete(const ExecutionContext &exe_ctx,
106                              llvm::StringRef name, StringList &matches,
107                              bool &word_complete);
108
109   CompilerDeclContext GetDeclContext();
110
111   CompilerDecl GetDecl();
112
113 protected:
114   ConstString m_name; // The basename of the variable (no namespaces)
115   Mangled m_mangled;  // The mangled name of the variable
116   lldb::SymbolFileTypeSP m_symfile_type_sp; // The type pointer of the variable
117                                             // (int, struct, class, etc)
118   lldb::ValueType m_scope;                  // global, parameter, local
119   SymbolContextScope
120       *m_owner_scope; // The symbol file scope that this variable was defined in
121   RangeList m_scope_range; // The list of ranges inside the owner's scope where
122                            // this variable is valid
123   Declaration m_declaration;  // Declaration location for this item.
124   DWARFExpression m_location; // The location of this variable that can be fed
125                               // to DWARFExpression::Evaluate()
126   uint8_t m_external : 1,     // Visible outside the containing compile unit?
127       m_artificial : 1, // Non-zero if the variable is not explicitly declared
128                         // in source
129       m_loc_is_const_data : 1, // The m_location expression contains the
130                                // constant variable value data, not a DWARF
131                                // location
132       m_static_member : 1; // Non-zero if variable is static member of a class
133                            // or struct.
134 private:
135   Variable(const Variable &rhs);
136   Variable &operator=(const Variable &rhs);
137 };
138
139 } // namespace lldb_private
140
141 #endif // liblldb_Variable_h_