blob: d73e6012c62cff620580317c108fb8d61466c539 [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 Chen854a1ba2011-07-18 19:08:30 +000085 bool
86 IsInScope ();
87
88 lldb::Format
89 GetFormat () const;
90
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
188 CreateChildAtOffset (const char *name, uint32_t offset, const SBType& type);
189
190 lldb::SBValue
191 SBValue::Cast(const 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
197 CreateValueFromAddress(const char* name, lldb::addr_t address, const SBType& type);
198
199 lldb::SBType
200 GetType();
201
Johnny Chen854a1ba2011-07-18 19:08:30 +0000202 %feature("docstring", "
203 //------------------------------------------------------------------
204 /// Returns the child member index.
205 ///
206 /// Matches children of this object only and will match base classes and
207 /// member names if this is a clang typed object.
208 ///
209 /// @param[in] name
210 /// The name of the child value to get
211 ///
212 /// @return
213 /// An index to the child member value.
214 //------------------------------------------------------------------
215 ") GetIndexOfChildWithName;
216 uint32_t
217 GetIndexOfChildWithName (const char *name);
218
219 lldb::SBValue
220 GetChildMemberWithName (const char *name);
221
222 %feature("docstring", "
223 //------------------------------------------------------------------
224 /// Returns the child member value.
225 ///
226 /// Matches child members of this object and child members of any base
227 /// classes.
228 ///
229 /// @param[in] name
230 /// The name of the child value to get
231 ///
232 /// @param[in] use_dynamic
233 /// An enumeration that specifies wether to get dynamic values,
234 /// and also if the target can be run to figure out the dynamic
235 /// type of the child value.
236 ///
237 /// @return
238 /// A new SBValue object that represents the child member value.
239 //------------------------------------------------------------------
240 ") GetChildMemberWithName;
241 lldb::SBValue
242 GetChildMemberWithName (const char *name, lldb::DynamicValueType use_dynamic);
243
244 %feature("docstring", "Expands nested expressions like .a->b[0].c[1]->d."
245 ) GetValueForExpressionPath;
246 lldb::SBValue
247 GetValueForExpressionPath(const char* expr_path);
248
249 uint32_t
250 GetNumChildren ();
251
252 void *
253 GetOpaqueType();
254
Johnny Chen854a1ba2011-07-18 19:08:30 +0000255 lldb::SBValue
256 Dereference ();
257
Enrico Granata979e20d2011-07-29 19:53:35 +0000258 lldb::SBValue
259 AddressOf();
260
Johnny Chen854a1ba2011-07-18 19:08:30 +0000261 bool
262 TypeIsPointerType ();
Enrico Granata979e20d2011-07-29 19:53:35 +0000263
264 lldb::SBTarget
265 GetTarget();
Johnny Chen854a1ba2011-07-18 19:08:30 +0000266
Enrico Granata979e20d2011-07-29 19:53:35 +0000267 lldb::SBProcess
268 GetProcess();
269
270 lldb::SBThread
271 GetThread();
272
273 lldb::SBFrame
274 GetFrame();
275
Johnny Chen854a1ba2011-07-18 19:08:30 +0000276 bool
277 GetDescription (lldb::SBStream &description);
278
279 bool
280 GetExpressionPath (lldb::SBStream &description);
281
282 %feature("docstring", "Returns an expression path for this value."
283 ) GetValueForExpressionPath;
284 bool
285 GetExpressionPath (lldb::SBStream &description, bool qualify_cxx_base_classes);
286};
287
288} // namespace lldb