[Lldb-commits] [lldb] r193724 - This checkin introduces the notion of hardcoded formatters, which LLDB can bind to a ValueObject internally depending on any criteria

Enrico Granata egranata at apple.com
Wed Oct 30 16:46:27 PDT 2013


Author: enrico
Date: Wed Oct 30 18:46:27 2013
New Revision: 193724

URL: http://llvm.org/viewvc/llvm-project?rev=193724&view=rev
Log:
This checkin introduces the notion of hardcoded formatters, which LLDB can bind to a ValueObject internally depending on any criteria
User-vended by-type formatters still would prevail on these hardcoded ones

For the time being, while the infrastructure is there, no such formatters exist

This can be useful for cases such as expanding vtables for C++ class pointers, when there is no clear cut notion of a typename matching, and the feature is low-level enough that it makes sense for the debugger core to be vending it

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=193724&r1=193723&r2=193724&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/FormatManager.cpp (original)
+++ lldb/trunk/source/DataFormatters/FormatManager.cpp Wed Oct 30 18:46:27 2013
@@ -420,6 +420,13 @@ GetTypeForCache (ValueObject& valobj,
     return ConstString();
 }
 
+static lldb::TypeFormatImplSP
+GetHardcodedFormat (ValueObject& valobj,
+                    lldb::DynamicValueType use_dynamic)
+{
+    return lldb::TypeFormatImplSP();
+}
+
 lldb::TypeFormatImplSP
 FormatManager::GetFormat (ValueObject& valobj,
                           lldb::DynamicValueType use_dynamic)
@@ -445,6 +452,12 @@ FormatManager::GetFormat (ValueObject& v
             log->Printf("[FormatManager::GetFormat] Cache search failed. Going normal route");
     }
     retval = m_categories_map.GetFormat(valobj, use_dynamic);
+    if (!retval)
+    {
+        if (log)
+            log->Printf("[FormatManager::GetFormat] Search failed. Giving hardcoded a chance.");
+        retval = GetHardcodedFormat(valobj, use_dynamic);
+    }
     if (valobj_type)
     {
         if (log)
@@ -456,6 +469,13 @@ FormatManager::GetFormat (ValueObject& v
     return retval;
 }
 
+static lldb::TypeSummaryImplSP
+GetHardcodedSummaryFormat (ValueObject& valobj,
+                               lldb::DynamicValueType use_dynamic)
+{
+    return lldb::TypeSummaryImplSP();
+}
+
 lldb::TypeSummaryImplSP
 FormatManager::GetSummaryFormat (ValueObject& valobj,
                                  lldb::DynamicValueType use_dynamic)
@@ -481,6 +501,12 @@ FormatManager::GetSummaryFormat (ValueOb
             log->Printf("[FormatManager::GetSummaryFormat] Cache search failed. Going normal route");
     }
     retval = m_categories_map.GetSummaryFormat(valobj, use_dynamic);
+    if (!retval)
+    {
+        if (log)
+            log->Printf("[FormatManager::GetSummaryFormat] Search failed. Giving hardcoded a chance.");
+        retval = GetHardcodedSummaryFormat(valobj, use_dynamic);
+    }
     if (valobj_type)
     {
         if (log)
@@ -493,6 +519,13 @@ FormatManager::GetSummaryFormat (ValueOb
 }
 
 #ifndef LLDB_DISABLE_PYTHON
+static lldb::SyntheticChildrenSP
+GetHardcodedSyntheticChildren (ValueObject& valobj,
+                               lldb::DynamicValueType use_dynamic)
+{
+    return lldb::SyntheticChildrenSP();
+}
+
 lldb::SyntheticChildrenSP
 FormatManager::GetSyntheticChildren (ValueObject& valobj,
                                      lldb::DynamicValueType use_dynamic)
@@ -518,6 +551,12 @@ FormatManager::GetSyntheticChildren (Val
             log->Printf("[FormatManager::GetSyntheticChildren] Cache search failed. Going normal route");
     }
     retval = m_categories_map.GetSyntheticChildren(valobj, use_dynamic);
+    if (!retval)
+    {
+        if (log)
+            log->Printf("[FormatManager::GetSyntheticChildren] Search failed. Giving hardcoded a chance.");
+        retval = GetHardcodedSyntheticChildren(valobj, use_dynamic);
+    }
     if (valobj_type)
     {
         if (log)





More information about the lldb-commits mailing list