blob: 8792464b2451914e562af441068690e2a489a688 [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
Greg Claytond68e0892011-09-09 23:04:00 +000068 IsValid();
Johnny Chen854a1ba2011-07-18 19:08:30 +000069
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 Chen854a1ba2011-07-18 19:08:30 +000085 bool
86 IsInScope ();
87
88 lldb::Format
Greg Claytond68e0892011-09-09 23:04:00 +000089 GetFormat ();
Johnny Chen854a1ba2011-07-18 19:08:30 +000090
91 void
92 SetFormat (lldb::Format format);
93
Johnny Chen854a1ba2011-07-18 19:08:30 +000094 const char *
95 GetValue ();
96
Greg Clayton0fb0bcc2011-08-03 22:57:10 +000097 int64_t
Enrico Granatac92eb402011-08-04 01:41:02 +000098 GetValueAsSigned(SBError& error, int64_t fail_value=0);
Greg Clayton0fb0bcc2011-08-03 22:57:10 +000099
100 uint64_t
Enrico Granatac92eb402011-08-04 01:41:02 +0000101 GetValueAsUnsigned(SBError& error, uint64_t fail_value=0);
102
103 int64_t
104 GetValueAsSigned(int64_t fail_value=0);
105
106 uint64_t
Greg Clayton0fb0bcc2011-08-03 22:57:10 +0000107 GetValueAsUnsigned(uint64_t fail_value=0);
108
Johnny Chen854a1ba2011-07-18 19:08:30 +0000109 ValueType
110 GetValueType ();
111
Johnny Chen854a1ba2011-07-18 19:08:30 +0000112 bool
113 GetValueDidChange ();
114
Johnny Chen854a1ba2011-07-18 19:08:30 +0000115 const char *
116 GetSummary ();
117
Johnny Chen854a1ba2011-07-18 19:08:30 +0000118 const char *
119 GetObjectDescription ();
120
Johnny Chen854a1ba2011-07-18 19:08:30 +0000121 const char *
122 GetLocation ();
123
Johnny Chen854a1ba2011-07-18 19:08:30 +0000124 bool
125 SetValueFromCString (const char *value_str);
126
127 lldb::SBValue
128 GetChildAtIndex (uint32_t idx);
129
130 %feature("docstring", "
131 //------------------------------------------------------------------
132 /// Get a child value by index from a value.
133 ///
134 /// Structs, unions, classes, arrays and and pointers have child
135 /// values that can be access by index.
136 ///
137 /// Structs and unions access child members using a zero based index
138 /// for each child member. For
139 ///
140 /// Classes reserve the first indexes for base classes that have
141 /// members (empty base classes are omitted), and all members of the
142 /// current class will then follow the base classes.
143 ///
144 /// Pointers differ depending on what they point to. If the pointer
145 /// points to a simple type, the child at index zero
146 /// is the only child value available, unless \a synthetic_allowed
147 /// is \b true, in which case the pointer will be used as an array
148 /// and can create 'synthetic' child values using positive or
149 /// negative indexes. If the pointer points to an aggregate type
150 /// (an array, class, union, struct), then the pointee is
151 /// transparently skipped and any children are going to be the indexes
152 /// of the child values within the aggregate type. For example if
153 /// we have a 'Point' type and we have a SBValue that contains a
154 /// pointer to a 'Point' type, then the child at index zero will be
155 /// the 'x' member, and the child at index 1 will be the 'y' member
156 /// (the child at index zero won't be a 'Point' instance).
157 ///
158 /// Arrays have a preset number of children that can be accessed by
159 /// index and will returns invalid child values for indexes that are
160 /// out of bounds unless the \a synthetic_allowed is \b true. In this
161 /// case the array can create 'synthetic' child values for indexes
162 /// that aren't in the array bounds using positive or negative
163 /// indexes.
164 ///
165 /// @param[in] idx
166 /// The index of the child value to get
167 ///
168 /// @param[in] use_dynamic
169 /// An enumeration that specifies wether to get dynamic values,
170 /// and also if the target can be run to figure out the dynamic
171 /// type of the child value.
172 ///
173 /// @param[in] synthetic_allowed
174 /// If \b true, then allow child values to be created by index
175 /// for pointers and arrays for indexes that normally wouldn't
176 /// be allowed.
177 ///
178 /// @return
179 /// A new SBValue object that represents the child member value.
180 //------------------------------------------------------------------
181 ") GetChildAtIndex;
182 lldb::SBValue
183 GetChildAtIndex (uint32_t idx,
184 lldb::DynamicValueType use_dynamic,
185 bool can_create_synthetic);
Enrico Granata979e20d2011-07-29 19:53:35 +0000186
187 lldb::SBValue
Greg Claytond68e0892011-09-09 23:04:00 +0000188 CreateChildAtOffset (const char *name, uint32_t offset, lldb::SBType type);
Enrico Granata979e20d2011-07-29 19:53:35 +0000189
190 lldb::SBValue
Greg Claytond68e0892011-09-09 23:04:00 +0000191 SBValue::Cast (lldb::SBType type);
Johnny Chen854a1ba2011-07-18 19:08:30 +0000192
Enrico Granata979e20d2011-07-29 19:53:35 +0000193 lldb::SBValue
194 CreateValueFromExpression (const char *name, const char* expression);
195
196 lldb::SBValue
Greg Claytond68e0892011-09-09 23:04:00 +0000197 CreateValueFromAddress(const char* name, lldb::addr_t address, lldb::SBType type);
Enrico Granata979e20d2011-07-29 19:53:35 +0000198
Enrico Granata91544802011-09-06 19:20:51 +0000199 lldb::SBValue
200 CreateValueFromData (const char* name,
Greg Claytond68e0892011-09-09 23:04:00 +0000201 lldb::SBData data,
202 lldb::SBType type);
Enrico Granata91544802011-09-06 19:20:51 +0000203
Enrico Granata979e20d2011-07-29 19:53:35 +0000204 lldb::SBType
205 GetType();
206
Johnny Chen854a1ba2011-07-18 19:08:30 +0000207 %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
Johnny Chen854a1ba2011-07-18 19:08:30 +0000260 lldb::SBValue
261 Dereference ();
262
Enrico Granata979e20d2011-07-29 19:53:35 +0000263 lldb::SBValue
264 AddressOf();
265
Johnny Chen854a1ba2011-07-18 19:08:30 +0000266 bool
267 TypeIsPointerType ();
Enrico Granata979e20d2011-07-29 19:53:35 +0000268
269 lldb::SBTarget
270 GetTarget();
Johnny Chen854a1ba2011-07-18 19:08:30 +0000271
Enrico Granata979e20d2011-07-29 19:53:35 +0000272 lldb::SBProcess
273 GetProcess();
274
275 lldb::SBThread
276 GetThread();
277
278 lldb::SBFrame
279 GetFrame();
280
Johnny Chen854a1ba2011-07-18 19:08:30 +0000281 bool
282 GetDescription (lldb::SBStream &description);
283
284 bool
285 GetExpressionPath (lldb::SBStream &description);
Enrico Granata91544802011-09-06 19:20:51 +0000286
287 %feature("docstring", "
288 //------------------------------------------------------------------
289 /// Get an SBData wrapping what this SBValue points to.
290 ///
291 /// This method will dereference the current SBValue, if its
292 /// data type is a T* or T[], and extract item_count elements
293 /// of type T from it, copying their contents in an SBData.
294 ///
295 /// @param[in] item_idx
296 /// The index of the first item to retrieve. For an array
297 /// this is equivalent to array[item_idx], for a pointer
298 /// to *(pointer + item_idx). In either case, the measurement
299 /// unit for item_idx is the sizeof(T) rather than the byte
300 ///
301 /// @param[in] item_count
302 /// How many items should be copied into the output. By default
303 /// only one item is copied, but more can be asked for.
304 ///
305 /// @return
306 /// An SBData with the contents of the copied items, on success.
307 /// An empty SBData otherwise.
308 //------------------------------------------------------------------
309 ") GetPointeeData;
310 lldb::SBData
311 GetPointeeData (uint32_t item_idx = 0,
312 uint32_t item_count = 1);
313
314 %feature("docstring", "
315 //------------------------------------------------------------------
316 /// Get an SBData wrapping the contents of this SBValue.
317 ///
318 /// This method will read the contents of this object in memory
319 /// and copy them into an SBData for future use.
320 ///
321 /// @return
322 /// An SBData with the contents of this SBValue, on success.
323 /// An empty SBData otherwise.
324 //------------------------------------------------------------------
325 ") GetData;
326 lldb::SBData
327 GetData ();
328
329 lldb::addr_t
330 GetLoadAddress();
331
332 lldb::SBAddress
333 GetAddress();
Johnny Chen854a1ba2011-07-18 19:08:30 +0000334
335 %feature("docstring", "Returns an expression path for this value."
Enrico Granata91544802011-09-06 19:20:51 +0000336 ) GetExpressionPath;
Johnny Chen854a1ba2011-07-18 19:08:30 +0000337 bool
338 GetExpressionPath (lldb::SBStream &description, bool qualify_cxx_base_classes);
339};
340
341} // namespace lldb