1 //===-- SBType.h ------------------------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLDB_API_SBTYPE_H 10 #define LLDB_API_SBTYPE_H 11 12 #include "lldb/API/SBDefines.h" 13 14 namespace lldb { 15 16 class SBTypeList; 17 18 class LLDB_API SBTypeMember { 19 public: 20 SBTypeMember(); 21 22 SBTypeMember(const lldb::SBTypeMember &rhs); 23 24 ~SBTypeMember(); 25 26 lldb::SBTypeMember &operator=(const lldb::SBTypeMember &rhs); 27 28 explicit operator bool() const; 29 30 bool IsValid() const; 31 32 const char *GetName(); 33 34 lldb::SBType GetType(); 35 36 uint64_t GetOffsetInBytes(); 37 38 uint64_t GetOffsetInBits(); 39 40 bool IsBitfield(); 41 42 uint32_t GetBitfieldSizeInBits(); 43 44 bool GetDescription(lldb::SBStream &description, 45 lldb::DescriptionLevel description_level); 46 47 protected: 48 friend class SBType; 49 50 void reset(lldb_private::TypeMemberImpl *); 51 52 lldb_private::TypeMemberImpl &ref(); 53 54 const lldb_private::TypeMemberImpl &ref() const; 55 56 std::unique_ptr<lldb_private::TypeMemberImpl> m_opaque_up; 57 }; 58 59 class SBTypeMemberFunction { 60 public: 61 SBTypeMemberFunction(); 62 63 SBTypeMemberFunction(const lldb::SBTypeMemberFunction &rhs); 64 65 ~SBTypeMemberFunction(); 66 67 lldb::SBTypeMemberFunction &operator=(const lldb::SBTypeMemberFunction &rhs); 68 69 explicit operator bool() const; 70 71 bool IsValid() const; 72 73 const char *GetName(); 74 75 const char *GetDemangledName(); 76 77 const char *GetMangledName(); 78 79 lldb::SBType GetType(); 80 81 lldb::SBType GetReturnType(); 82 83 uint32_t GetNumberOfArguments(); 84 85 lldb::SBType GetArgumentTypeAtIndex(uint32_t); 86 87 lldb::MemberFunctionKind GetKind(); 88 89 bool GetDescription(lldb::SBStream &description, 90 lldb::DescriptionLevel description_level); 91 92 protected: 93 friend class SBType; 94 95 void reset(lldb_private::TypeMemberFunctionImpl *); 96 97 lldb_private::TypeMemberFunctionImpl &ref(); 98 99 const lldb_private::TypeMemberFunctionImpl &ref() const; 100 101 lldb::TypeMemberFunctionImplSP m_opaque_sp; 102 }; 103 104 class SBType { 105 public: 106 SBType(); 107 108 SBType(const lldb::SBType &rhs); 109 110 ~SBType(); 111 112 explicit operator bool() const; 113 114 bool IsValid() const; 115 116 uint64_t GetByteSize(); 117 118 bool IsPointerType(); 119 120 bool IsReferenceType(); 121 122 bool IsFunctionType(); 123 124 bool IsPolymorphicClass(); 125 126 bool IsArrayType(); 127 128 bool IsVectorType(); 129 130 bool IsTypedefType(); 131 132 bool IsAnonymousType(); 133 134 bool IsScopedEnumerationType(); 135 136 lldb::SBType GetPointerType(); 137 138 lldb::SBType GetPointeeType(); 139 140 lldb::SBType GetReferenceType(); 141 142 lldb::SBType GetTypedefedType(); 143 144 lldb::SBType GetDereferencedType(); 145 146 lldb::SBType GetUnqualifiedType(); 147 148 lldb::SBType GetArrayElementType(); 149 150 lldb::SBType GetArrayType(uint64_t size); 151 152 lldb::SBType GetVectorElementType(); 153 154 lldb::SBType GetCanonicalType(); 155 156 lldb::SBType GetEnumerationIntegerType(); 157 158 // Get the "lldb::BasicType" enumeration for a type. If a type is not a basic 159 // type eBasicTypeInvalid will be returned 160 lldb::BasicType GetBasicType(); 161 162 // The call below confusing and should really be renamed to "CreateBasicType" 163 lldb::SBType GetBasicType(lldb::BasicType type); 164 165 uint32_t GetNumberOfFields(); 166 167 uint32_t GetNumberOfDirectBaseClasses(); 168 169 uint32_t GetNumberOfVirtualBaseClasses(); 170 171 lldb::SBTypeMember GetFieldAtIndex(uint32_t idx); 172 173 lldb::SBTypeMember GetDirectBaseClassAtIndex(uint32_t idx); 174 175 lldb::SBTypeMember GetVirtualBaseClassAtIndex(uint32_t idx); 176 177 lldb::SBTypeEnumMemberList GetEnumMembers(); 178 179 uint32_t GetNumberOfTemplateArguments(); 180 181 lldb::SBType GetTemplateArgumentType(uint32_t idx); 182 183 lldb::TemplateArgumentKind GetTemplateArgumentKind(uint32_t idx); 184 185 lldb::SBType GetFunctionReturnType(); 186 187 lldb::SBTypeList GetFunctionArgumentTypes(); 188 189 uint32_t GetNumberOfMemberFunctions(); 190 191 lldb::SBTypeMemberFunction GetMemberFunctionAtIndex(uint32_t idx); 192 193 lldb::SBModule GetModule(); 194 195 const char *GetName(); 196 197 const char *GetDisplayTypeName(); 198 199 lldb::TypeClass GetTypeClass(); 200 201 bool IsTypeComplete(); 202 203 uint32_t GetTypeFlags(); 204 205 bool GetDescription(lldb::SBStream &description, 206 lldb::DescriptionLevel description_level); 207 208 lldb::SBType &operator=(const lldb::SBType &rhs); 209 210 bool operator==(lldb::SBType &rhs); 211 212 bool operator!=(lldb::SBType &rhs); 213 214 protected: 215 lldb_private::TypeImpl &ref(); 216 217 const lldb_private::TypeImpl &ref() const; 218 219 lldb::TypeImplSP GetSP(); 220 221 void SetSP(const lldb::TypeImplSP &type_impl_sp); 222 223 lldb::TypeImplSP m_opaque_sp; 224 225 friend class SBFunction; 226 friend class SBModule; 227 friend class SBTarget; 228 friend class SBTypeEnumMember; 229 friend class SBTypeEnumMemberList; 230 friend class SBTypeNameSpecifier; 231 friend class SBTypeMember; 232 friend class SBTypeMemberFunction; 233 friend class SBTypeList; 234 friend class SBValue; 235 236 SBType(const lldb_private::CompilerType &); 237 SBType(const lldb::TypeSP &); 238 SBType(const lldb::TypeImplSP &); 239 }; 240 241 class SBTypeList { 242 public: 243 SBTypeList(); 244 245 SBTypeList(const lldb::SBTypeList &rhs); 246 247 ~SBTypeList(); 248 249 lldb::SBTypeList &operator=(const lldb::SBTypeList &rhs); 250 251 explicit operator bool() const; 252 253 bool IsValid(); 254 255 void Append(lldb::SBType type); 256 257 lldb::SBType GetTypeAtIndex(uint32_t index); 258 259 uint32_t GetSize(); 260 261 private: 262 std::unique_ptr<lldb_private::TypeListImpl> m_opaque_up; 263 friend class SBModule; 264 friend class SBCompileUnit; 265 }; 266 267 } // namespace lldb 268 269 #endif // LLDB_API_SBTYPE_H 270