blob: 22186e1b8a3a345c6b704ddf9749a3c23aa67c92 [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
98 GetValueAsSigned(int64_t fail_value=0);
99
100 uint64_t
101 GetValueAsUnsigned(uint64_t fail_value=0);
102
Johnny Chen854a1ba2011-07-18 19:08:30 +0000103 ValueType
104 GetValueType ();
105
Johnny Chen854a1ba2011-07-18 19:08:30 +0000106 bool
107 GetValueDidChange ();
108
Johnny Chen854a1ba2011-07-18 19:08:30 +0000109 const char *
110 GetSummary ();
111
Johnny Chen854a1ba2011-07-18 19:08:30 +0000112 const char *
113 GetObjectDescription ();
114
Johnny Chen854a1ba2011-07-18 19:08:30 +0000115 const char *
116 GetLocation ();
117
Johnny Chen854a1ba2011-07-18 19:08:30 +0000118 bool
119 SetValueFromCString (const char *value_str);
120
121 lldb::SBValue
122 GetChildAtIndex (uint32_t idx);
123
124 %feature("docstring", "
125 //------------------------------------------------------------------
126 /// Get a child value by index from a value.
127 ///
128 /// Structs, unions, classes, arrays and and pointers have child
129 /// values that can be access by index.
130 ///
131 /// Structs and unions access child members using a zero based index
132 /// for each child member. For
133 ///
134 /// Classes reserve the first indexes for base classes that have
135 /// members (empty base classes are omitted), and all members of the
136 /// current class will then follow the base classes.
137 ///
138 /// Pointers differ depending on what they point to. If the pointer
139 /// points to a simple type, the child at index zero
140 /// is the only child value available, unless \a synthetic_allowed
141 /// is \b true, in which case the pointer will be used as an array
142 /// and can create 'synthetic' child values using positive or
143 /// negative indexes. If the pointer points to an aggregate type
144 /// (an array, class, union, struct), then the pointee is
145 /// transparently skipped and any children are going to be the indexes
146 /// of the child values within the aggregate type. For example if
147 /// we have a 'Point' type and we have a SBValue that contains a
148 /// pointer to a 'Point' type, then the child at index zero will be
149 /// the 'x' member, and the child at index 1 will be the 'y' member
150 /// (the child at index zero won't be a 'Point' instance).
151 ///
152 /// Arrays have a preset number of children that can be accessed by
153 /// index and will returns invalid child values for indexes that are
154 /// out of bounds unless the \a synthetic_allowed is \b true. In this
155 /// case the array can create 'synthetic' child values for indexes
156 /// that aren't in the array bounds using positive or negative
157 /// indexes.
158 ///
159 /// @param[in] idx
160 /// The index of the child value to get
161 ///
162 /// @param[in] use_dynamic
163 /// An enumeration that specifies wether to get dynamic values,
164 /// and also if the target can be run to figure out the dynamic
165 /// type of the child value.
166 ///
167 /// @param[in] synthetic_allowed
168 /// If \b true, then allow child values to be created by index
169 /// for pointers and arrays for indexes that normally wouldn't
170 /// be allowed.
171 ///
172 /// @return
173 /// A new SBValue object that represents the child member value.
174 //------------------------------------------------------------------
175 ") GetChildAtIndex;
176 lldb::SBValue
177 GetChildAtIndex (uint32_t idx,
178 lldb::DynamicValueType use_dynamic,
179 bool can_create_synthetic);
Enrico Granata979e20d2011-07-29 19:53:35 +0000180
181 lldb::SBValue
182 CreateChildAtOffset (const char *name, uint32_t offset, const SBType& type);
183
184 lldb::SBValue
185 SBValue::Cast(const SBType& type);
Johnny Chen854a1ba2011-07-18 19:08:30 +0000186
Enrico Granata979e20d2011-07-29 19:53:35 +0000187 lldb::SBValue
188 CreateValueFromExpression (const char *name, const char* expression);
189
190 lldb::SBValue
191 CreateValueFromAddress(const char* name, lldb::addr_t address, const SBType& type);
192
193 lldb::SBType
194 GetType();
195
Johnny Chen854a1ba2011-07-18 19:08:30 +0000196 %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
Johnny Chen854a1ba2011-07-18 19:08:30 +0000249 lldb::SBValue
250 Dereference ();
251
Enrico Granata979e20d2011-07-29 19:53:35 +0000252 lldb::SBValue
253 AddressOf();
254
Johnny Chen854a1ba2011-07-18 19:08:30 +0000255 bool
256 TypeIsPointerType ();
Enrico Granata979e20d2011-07-29 19:53:35 +0000257
258 lldb::SBTarget
259 GetTarget();
Johnny Chen854a1ba2011-07-18 19:08:30 +0000260
Enrico Granata979e20d2011-07-29 19:53:35 +0000261 lldb::SBProcess
262 GetProcess();
263
264 lldb::SBThread
265 GetThread();
266
267 lldb::SBFrame
268 GetFrame();
269
Johnny Chen854a1ba2011-07-18 19:08:30 +0000270 bool
271 GetDescription (lldb::SBStream &description);
272
273 bool
274 GetExpressionPath (lldb::SBStream &description);
275
276 %feature("docstring", "Returns an expression path for this value."
277 ) GetValueForExpressionPath;
278 bool
279 GetExpressionPath (lldb::SBStream &description, bool qualify_cxx_base_classes);
280};
281
282} // namespace lldb