[Lldb-commits] [lldb] r280294 - Fix an issue where a synthetic child provider could only provide a value of the same size as the containing type

Enrico Granata via lldb-commits lldb-commits at lists.llvm.org
Wed Aug 31 14:46:22 PDT 2016


Author: enrico
Date: Wed Aug 31 16:46:21 2016
New Revision: 280294

URL: http://llvm.org/viewvc/llvm-project?rev=280294&view=rev
Log:
Fix an issue where a synthetic child provider could only provide a value of the same size as the containing type


Modified:
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/main.cpp
    lldb/trunk/source/DataFormatters/TypeFormat.cpp

Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py?rev=280294&r1=280293&r2=280294&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py Wed Aug 31 16:46:21 2016
@@ -55,32 +55,40 @@ class DataFormatterSynthValueTestCase(Te
         y.SetPreferSyntheticValue(True)
         z = self.frame().FindVariable("z")
         z.SetPreferSyntheticValue(True)
+        q = self.frame().FindVariable("q")
+        z.SetPreferSyntheticValue(True)
 
         x_val = x.GetValueAsUnsigned
         y_val = y.GetValueAsUnsigned
         z_val = z.GetValueAsUnsigned
+        q_val = q.GetValueAsUnsigned
         
         if self.TraceOn():
-            print("x_val = %s; y_val = %s; z_val = %s" % (x_val(),y_val(),z_val()))
+            print("x_val = %s; y_val = %s; z_val = %s; q_val = %s" % (x_val(),y_val(),z_val(),q_val()))
 
         self.assertFalse(x_val() == 3, "x == 3 before synthetics")
         self.assertFalse(y_val() == 4, "y == 4 before synthetics")
         self.assertFalse(z_val() == 7, "z == 7 before synthetics")
+        self.assertFalse(q_val() == 8, "q == 8 before synthetics")
 
         # now set up the synth
         self.runCmd("script from myIntSynthProvider import *")
         self.runCmd("type synth add -l myIntSynthProvider myInt")
         self.runCmd("type synth add -l myArraySynthProvider myArray")
+        self.runCmd("type synth add -l myIntSynthProvider myIntAndStuff")
         
         if self.TraceOn():
-            print("x_val = %s; y_val = %s; z_val = %s" % (x_val(),y_val(),z_val()))
+            print("x_val = %s; y_val = %s; z_val = %s; q_val = %s" % (x_val(),y_val(),z_val(),q_val()))
         
         self.assertTrue(x_val() == 3, "x != 3 after synthetics")
         self.assertTrue(y_val() == 4, "y != 4 after synthetics")
         self.assertTrue(z_val() == 7, "z != 7 after synthetics")
+        self.assertTrue(q_val() == 8, "q != 8 after synthetics")
         
         self.expect("frame variable x", substrs=['3'])
         self.expect("frame variable x", substrs=['theValue = 3'], matching=False)
+        self.expect("frame variable q", substrs=['8'])
+        self.expect("frame variable q", substrs=['theValue = 8'], 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)'])

Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/main.cpp?rev=280294&r1=280293&r2=280294&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/main.cpp (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/main.cpp Wed Aug 31 16:46:21 2016
@@ -5,6 +5,16 @@ class myInt {
     int val() { return theValue; }
 };
 
+class myIntAndStuff {
+private:
+  int theValue;
+  double theExtraFluff;
+public:
+  myIntAndStuff() : theValue(0), theExtraFluff(1.25) {}
+  myIntAndStuff(int _x) : theValue(_x), theExtraFluff(1.25) {}
+  int val() { return theValue; }
+};
+
 class myArray {
 public:
     int array[16];
@@ -17,11 +27,13 @@ class hasAnInt {
 };
 
 myInt operator + (myInt x, myInt y) { return myInt(x.val() + y.val()); }
+myInt operator + (myInt x, myIntAndStuff y) { return myInt(x.val() + y.val()); }
 
 int main() {
     myInt x{3};
     myInt y{4};
     myInt z {x+y};
+    myIntAndStuff q {z.val()+1};
     hasAnInt hi;
     myArray ma;
 

Modified: lldb/trunk/source/DataFormatters/TypeFormat.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/TypeFormat.cpp?rev=280294&r1=280293&r2=280294&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/TypeFormat.cpp (original)
+++ lldb/trunk/source/DataFormatters/TypeFormat.cpp Wed Aug 31 16:46:21 2016
@@ -121,14 +121,15 @@ TypeFormatImpl_Format::FormatObject (Val
                 }
                 
                 StreamString sstr;
-                compiler_type.DumpTypeValue (&sstr,                         // The stream to use for display
-                                          GetFormat(),                  // Format to display this type with
-                                          data,                         // Data to extract from
-                                          0,                             // Byte offset into "m_data"
-                                          valobj->GetByteSize(),                 // Byte size of item in "m_data"
-                                          valobj->GetBitfieldBitSize(),          // Bitfield bit size
-                                          valobj->GetBitfieldBitOffset(),        // Bitfield bit offset
-                                          exe_ctx.GetBestExecutionContextScope());
+                ExecutionContextScope *exe_scope(exe_ctx.GetBestExecutionContextScope());
+                compiler_type.DumpTypeValue (&sstr,                                 // The stream to use for display
+                                             GetFormat(),                           // Format to display this type with
+                                             data,                                  // Data to extract from
+                                             0,                                     // Byte offset into "m_data"
+                                             compiler_type.GetByteSize(exe_scope),  // Byte size of item in "m_data"
+                                             valobj->GetBitfieldBitSize(),          // Bitfield bit size
+                                             valobj->GetBitfieldBitOffset(),        // Bitfield bit offset
+                                             exe_scope);
                 // Given that we do not want to set the ValueObject's m_error
                 // for a formatting error (or else we wouldn't be able to reformat
                 // until a next update), an empty string is treated as a "false"




More information about the lldb-commits mailing list