Fix a bug where the std::list synthetic child provider would not clean its cache correctly on update, causing stale children to be returned in some circumstances

Fixes rdar://20560680

llvm-svn: 243472
This commit is contained in:
Enrico Granata 2015-07-28 20:19:45 +00:00
parent 80d13bac02
commit 8eb9c3068c
3 changed files with 27 additions and 2 deletions

View File

@ -312,6 +312,7 @@ lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::GetChildAtIndex (size_
bool
lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::Update()
{
m_children.clear();
m_head = m_tail = NULL;
m_node_address = 0;
m_count = UINT32_MAX;

View File

@ -33,6 +33,8 @@ class LibcxxListDataFormatterTestCase(TestBase):
# Find the line number to break at.
self.line = line_number('main.cpp', '// Set break point at this line.')
self.line2 = line_number('main.cpp', '// Set second break point at this line.')
self.line3 = line_number('main.cpp', '// Set third break point at this line.')
self.line4 = line_number('main.cpp', '// Set fourth break point at this line.')
def data_formatter_commands(self):
"""Test that that file and class static variables display correctly."""
@ -40,6 +42,8 @@ class LibcxxListDataFormatterTestCase(TestBase):
lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1)
lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line2, num_expected_locations=-1)
lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line3, num_expected_locations=-1)
lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line4, num_expected_locations=-1)
self.runCmd("run", RUN_SUCCEEDED)
@ -173,6 +177,21 @@ class LibcxxListDataFormatterTestCase(TestBase):
self.expect("frame variable text_list[3]",
substrs = ['!!!']);
self.runCmd("continue")
# check that the list provider correctly updates if elements move
countingList = self.frame().FindVariable("countingList")
countingList.SetPreferDynamicValue(True)
countingList.SetPreferSyntheticValue(True)
self.assertTrue(countingList.GetChildAtIndex(0).GetValueAsUnsigned(0) == 3141, "list[0] == 3141")
self.assertTrue(countingList.GetChildAtIndex(1).GetValueAsUnsigned(0) == 3141, "list[1] == 3141")
self.runCmd("continue")
self.assertTrue(countingList.GetChildAtIndex(0).GetValueAsUnsigned(0) == 3141, "uniqued list[0] == 3141")
self.assertTrue(countingList.GetChildAtIndex(1).GetValueAsUnsigned(0) == 3142, "uniqued list[1] == 3142")
if __name__ == '__main__':
import atexit
lldb.SBDebugger.Initialize()

View File

@ -34,5 +34,10 @@ int main()
(text_list.push_back(std::string("!!!"))); // Set second break point at this line.
std::list<int> countingList = {3141, 3142, 3142,3142,3142, 3142, 3142, 3141};
countingList.sort();
countingList.unique(); // Set third break point at this line.
countingList.size(); // Set fourth break point at this line.
return 0;
}