blob: a1ab884c589b12a652bb353ec11d990cd9ce9e67 [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
Jim Ingham1b425752011-12-08 19:44:08 +0000121 lldb::SBValue
122 GetDynamicValue (lldb::DynamicValueType use_dynamic);
123
124 lldb::SBValue
125 GetStaticValue ();
126
127 bool
128 IsDynamic();
129
Johnny Chen854a1ba2011-07-18 19:08:30 +0000130 const char *
131 GetLocation ();
132
Johnny Chen854a1ba2011-07-18 19:08:30 +0000133 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);
Enrico Granata979e20d2011-07-29 19:53:35 +0000195
196 lldb::SBValue
Greg Claytond68e0892011-09-09 23:04:00 +0000197 CreateChildAtOffset (const char *name, uint32_t offset, lldb::SBType type);
Enrico Granata979e20d2011-07-29 19:53:35 +0000198
199 lldb::SBValue
Greg Claytond68e0892011-09-09 23:04:00 +0000200 SBValue::Cast (lldb::SBType type);
Johnny Chen854a1ba2011-07-18 19:08:30 +0000201
Enrico Granata979e20d2011-07-29 19:53:35 +0000202 lldb::SBValue
203 CreateValueFromExpression (const char *name, const char* expression);
204
205 lldb::SBValue
Greg Claytond68e0892011-09-09 23:04:00 +0000206 CreateValueFromAddress(const char* name, lldb::addr_t address, lldb::SBType type);
Enrico Granata979e20d2011-07-29 19:53:35 +0000207
Enrico Granata91544802011-09-06 19:20:51 +0000208 lldb::SBValue
209 CreateValueFromData (const char* name,
Greg Claytond68e0892011-09-09 23:04:00 +0000210 lldb::SBData data,
211 lldb::SBType type);
Enrico Granata91544802011-09-06 19:20:51 +0000212
Enrico Granata979e20d2011-07-29 19:53:35 +0000213 lldb::SBType
214 GetType();
215
Johnny Chen854a1ba2011-07-18 19:08:30 +0000216 %feature("docstring", "
217 //------------------------------------------------------------------
218 /// Returns the child member index.
219 ///
220 /// Matches children of this object only and will match base classes and
221 /// member names if this is a clang typed object.
222 ///
223 /// @param[in] name
224 /// The name of the child value to get
225 ///
226 /// @return
227 /// An index to the child member value.
228 //------------------------------------------------------------------
229 ") GetIndexOfChildWithName;
230 uint32_t
231 GetIndexOfChildWithName (const char *name);
232
233 lldb::SBValue
234 GetChildMemberWithName (const char *name);
235
236 %feature("docstring", "
237 //------------------------------------------------------------------
238 /// Returns the child member value.
239 ///
240 /// Matches child members of this object and child members of any base
241 /// classes.
242 ///
243 /// @param[in] name
244 /// The name of the child value to get
245 ///
246 /// @param[in] use_dynamic
247 /// An enumeration that specifies wether to get dynamic values,
248 /// and also if the target can be run to figure out the dynamic
249 /// type of the child value.
250 ///
251 /// @return
252 /// A new SBValue object that represents the child member value.
253 //------------------------------------------------------------------
254 ") GetChildMemberWithName;
255 lldb::SBValue
256 GetChildMemberWithName (const char *name, lldb::DynamicValueType use_dynamic);
257
258 %feature("docstring", "Expands nested expressions like .a->b[0].c[1]->d."
259 ) GetValueForExpressionPath;
260 lldb::SBValue
261 GetValueForExpressionPath(const char* expr_path);
262
263 uint32_t
264 GetNumChildren ();
265
266 void *
267 GetOpaqueType();
268
Johnny Chen854a1ba2011-07-18 19:08:30 +0000269 lldb::SBValue
270 Dereference ();
271
Enrico Granata979e20d2011-07-29 19:53:35 +0000272 lldb::SBValue
273 AddressOf();
274
Johnny Chen854a1ba2011-07-18 19:08:30 +0000275 bool
276 TypeIsPointerType ();
Enrico Granata979e20d2011-07-29 19:53:35 +0000277
278 lldb::SBTarget
279 GetTarget();
Johnny Chen854a1ba2011-07-18 19:08:30 +0000280
Enrico Granata979e20d2011-07-29 19:53:35 +0000281 lldb::SBProcess
282 GetProcess();
283
284 lldb::SBThread
285 GetThread();
286
287 lldb::SBFrame
288 GetFrame();
289
Johnny Chenecd4feb2011-10-14 00:42:25 +0000290 %feature("docstring", "
291 /// Find and watch a variable.
292 /// It returns an SBWatchpoint, which may be invalid.
293 ") Watch;
Greg Clayton1fa6b3d2011-10-13 18:08:26 +0000294 lldb::SBWatchpoint
295 Watch (bool resolve_location, bool read, bool write);
296
Johnny Chenecd4feb2011-10-14 00:42:25 +0000297 %feature("docstring", "
298 /// Find and watch the location pointed to by a variable.
299 /// It returns an SBWatchpoint, which may be invalid.
300 ") WatchPointee;
Greg Clayton1fa6b3d2011-10-13 18:08:26 +0000301 lldb::SBWatchpoint
302 WatchPointee (bool resolve_location, bool read, bool write);
303
Johnny Chen854a1ba2011-07-18 19:08:30 +0000304 bool
305 GetDescription (lldb::SBStream &description);
306
307 bool
308 GetExpressionPath (lldb::SBStream &description);
Enrico Granata91544802011-09-06 19:20:51 +0000309
310 %feature("docstring", "
311 //------------------------------------------------------------------
312 /// Get an SBData wrapping what this SBValue points to.
313 ///
314 /// This method will dereference the current SBValue, if its
315 /// data type is a T* or T[], and extract item_count elements
316 /// of type T from it, copying their contents in an SBData.
317 ///
318 /// @param[in] item_idx
319 /// The index of the first item to retrieve. For an array
320 /// this is equivalent to array[item_idx], for a pointer
321 /// to *(pointer + item_idx). In either case, the measurement
322 /// unit for item_idx is the sizeof(T) rather than the byte
323 ///
324 /// @param[in] item_count
325 /// How many items should be copied into the output. By default
326 /// only one item is copied, but more can be asked for.
327 ///
328 /// @return
329 /// An SBData with the contents of the copied items, on success.
330 /// An empty SBData otherwise.
331 //------------------------------------------------------------------
332 ") GetPointeeData;
333 lldb::SBData
334 GetPointeeData (uint32_t item_idx = 0,
335 uint32_t item_count = 1);
336
337 %feature("docstring", "
338 //------------------------------------------------------------------
339 /// Get an SBData wrapping the contents of this SBValue.
340 ///
341 /// This method will read the contents of this object in memory
342 /// and copy them into an SBData for future use.
343 ///
344 /// @return
345 /// An SBData with the contents of this SBValue, on success.
346 /// An empty SBData otherwise.
347 //------------------------------------------------------------------
348 ") GetData;
349 lldb::SBData
350 GetData ();
351
352 lldb::addr_t
353 GetLoadAddress();
354
355 lldb::SBAddress
356 GetAddress();
Johnny Chen854a1ba2011-07-18 19:08:30 +0000357
358 %feature("docstring", "Returns an expression path for this value."
Enrico Granata91544802011-09-06 19:20:51 +0000359 ) GetExpressionPath;
Johnny Chen854a1ba2011-07-18 19:08:30 +0000360 bool
361 GetExpressionPath (lldb::SBStream &description, bool qualify_cxx_base_classes);
362};
363
364} // namespace lldb