Johnny Chen | 854a1ba | 2011-07-18 19:08:30 +0000 | [diff] [blame^] | 1 | //===-- SBValue.h -----------------------------------------------*- C++ -*-===// |
| 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 |
| 52 | Name: gs Value: 0x0000000000000048 |
| 53 | " |
| 54 | ) SBValue; |
| 55 | class SBValue |
| 56 | { |
| 57 | public: |
| 58 | SBValue (); |
| 59 | |
| 60 | SBValue (const SBValue &rhs); |
| 61 | |
| 62 | ~SBValue (); |
| 63 | |
| 64 | bool |
| 65 | IsValid() const; |
| 66 | |
| 67 | SBError |
| 68 | GetError(); |
| 69 | |
| 70 | lldb::user_id_t |
| 71 | GetID (); |
| 72 | |
| 73 | const char * |
| 74 | GetName(); |
| 75 | |
| 76 | const char * |
| 77 | GetTypeName (); |
| 78 | |
| 79 | size_t |
| 80 | GetByteSize (); |
| 81 | |
| 82 | bool |
| 83 | IsInScope (const lldb::SBFrame &frame); // DEPRECATED - SBValues know their own frames. |
| 84 | |
| 85 | bool |
| 86 | IsInScope (); |
| 87 | |
| 88 | lldb::Format |
| 89 | GetFormat () const; |
| 90 | |
| 91 | void |
| 92 | SetFormat (lldb::Format format); |
| 93 | |
| 94 | const char * |
| 95 | GetValue (const lldb::SBFrame &frame); // DEPRECATED - SBValues know their own frames. |
| 96 | |
| 97 | const char * |
| 98 | GetValue (); |
| 99 | |
| 100 | ValueType |
| 101 | GetValueType (); |
| 102 | |
| 103 | bool |
| 104 | GetValueDidChange (const lldb::SBFrame &frame); // DEPRECATED - SBValues know their own frames. |
| 105 | |
| 106 | bool |
| 107 | GetValueDidChange (); |
| 108 | |
| 109 | const char * |
| 110 | GetSummary (const lldb::SBFrame &frame); // DEPRECATED - SBValues know their own frames. |
| 111 | |
| 112 | const char * |
| 113 | GetSummary (); |
| 114 | |
| 115 | const char * |
| 116 | GetObjectDescription (const lldb::SBFrame &frame); // DEPRECATED - SBValues know their own frames. |
| 117 | |
| 118 | const char * |
| 119 | GetObjectDescription (); |
| 120 | |
| 121 | const char * |
| 122 | GetLocation (const lldb::SBFrame &frame); // DEPRECATED - SBValues know their own frames. |
| 123 | |
| 124 | const char * |
| 125 | GetLocation (); |
| 126 | |
| 127 | bool |
| 128 | SetValueFromCString (const lldb::SBFrame &frame, const char *value_str); // DEPRECATED - SBValues know their own frames. |
| 129 | |
| 130 | bool |
| 131 | SetValueFromCString (const char *value_str); |
| 132 | |
| 133 | lldb::SBValue |
| 134 | GetChildAtIndex (uint32_t idx); |
| 135 | |
| 136 | %feature("docstring", " |
| 137 | //------------------------------------------------------------------ |
| 138 | /// Get a child value by index from a value. |
| 139 | /// |
| 140 | /// Structs, unions, classes, arrays and and pointers have child |
| 141 | /// values that can be access by index. |
| 142 | /// |
| 143 | /// Structs and unions access child members using a zero based index |
| 144 | /// for each child member. For |
| 145 | /// |
| 146 | /// Classes reserve the first indexes for base classes that have |
| 147 | /// members (empty base classes are omitted), and all members of the |
| 148 | /// current class will then follow the base classes. |
| 149 | /// |
| 150 | /// Pointers differ depending on what they point to. If the pointer |
| 151 | /// points to a simple type, the child at index zero |
| 152 | /// is the only child value available, unless \a synthetic_allowed |
| 153 | /// is \b true, in which case the pointer will be used as an array |
| 154 | /// and can create 'synthetic' child values using positive or |
| 155 | /// negative indexes. If the pointer points to an aggregate type |
| 156 | /// (an array, class, union, struct), then the pointee is |
| 157 | /// transparently skipped and any children are going to be the indexes |
| 158 | /// of the child values within the aggregate type. For example if |
| 159 | /// we have a 'Point' type and we have a SBValue that contains a |
| 160 | /// pointer to a 'Point' type, then the child at index zero will be |
| 161 | /// the 'x' member, and the child at index 1 will be the 'y' member |
| 162 | /// (the child at index zero won't be a 'Point' instance). |
| 163 | /// |
| 164 | /// Arrays have a preset number of children that can be accessed by |
| 165 | /// index and will returns invalid child values for indexes that are |
| 166 | /// out of bounds unless the \a synthetic_allowed is \b true. In this |
| 167 | /// case the array can create 'synthetic' child values for indexes |
| 168 | /// that aren't in the array bounds using positive or negative |
| 169 | /// indexes. |
| 170 | /// |
| 171 | /// @param[in] idx |
| 172 | /// The index of the child value to get |
| 173 | /// |
| 174 | /// @param[in] use_dynamic |
| 175 | /// An enumeration that specifies wether to get dynamic values, |
| 176 | /// and also if the target can be run to figure out the dynamic |
| 177 | /// type of the child value. |
| 178 | /// |
| 179 | /// @param[in] synthetic_allowed |
| 180 | /// If \b true, then allow child values to be created by index |
| 181 | /// for pointers and arrays for indexes that normally wouldn't |
| 182 | /// be allowed. |
| 183 | /// |
| 184 | /// @return |
| 185 | /// A new SBValue object that represents the child member value. |
| 186 | //------------------------------------------------------------------ |
| 187 | ") GetChildAtIndex; |
| 188 | lldb::SBValue |
| 189 | GetChildAtIndex (uint32_t idx, |
| 190 | lldb::DynamicValueType use_dynamic, |
| 191 | bool can_create_synthetic); |
| 192 | |
| 193 | %feature("docstring", " |
| 194 | //------------------------------------------------------------------ |
| 195 | /// Returns the child member index. |
| 196 | /// |
| 197 | /// Matches children of this object only and will match base classes and |
| 198 | /// member names if this is a clang typed object. |
| 199 | /// |
| 200 | /// @param[in] name |
| 201 | /// The name of the child value to get |
| 202 | /// |
| 203 | /// @return |
| 204 | /// An index to the child member value. |
| 205 | //------------------------------------------------------------------ |
| 206 | ") GetIndexOfChildWithName; |
| 207 | uint32_t |
| 208 | GetIndexOfChildWithName (const char *name); |
| 209 | |
| 210 | lldb::SBValue |
| 211 | GetChildMemberWithName (const char *name); |
| 212 | |
| 213 | %feature("docstring", " |
| 214 | //------------------------------------------------------------------ |
| 215 | /// Returns the child member value. |
| 216 | /// |
| 217 | /// Matches child members of this object and child members of any base |
| 218 | /// classes. |
| 219 | /// |
| 220 | /// @param[in] name |
| 221 | /// The name of the child value to get |
| 222 | /// |
| 223 | /// @param[in] use_dynamic |
| 224 | /// An enumeration that specifies wether to get dynamic values, |
| 225 | /// and also if the target can be run to figure out the dynamic |
| 226 | /// type of the child value. |
| 227 | /// |
| 228 | /// @return |
| 229 | /// A new SBValue object that represents the child member value. |
| 230 | //------------------------------------------------------------------ |
| 231 | ") GetChildMemberWithName; |
| 232 | lldb::SBValue |
| 233 | GetChildMemberWithName (const char *name, lldb::DynamicValueType use_dynamic); |
| 234 | |
| 235 | %feature("docstring", "Expands nested expressions like .a->b[0].c[1]->d." |
| 236 | ) GetValueForExpressionPath; |
| 237 | lldb::SBValue |
| 238 | GetValueForExpressionPath(const char* expr_path); |
| 239 | |
| 240 | uint32_t |
| 241 | GetNumChildren (); |
| 242 | |
| 243 | void * |
| 244 | GetOpaqueType(); |
| 245 | |
| 246 | |
| 247 | lldb::SBValue |
| 248 | Dereference (); |
| 249 | |
| 250 | bool |
| 251 | TypeIsPointerType (); |
| 252 | |
| 253 | bool |
| 254 | GetDescription (lldb::SBStream &description); |
| 255 | |
| 256 | bool |
| 257 | GetExpressionPath (lldb::SBStream &description); |
| 258 | |
| 259 | %feature("docstring", "Returns an expression path for this value." |
| 260 | ) GetValueForExpressionPath; |
| 261 | bool |
| 262 | GetExpressionPath (lldb::SBStream &description, bool qualify_cxx_base_classes); |
| 263 | }; |
| 264 | |
| 265 | } // namespace lldb |