SBValue.h revision 0fb0bcc9d4e951145e1b8c783652224c09b23af4
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#ifndef LLDB_SBValue_h_ 11#define LLDB_SBValue_h_ 12 13#include "lldb/API/SBDefines.h" 14#include "lldb/API/SBType.h" 15 16#include <stdio.h> 17 18#ifndef SWIG 19class lldb_private::SyntheticScriptProvider; 20#endif 21 22namespace lldb { 23 24class SBValue 25{ 26public: 27 SBValue (); 28 29 SBValue (const SBValue &rhs); 30 31#ifndef SWIG 32 const SBValue & 33 operator =(const SBValue &rhs); 34#endif 35 36 ~SBValue (); 37 38 bool 39 IsValid() const; 40 41 SBError 42 GetError(); 43 44 lldb::user_id_t 45 GetID (); 46 47 const char * 48 GetName(); 49 50 const char * 51 GetTypeName (); 52 53 size_t 54 GetByteSize (); 55 56 bool 57 IsInScope (const lldb::SBFrame &frame); // DEPRECATED - SBValues know their own frames. 58 59 bool 60 IsInScope (); 61 62 lldb::Format 63 GetFormat () const; 64 65 void 66 SetFormat (lldb::Format format); 67 68 const char * 69 GetValue (const lldb::SBFrame &frame); // DEPRECATED - SBValues know their own frames. 70 71 const char * 72 GetValue (); 73 74 int64_t 75 GetValueAsSigned(int64_t fail_value=0); 76 77 uint64_t 78 GetValueAsUnsigned(uint64_t fail_value=0); 79 80 ValueType 81 GetValueType (); 82 83 bool 84 GetValueDidChange (const lldb::SBFrame &frame); // DEPRECATED - SBValues know their own frames. 85 86 bool 87 GetValueDidChange (); 88 89 const char * 90 GetSummary (const lldb::SBFrame &frame); // DEPRECATED - SBValues know their own frames. 91 92 const char * 93 GetSummary (); 94 95 const char * 96 GetObjectDescription (const lldb::SBFrame &frame); // DEPRECATED - SBValues know their own frames. 97 98 const char * 99 GetObjectDescription (); 100 101 const char * 102 GetLocation (const lldb::SBFrame &frame); // DEPRECATED - SBValues know their own frames. 103 104 const char * 105 GetLocation (); 106 107 bool 108 SetValueFromCString (const lldb::SBFrame &frame, const char *value_str); // DEPRECATED - SBValues know their own frames. 109 110 bool 111 SetValueFromCString (const char *value_str); 112 113 lldb::SBValue 114 GetChildAtIndex (uint32_t idx); 115 116 lldb::SBValue 117 CreateChildAtOffset (const char *name, uint32_t offset, const SBType& type); 118 119 lldb::SBValue 120 Cast(const SBType& type); 121 122 lldb::SBValue 123 CreateValueFromExpression (const char *name, const char* expression); 124 125 lldb::SBValue 126 CreateValueFromAddress(const char* name, lldb::addr_t address, const SBType& type); 127 128 //------------------------------------------------------------------ 129 /// Get a child value by index from a value. 130 /// 131 /// Structs, unions, classes, arrays and and pointers have child 132 /// values that can be access by index. 133 /// 134 /// Structs and unions access child members using a zero based index 135 /// for each child member. For 136 /// 137 /// Classes reserve the first indexes for base classes that have 138 /// members (empty base classes are omitted), and all members of the 139 /// current class will then follow the base classes. 140 /// 141 /// Pointers differ depending on what they point to. If the pointer 142 /// points to a simple type, the child at index zero 143 /// is the only child value available, unless \a synthetic_allowed 144 /// is \b true, in which case the pointer will be used as an array 145 /// and can create 'synthetic' child values using positive or 146 /// negative indexes. If the pointer points to an aggregate type 147 /// (an array, class, union, struct), then the pointee is 148 /// transparently skipped and any children are going to be the indexes 149 /// of the child values within the aggregate type. For example if 150 /// we have a 'Point' type and we have a SBValue that contains a 151 /// pointer to a 'Point' type, then the child at index zero will be 152 /// the 'x' member, and the child at index 1 will be the 'y' member 153 /// (the child at index zero won't be a 'Point' instance). 154 /// 155 /// Arrays have a preset number of children that can be accessed by 156 /// index and will returns invalid child values for indexes that are 157 /// out of bounds unless the \a synthetic_allowed is \b true. In this 158 /// case the array can create 'synthetic' child values for indexes 159 /// that aren't in the array bounds using positive or negative 160 /// indexes. 161 /// 162 /// @param[in] idx 163 /// The index of the child value to get 164 /// 165 /// @param[in] use_dynamic 166 /// An enumeration that specifies wether to get dynamic values, 167 /// and also if the target can be run to figure out the dynamic 168 /// type of the child value. 169 /// 170 /// @param[in] synthetic_allowed 171 /// If \b true, then allow child values to be created by index 172 /// for pointers and arrays for indexes that normally wouldn't 173 /// be allowed. 174 /// 175 /// @return 176 /// A new SBValue object that represents the child member value. 177 //------------------------------------------------------------------ 178 lldb::SBValue 179 GetChildAtIndex (uint32_t idx, 180 lldb::DynamicValueType use_dynamic, 181 bool can_create_synthetic); 182 183 // Matches children of this object only and will match base classes and 184 // member names if this is a clang typed object. 185 uint32_t 186 GetIndexOfChildWithName (const char *name); 187 188 // Matches child members of this object and child members of any base 189 // classes. 190 lldb::SBValue 191 GetChildMemberWithName (const char *name); 192 193 // Matches child members of this object and child members of any base 194 // classes. 195 lldb::SBValue 196 GetChildMemberWithName (const char *name, lldb::DynamicValueType use_dynamic); 197 198 // Expands nested expressions like .a->b[0].c[1]->d 199 lldb::SBValue 200 GetValueForExpressionPath(const char* expr_path); 201 202 lldb::SBValue 203 AddressOf(); 204 205 uint32_t 206 GetNumChildren (); 207 208 void * 209 GetOpaqueType(); 210 211 lldb::SBTarget 212 GetTarget(); 213 214 lldb::SBProcess 215 GetProcess(); 216 217 lldb::SBThread 218 GetThread(); 219 220 lldb::SBFrame 221 GetFrame(); 222 223 lldb::SBValue 224 Dereference (); 225 226 bool 227 TypeIsPointerType (); 228 229 SBType 230 GetType(); 231 232 bool 233 GetDescription (lldb::SBStream &description); 234 235 bool 236 GetExpressionPath (lldb::SBStream &description); 237 238 bool 239 GetExpressionPath (lldb::SBStream &description, bool qualify_cxx_base_classes); 240 241 SBValue (const lldb::ValueObjectSP &value_sp); 242 243protected: 244 friend class SBValueList; 245 friend class SBFrame; 246 247#ifndef SWIG 248 // need this to decapsulate the SP from here 249 friend class lldb_private::SyntheticScriptProvider; 250 251 // Mimic shared pointer... 252 lldb_private::ValueObject * 253 get() const; 254 255 lldb_private::ValueObject * 256 operator->() const; 257 258 lldb::ValueObjectSP & 259 operator*(); 260 261 const lldb::ValueObjectSP & 262 operator*() const; 263 264#endif 265 266private: 267 lldb::ValueObjectSP m_opaque_sp; 268}; 269 270} // namespace lldb 271 272#endif // LLDB_SBValue_h_ 273