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 lldb::SBType GetPointerType(); 135 136 lldb::SBType GetPointeeType(); 137 138 lldb::SBType GetReferenceType(); 139 140 lldb::SBType GetTypedefedType(); 141 142 lldb::SBType GetDereferencedType(); 143 144 lldb::SBType GetUnqualifiedType(); 145 146 lldb::SBType GetArrayElementType(); 147 148 lldb::SBType GetArrayType(uint64_t size); 149 150 lldb::SBType GetVectorElementType(); 151 152 lldb::SBType GetCanonicalType(); 153 // Get the "lldb::BasicType" enumeration for a type. If a type is not a basic 154 // type eBasicTypeInvalid will be returned 155 lldb::BasicType GetBasicType(); 156 157 // The call below confusing and should really be renamed to "CreateBasicType" 158 lldb::SBType GetBasicType(lldb::BasicType type); 159 160 uint32_t GetNumberOfFields(); 161 162 uint32_t GetNumberOfDirectBaseClasses(); 163 164 uint32_t GetNumberOfVirtualBaseClasses(); 165 166 lldb::SBTypeMember GetFieldAtIndex(uint32_t idx); 167 168 lldb::SBTypeMember GetDirectBaseClassAtIndex(uint32_t idx); 169 170 lldb::SBTypeMember GetVirtualBaseClassAtIndex(uint32_t idx); 171 172 lldb::SBTypeEnumMemberList GetEnumMembers(); 173 174 uint32_t GetNumberOfTemplateArguments(); 175 176 lldb::SBType GetTemplateArgumentType(uint32_t idx); 177 178 lldb::TemplateArgumentKind GetTemplateArgumentKind(uint32_t idx); 179 180 lldb::SBType GetFunctionReturnType(); 181 182 lldb::SBTypeList GetFunctionArgumentTypes(); 183 184 uint32_t GetNumberOfMemberFunctions(); 185 186 lldb::SBTypeMemberFunction GetMemberFunctionAtIndex(uint32_t idx); 187 188 lldb::SBModule GetModule(); 189 190 const char *GetName(); 191 192 const char *GetDisplayTypeName(); 193 194 lldb::TypeClass GetTypeClass(); 195 196 bool IsTypeComplete(); 197 198 uint32_t GetTypeFlags(); 199 200 bool GetDescription(lldb::SBStream &description, 201 lldb::DescriptionLevel description_level); 202 203 lldb::SBType &operator=(const lldb::SBType &rhs); 204 205 bool operator==(lldb::SBType &rhs); 206 207 bool operator!=(lldb::SBType &rhs); 208 209 protected: 210 lldb_private::TypeImpl &ref(); 211 212 const lldb_private::TypeImpl &ref() const; 213 214 lldb::TypeImplSP GetSP(); 215 216 void SetSP(const lldb::TypeImplSP &type_impl_sp); 217 218 lldb::TypeImplSP m_opaque_sp; 219 220 friend class SBFunction; 221 friend class SBModule; 222 friend class SBTarget; 223 friend class SBTypeEnumMember; 224 friend class SBTypeEnumMemberList; 225 friend class SBTypeNameSpecifier; 226 friend class SBTypeMember; 227 friend class SBTypeMemberFunction; 228 friend class SBTypeList; 229 friend class SBValue; 230 231 SBType(const lldb_private::CompilerType &); 232 SBType(const lldb::TypeSP &); 233 SBType(const lldb::TypeImplSP &); 234 }; 235 236 class SBTypeList { 237 public: 238 SBTypeList(); 239 240 SBTypeList(const lldb::SBTypeList &rhs); 241 242 ~SBTypeList(); 243 244 lldb::SBTypeList &operator=(const lldb::SBTypeList &rhs); 245 246 explicit operator bool() const; 247 248 bool IsValid(); 249 250 void Append(lldb::SBType type); 251 252 lldb::SBType GetTypeAtIndex(uint32_t index); 253 254 uint32_t GetSize(); 255 256 private: 257 std::unique_ptr<lldb_private::TypeListImpl> m_opaque_up; 258 friend class SBModule; 259 friend class SBCompileUnit; 260 }; 261 262 } // namespace lldb 263 264 #endif // LLDB_API_SBTYPE_H 265