[Lldb-commits] [lldb] r219427 - If a ValueObject has a child that vends synthetic children, but only does so to generate a value for itself, that's not a disqualifier from one-line printing. Also, fetch synthetic values if available and requested for children as well while printing them

Enrico Granata egranata at apple.com
Thu Oct 9 11:47:37 PDT 2014


Author: enrico
Date: Thu Oct  9 13:47:36 2014
New Revision: 219427

URL: http://llvm.org/viewvc/llvm-project?rev=219427&view=rev
Log:
If a ValueObject has a child that vends synthetic children, but only does so to generate a value for itself, that's not a disqualifier from one-line printing. Also, fetch synthetic values if available and requested for children as well while printing them

Modified:
    lldb/trunk/source/DataFormatters/FormatManager.cpp
    lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp
    lldb/trunk/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py
    lldb/trunk/test/functionalities/data-formatter/data-formatter-synthval/myIntSynthProvider.py

Modified: lldb/trunk/source/DataFormatters/FormatManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/FormatManager.cpp?rev=219427&r1=219426&r2=219427&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/FormatManager.cpp (original)
+++ lldb/trunk/source/DataFormatters/FormatManager.cpp Thu Oct  9 13:47:36 2014
@@ -541,6 +541,7 @@ FormatManager::ShouldPrintAsOneLiner (Va
          idx < valobj.GetNumChildren();
          idx++)
     {
+        bool is_synth_val = false;
         ValueObjectSP child_sp(valobj.GetChildAtIndex(idx, true));
         // something is wrong here - bail out
         if (!child_sp)
@@ -548,7 +549,17 @@ FormatManager::ShouldPrintAsOneLiner (Va
         // if we decided to define synthetic children for a type, we probably care enough
         // to show them, but avoid nesting children in children
         if (child_sp->GetSyntheticChildren().get() != nullptr)
-            return false;
+        {
+            ValueObjectSP synth_sp(child_sp->GetSyntheticValue());
+            // wait.. wat? just get out of here..
+            if (!synth_sp)
+                return false;
+            // but if we only have them to provide a value, keep going
+            if (synth_sp->MightHaveChildren() == false && synth_sp->DoesProvideSyntheticValue())
+                is_synth_val = true;
+            else
+                return false;
+        }
         
         total_children_name_len += child_sp->GetName().GetLength();
         
@@ -572,7 +583,7 @@ FormatManager::ShouldPrintAsOneLiner (Va
             // ...and no summary...
             // (if it had a summary and the summary wanted children, we would have bailed out anyway
             //  so this only makes us bail out if this has no summary and we would then print children)
-            if (!child_sp->GetSummaryFormat())
+            if (!child_sp->GetSummaryFormat() && !is_synth_val) // but again only do that if not a synthetic valued child
                 return false; // then bail out
         }
     }

Modified: lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp?rev=219427&r1=219426&r2=219427&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp (original)
+++ lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp Thu Oct  9 13:47:36 2014
@@ -591,9 +591,8 @@ ValueObjectPrinter::PrintChildrenOneLine
         for (uint32_t idx=0; idx<num_children; ++idx)
         {
             lldb::ValueObjectSP child_sp(synth_m_valobj->GetChildAtIndex(idx, true));
-            lldb::ValueObjectSP child_dyn_sp = child_sp.get() ? child_sp->GetDynamicValue(options.m_use_dynamic) : child_sp;
-            if (child_dyn_sp)
-                child_sp = child_dyn_sp;
+            if (child_sp)
+                child_sp = child_sp->GetQualifiedRepresentationIfAvailable(options.m_use_dynamic, options.m_use_synthetic);
             if (child_sp)
             {
                 if (idx)

Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py?rev=219427&r1=219426&r2=219427&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py (original)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py Thu Oct  9 13:47:36 2014
@@ -87,6 +87,9 @@ class DataFormatterSynthValueTestCase(Te
         
         self.expect("frame variable x", substrs=['3'])
         self.expect("frame variable x", substrs=['theValue = 3'], matching=False)
+        
+        # check that an aptly defined synthetic provider does not affect one-lining
+        self.expect("expression struct S { myInt theInt{12}; }; S()", substrs = ['(theInt = 12)'])
 
 if __name__ == '__main__':
     import atexit

Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-synthval/myIntSynthProvider.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-synthval/myIntSynthProvider.py?rev=219427&r1=219426&r2=219427&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-synthval/myIntSynthProvider.py (original)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-synthval/myIntSynthProvider.py Thu Oct  9 13:47:36 2014
@@ -10,7 +10,7 @@ class myIntSynthProvider(object):
 	    return None
 	def update(self):
 		return False
-	def might_have_children(self):
+	def has_children(self):
 	    return False
 	def get_value(self):
 	    return self.val





More information about the lldb-commits mailing list