[Lldb-commits] [lldb] r199939 - Added the ability to get the type that a typedef points to via:

Greg Clayton gclayton at apple.com
Thu Jan 23 13:38:35 PST 2014


Author: gclayton
Date: Thu Jan 23 15:38:34 2014
New Revision: 199939

URL: http://llvm.org/viewvc/llvm-project?rev=199939&view=rev
Log:
Added the ability to get the type that a typedef points to via:

SBType SBType::GetTypedefedType();

Also added the ability to get a type by type ID from a SBModule:

SBType SBModule::GetTypeByID (lldb::user_id_t uid);



Modified:
    lldb/trunk/include/lldb/API/SBModule.h
    lldb/trunk/include/lldb/API/SBType.h
    lldb/trunk/include/lldb/Symbol/Type.h
    lldb/trunk/scripts/Python/interface/SBModule.i
    lldb/trunk/scripts/Python/interface/SBType.i
    lldb/trunk/source/API/SBModule.cpp
    lldb/trunk/source/API/SBType.cpp
    lldb/trunk/source/Symbol/Type.cpp

Modified: lldb/trunk/include/lldb/API/SBModule.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBModule.h?rev=199939&r1=199938&r2=199939&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBModule.h (original)
+++ lldb/trunk/include/lldb/API/SBModule.h Thu Jan 23 15:38:34 2014
@@ -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);
 

Modified: lldb/trunk/include/lldb/API/SBType.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBType.h?rev=199939&r1=199938&r2=199939&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBType.h (original)
+++ lldb/trunk/include/lldb/API/SBType.h Thu Jan 23 15:38:34 2014
@@ -106,6 +106,9 @@ public:
     GetReferenceType();
     
     lldb::SBType
+    GetTypedefedType();
+
+    lldb::SBType
     GetDereferencedType();
 
     lldb::SBType

Modified: lldb/trunk/include/lldb/Symbol/Type.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Type.h?rev=199939&r1=199938&r2=199939&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Type.h (original)
+++ lldb/trunk/include/lldb/Symbol/Type.h Thu Jan 23 15:38:34 2014
@@ -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
     {
@@ -513,6 +521,9 @@ public:
     GetReferenceType () const;
     
     TypeImpl
+    GetTypedefedType () const;
+
+    TypeImpl
     GetDereferencedType () const;
     
     TypeImpl

Modified: lldb/trunk/scripts/Python/interface/SBModule.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBModule.i?rev=199939&r1=199938&r2=199939&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBModule.i (original)
+++ lldb/trunk/scripts/Python/interface/SBModule.i Thu Jan 23 15:38:34 2014
@@ -231,6 +231,9 @@ public:
     FindTypes (const char* type);
 
     lldb::SBType
+    GetTypeByID (lldb::user_id_t uid);
+
+    lldb::SBType
     GetBasicType(lldb::BasicType type);
 
     %feature("docstring", "

Modified: lldb/trunk/scripts/Python/interface/SBType.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBType.i?rev=199939&r1=199938&r2=199939&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBType.i (original)
+++ lldb/trunk/scripts/Python/interface/SBType.i Thu Jan 23 15:38:34 2014
@@ -178,6 +178,9 @@ public:
     GetReferenceType();
 
     lldb::SBType
+    SBType::GetTypedefedType();
+    
+    lldb::SBType
     GetDereferencedType();
 
     lldb::SBType

Modified: lldb/trunk/source/API/SBModule.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBModule.cpp?rev=199939&r1=199938&r2=199939&view=diff
==============================================================================
--- lldb/trunk/source/API/SBModule.cpp (original)
+++ lldb/trunk/source/API/SBModule.cpp Thu Jan 23 15:38:34 2014
@@ -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)
 {

Modified: lldb/trunk/source/API/SBType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBType.cpp?rev=199939&r1=199938&r2=199939&view=diff
==============================================================================
--- lldb/trunk/source/API/SBType.cpp (original)
+++ lldb/trunk/source/API/SBType.cpp Thu Jan 23 15:38:34 2014
@@ -186,6 +186,14 @@ SBType::GetReferenceType()
 }
 
 SBType
+SBType::GetTypedefedType()
+{
+    if (!IsValid())
+        return SBType();
+    return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetTypedefedType())));
+}
+
+SBType
 SBType::GetDereferencedType()
 {
     if (!IsValid())

Modified: lldb/trunk/source/Symbol/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=199939&r1=199938&r2=199939&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Type.cpp (original)
+++ lldb/trunk/source/Symbol/Type.cpp Thu Jan 23 15:38:34 2014
@@ -1084,6 +1084,16 @@ TypeImpl::GetReferenceType () const
 }
 
 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
 {
     if (m_dynamic_type.IsValid())





More information about the lldb-commits mailing list