1//===-- ValueObjectRegister.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_ValueObjectRegister_h_
11#define liblldb_ValueObjectRegister_h_
12
13// C Includes
14// C++ Includes
15// Other libraries and framework includes
16// Project includes
17#include "lldb/lldb-private.h"
18#include "lldb/Core/RegisterValue.h"
19#include "lldb/Core/ValueObject.h"
20
21namespace lldb_private {
22
23//----------------------------------------------------------------------
24// A ValueObject that contains a root variable that may or may not
25// have children.
26//----------------------------------------------------------------------
27class ValueObjectRegisterContext : public ValueObject
28{
29public:
30
31    virtual
32    ~ValueObjectRegisterContext();
33
34    virtual uint64_t
35    GetByteSize();
36
37    virtual lldb::ValueType
38    GetValueType () const
39    {
40        return lldb::eValueTypeRegisterSet;
41    }
42
43    virtual ConstString
44    GetTypeName();
45
46    virtual ConstString
47    GetQualifiedTypeName();
48
49    virtual size_t
50    CalculateNumChildren();
51
52    virtual ValueObject *
53    CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index);
54
55protected:
56    virtual bool
57    UpdateValue ();
58
59    virtual ClangASTType
60    GetClangTypeImpl ();
61
62    lldb::RegisterContextSP m_reg_ctx_sp;
63
64private:
65    ValueObjectRegisterContext (ValueObject &parent, lldb::RegisterContextSP &reg_ctx_sp);
66    //------------------------------------------------------------------
67    // For ValueObject only
68    //------------------------------------------------------------------
69    DISALLOW_COPY_AND_ASSIGN (ValueObjectRegisterContext);
70};
71
72class ValueObjectRegisterSet : public ValueObject
73{
74public:
75    static lldb::ValueObjectSP
76    Create (ExecutionContextScope *exe_scope, lldb::RegisterContextSP &reg_ctx_sp, uint32_t set_idx);
77
78    virtual
79    ~ValueObjectRegisterSet();
80
81    virtual uint64_t
82    GetByteSize();
83
84    virtual lldb::ValueType
85    GetValueType () const
86    {
87        return lldb::eValueTypeRegisterSet;
88    }
89
90    virtual ConstString
91    GetTypeName();
92
93    virtual ConstString
94    GetQualifiedTypeName();
95
96    virtual size_t
97    CalculateNumChildren();
98
99    virtual ValueObject *
100    CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index);
101
102    virtual lldb::ValueObjectSP
103    GetChildMemberWithName (const ConstString &name, bool can_create);
104
105    virtual size_t
106    GetIndexOfChildWithName (const ConstString &name);
107
108
109protected:
110    virtual bool
111    UpdateValue ();
112
113    virtual ClangASTType
114    GetClangTypeImpl ();
115
116    lldb::RegisterContextSP m_reg_ctx_sp;
117    const RegisterSet *m_reg_set;
118    uint32_t m_reg_set_idx;
119
120private:
121    friend class ValueObjectRegisterContext;
122    ValueObjectRegisterSet (ExecutionContextScope *exe_scope, lldb::RegisterContextSP &reg_ctx_sp, uint32_t set_idx);
123
124    //------------------------------------------------------------------
125    // For ValueObject only
126    //------------------------------------------------------------------
127    DISALLOW_COPY_AND_ASSIGN (ValueObjectRegisterSet);
128};
129
130class ValueObjectRegister : public ValueObject
131{
132public:
133    static lldb::ValueObjectSP
134    Create (ExecutionContextScope *exe_scope, lldb::RegisterContextSP &reg_ctx_sp, uint32_t reg_num);
135
136    virtual
137    ~ValueObjectRegister();
138
139    virtual uint64_t
140    GetByteSize();
141
142    virtual lldb::ValueType
143    GetValueType () const
144    {
145        return lldb::eValueTypeRegister;
146    }
147
148    virtual ConstString
149    GetTypeName();
150
151    virtual size_t
152    CalculateNumChildren();
153
154    virtual bool
155    SetValueFromCString (const char *value_str, Error& error);
156
157    virtual bool
158    SetData (DataExtractor &data, Error &error);
159
160    virtual bool
161    ResolveValue (Scalar &scalar);
162
163    virtual void
164    GetExpressionPath (Stream &s, bool qualify_cxx_base_classes, GetExpressionPathFormat epformat = eGetExpressionPathFormatDereferencePointers);
165
166protected:
167    virtual bool
168    UpdateValue ();
169
170    virtual ClangASTType
171    GetClangTypeImpl ();
172
173    lldb::RegisterContextSP m_reg_ctx_sp;
174    RegisterInfo m_reg_info;
175    RegisterValue m_reg_value;
176    ConstString m_type_name;
177    ClangASTType m_clang_type;
178
179private:
180    void
181    ConstructObject (uint32_t reg_num);
182
183    friend class ValueObjectRegisterSet;
184    ValueObjectRegister (ValueObject &parent, lldb::RegisterContextSP &reg_ctx_sp, uint32_t reg_num);
185    ValueObjectRegister (ExecutionContextScope *exe_scope, lldb::RegisterContextSP &reg_ctx_sp, uint32_t reg_num);
186
187    //------------------------------------------------------------------
188    // For ValueObject only
189    //------------------------------------------------------------------
190    DISALLOW_COPY_AND_ASSIGN (ValueObjectRegister);
191};
192
193} // namespace lldb_private
194
195#endif  // liblldb_ValueObjectRegister_h_
196