From 8eb9c3068c1808e03faf55d8d080e44451d00ed5 Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Tue, 28 Jul 2015 20:19:45 +0000 Subject: [PATCH] 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 --- lldb/source/DataFormatters/LibCxxList.cpp | 1 + .../list/TestDataFormatterLibcxxList.py | 19 +++++++++++++++++++ .../data-formatter-stl/libcxx/list/main.cpp | 9 +++++++-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lldb/source/DataFormatters/LibCxxList.cpp b/lldb/source/DataFormatters/LibCxxList.cpp index f3e07fe7a017..17e460d0f93e 100644 --- a/lldb/source/DataFormatters/LibCxxList.cpp +++ b/lldb/source/DataFormatters/LibCxxList.cpp @@ -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; diff --git a/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py b/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py index ee743b96ee2d..be1f16f325a5 100644 --- a/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py +++ b/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py @@ -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) @@ -172,6 +176,21 @@ class LibcxxListDataFormatterTestCase(TestBase): substrs = ['goofy']); 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 diff --git a/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/main.cpp b/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/main.cpp index ab27a310a4cb..4f2bd74495a9 100644 --- a/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/main.cpp +++ b/lldb/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/main.cpp @@ -33,6 +33,11 @@ int main() (text_list.push_back(std::string("smart"))); (text_list.push_back(std::string("!!!"))); // Set second break point at this line. - + + std::list 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; -} \ No newline at end of file +}