SBValue.i revision de856cc86c68a51e93aa72b8a478faf50de663c0
1//===-- SWIG Interface for SBValue ------------------------------*- 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
10namespace lldb {
11
12%feature("docstring",
13"Represents the value of a variable, a register, or an expression.
14
15SBValue supports iteration through its child, which in turn is represented
16as an SBValue.  For example, we can get the general purpose registers of a
17frame as an SBValue, and iterate through all the registers,
18
19    registerSet = frame.GetRegisters() # Returns an SBValueList.
20    for regs in registerSet:
21        if 'general purpose registers' in regs.getName().lower():
22            GPRs = regs
23            break
24
25    print '%s (number of children = %d):' % (GPRs.GetName(), GPRs.GetNumChildren())
26    for reg in GPRs:
27        print 'Name: ', reg.GetName(), ' Value: ', reg.GetValue()
28
29produces the output:
30
31General Purpose Registers (number of children = 21):
32Name:  rax  Value:  0x0000000100000c5c
33Name:  rbx  Value:  0x0000000000000000
34Name:  rcx  Value:  0x00007fff5fbffec0
35Name:  rdx  Value:  0x00007fff5fbffeb8
36Name:  rdi  Value:  0x0000000000000001
37Name:  rsi  Value:  0x00007fff5fbffea8
38Name:  rbp  Value:  0x00007fff5fbffe80
39Name:  rsp  Value:  0x00007fff5fbffe60
40Name:  r8  Value:  0x0000000008668682
41Name:  r9  Value:  0x0000000000000000
42Name:  r10  Value:  0x0000000000001200
43Name:  r11  Value:  0x0000000000000206
44Name:  r12  Value:  0x0000000000000000
45Name:  r13  Value:  0x0000000000000000
46Name:  r14  Value:  0x0000000000000000
47Name:  r15  Value:  0x0000000000000000
48Name:  rip  Value:  0x0000000100000dae
49Name:  rflags  Value:  0x0000000000000206
50Name:  cs  Value:  0x0000000000000027
51Name:  fs  Value:  0x0000000000000010
52Name:  gs  Value:  0x0000000000000048
53
54See also linked_list_iter() for another perspective on how to iterate through an
55SBValue instance which interprets the value object as representing the head of a
56linked list."
57) SBValue;
58class SBValue
59{
60public:
61    SBValue ();
62
63    SBValue (const SBValue &rhs);
64
65    ~SBValue ();
66
67    bool
68    IsValid() const;
69
70    SBError
71    GetError();
72
73    lldb::user_id_t
74    GetID ();
75
76    const char *
77    GetName();
78
79    const char *
80    GetTypeName ();
81
82    size_t
83    GetByteSize ();
84
85    bool
86    IsInScope (const lldb::SBFrame &frame);  // DEPRECATED - SBValues know their own frames.
87
88    bool
89    IsInScope ();
90
91    lldb::Format
92    GetFormat () const;
93
94    void
95    SetFormat (lldb::Format format);
96
97    const char *
98    GetValue (const lldb::SBFrame &frame);   // DEPRECATED - SBValues know their own frames.
99
100    const char *
101    GetValue ();
102
103    ValueType
104    GetValueType ();
105
106    bool
107    GetValueDidChange (const lldb::SBFrame &frame);  // DEPRECATED - SBValues know their own frames.
108
109    bool
110    GetValueDidChange ();
111
112    const char *
113    GetSummary (const lldb::SBFrame &frame);  // DEPRECATED - SBValues know their own frames.
114
115    const char *
116    GetSummary ();
117
118    const char *
119    GetObjectDescription (const lldb::SBFrame &frame);  // DEPRECATED - SBValues know their own frames.
120
121    const char *
122    GetObjectDescription ();
123
124    const char *
125    GetLocation (const lldb::SBFrame &frame);  // DEPRECATED - SBValues know their own frames.
126
127    const char *
128    GetLocation ();
129
130    bool
131    SetValueFromCString (const lldb::SBFrame &frame, const char *value_str);  // DEPRECATED - SBValues know their own frames.
132
133    bool
134    SetValueFromCString (const char *value_str);
135
136    lldb::SBValue
137    GetChildAtIndex (uint32_t idx);
138
139    %feature("docstring", "
140    //------------------------------------------------------------------
141    /// Get a child value by index from a value.
142    ///
143    /// Structs, unions, classes, arrays and and pointers have child
144    /// values that can be access by index.
145    ///
146    /// Structs and unions access child members using a zero based index
147    /// for each child member. For
148    ///
149    /// Classes reserve the first indexes for base classes that have
150    /// members (empty base classes are omitted), and all members of the
151    /// current class will then follow the base classes.
152    ///
153    /// Pointers differ depending on what they point to. If the pointer
154    /// points to a simple type, the child at index zero
155    /// is the only child value available, unless \a synthetic_allowed
156    /// is \b true, in which case the pointer will be used as an array
157    /// and can create 'synthetic' child values using positive or
158    /// negative indexes. If the pointer points to an aggregate type
159    /// (an array, class, union, struct), then the pointee is
160    /// transparently skipped and any children are going to be the indexes
161    /// of the child values within the aggregate type. For example if
162    /// we have a 'Point' type and we have a SBValue that contains a
163    /// pointer to a 'Point' type, then the child at index zero will be
164    /// the 'x' member, and the child at index 1 will be the 'y' member
165    /// (the child at index zero won't be a 'Point' instance).
166    ///
167    /// Arrays have a preset number of children that can be accessed by
168    /// index and will returns invalid child values for indexes that are
169    /// out of bounds unless the \a synthetic_allowed is \b true. In this
170    /// case the array can create 'synthetic' child values for indexes
171    /// that aren't in the array bounds using positive or negative
172    /// indexes.
173    ///
174    /// @param[in] idx
175    ///     The index of the child value to get
176    ///
177    /// @param[in] use_dynamic
178    ///     An enumeration that specifies wether to get dynamic values,
179    ///     and also if the target can be run to figure out the dynamic
180    ///     type of the child value.
181    ///
182    /// @param[in] synthetic_allowed
183    ///     If \b true, then allow child values to be created by index
184    ///     for pointers and arrays for indexes that normally wouldn't
185    ///     be allowed.
186    ///
187    /// @return
188    ///     A new SBValue object that represents the child member value.
189    //------------------------------------------------------------------
190    ") GetChildAtIndex;
191    lldb::SBValue
192    GetChildAtIndex (uint32_t idx,
193                     lldb::DynamicValueType use_dynamic,
194                     bool can_create_synthetic);
195
196    %feature("docstring", "
197    //------------------------------------------------------------------
198    /// Returns the child member index.
199    ///
200    /// Matches children of this object only and will match base classes and
201    /// member names if this is a clang typed object.
202    ///
203    /// @param[in] name
204    ///     The name of the child value to get
205    ///
206    /// @return
207    ///     An index to the child member value.
208    //------------------------------------------------------------------
209    ") GetIndexOfChildWithName;
210    uint32_t
211    GetIndexOfChildWithName (const char *name);
212
213    lldb::SBValue
214    GetChildMemberWithName (const char *name);
215
216    %feature("docstring", "
217    //------------------------------------------------------------------
218    /// Returns the child member value.
219    ///
220    /// Matches child members of this object and child members of any base
221    /// classes.
222    ///
223    /// @param[in] name
224    ///     The name of the child value to get
225    ///
226    /// @param[in] use_dynamic
227    ///     An enumeration that specifies wether to get dynamic values,
228    ///     and also if the target can be run to figure out the dynamic
229    ///     type of the child value.
230    ///
231    /// @return
232    ///     A new SBValue object that represents the child member value.
233    //------------------------------------------------------------------
234    ") GetChildMemberWithName;
235    lldb::SBValue
236    GetChildMemberWithName (const char *name, lldb::DynamicValueType use_dynamic);
237
238    %feature("docstring", "Expands nested expressions like .a->b[0].c[1]->d."
239    ) GetValueForExpressionPath;
240    lldb::SBValue
241    GetValueForExpressionPath(const char* expr_path);
242
243    uint32_t
244    GetNumChildren ();
245
246    void *
247    GetOpaqueType();
248
249
250    lldb::SBValue
251    Dereference ();
252
253    bool
254    TypeIsPointerType ();
255
256    bool
257    GetDescription (lldb::SBStream &description);
258
259    bool
260    GetExpressionPath (lldb::SBStream &description);
261
262    %feature("docstring", "Returns an expression path for this value."
263    ) GetValueForExpressionPath;
264    bool
265    GetExpressionPath (lldb::SBStream &description, bool qualify_cxx_base_classes);
266};
267
268} // namespace lldb
269