<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

llvm-svn: 201455
This commit is contained in:
Enrico Granata 2014-02-15 01:24:44 +00:00
parent 144d9a059b
commit 465f4bc287
3 changed files with 20 additions and 28 deletions

View File

@ -1685,12 +1685,8 @@ ValueObject::DumpPrintableRepresentation(Stream& s,
// 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(Stream& s,
}
}
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(Stream& s,
// 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;

View File

@ -282,15 +282,17 @@ ValueObjectPrinter::GetValueSummaryError (std::string& value,
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 (std::string& value,
}
}
}
if (custom_format)
m_valobj->SetFormat(original_format);
}
bool

View File

@ -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(TestBase):
@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(TestBase):
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(TestBase):
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