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 liblldb_ValueObjectVariable_h_
10 #define liblldb_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 <stddef.h>
22 #include <stdint.h>
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   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   CompilerType GetCompilerTypeImpl() override;
72 
73   lldb::VariableSP
74       m_variable_sp;      ///< The variable that this value object is based upon
75   Value m_resolved_value; ///< The value that DWARFExpression resolves this
76                           ///variable to before we patch it up
77 
78 private:
79   ValueObjectVariable(ExecutionContextScope *exe_scope,
80                       const lldb::VariableSP &var_sp);
81   // For ValueObject only
82   DISALLOW_COPY_AND_ASSIGN(ValueObjectVariable);
83 };
84 
85 } // namespace lldb_private
86 
87 #endif // liblldb_ValueObjectVariable_h_
88