Johnny Chen | 7be5a4f | 2011-07-18 19:15:22 +0000 | [diff] [blame] | 1 | //===-- SWIG Interface for SBValue ------------------------------*- C++ -*-===// |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 2 | // |
| 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 | |
| 10 | namespace lldb { |
| 11 | |
| 12 | %feature("docstring", |
| 13 | "Represents the value of a variable, a register, or an expression. |
| 14 | |
| 15 | SBValue supports iteration through its child, which in turn is represented |
| 16 | as an SBValue. For example, we can get the general purpose registers of a |
| 17 | frame 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 | |
| 29 | produces the output: |
| 30 | |
| 31 | General Purpose Registers (number of children = 21): |
| 32 | Name: rax Value: 0x0000000100000c5c |
| 33 | Name: rbx Value: 0x0000000000000000 |
| 34 | Name: rcx Value: 0x00007fff5fbffec0 |
| 35 | Name: rdx Value: 0x00007fff5fbffeb8 |
| 36 | Name: rdi Value: 0x0000000000000001 |
| 37 | Name: rsi Value: 0x00007fff5fbffea8 |
| 38 | Name: rbp Value: 0x00007fff5fbffe80 |
| 39 | Name: rsp Value: 0x00007fff5fbffe60 |
| 40 | Name: r8 Value: 0x0000000008668682 |
| 41 | Name: r9 Value: 0x0000000000000000 |
| 42 | Name: r10 Value: 0x0000000000001200 |
| 43 | Name: r11 Value: 0x0000000000000206 |
| 44 | Name: r12 Value: 0x0000000000000000 |
| 45 | Name: r13 Value: 0x0000000000000000 |
| 46 | Name: r14 Value: 0x0000000000000000 |
| 47 | Name: r15 Value: 0x0000000000000000 |
| 48 | Name: rip Value: 0x0000000100000dae |
| 49 | Name: rflags Value: 0x0000000000000206 |
| 50 | Name: cs Value: 0x0000000000000027 |
| 51 | Name: fs Value: 0x0000000000000010 |
Johnny Chen | de856cc | 2011-07-25 23:41:08 +0000 | [diff] [blame] | 52 | Name: gs Value: 0x0000000000000048 |
| 53 | |
| 54 | See also linked_list_iter() for another perspective on how to iterate through an |
| 55 | SBValue instance which interprets the value object as representing the head of a |
| 56 | linked list." |
Johnny Chen | c3fba81 | 2011-07-18 20:13:38 +0000 | [diff] [blame] | 57 | ) SBValue; |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 58 | class SBValue |
| 59 | { |
| 60 | public: |
| 61 | SBValue (); |
| 62 | |
| 63 | SBValue (const SBValue &rhs); |
| 64 | |
| 65 | ~SBValue (); |
| 66 | |
| 67 | bool |
Greg Clayton | d68e089 | 2011-09-09 23:04:00 +0000 | [diff] [blame] | 68 | IsValid(); |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 69 | |
Jim Ingham | e0bd571 | 2011-12-19 20:39:44 +0000 | [diff] [blame] | 70 | void |
| 71 | Clear(); |
| 72 | |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 73 | SBError |
| 74 | GetError(); |
| 75 | |
| 76 | lldb::user_id_t |
| 77 | GetID (); |
| 78 | |
| 79 | const char * |
| 80 | GetName(); |
| 81 | |
| 82 | const char * |
| 83 | GetTypeName (); |
| 84 | |
| 85 | size_t |
| 86 | GetByteSize (); |
| 87 | |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 88 | bool |
| 89 | IsInScope (); |
| 90 | |
| 91 | lldb::Format |
Greg Clayton | d68e089 | 2011-09-09 23:04:00 +0000 | [diff] [blame] | 92 | GetFormat (); |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 93 | |
| 94 | void |
| 95 | SetFormat (lldb::Format format); |
| 96 | |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 97 | const char * |
| 98 | GetValue (); |
| 99 | |
Greg Clayton | 0fb0bcc | 2011-08-03 22:57:10 +0000 | [diff] [blame] | 100 | int64_t |
Enrico Granata | c92eb40 | 2011-08-04 01:41:02 +0000 | [diff] [blame] | 101 | GetValueAsSigned(SBError& error, int64_t fail_value=0); |
Greg Clayton | 0fb0bcc | 2011-08-03 22:57:10 +0000 | [diff] [blame] | 102 | |
| 103 | uint64_t |
Enrico Granata | c92eb40 | 2011-08-04 01:41:02 +0000 | [diff] [blame] | 104 | GetValueAsUnsigned(SBError& error, uint64_t fail_value=0); |
| 105 | |
| 106 | int64_t |
| 107 | GetValueAsSigned(int64_t fail_value=0); |
| 108 | |
| 109 | uint64_t |
Greg Clayton | 0fb0bcc | 2011-08-03 22:57:10 +0000 | [diff] [blame] | 110 | GetValueAsUnsigned(uint64_t fail_value=0); |
| 111 | |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 112 | ValueType |
| 113 | GetValueType (); |
| 114 | |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 115 | bool |
| 116 | GetValueDidChange (); |
| 117 | |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 118 | const char * |
| 119 | GetSummary (); |
| 120 | |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 121 | const char * |
| 122 | GetObjectDescription (); |
| 123 | |
Jim Ingham | 1b42575 | 2011-12-08 19:44:08 +0000 | [diff] [blame] | 124 | lldb::SBValue |
| 125 | GetDynamicValue (lldb::DynamicValueType use_dynamic); |
| 126 | |
| 127 | lldb::SBValue |
| 128 | GetStaticValue (); |
| 129 | |
| 130 | bool |
| 131 | IsDynamic(); |
| 132 | |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 133 | const char * |
| 134 | GetLocation (); |
| 135 | |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 136 | bool |
| 137 | SetValueFromCString (const char *value_str); |
| 138 | |
| 139 | lldb::SBValue |
| 140 | GetChildAtIndex (uint32_t idx); |
| 141 | |
| 142 | %feature("docstring", " |
| 143 | //------------------------------------------------------------------ |
| 144 | /// Get a child value by index from a value. |
| 145 | /// |
| 146 | /// Structs, unions, classes, arrays and and pointers have child |
| 147 | /// values that can be access by index. |
| 148 | /// |
| 149 | /// Structs and unions access child members using a zero based index |
| 150 | /// for each child member. For |
| 151 | /// |
| 152 | /// Classes reserve the first indexes for base classes that have |
| 153 | /// members (empty base classes are omitted), and all members of the |
| 154 | /// current class will then follow the base classes. |
| 155 | /// |
| 156 | /// Pointers differ depending on what they point to. If the pointer |
| 157 | /// points to a simple type, the child at index zero |
| 158 | /// is the only child value available, unless \a synthetic_allowed |
| 159 | /// is \b true, in which case the pointer will be used as an array |
| 160 | /// and can create 'synthetic' child values using positive or |
| 161 | /// negative indexes. If the pointer points to an aggregate type |
| 162 | /// (an array, class, union, struct), then the pointee is |
| 163 | /// transparently skipped and any children are going to be the indexes |
| 164 | /// of the child values within the aggregate type. For example if |
| 165 | /// we have a 'Point' type and we have a SBValue that contains a |
| 166 | /// pointer to a 'Point' type, then the child at index zero will be |
| 167 | /// the 'x' member, and the child at index 1 will be the 'y' member |
| 168 | /// (the child at index zero won't be a 'Point' instance). |
| 169 | /// |
| 170 | /// Arrays have a preset number of children that can be accessed by |
| 171 | /// index and will returns invalid child values for indexes that are |
| 172 | /// out of bounds unless the \a synthetic_allowed is \b true. In this |
| 173 | /// case the array can create 'synthetic' child values for indexes |
| 174 | /// that aren't in the array bounds using positive or negative |
| 175 | /// indexes. |
| 176 | /// |
| 177 | /// @param[in] idx |
| 178 | /// The index of the child value to get |
| 179 | /// |
| 180 | /// @param[in] use_dynamic |
| 181 | /// An enumeration that specifies wether to get dynamic values, |
| 182 | /// and also if the target can be run to figure out the dynamic |
| 183 | /// type of the child value. |
| 184 | /// |
| 185 | /// @param[in] synthetic_allowed |
| 186 | /// If \b true, then allow child values to be created by index |
| 187 | /// for pointers and arrays for indexes that normally wouldn't |
| 188 | /// be allowed. |
| 189 | /// |
| 190 | /// @return |
| 191 | /// A new SBValue object that represents the child member value. |
| 192 | //------------------------------------------------------------------ |
| 193 | ") GetChildAtIndex; |
| 194 | lldb::SBValue |
| 195 | GetChildAtIndex (uint32_t idx, |
| 196 | lldb::DynamicValueType use_dynamic, |
| 197 | bool can_create_synthetic); |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 198 | |
| 199 | lldb::SBValue |
Greg Clayton | d68e089 | 2011-09-09 23:04:00 +0000 | [diff] [blame] | 200 | CreateChildAtOffset (const char *name, uint32_t offset, lldb::SBType type); |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 201 | |
| 202 | lldb::SBValue |
Greg Clayton | d68e089 | 2011-09-09 23:04:00 +0000 | [diff] [blame] | 203 | SBValue::Cast (lldb::SBType type); |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 204 | |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 205 | lldb::SBValue |
| 206 | CreateValueFromExpression (const char *name, const char* expression); |
| 207 | |
| 208 | lldb::SBValue |
Greg Clayton | d68e089 | 2011-09-09 23:04:00 +0000 | [diff] [blame] | 209 | CreateValueFromAddress(const char* name, lldb::addr_t address, lldb::SBType type); |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 210 | |
Enrico Granata | 9154480 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 211 | lldb::SBValue |
| 212 | CreateValueFromData (const char* name, |
Greg Clayton | d68e089 | 2011-09-09 23:04:00 +0000 | [diff] [blame] | 213 | lldb::SBData data, |
| 214 | lldb::SBType type); |
Enrico Granata | 9154480 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 215 | |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 216 | lldb::SBType |
| 217 | GetType(); |
| 218 | |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 219 | %feature("docstring", " |
| 220 | //------------------------------------------------------------------ |
| 221 | /// Returns the child member index. |
| 222 | /// |
| 223 | /// Matches children of this object only and will match base classes and |
| 224 | /// member names if this is a clang typed object. |
| 225 | /// |
| 226 | /// @param[in] name |
| 227 | /// The name of the child value to get |
| 228 | /// |
| 229 | /// @return |
| 230 | /// An index to the child member value. |
| 231 | //------------------------------------------------------------------ |
| 232 | ") GetIndexOfChildWithName; |
| 233 | uint32_t |
| 234 | GetIndexOfChildWithName (const char *name); |
| 235 | |
| 236 | lldb::SBValue |
| 237 | GetChildMemberWithName (const char *name); |
| 238 | |
| 239 | %feature("docstring", " |
| 240 | //------------------------------------------------------------------ |
| 241 | /// Returns the child member value. |
| 242 | /// |
| 243 | /// Matches child members of this object and child members of any base |
| 244 | /// classes. |
| 245 | /// |
| 246 | /// @param[in] name |
| 247 | /// The name of the child value to get |
| 248 | /// |
| 249 | /// @param[in] use_dynamic |
| 250 | /// An enumeration that specifies wether to get dynamic values, |
| 251 | /// and also if the target can be run to figure out the dynamic |
| 252 | /// type of the child value. |
| 253 | /// |
| 254 | /// @return |
| 255 | /// A new SBValue object that represents the child member value. |
| 256 | //------------------------------------------------------------------ |
| 257 | ") GetChildMemberWithName; |
| 258 | lldb::SBValue |
| 259 | GetChildMemberWithName (const char *name, lldb::DynamicValueType use_dynamic); |
| 260 | |
| 261 | %feature("docstring", "Expands nested expressions like .a->b[0].c[1]->d." |
| 262 | ) GetValueForExpressionPath; |
| 263 | lldb::SBValue |
| 264 | GetValueForExpressionPath(const char* expr_path); |
| 265 | |
| 266 | uint32_t |
| 267 | GetNumChildren (); |
| 268 | |
| 269 | void * |
| 270 | GetOpaqueType(); |
| 271 | |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 272 | lldb::SBValue |
| 273 | Dereference (); |
| 274 | |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 275 | lldb::SBValue |
| 276 | AddressOf(); |
| 277 | |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 278 | bool |
| 279 | TypeIsPointerType (); |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 280 | |
| 281 | lldb::SBTarget |
| 282 | GetTarget(); |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 283 | |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 284 | lldb::SBProcess |
| 285 | GetProcess(); |
| 286 | |
| 287 | lldb::SBThread |
| 288 | GetThread(); |
| 289 | |
| 290 | lldb::SBFrame |
| 291 | GetFrame(); |
| 292 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 293 | %feature("docstring", " |
| 294 | /// Find and watch a variable. |
| 295 | /// It returns an SBWatchpoint, which may be invalid. |
| 296 | ") Watch; |
Greg Clayton | 1fa6b3d | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 297 | lldb::SBWatchpoint |
| 298 | Watch (bool resolve_location, bool read, bool write); |
| 299 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 300 | %feature("docstring", " |
| 301 | /// Find and watch the location pointed to by a variable. |
| 302 | /// It returns an SBWatchpoint, which may be invalid. |
| 303 | ") WatchPointee; |
Greg Clayton | 1fa6b3d | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 304 | lldb::SBWatchpoint |
| 305 | WatchPointee (bool resolve_location, bool read, bool write); |
| 306 | |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 307 | bool |
| 308 | GetDescription (lldb::SBStream &description); |
| 309 | |
| 310 | bool |
| 311 | GetExpressionPath (lldb::SBStream &description); |
Enrico Granata | 9154480 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 312 | |
| 313 | %feature("docstring", " |
| 314 | //------------------------------------------------------------------ |
| 315 | /// Get an SBData wrapping what this SBValue points to. |
| 316 | /// |
| 317 | /// This method will dereference the current SBValue, if its |
| 318 | /// data type is a T* or T[], and extract item_count elements |
| 319 | /// of type T from it, copying their contents in an SBData. |
| 320 | /// |
| 321 | /// @param[in] item_idx |
| 322 | /// The index of the first item to retrieve. For an array |
| 323 | /// this is equivalent to array[item_idx], for a pointer |
| 324 | /// to *(pointer + item_idx). In either case, the measurement |
| 325 | /// unit for item_idx is the sizeof(T) rather than the byte |
| 326 | /// |
| 327 | /// @param[in] item_count |
| 328 | /// How many items should be copied into the output. By default |
| 329 | /// only one item is copied, but more can be asked for. |
| 330 | /// |
| 331 | /// @return |
| 332 | /// An SBData with the contents of the copied items, on success. |
| 333 | /// An empty SBData otherwise. |
| 334 | //------------------------------------------------------------------ |
| 335 | ") GetPointeeData; |
| 336 | lldb::SBData |
| 337 | GetPointeeData (uint32_t item_idx = 0, |
| 338 | uint32_t item_count = 1); |
| 339 | |
| 340 | %feature("docstring", " |
| 341 | //------------------------------------------------------------------ |
| 342 | /// Get an SBData wrapping the contents of this SBValue. |
| 343 | /// |
| 344 | /// This method will read the contents of this object in memory |
| 345 | /// and copy them into an SBData for future use. |
| 346 | /// |
| 347 | /// @return |
| 348 | /// An SBData with the contents of this SBValue, on success. |
| 349 | /// An empty SBData otherwise. |
| 350 | //------------------------------------------------------------------ |
| 351 | ") GetData; |
| 352 | lldb::SBData |
| 353 | GetData (); |
| 354 | |
| 355 | lldb::addr_t |
| 356 | GetLoadAddress(); |
| 357 | |
| 358 | lldb::SBAddress |
| 359 | GetAddress(); |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 360 | |
| 361 | %feature("docstring", "Returns an expression path for this value." |
Enrico Granata | 9154480 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 362 | ) GetExpressionPath; |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 363 | bool |
| 364 | GetExpressionPath (lldb::SBStream &description, bool qualify_cxx_base_classes); |
| 365 | }; |
| 366 | |
| 367 | } // namespace lldb |