[Lldb-commits] [lldb] r184215 - <rdar://problem/12717717>

Enrico Granata egranata at apple.com
Tue Jun 18 11:23:07 PDT 2013


Author: enrico
Date: Tue Jun 18 13:23:07 2013
New Revision: 184215

URL: http://llvm.org/viewvc/llvm-project?rev=184215&view=rev
Log:
<rdar://problem/12717717>

Modifying our data formatters matching algorithm to ensure that "const X*" is treated as equivalent to "X*"
Also, a couple improvements to the "lldb types" logging


Modified:
    lldb/trunk/include/lldb/DataFormatters/FormatNavigator.h
    lldb/trunk/include/lldb/Symbol/ClangASTType.h
    lldb/trunk/source/Core/Debugger.cpp
    lldb/trunk/source/DataFormatters/FormatManager.cpp
    lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp
    lldb/trunk/source/Symbol/ClangASTType.cpp

Modified: lldb/trunk/include/lldb/DataFormatters/FormatNavigator.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormatNavigator.h?rev=184215&r1=184214&r2=184215&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/FormatNavigator.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/FormatNavigator.h Tue Jun 18 13:23:07 2013
@@ -28,6 +28,7 @@
 #include "lldb/DataFormatters/FormatClasses.h"
 
 #include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/ClangASTType.h"
 
 #include "lldb/Target/ObjCLanguageRuntime.h"
 #include "lldb/Target/Process.h"
@@ -648,6 +649,36 @@ protected:
         if (Get_Impl (valobj,type,entry,use_dynamic,reason))
             return true;
         
