blob: 68e97e3323eb058d1182f0c633ba376c74078a03 [file] [log] [blame]
Johnny Chen7be5a4f2011-07-18 19:15:22 +00001//===-- SWIG Interface for SBValue ------------------------------*- C++ -*-===//
Johnny Chen854a1ba2011-07-18 19:08:30 +00002//
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
Johnny Chende856cc2011-07-25 23:41:08 +000052Name: 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."
Johnny Chenc3fba812011-07-18 20:13:38 +000057) SBValue;
Johnny Chen854a1ba2011-07-18 19:08:30 +000058class 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
Johnny Chen7b9eeac2011-07-27 00:08:59 +000085 %define DEPRECATED
86 "The method which takes an SBFrame is deprecated - SBValues know their own frames."
87 %enddef
88
89 %feature("docstring", DEPRECATED) IsInScope;
Johnny Chen854a1ba2011-07-18 19:08:30 +000090 bool
Johnny Chen7b9eeac2011-07-27 00:08:59 +000091 IsInScope (const lldb::SBFrame &frame);
Johnny Chen854a1ba2011-07-18 19:08:30 +000092
93 bool
94 IsInScope ();
95
96 lldb::Format
97 GetFormat () const;
98
99 void
100 SetFormat (lldb::Format format);
101
Johnny Chen7b9eeac2011-07-27 00:08:59 +0000102 %feature("docstring", DEPRECATED) GetValue;
Johnny Chen854a1ba2011-07-18 19:08:30 +0000103 const char *
Johnny Chen7b9eeac2011-07-27 00:08:59 +0000104 GetValue (const lldb::SBFrame &frame);
Johnny Chen854a1ba2011-07-18 19:08:30 +0000105
106 const char *
107 GetValue ();
108
109 ValueType
110 GetValueType ();
111
Johnny Chen7b9eeac2011-07-27 00:08:59 +0000112 %feature("docstring", DEPRECATED) GetValueDidChange;
Johnny Chen854a1ba2011-07-18 19:08:30 +0000113 bool
Johnny Chen7b9eeac2011-07-27 00:08:59 +0000114 GetValueDidChange (const lldb::SBFrame &frame);
Johnny Chen854a1ba2011-07-18 19:08:30 +0000115
116 bool
117 GetValueDidChange ();
118
Johnny Chen7b9eeac2011-07-27 00:08:59 +0000119 %feature("docstring", DEPRECATED) GetSummary;
Johnny Chen854a1ba2011-07-18 19:08:30 +0000120 const char *
Johnny Chen7b9eeac2011-07-27 00:08:59 +0000121 GetSummary (const lldb::SBFrame &frame);
Johnny Chen854a1ba2011-07-18 19:08:30 +0000122
123 const char *
124 GetSummary ();
125
Johnny Chen7b9eeac2011-07-27 00:08:59 +0000126 %feature("docstring", DEPRECATED) GetObjectDescription;
Johnny Chen854a1ba2011-07-18 19:08:30 +0000127 const char *
Johnny Chen7b9eeac2011-07-27 00:08:59 +0000128 GetObjectDescription (const lldb::SBFrame &frame);
Johnny Chen854a1ba2011-07-18 19:08:30 +0000129
130 const char *
131 GetObjectDescription ();
132
Johnny Chen7b9eeac2011-07-27 00:08:59 +0000133 %feature("docstring", DEPRECATED) GetLocation;
Johnny Chen854a1ba2011-07-18 19:08:30 +0000134 const char *
Johnny Chen7b9eeac2011-07-27 00:08:59 +0000135 GetLocation (const lldb::SBFrame &frame);
Johnny Chen854a1ba2011-07-18 19:08:30 +0000136
137 const char *
138 GetLocation ();
139
Johnny Chen7b9eeac2011-07-27 00:08:59 +0000140 %feature("docstring", DEPRECATED) SetValueFromCString;
Johnny Chen854a1ba2011-07-18 19:08:30 +0000141 bool
Johnny Chen7b9eeac2011-07-27 00:08:59 +0000142 SetValueFromCString (const lldb::SBFrame &frame, const char *value_str);
Johnny Chen854a1ba2011-07-18 19:08:30 +0000143
144 bool
145 SetValueFromCString (const char *value_str);
146
147 lldb::SBValue
148 GetChildAtIndex (uint32_t idx);
149
150 %feature("docstring", "
151 //------------------------------------------------------------------
152 /// Get a child value by index from a value.
153 ///
154 /// Structs, unions, classes, arrays and and pointers have child
155 /// values that can be access by index.
156 ///
157 /// Structs and unions access child members using a zero based index
158 /// for each child member. For
159 ///
160 /// Classes reserve the first indexes for base classes that have
161 /// members (empty base classes are omitted), and all members of the
162 /// current class will then follow the base classes.
163 ///
164 /// Pointers differ depending on what they point to. If the pointer
165 /// points to a simple type, the child at index zero
166 /// is the only child value available, unless \a synthetic_allowed
167 /// is \b true, in which case the pointer will be used as an array
168 /// and can create 'synthetic' child values using positive or
169 /// negative indexes. If the pointer points to an aggregate type
170 /// (an array, class, union, struct), then the pointee is
171 /// transparently skipped and any children are going to be the indexes
172 /// of the child values within the aggregate type. For example if
173 /// we have a 'Point' type and we have a SBValue that contains a
174 /// pointer to a 'Point' type, then the child at index zero will be
175 /// the 'x' member, and the child at index 1 will be the 'y' member
176 /// (the child at index zero won't be a 'Point' instance).
177 ///
178 /// Arrays have a preset number of children that can be accessed by
179 /// index and will returns invalid child values for indexes that are
180 /// out of bounds unless the \a synthetic_allowed is \b true. In this
181 /// case the array can create 'synthetic' child values for indexes
182 /// that aren't in the array bounds using positive or negative
183 /// indexes.
184 ///
185 /// @param[in] idx
186 /// The index of the child value to get
187 ///
188 /// @param[in] use_dynamic
189 /// An enumeration that specifies wether to get dynamic values,
190 /// and also if the target can be run to figure out the dynamic
191 /// type of the child value.
192 ///
193 /// @param[in] synthetic_allowed
194 /// If \b true, then allow child values to be created by index
195 /// for pointers and arrays for indexes that normally wouldn't
196 /// be allowed.
197 ///
198 /// @return
199 /// A new SBValue object that represents the child member value.
200 //------------------------------------------------------------------
201 ") GetChildAtIndex;
202 lldb::SBValue
203 GetChildAtIndex (uint32_t idx,
204 lldb::DynamicValueType use_dynamic,
205 bool can_create_synthetic);
206
207 %feature("docstring", "
208 //------------------------------------------------------------------
209 /// Returns the child member index.
210 ///
211 /// Matches children of this object only and will match base classes and
212 /// member names if this is a clang typed object.
213 ///
214 /// @param[in] name
215 /// The name of the child value to get
216 ///
217 /// @return
218 /// An index to the child member value.
219 //------------------------------------------------------------------
220 ") GetIndexOfChildWithName;
221 uint32_t
222 GetIndexOfChildWithName (const char *name);
223
224 lldb::SBValue
225 GetChildMemberWithName (const char *name);
226
227 %feature("docstring", "
228 //------------------------------------------------------------------
229 /// Returns the child member value.
230 ///
231 /// Matches child members of this object and child members of any base
232 /// classes.
233 ///
234 /// @param[in] name
235 /// The name of the child value to get
236 ///
237 /// @param[in] use_dynamic
238 /// An enumeration that specifies wether to get dynamic values,
239 /// and also if the target can be run to figure out the dynamic
240 /// type of the child value.
241 ///
242 /// @return
243 /// A new SBValue object that represents the child member value.
244 //------------------------------------------------------------------
245 ") GetChildMemberWithName;
246 lldb::SBValue
247 GetChildMemberWithName (const char *name, lldb::DynamicValueType use_dynamic);
248
249 %feature("docstring", "Expands nested expressions like .a->b[0].c[1]->d."
250 ) GetValueForExpressionPath;
251 lldb::SBValue
252 GetValueForExpressionPath(const char* expr_path);
253
254 uint32_t
255 GetNumChildren ();
256
257 void *
258 GetOpaqueType();
259
260
261 lldb::SBValue
262 Dereference ();
263
264 bool
265 TypeIsPointerType ();
266
267 bool
268 GetDescription (lldb::SBStream &description);
269
270 bool
271 GetExpressionPath (lldb::SBStream &description);
272
273 %feature("docstring", "Returns an expression path for this value."
274 ) GetValueForExpressionPath;
275 bool
276 GetExpressionPath (lldb::SBStream &description, bool qualify_cxx_base_classes);
277};
278
279} // namespace lldb