[Lldb-commits] [lldb] r201455 - <rdar://problem/16006373>

Enrico Granata egranata at apple.com
Fri Feb 14 17:24:44 PST 2014


Author: enrico
Date: Fri Feb 14 19:24:44 2014
New Revision: 201455

URL: http://llvm.org/viewvc/llvm-project?rev=201455&view=rev
Log:
<rdar://problem/16006373>

Revert the spirit of r199857 - a convincing case can be made that overriding a summary's format markers behind its back is not the right thing to do
This commit reverts the behavior of the code to the previous model, and changes the test case to validate the opposite of what it was validating before


Modified:
    lldb/trunk/source/Core/ValueObject.cpp
    lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp
    lldb/trunk/test/functionalities/data-formatter/user-format-vs-summary/TestUserFormatVsSummary.py

Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=201455&r1=201454&r2=201455&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Fri Feb 14 19:24:44 2014
@@ -1685,12 +1685,8 @@ ValueObject::DumpPrintableRepresentation
         // area for cases where our desired output is not backed by some other longer-term storage
         StreamString strm;
 
-        bool reset_format = false;
-        if (custom_format != eFormatInvalid && GetFormat() == lldb::eFormatDefault)
-        {
-            reset_format = true;
+        if (custom_format != eFormatInvalid)
             SetFormat(custom_format);
-        }
         
         switch(val_obj_display)
         {
@@ -1745,17 +1741,10 @@ ValueObject::DumpPrintableRepresentation
             }
         }
         
-        
         if (cstr)
-        {
             s.PutCString(cstr);
-            if (reset_format)
-                SetFormat(lldb::eFormatDefault);
-        }
         else
         {
-            if (reset_format)
-                SetFormat(lldb::eFormatDefault);
             if (m_error.Fail())
             {
                 if (do_dump_error)
@@ -1777,6 +1766,9 @@ ValueObject::DumpPrintableRepresentation
         // even if we have an error message as output, that's a success
         // from our callers' perspective, so return true
         var_success = true;
+        
+        if (custom_format != eFormatInvalid)
+            SetFormat(eFormatDefault);
     }
     
     return var_success;

Modified: lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp?rev=201455&r1=201454&r2=201455&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp (original)
+++ lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp Fri Feb 14 19:24:44 2014
@@ -282,15 +282,17 @@ ValueObjectPrinter::GetValueSummaryError
                                           std::string& summary,
                                           std::string& error)
 {
-    lldb::Format original_format;
-    bool custom_format = options.m_format != eFormatDefault && options.m_format != m_valobj->GetFormat();
-    if (custom_format)
+    if (options.m_format != eFormatDefault && options.m_format != m_valobj->GetFormat())
     {
-        original_format = m_valobj->GetFormat();
-        m_valobj->SetFormat(options.m_format);
+        m_valobj->GetValueAsCString(options.m_format,
+                                    value);
+    }
+    else
+    {
+        const char* val_cstr = m_valobj->GetValueAsCString();
+        if (val_cstr)
+            value.assign(val_cstr);
     }
-    const char* val_cstr = m_valobj->GetValueAsCString();
-    value.assign(val_cstr ? val_cstr : "");
     const char* err_cstr = m_valobj->GetError().AsCString();
     if (err_cstr)
         error.assign(err_cstr);
@@ -312,8 +314,6 @@ ValueObjectPrinter::GetValueSummaryError
             }
         }
     }
-    if (custom_format)
-        m_valobj->SetFormat(original_format);
 }
 
 bool

Modified: lldb/trunk/test/functionalities/data-formatter/user-format-vs-summary/TestUserFormatVsSummary.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/user-format-vs-summary/TestUserFormatVsSummary.py?rev=201455&r1=201454&r2=201455&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/user-format-vs-summary/TestUserFormatVsSummary.py (original)
+++ lldb/trunk/test/functionalities/data-formatter/user-format-vs-summary/TestUserFormatVsSummary.py Fri Feb 14 19:24:44 2014
@@ -1,5 +1,5 @@
 """
-Test that the user can input a format and it will prevail over summary format's choices.
+Test that the user can input a format but it will not prevail over summary format's choices.
 """
 
 import os, time
@@ -15,13 +15,13 @@ class UserFormatVSSummaryTestCase(TestBa
     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
     @dsym_test
     def test_with_dsym_and_run_command(self):
-        """Test that the user can input a format and it will prevail over summary format's choices."""
+        """Test that the user can input a format but it will not prevail over summary format's choices."""
         self.buildDsym()
         self.data_formatter_commands()
 
     @dwarf_test
     def test_with_dwarf_and_run_command(self):
-        """Test that the user can input a format and it will prevail over summary format's choices."""
+        """Test that the user can input a format but it will not prevail over summary format's choices."""
         self.buildDwarf()
         self.data_formatter_commands()
 
@@ -32,7 +32,7 @@ class UserFormatVSSummaryTestCase(TestBa
         self.line = line_number('main.cpp', '// Set break point at this line.')
 
     def data_formatter_commands(self):
-        """Test that the user can input a format and it will prevail over summary format's choices."""
+        """Test that the user can input a format but it will not prevail over summary format's choices."""
         self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
 
         lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
@@ -58,14 +58,14 @@ class UserFormatVSSummaryTestCase(TestBa
         self.runCmd('type summary add Pair -s "x=${var.x%d},y=${var.y%u}"')
 
         self.expect("frame variable p1", substrs = ['(Pair) p1 = x=3,y=4294967293']);
-        self.expect("frame variable -f x p1", substrs = ['(Pair) p1 = x=0x00000003,y=0xfffffffd']);
-        self.expect("frame variable -f d p1", substrs = ['(Pair) p1 = x=3,y=-3']);
+        self.expect("frame variable -f x p1", substrs = ['(Pair) p1 = x=0x00000003,y=0xfffffffd'], matching=False);
+        self.expect("frame variable -f d p1", substrs = ['(Pair) p1 = x=3,y=-3'], matching=False);
         self.expect("frame variable p1", substrs = ['(Pair) p1 = x=3,y=4294967293']);
 
         self.runCmd('type summary add Pair -s "x=${var.x%x},y=${var.y%u}"')
 
         self.expect("frame variable p1", substrs = ['(Pair) p1 = x=0x00000003,y=4294967293']);
-        self.expect("frame variable -f d p1", substrs = ['(Pair) p1 = x=3,y=-3']);
+        self.expect("frame variable -f d p1", substrs = ['(Pair) p1 = x=3,y=-3'],matching=False);
 
 if __name__ == '__main__':
     import atexit





More information about the lldb-commits mailing list