[Lldb-commits] [lldb] r192928 - This is the last piece of work for "formats in categories": we now cache formats as well as summaries and synthetics

Enrico Granata egranata at apple.com
Thu Oct 17 15:27:19 PDT 2013


Author: enrico
Date: Thu Oct 17 17:27:19 2013
New Revision: 192928

URL: http://llvm.org/viewvc/llvm-project?rev=192928&view=rev
Log:
This is the last piece of work for "formats in categories": we now cache formats as well as summaries and synthetics


Modified:
    lldb/trunk/include/lldb/DataFormatters/FormatCache.h
    lldb/trunk/source/DataFormatters/FormatCache.cpp
    lldb/trunk/source/DataFormatters/FormatManager.cpp
    lldb/trunk/test/dotest.py

Modified: lldb/trunk/include/lldb/DataFormatters/FormatCache.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormatCache.h?rev=192928&r1=192927&r2=192928&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/FormatCache.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/FormatCache.h Thu Oct 17 17:27:19 2013
@@ -27,23 +27,32 @@ private:
     struct Entry
     {
     private:
+        bool m_format_cached : 1;
         bool m_summary_cached : 1;
         bool m_synthetic_cached : 1;
         
+        lldb::TypeFormatImplSP m_format_sp;
         lldb::TypeSummaryImplSP m_summary_sp;
         lldb::SyntheticChildrenSP m_synthetic_sp;
     public:
         Entry ();
+        Entry (lldb::TypeFormatImplSP);
         Entry (lldb::TypeSummaryImplSP);
         Entry (lldb::SyntheticChildrenSP);
-        Entry (lldb::TypeSummaryImplSP,lldb::SyntheticChildrenSP);
+        Entry (lldb::TypeFormatImplSP,lldb::TypeSummaryImplSP,lldb::SyntheticChildrenSP);
 
         bool
+        IsFormatCached ();
+        
+        bool
         IsSummaryCached ();
         
         bool
         IsSyntheticCached ();
         
+        lldb::TypeFormatImplSP
+        GetFormat ();
+        
         lldb::TypeSummaryImplSP
         GetSummary ();
         
@@ -51,6 +60,9 @@ private:
         GetSynthetic ();
         
         void
+        SetFormat (lldb::TypeFormatImplSP);
+        
+        void
         SetSummary (lldb::TypeSummaryImplSP);
         
         void
@@ -70,12 +82,18 @@ public:
     FormatCache ();
     
     bool
+    GetFormat (const ConstString& type,lldb::TypeFormatImplSP& format_sp);
+    
+    bool
     GetSummary (const ConstString& type,lldb::TypeSummaryImplSP& summary_sp);
 
     bool
     GetSynthetic (const ConstString& type,lldb::SyntheticChildrenSP& synthetic_sp);
     
     void
+    SetFormat (const ConstString& type,lldb::TypeFormatImplSP& format_sp);
+    
+    void
     SetSummary (const ConstString& type,lldb::TypeSummaryImplSP& summary_sp);
     
     void

Modified: lldb/trunk/source/DataFormatters/FormatCache.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/FormatCache.cpp?rev=192928&r1=192927&r2=192928&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/FormatCache.cpp (original)
+++ lldb/trunk/source/DataFormatters/FormatCache.cpp Thu Oct 17 17:27:19 2013
@@ -22,33 +22,55 @@ using namespace lldb;
 using namespace lldb_private;
 
 FormatCache::Entry::Entry () :
+m_format_cached(false),
 m_summary_cached(false),
 m_synthetic_cached(false),
+m_format_sp(),
 m_summary_sp(),
 m_synthetic_sp()
 {}
 
+FormatCache::Entry::Entry (lldb::TypeFormatImplSP format_sp) :
+m_summary_cached(false),
+m_synthetic_cached(false),
+m_summary_sp(),
+m_synthetic_sp()
+{
+    SetFormat (format_sp);
+}
+
 FormatCache::Entry::Entry (lldb::TypeSummaryImplSP summary_sp) :
+m_format_cached(false),
 m_synthetic_cached(false),
+m_format_sp(),
 m_synthetic_sp()
 {
     SetSummary (summary_sp);
 }
 
 FormatCache::Entry::Entry (lldb::SyntheticChildrenSP synthetic_sp) :
+m_format_cached(false),
 m_summary_cached(false),
+m_format_sp(),
 m_summary_sp()
 {
     SetSynthetic (synthetic_sp);
 }
 
-FormatCache::Entry::Entry (lldb::TypeSummaryImplSP summary_sp,lldb::SyntheticChildrenSP synthetic_sp)
+FormatCache::Entry::Entry (lldb::TypeFormatImplSP format_sp, lldb::TypeSummaryImplSP summary_sp, lldb::SyntheticChildrenSP synthetic_sp)
 {
+    SetFormat (format_sp);
     SetSummary (summary_sp);
     SetSynthetic (synthetic_sp);
 }
 
 bool
+FormatCache::Entry::IsFormatCached ()
+{
+    return m_format_cached;
+}
+
+bool
 FormatCache::Entry::IsSummaryCached ()
 {
     return m_summary_cached;
@@ -60,6 +82,12 @@ FormatCache::Entry::IsSyntheticCached ()
     return m_synthetic_cached;
 }
 
+lldb::TypeFormatImplSP
+FormatCache::Entry::GetFormat ()
+{
+    return m_format_sp;
+}
+
 lldb::TypeSummaryImplSP
 FormatCache::Entry::GetSummary ()
 {
@@ -73,6 +101,13 @@ FormatCache::Entry::GetSynthetic ()
 }
 
 void
+FormatCache::Entry::SetFormat (lldb::TypeFormatImplSP format_sp)
+{
+    m_format_cached = true;
+    m_format_sp = format_sp;
+}
+
+void
 FormatCache::Entry::SetSummary (lldb::TypeSummaryImplSP summary_sp)
 {
     m_summary_cached = true;
@@ -107,6 +142,26 @@ FormatCache::GetEntry (const ConstString
 }
 
 bool
+FormatCache::GetFormat (const ConstString& type,lldb::TypeFormatImplSP& format_sp)
+{
+    Mutex::Locker lock(m_mutex);
+    auto entry = GetEntry(type);
+    if (entry.IsSummaryCached())
+    {
+#ifdef LLDB_CONFIGURATION_DEBUG
+        m_cache_hits++;
+#endif
+        format_sp = entry.GetFormat();
+        return true;
+    }
+#ifdef LLDB_CONFIGURATION_DEBUG
+    m_cache_misses++;
+#endif
+    format_sp.reset();
+    return false;
+}
+
+bool
 FormatCache::GetSummary (const ConstString& type,lldb::TypeSummaryImplSP& summary_sp)
 {
     Mutex::Locker lock(m_mutex);
@@ -147,6 +202,13 @@ FormatCache::GetSynthetic (const ConstSt
 }
 
 void
+FormatCache::SetFormat (const ConstString& type,lldb::TypeFormatImplSP& format_sp)
+{
+    Mutex::Locker lock(m_mutex);
+    GetEntry(type).SetFormat(format_sp);
+}
+
+void
 FormatCache::SetSummary (const ConstString& type,lldb::TypeSummaryImplSP& summary_sp)
 {
     Mutex::Locker lock(m_mutex);

Modified: lldb/trunk/source/DataFormatters/FormatManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/FormatManager.cpp?rev=192928&r1=192927&r2=192928&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/FormatManager.cpp (original)
+++ lldb/trunk/source/DataFormatters/FormatManager.cpp Thu Oct 17 17:27:19 2013
@@ -425,34 +425,34 @@ FormatManager::GetFormat (ValueObject& v
                           lldb::DynamicValueType use_dynamic)
 {
     TypeFormatImplSP retval;
-//    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
-//    ConstString valobj_type(GetTypeForCache(valobj, use_dynamic));
-//    if (valobj_type)
-//    {
-//        if (log)
-//            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.");
-//                if (log->GetDebug())
-//                    log->Printf("[FormatManager::GetSummaryFormat] Cache hits: %" PRIu64 " - Cache Misses: %" PRIu64, m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
-//            }
-//            return retval;
-//        }
-//        if (log)
-//            log->Printf("[FormatManager::GetSummaryFormat] Cache search failed. Going normal route");
-//    }
+    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
+    ConstString valobj_type(GetTypeForCache(valobj, use_dynamic));
+    if (valobj_type)
+    {
+        if (log)
+            log->Printf("\n\n[FormatManager::GetFormat] Looking into cache for type %s", valobj_type.AsCString("<invalid>"));
+        if (m_format_cache.GetFormat(valobj_type,retval))
+        {
+            if (log)
+            {
+                log->Printf("[FormatManager::GetFormat] Cache search success. Returning.");
+                if (log->GetDebug())
+                    log->Printf("[FormatManager::GetFormat] Cache hits: %" PRIu64 " - Cache Misses: %" PRIu64, m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
+            }
+            return retval;
+        }
+        if (log)
+            log->Printf("[FormatManager::GetFormat] Cache search failed. Going normal route");
+    }
     retval = m_categories_map.GetFormat(valobj, use_dynamic);
-//    if (valobj_type)
-//    {
-//        if (log)
-//            log->Printf("[FormatManager::GetSummaryFormat] Caching %p for type %s",retval.get(),valobj_type.AsCString("<invalid>"));
-//        m_format_cache.SetSummary(valobj_type,retval);
-//    }
-//    if (log && log->GetDebug())
-//        log->Printf("[FormatManager::GetSummaryFormat] Cache hits: %" PRIu64 " - Cache Misses: %" PRIu64, m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
+    if (valobj_type)
+    {
+        if (log)
+            log->Printf("[FormatManager::GetFormat] Caching %p for type %s",retval.get(),valobj_type.AsCString("<invalid>"));
+        m_format_cache.SetFormat(valobj_type,retval);
+    }
+    if (log && log->GetDebug())
+        log->Printf("[FormatManager::GetFormat] Cache hits: %" PRIu64 " - Cache Misses: %" PRIu64, m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
     return retval;
 }
 

Modified: lldb/trunk/test/dotest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=192928&r1=192927&r2=192928&view=diff
==============================================================================
--- lldb/trunk/test/dotest.py (original)
+++ lldb/trunk/test/dotest.py Thu Oct 17 17:27:19 2013
@@ -624,7 +624,7 @@ def parseOptionsAndInitTestdirs():
         noHeaders = True
         parsable = True
 
-    if args.P:
+    if args.P and not args.v:
         progress_bar = True
         verbose = 0
 





More information about the lldb-commits mailing list