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 |
| 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 Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 85 | bool |
| 86 | IsInScope (); |
| 87 | |
| 88 | lldb::Format |
| 89 | GetFormat () const; |
| 90 | |
| 91 | void |
| 92 | SetFormat (lldb::Format format); |
| 93 | |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 94 | const char * |
| 95 | GetValue (); |
| 96 | |
Greg Clayton | 0fb0bcc | 2011-08-03 22:57:10 +0000 | [diff] [blame] | 97 | int64_t |
Enrico Granata | c92eb40 | 2011-08-04 01:41:02 +0000 | [diff] [blame] | 98 | GetValueAsSigned(SBError& error, int64_t fail_value=0); |
Greg Clayton | 0fb0bcc | 2011-08-03 22:57:10 +0000 | [diff] [blame] | 99 | |
| 100 | uint64_t |
Enrico Granata | c92eb40 | 2011-08-04 01:41:02 +0000 | [diff] [blame] | 101 | GetValueAsUnsigned(SBError& error, uint64_t fail_value=0); |
| 102 | |
| 103 | int64_t |
| 104 | GetValueAsSigned(int64_t fail_value=0); |
| 105 | |
| 106 | uint64_t |
Greg Clayton | 0fb0bcc | 2011-08-03 22:57:10 +0000 | [diff] [blame] | 107 | GetValueAsUnsigned(uint64_t fail_value=0); |
| 108 | |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 109 | ValueType |
| 110 | GetValueType (); |
| 111 | |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 112 | bool |
| 113 | GetValueDidChange (); |
| 114 | |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 115 | const char * |
| 116 | GetSummary (); |
| 117 | |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 118 | const char * |
| 119 | GetObjectDescription (); |
| 120 | |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 121 | const char * |
| 122 | GetLocation (); |
| 123 | |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 124 | 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 Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 186 | |
| 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 Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 192 | |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 193 | 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 Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 202 | %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 Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 255 | lldb::SBValue |
| 256 | Dereference (); |
| 257 | |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 258 | lldb::SBValue |
| 259 | AddressOf(); |
| 260 | |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 261 | bool |
| 262 | TypeIsPointerType (); |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 263 | |
| 264 | lldb::SBTarget |
| 265 | GetTarget(); |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 266 | |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 267 | lldb::SBProcess |
| 268 | GetProcess(); |
| 269 | |
| 270 | lldb::SBThread |
| 271 | GetThread(); |
| 272 | |
| 273 | lldb::SBFrame |
| 274 | GetFrame(); |
| 275 | |
Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame] | 276 | 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 |