[Lldb-commits] [lldb] r184900 - Remove the #define USE_CACHE since the formatters cache has been operational for a while now and has not caused issues that warrant disabling it

Enrico Granata egranata at apple.com
Tue Jun 25 18:03:38 PDT 2013


Author: enrico
Date: Tue Jun 25 20:03:38 2013
New Revision: 184900

URL: http://llvm.org/viewvc/llvm-project?rev=184900&view=rev
Log:
Remove the #define USE_CACHE since the formatters cache has been operational for a while now and has not caused issues that warrant disabling it
Also, print the cache hits statistics if the log is in debugging mode vs. LLDB being a debug build - this should make it easier to gather useful metrics on cache success rate for real users

Modified:
    lldb/trunk/source/DataFormatters/FormatManager.cpp

Modified: lldb/trunk/source/DataFormatters/FormatManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/FormatManager.cpp?rev=184900&r1=184899&r2=184900&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/FormatManager.cpp (original)
+++ lldb/trunk/source/DataFormatters/FormatManager.cpp Tue Jun 25 20:03:38 2013
@@ -334,13 +334,11 @@ GetTypeForCache (ValueObject& valobj,
     return ConstString();
 }
 
-#define USE_CACHE 1
 lldb::TypeSummaryImplSP
 FormatManager::GetSummaryFormat (ValueObject& valobj,
                                  lldb::DynamicValueType use_dynamic)
 {
     TypeSummaryImplSP retval;
-#if USE_CACHE
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
     ConstString valobj_type(GetTypeForCache(valobj, use_dynamic));
     if (valobj_type)
@@ -352,39 +350,32 @@ FormatManager::GetSummaryFormat (ValueOb
             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
+                if (log->GetDebug())
+                    log->Printf("[FormatManager::GetSummaryFormat] Cache hits: %llu - Cache Misses: %llu", m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
             }
             return retval;
         }
         if (log)
             log->Printf("[FormatManager::GetSummaryFormat] Cache search failed. Going normal route");
     }
-#endif
     retval = m_categories_map.GetSummaryFormat(valobj, use_dynamic);
-#if USE_CACHE
     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);
     }
-#ifdef LLDB_CONFIGURATION_DEBUG
-    if (log)
+    if (log && log->GetDebug())
         log->Printf("[FormatManager::GetSummaryFormat] Cache hits: %llu - Cache Misses: %llu", m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
-#endif
-#endif
     return retval;
 }
 
 #ifndef LLDB_DISABLE_PYTHON
 lldb::SyntheticChildrenSP
 FormatManager::GetSyntheticChildren (ValueObject& valobj,
-                      lldb::DynamicValueType use_dynamic)
+                                     lldb::DynamicValueType use_dynamic)
 {
     SyntheticChildrenSP retval;
-#if USE_CACHE
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
     ConstString valobj_type(GetTypeForCache(valobj, use_dynamic));
     if (valobj_type)
@@ -396,33 +387,26 @@ FormatManager::GetSyntheticChildren (Val
             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
+                if (log->GetDebug())
+                    log->Printf("[FormatManager::GetSyntheticChildren] Cache hits: %llu - Cache Misses: %llu", m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
             }
             return retval;
         }
         if (log)
             log->Printf("[FormatManager::GetSyntheticChildren] Cache search failed. Going normal route");
     }
-#endif
     retval = m_categories_map.GetSyntheticChildren(valobj, use_dynamic);
-#if USE_CACHE
     if (valobj_type)
     {
         if (log)
             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
-    if (log)
+    if (log && log->GetDebug())
         log->Printf("[FormatManager::GetSyntheticChildren] Cache hits: %llu - Cache Misses: %llu", m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
-#endif
-#endif
     return retval;
 }
 #endif
-#undef USE_CACHE
 
 FormatManager::FormatManager() :
     m_format_cache(),





More information about the lldb-commits mailing list