1 //===-- ValueObjectVariable.h -----------------------------------*- C++ -*-===//
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 
9 #ifndef LLDB_CORE_VALUEOBJECTVARIABLE_H
10 #define LLDB_CORE_VALUEOBJECTVARIABLE_H
11 
12 #include "lldb/Core/ValueObject.h"
13 
14 #include "lldb/Core/Value.h"
15 #include "lldb/Symbol/CompilerType.h"
16 #include "lldb/Utility/ConstString.h"
17 #include "lldb/lldb-defines.h"
18 #include "lldb/lldb-enumerations.h"
19 #include "lldb/lldb-forward.h"
20 
21 #include <cstddef>
22 #include <cstdint>
23 
24 namespace lldb_private {
25 class DataExtractor;
26 class Declaration;
27 class Status;
28 class ExecutionContextScope;
29 class SymbolContextScope;
30 
31 /// A ValueObject that contains a root variable that may or may not
32 /// have children.
33 class ValueObjectVariable : public ValueObject {
34 public:
35   ~ValueObjectVariable() override;
36 
37   static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope,
38                                     const lldb::VariableSP &var_sp);
39 
40   llvm::Optional<uint64_t> GetByteSize() override;
41 
42   ConstString GetTypeName() override;
43 
44   ConstString GetQualifiedTypeName() override;
45 
46   ConstString GetDisplayTypeName() override;
47 
48   size_t CalculateNumChildren(uint32_t max) override;
49 
50   lldb::ValueType GetValueType() const override;
51 
52   bool IsInScope() override;
53 
54   lldb::ModuleSP GetModule() override;
55 
56   SymbolContextScope *GetSymbolContextScope() override;
57 
58   bool GetDeclaration(Declaration &decl) override;
59 
60   const char *GetLocationAsCString() override;
61 
62   bool SetValueFromCString(const char *value_str, Status &error) override;
63 
64   bool SetData(DataExtractor &data, Status &error) override;
65 
66   lldb::VariableSP GetVariable() override { return m_variable_sp; }
67 
68 protected:
69   bool UpdateValue() override;
70 
71   void DoUpdateChildrenAddressType(ValueObject &valobj) override;
72 
73   CompilerType GetCompilerTypeImpl() override;
74 
75   /// The variable that this value object is based upon.
76   lldb::VariableSP m_variable_sp;
77   ///< The value that DWARFExpression resolves this variable to before we patch
78   ///< it up.
79   Value m_resolved_value;
80 
81 private:
82   ValueObjectVariable(ExecutionContextScope *exe_scope,
83                       ValueObjectManager &manager,
84                       const lldb::VariableSP &var_sp);
85   // For ValueObject only
86   ValueObjectVariable(const ValueObjectVariable &) = delete;
87   const ValueObjectVariable &operator=(const ValueObjectVariable &) = delete;
88 };
89 
90 } // namespace lldb_private
91 
92 #endif // LLDB_CORE_VALUEOBJECTVARIABLE_H
93