diff --git a/lldb/include/lldb/API/SBModule.h b/lldb/include/lldb/API/SBModule.h index f5955b39734d..e85654bccc72 100644 --- a/lldb/include/lldb/API/SBModule.h +++ b/lldb/include/lldb/API/SBModule.h @@ -235,6 +235,25 @@ public: lldb::SBTypeList FindTypes (const char* type); + //------------------------------------------------------------------ + /// Get a type using its type ID. + /// + /// Each symbol file reader will assign different user IDs to their + /// types, but it is sometimes useful when debugging type issues to + /// be able to grab a type using its type ID. + /// + /// For DWARF debug info, the type ID is the DIE offset. + /// + /// @param[in] uid + /// The type user ID. + /// + /// @return + /// An SBType for the given type ID, or an empty SBType if the + /// type was not found. + //------------------------------------------------------------------ + lldb::SBType + GetTypeByID (lldb::user_id_t uid); + lldb::SBType GetBasicType(lldb::BasicType type); diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h index 3729b2f84b90..2cd9b4459a33 100644 --- a/lldb/include/lldb/API/SBType.h +++ b/lldb/include/lldb/API/SBType.h @@ -105,6 +105,9 @@ public: lldb::SBType GetReferenceType(); + lldb::SBType + GetTypedefedType(); + lldb::SBType GetDereferencedType(); diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h index 920f571fa1e9..da327439936c 100644 --- a/lldb/include/lldb/Symbol/Type.h +++ b/lldb/include/lldb/Symbol/Type.h @@ -417,7 +417,15 @@ public: return type_sp->GetClangLayoutType().GetLValueReferenceType(); return clang_type.GetLValueReferenceType(); } - + + ClangASTType + GetTypedefedType () const + { + if (type_sp) + return type_sp->GetClangFullType().GetTypedefedType(); + return clang_type.GetTypedefedType(); + } + ClangASTType GetDereferencedType () const { @@ -512,6 +520,9 @@ public: TypeImpl GetReferenceType () const; + TypeImpl + GetTypedefedType () const; + TypeImpl GetDereferencedType () const; diff --git a/lldb/scripts/Python/interface/SBModule.i b/lldb/scripts/Python/interface/SBModule.i index 21f9dcc4055f..387a2741e020 100644 --- a/lldb/scripts/Python/interface/SBModule.i +++ b/lldb/scripts/Python/interface/SBModule.i @@ -230,6 +230,9 @@ public: lldb::SBTypeList FindTypes (const char* type); + lldb::SBType + GetTypeByID (lldb::user_id_t uid); + lldb::SBType GetBasicType(lldb::BasicType type); diff --git a/lldb/scripts/Python/interface/SBType.i b/lldb/scripts/Python/interface/SBType.i index fbeed3efd665..936bf2ccf277 100644 --- a/lldb/scripts/Python/interface/SBType.i +++ b/lldb/scripts/Python/interface/SBType.i @@ -177,6 +177,9 @@ public: lldb::SBType GetReferenceType(); + lldb::SBType + SBType::GetTypedefedType(); + lldb::SBType GetDereferencedType(); diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp index 0285cf304d4d..19c3ee7fce53 100644 --- a/lldb/source/API/SBModule.cpp +++ b/lldb/source/API/SBModule.cpp @@ -579,6 +579,23 @@ SBModule::FindTypes (const char *type) return retval; } +lldb::SBType +SBModule::GetTypeByID (lldb::user_id_t uid) +{ + ModuleSP module_sp (GetSP ()); + if (module_sp) + { + SymbolVendor* vendor = module_sp->GetSymbolVendor(); + if (vendor) + { + Type *type_ptr = vendor->ResolveTypeUID(uid); + if (type_ptr) + return SBType(type_ptr->shared_from_this()); + } + } + return SBType(); +} + lldb::SBTypeList SBModule::GetTypes (uint32_t type_mask) { diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp index 3055c2752083..5ca7ddf3d813 100644 --- a/lldb/source/API/SBType.cpp +++ b/lldb/source/API/SBType.cpp @@ -185,6 +185,14 @@ SBType::GetReferenceType() return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetReferenceType()))); } +SBType +SBType::GetTypedefedType() +{ + if (!IsValid()) + return SBType(); + return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetTypedefedType()))); +} + SBType SBType::GetDereferencedType() { diff --git a/lldb/source/Symbol/Type.cpp b/lldb/source/Symbol/Type.cpp index 32a1d474053f..073940e8a7f7 100644 --- a/lldb/source/Symbol/Type.cpp +++ b/lldb/source/Symbol/Type.cpp @@ -1083,6 +1083,16 @@ TypeImpl::GetReferenceType () const return TypeImpl(m_static_type.GetReferenceType()); } +TypeImpl +TypeImpl::GetTypedefedType () const +{ + if (m_dynamic_type.IsValid()) + { + return TypeImpl(m_static_type, m_dynamic_type.GetTypedefedType()); + } + return TypeImpl(m_static_type.GetTypedefedType()); +} + TypeImpl TypeImpl::GetDereferencedType () const {