+        // try going to the unqualified type
+        do {
+            if (log)
+                log->Printf("[Get] trying the unqualified type");
+            lldb::clang_type_t opaque_type = type.getAsOpaquePtr();
+            if (!opaque_type)
+            {
+                if (log)
+                    log->Printf("[Get] could not get the opaque_type");
+                break;
+            }
+            ClangASTType unqual_clang_ast_type = ClangASTType::GetFullyUnqualifiedType(valobj.GetClangAST(),opaque_type);
+            if (!unqual_clang_ast_type.IsValid())
+            {
+                if (log)
+                    log->Printf("[Get] could not get the unqual_clang_ast_type");
+                break;
+            }
+            clang::QualType unqualified_qual_type = clang::QualType::getFromOpaquePtr(unqual_clang_ast_type.GetOpaqueQualType());
+            if (unqualified_qual_type.getTypePtrOrNull() != type.getTypePtrOrNull())
+            {
+                if (log)
+                    log->Printf("[Get] unqualified type is there and is not the same, let's try");
+                if (Get_Impl (valobj,unqualified_qual_type,entry,use_dynamic,reason))
+                    return true;
+            }
+            else if (log)
+                log->Printf("[Get] unqualified type same as original type");
+        } while(false);
+        
         // if all else fails, go to static type
         if (valobj.IsDynamic())
         {

Modified: lldb/trunk/include/lldb/Symbol/ClangASTType.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTType.h?rev=184215&r1=184214&r2=184215&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTType.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTType.h Tue Jun 18 13:23:07 2013
@@ -151,7 +151,13 @@ public:
     {
         return GetTypeClass (GetASTContext(), GetOpaqueQualType());
     }
-
+    
+    ClangASTType
+    GetFullyUnqualifiedType ();
+    
+    static ClangASTType
+    GetFullyUnqualifiedType (clang::ASTContext *ast_context, lldb::clang_type_t clang_type);
+    
     void
     DumpValue (ExecutionContext *exe_ctx,
                Stream *s,

Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=184215&r1=184214&r2=184215&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Tue Jun 18 13:23:07 2013
@@ -1204,13 +1204,13 @@ ScanFormatDescriptor (const char* var_na
         *var_name_final = *percent_position;
         std::string format_name(*var_name_final+1, var_name_end-*var_name_final-1);
         if (log)
-            log->Printf("ScanFormatDescriptor] parsing %s as a format descriptor", format_name.c_str());
+            log->Printf("[ScanFormatDescriptor] parsing %s as a format descriptor", format_name.c_str());
         if ( !FormatManager::GetFormatFromCString(format_name.c_str(),
                                                   true,
                                                   *custom_format) )
         {
             if (log)
-                log->Printf("ScanFormatDescriptor] %s is an unknown format", format_name.c_str());
+                log->Printf("[ScanFormatDescriptor] %s is an unknown format", format_name.c_str());
             
             switch (format_name.front())
             {
@@ -1242,12 +1242,12 @@ ScanFormatDescriptor (const char* var_na
         else
         {
             if (log)
-                log->Printf("ScanFormatDescriptor] will display value for this VO");
+                log->Printf("[ScanFormatDescriptor] will display value for this VO");
             *val_obj_display = ValueObject::eValueObjectRepresentationStyleValue;
         }
     }
     if (log)
-        log->Printf("ScanFormatDescriptor] final format description outcome: custom_format = %d, val_obj_display = %d",
+        log->Printf("[ScanFormatDescriptor] final format description outcome: custom_format = %d, val_obj_display = %d",
                     *custom_format,
                     *val_obj_display);
     return true;
@@ -1469,11 +1469,10 @@ FormatPromptRecurse
                                 {
                                     do_deref_pointer = true;
                                     var_name_begin++;
+                                    if (log)
+                                        log->Printf("[Debugger::FormatPrompt] found a deref, new string is: %s",var_name_begin);
                                 }
                                 
-                                if (log)
-                                    log->Printf("[Debugger::FormatPrompt] initial string: %s",var_name_begin);
-                                
                                 if (*var_name_begin == 's')
                                 {
                                     if (!valobj->IsSynthetic())
@@ -1481,17 +1480,16 @@ FormatPromptRecurse
                                     if (!valobj)
                                         break;
                                     var_name_begin++;
+                                    if (log)
+                                        log->Printf("[Debugger::FormatPrompt] found a synthetic, new string is: %s",var_name_begin);
                                 }
                                 
-                                if (log)
-                                    log->Printf("[Debugger::FormatPrompt] initial string: %s",var_name_begin);
-                                
                                 // should be a 'v' by now
                                 if (*var_name_begin != 'v')
                                     break;
                                 
                                 if (log)
-                                    log->Printf("[Debugger::FormatPrompt] initial string: %s",var_name_begin);
+                                    log->Printf("[Debugger::FormatPrompt] string I am working with: %s",var_name_begin);
                                                                 
                                 ValueObject::ExpressionPathAftermath what_next = (do_deref_pointer ?
                                                                                   ValueObject::eExpressionPathAftermathDereference : ValueObject::eExpressionPathAftermathNothing);

Modified: lldb/trunk/source/DataFormatters/FormatManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/FormatManager.cpp?rev=184215&r1=184214&r2=184215&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/FormatManager.cpp (original)
+++ lldb/trunk/source/DataFormatters/FormatManager.cpp Tue Jun 18 13:23:07 2013
@@ -346,9 +346,18 @@ FormatManager::GetSummaryFormat (ValueOb
     if (valobj_type)
     {
         if (log)
-            log->Printf("[FormatManager::GetSummaryFormat] Looking into cache for type %s", valobj_type.AsCString("<invalid>"));
+            log->Printf("\n\n[FormatManager::GetSummaryFormat] Looking into cache for type %s", valobj_type.AsCString("<invalid>"));
         if (m_format_cache.GetSummary(valobj_type,retval))
+        {
+            if (log)
+            {
+                log->Printf("[FormatManager::GetSummaryFormat] Cache search success. Returning.");
+#ifdef LLDB_CONFIGURATION_DEBUG
+                log->Printf("[FormatManager::GetSummaryFormat] Cache hits: %llu - Cache Misses: %llu", m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
+#endif
+            }
             return retval;
+        }
         if (log)
             log->Printf("[FormatManager::GetSummaryFormat] Cache search failed. Going normal route");
     }
@@ -381,11 +390,20 @@ FormatManager::GetSyntheticChildren (Val
     if (valobj_type)
     {
         if (log)
-            log->Printf("[FormatManager::GetSyntheticChildren] Looking into cache for type %s\n", valobj_type.AsCString("<invalid>"));
+            log->Printf("\n\n[FormatManager::GetSyntheticChildren] Looking into cache for type %s", valobj_type.AsCString("<invalid>"));
         if (m_format_cache.GetSynthetic(valobj_type,retval))
+        {
+            if (log)
+            {
+                log->Printf("[FormatManager::GetSyntheticChildren] Cache search success. Returning.");
+#ifdef LLDB_CONFIGURATION_DEBUG
+                log->Printf("[FormatManager::GetSyntheticChildren] Cache hits: %llu - Cache Misses: %llu", m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
+#endif
+            }
             return retval;
+        }
         if (log)
-            log->Printf("[FormatManager::GetSyntheticChildren] Cache search failed. Going normal route\n");
+            log->Printf("[FormatManager::GetSyntheticChildren] Cache search failed. Going normal route");
     }
 #endif
     retval = m_categories_map.GetSyntheticChildren(valobj, use_dynamic);
@@ -393,7 +411,7 @@ FormatManager::GetSyntheticChildren (Val
     if (valobj_type)
     {
         if (log)
-            log->Printf("[FormatManager::GetSyntheticChildren] Caching %p for type %s\n",retval.get(),valobj_type.AsCString("<invalid>"));
+            log->Printf("[FormatManager::GetSyntheticChildren] Caching %p for type %s",retval.get(),valobj_type.AsCString("<invalid>"));
         m_format_cache.SetSynthetic(valobj_type,retval);
     }
 #ifdef LLDB_CONFIGURATION_DEBUG
@@ -690,9 +708,7 @@ FormatManager::LoadSystemFormatters()
     TypeCategoryImpl::SharedPointer sys_category_sp = GetCategory(m_system_category_name);
     
     sys_category_sp->GetSummaryNavigator()->Add(ConstString("char *"), string_format);
-    sys_category_sp->GetSummaryNavigator()->Add(ConstString("const char *"), string_format);
     sys_category_sp->GetSummaryNavigator()->Add(ConstString("unsigned char *"), string_format);
-    sys_category_sp->GetSummaryNavigator()->Add(ConstString("const unsigned char *"), string_format);
     sys_category_sp->GetRegexSummaryNavigator()->Add(any_size_char_arr, string_array_format);
     
     lldb::TypeSummaryImplSP ostype_summary(new StringSummaryFormat(TypeSummaryImpl::Flags().SetCascades(false)
@@ -709,16 +725,12 @@ FormatManager::LoadSystemFormatters()
 #ifndef LLDB_DISABLE_PYTHON
     // FIXME because of a bug in the FormatNavigator we need to add a summary for both X* and const X* (<rdar://problem/12717717>)
     AddCXXSummary(sys_category_sp, lldb_private::formatters::Char16StringSummaryProvider, "char16_t * summary provider", ConstString("char16_t *"), string_flags);
-    AddCXXSummary(sys_category_sp, lldb_private::formatters::Char16StringSummaryProvider, "char16_t * summary provider", ConstString("const char16_t *"), string_flags);
     
     AddCXXSummary(sys_category_sp, lldb_private::formatters::Char32StringSummaryProvider, "char32_t * summary provider", ConstString("char32_t *"), string_flags);
-    AddCXXSummary(sys_category_sp, lldb_private::formatters::Char32StringSummaryProvider, "char32_t * summary provider", ConstString("const char32_t *"), string_flags);
     
     AddCXXSummary(sys_category_sp, lldb_private::formatters::WCharStringSummaryProvider, "wchar_t * summary provider", ConstString("wchar_t *"), string_flags);
-    AddCXXSummary(sys_category_sp, lldb_private::formatters::WCharStringSummaryProvider, "wchar_t * summary provider", ConstString("const wchar_t *"), string_flags);
     
     AddCXXSummary(sys_category_sp, lldb_private::formatters::Char16StringSummaryProvider, "unichar * summary provider", ConstString("unichar *"), string_flags);
-    AddCXXSummary(sys_category_sp, lldb_private::formatters::Char16StringSummaryProvider, "unichar * summary provider", ConstString("const unichar *"), string_flags);
     
     TypeSummaryImpl::Flags widechar_flags;
     widechar_flags.SetDontShowValue(true)

Modified: lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp?rev=184215&r1=184214&r2=184215&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp (original)
+++ lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp Tue Jun 18 13:23:07 2013
@@ -192,13 +192,13 @@ TypeCategoryMap::GetSummaryFormat (Value
         lldb::TypeCategoryImplSP category_sp = *begin;
         lldb::TypeSummaryImplSP current_format;
         if (log)
-            log->Printf("[CategoryMap::GetSummaryFormat] Trying to use category %s\n", category_sp->GetName());
+            log->Printf("\n[CategoryMap::GetSummaryFormat] Trying to use category %s", category_sp->GetName());
         if (!category_sp->Get(valobj, current_format, use_dynamic, &reason_why))
             continue;
         return current_format;
     }
     if (log)
-        log->Printf("[CategoryMap::GetSummaryFormat] nothing found - returning empty SP\n");
+        log->Printf("[CategoryMap::GetSummaryFormat] nothing found - returning empty SP");
     return lldb::TypeSummaryImplSP();
 }
 
@@ -220,13 +220,13 @@ TypeCategoryMap::GetSyntheticChildren (V
         lldb::TypeCategoryImplSP category_sp = *begin;
         lldb::SyntheticChildrenSP current_format;
         if (log)
-            log->Printf("[CategoryMap::GetSyntheticChildren] Trying to use category %s\n", category_sp->GetName());
+            log->Printf("\n[CategoryMap::GetSyntheticChildren] Trying to use category %s", category_sp->GetName());
         if (!category_sp->Get(valobj, current_format, use_dynamic, &reason_why))
             continue;
         return current_format;
     }
     if (log)
-        log->Printf("[CategoryMap::GetSyntheticChildren] nothing found - returning empty SP\n");
+        log->Printf("[CategoryMap::GetSyntheticChildren] nothing found - returning empty SP");
     return lldb::SyntheticChildrenSP();
 }
 #endif

Modified: lldb/trunk/source/Symbol/ClangASTType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=184215&r1=184214&r2=184215&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTType.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTType.cpp Tue Jun 18 13:23:07 2013
@@ -195,6 +195,31 @@ ClangASTType::GetPointerType (clang::AST
     return NULL;
 }
 
+ClangASTType
+ClangASTType::GetFullyUnqualifiedType ()
+{
+    return GetFullyUnqualifiedType(m_ast, m_type);
+}
+
+static clang::QualType GetFullyUnqualifiedType_Impl (clang::QualType Ty,
+                                                     clang::ASTContext * ctx)
+{
+    if (Ty->isPointerType())
+        Ty = ctx->getPointerType(GetFullyUnqualifiedType_Impl(Ty->getPointeeType(),ctx));
+    else
+        Ty = Ty.getUnqualifiedType();
+    Ty.removeLocalConst();
+    Ty.removeLocalRestrict();
+    Ty.removeLocalVolatile();
+    return Ty;
+}
+
+ClangASTType
+ClangASTType::GetFullyUnqualifiedType (clang::ASTContext *ast_context, lldb::clang_type_t clang_type)
+{
+    return ClangASTType(ast_context,GetFullyUnqualifiedType_Impl(clang::QualType::getFromOpaquePtr(clang_type),ast_context).getAsOpaquePtr());
+}
+
 lldb::Encoding
 ClangASTType::GetEncoding (uint64_t &count)
 {





More information about the lldb-commits mailing list