diff options
Diffstat (limited to 'packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl')
30 files changed, 1601 insertions, 1057 deletions
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py index 083f713c259d..2b63dbb1c83b 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LibCxxAtomicTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -23,30 +24,39 @@ class LibCxxAtomicTestCase(TestBase): return var @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet def test(self): """Test that std::atomic as defined by libc++ is correctly printed by LLDB""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.")) + bkpt = self.target().FindBreakpointByID( + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.")) self.runCmd("run", RUN_SUCCEEDED) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) - + substrs=['stopped', + 'stop reason = breakpoint']) + s = self.get_variable('s') i = self.get_variable('i') - - if self.TraceOn(): print(s) - if self.TraceOn(): print(i) - + + if self.TraceOn(): + print(s) + if self.TraceOn(): + print(i) + self.assertTrue(i.GetValueAsUnsigned(0) == 5, "i == 5") self.assertTrue(s.GetNumChildren() == 2, "s has two children") - self.assertTrue(s.GetChildAtIndex(0).GetValueAsUnsigned(0) == 1, "s.x == 1") - self.assertTrue(s.GetChildAtIndex(1).GetValueAsUnsigned(0) == 2, "s.y == 2") + self.assertTrue( + s.GetChildAtIndex(0).GetValueAsUnsigned(0) == 1, + "s.x == 1") + self.assertTrue( + s.GetChildAtIndex(1).GetValueAsUnsigned(0) == 2, + "s.y == 2") diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/Makefile new file mode 100644 index 000000000000..fdd717119d95 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../../../make +CXX_SOURCES := main.cpp +CXXFLAGS += -std=c++11 +USE_LIBCPP := 1 +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py new file mode 100644 index 000000000000..6a832e02990a --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py @@ -0,0 +1,56 @@ +""" +Test lldb data formatter subsystem. +""" + +from __future__ import print_function + + +import os +import time +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class LibCxxFunctionTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def get_variable(self, name): + var = self.frame().FindVariable(name) + var.SetPreferDynamicValue(lldb.eDynamicCanRunTarget) + var.SetPreferSyntheticValue(True) + return var + + @skipIf(compiler="gcc") + @skipIfWindows # libc++ not ported to Windows yet + def test(self): + """Test that std::function as defined by libc++ is correctly printed by LLDB""" + self.build() + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + + bkpt = self.target().FindBreakpointByID( + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.")) + + self.runCmd("run", RUN_SUCCEEDED) + + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs=['stopped', + 'stop reason = breakpoint']) + + f1 = self.get_variable('f1') + f2 = self.get_variable('f2') + + if self.TraceOn(): + print(f1) + if self.TraceOn(): + print(f2) + + self.assertTrue(f1.GetValueAsUnsigned(0) != 0, 'f1 has a valid value') + self.assertTrue(f2.GetValueAsUnsigned(0) != 0, 'f2 has a valid value') diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp new file mode 100644 index 000000000000..cfe689b29b01 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp @@ -0,0 +1,25 @@ +//===-- main.cpp --------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <functional> + +int foo(int x, int y) { + return x + y - 1; +} + +int main () +{ + int acc = 42; + std::function<int (int,int)> f1 = foo; + std::function<int (int)> f2 = [acc,f1] (int x) -> int { + return x+f1(acc,x); + }; + return f1(acc,acc) + f2(acc); // Set break point at this line. +} + diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py index d452c1be69bf..f0857f420fc3 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py @@ -5,37 +5,44 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class InitializerListTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet @skipIf(compiler="gcc") - @expectedFailureAll(oslist=["linux"], bugnumber="fails on clang 3.5 and tot") + @expectedFailureAll( + oslist=["linux"], + bugnumber="fails on clang 3.5 and tot") def test(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.")) + bkpt = self.target().FindBreakpointByID( + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.")) self.runCmd("run", RUN_SUCCEEDED) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) - self.expect("frame variable ili", substrs = ['[1] = 2','[4] = 5']) - self.expect("frame variable ils", substrs = ['[4] = "surprise it is a long string!! yay!!"']) + self.expect("frame variable ili", substrs=['[1] = 2', '[4] = 5']) + self.expect("frame variable ils", substrs=[ + '[4] = "surprise it is a long string!! yay!!"']) - self.expect('image list', substrs = self.getLibcPlusPlusLibs()) + self.expect('image list', substrs=self.getLibcPlusPlusLibs()) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py index 23f6956cf3f0..5d23fcef04ce 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LibcxxIteratorDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -23,22 +24,24 @@ class LibcxxIteratorDataFormatterTestCase(TestBase): self.line = line_number('main.cpp', '// Set break point at this line.') @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet def test_with_run_command(self): """Test that libc++ iterators format properly.""" self.build() 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) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=-1) self.runCmd("run", RUN_SUCCEEDED) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -47,21 +50,31 @@ class LibcxxIteratorDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect('image list', substrs = self.getLibcPlusPlusLibs()) + self.expect('image list', substrs=self.getLibcPlusPlusLibs()) - self.expect('frame variable ivI', substrs = ['item = 3']) - self.expect('expr ivI', substrs = ['item = 3']) + self.expect('frame variable ivI', substrs=['item = 3']) + self.expect('expr ivI', substrs=['item = 3']) - self.expect('frame variable iimI', substrs = ['first = 0','second = 12']) - self.expect('expr iimI', substrs = ['first = 0','second = 12']) + self.expect( + 'frame variable iimI', + substrs=[ + 'first = 43981', + 'second = 61681']) + self.expect('expr iimI', substrs=['first = 43981', 'second = 61681']) - self.expect('frame variable simI', substrs = ['first = "world"','second = 42']) - self.expect('expr simI', substrs = ['first = "world"','second = 42']) + self.expect( + 'frame variable simI', + substrs=[ + 'first = "world"', + 'second = 42']) + self.expect('expr simI', substrs=['first = "world"', 'second = 42']) - self.expect('frame variable svI', substrs = ['item = "hello"']) - self.expect('expr svI', substrs = ['item = "hello"']) + self.expect('frame variable svI', substrs=['item = "hello"']) + self.expect('expr svI', substrs=['item = "hello"']) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/main.cpp index 97b37851f53d..058a79317d19 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/main.cpp @@ -20,23 +20,23 @@ typedef string_vector::iterator svter; int main() { - intint_map iim; - iim[0] = 12; - + intint_map iim; + iim[0xABCD] = 0xF0F1; + strint_map sim; sim["world"] = 42; - + int_vector iv; iv.push_back(3); - + string_vector sv; sv.push_back("hello"); iimter iimI = iim.begin(); simter simI = sim.begin(); - + ivter ivI = iv.begin(); svter svI = sv.begin(); - return 0; // Set break point at this line. + return 0; // Set break point at this line. }
\ No newline at end of file diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py index 6fcdc37465db..dd97a9ab5977 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py @@ -5,13 +5,15 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time, re +import os +import time +import re import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LibcxxListDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -21,31 +23,38 @@ class LibcxxListDataFormatterTestCase(TestBase): TestBase.setUp(self) # 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.') + 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.') @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet - @expectedFailureAll(oslist=["macosx"], bugnumber="rdar://25499635") + @skipIfWindows # libc++ not ported to Windows yet def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() 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) - 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) + + 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) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -54,135 +63,154 @@ class LibcxxListDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) self.runCmd("frame variable numbers_list --show-types") - self.runCmd("type summary add std::int_list std::string_list int_list string_list --summary-string \"list has ${svar%#} items\" -e") + self.runCmd( + "type summary add std::int_list std::string_list int_list string_list --summary-string \"list has ${svar%#} items\" -e") self.runCmd("type format add -f hex int") self.expect("frame variable numbers_list --raw", matching=False, - substrs = ['list has 0 items', - '{}']) + substrs=['list has 0 items', + '{}']) self.expect("frame variable numbers_list", - substrs = ['list has 0 items', - '{}']) + substrs=['list has 0 items', + '{}']) self.expect("p numbers_list", - substrs = ['list has 0 items', - '{}']) + substrs=['list has 0 items', + '{}']) self.runCmd("n") self.expect("frame variable numbers_list", - substrs = ['list has 1 items', - '[0] = ', - '0x12345678']) + substrs=['list has 1 items', + '[0] = ', + '0x12345678']) - self.runCmd("n");self.runCmd("n");self.runCmd("n"); + self.runCmd("n") + self.runCmd("n") + self.runCmd("n") self.expect("frame variable numbers_list", - substrs = ['list has 4 items', - '[0] = ', - '0x12345678', - '[1] =', - '0x11223344', - '[2] =', - '0xbeeffeed', - '[3] =', - '0x00abba00']) - - self.runCmd("n");self.runCmd("n"); + substrs=['list has 4 items', + '[0] = ', + '0x12345678', + '[1] =', + '0x11223344', + '[2] =', + '0xbeeffeed', + '[3] =', + '0x00abba00']) + + self.runCmd("n") + self.runCmd("n") self.expect("frame variable numbers_list", - substrs = ['list has 6 items', - '[0] = ', - '0x12345678', - '0x11223344', - '0xbeeffeed', - '0x00abba00', - '[4] =', - '0x0abcdef0', - '[5] =', - '0x0cab0cab']) + substrs=['list has 6 items', + '[0] = ', + '0x12345678', + '0x11223344', + '0xbeeffeed', + '0x00abba00', + '[4] =', + '0x0abcdef0', + '[5] =', + '0x0cab0cab']) self.expect("p numbers_list", - substrs = ['list has 6 items', - '[0] = ', - '0x12345678', - '0x11223344', - '0xbeeffeed', - '0x00abba00', - '[4] =', - '0x0abcdef0', - '[5] =', - '0x0cab0cab']) + substrs=['list has 6 items', + '[0] = ', + '0x12345678', + '0x11223344', + '0xbeeffeed', + '0x00abba00', + '[4] =', + '0x0abcdef0', + '[5] =', + '0x0cab0cab']) # check access-by-index self.expect("frame variable numbers_list[0]", - substrs = ['0x12345678']); + substrs=['0x12345678']) self.expect("frame variable numbers_list[1]", - substrs = ['0x11223344']); + substrs=['0x11223344']) self.runCmd("n") - + self.expect("frame variable numbers_list", - substrs = ['list has 0 items', - '{}']) + substrs=['list has 0 items', + '{}']) + + self.runCmd("n") + self.runCmd("n") + self.runCmd("n") + self.runCmd("n") - self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n"); - self.expect("frame variable numbers_list", - substrs = ['list has 4 items', - '[0] = ', '1', - '[1] = ', '2', - '[2] = ', '3', - '[3] = ', '4']) + substrs=['list has 4 items', + '[0] = ', '1', + '[1] = ', '2', + '[2] = ', '3', + '[3] = ', '4']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("numbers_list").MightHaveChildren(), "numbers_list.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("numbers_list").MightHaveChildren(), + "numbers_list.MightHaveChildren() says False for non empty!") self.runCmd("type format delete int") self.runCmd("c") self.expect("frame variable text_list", - substrs = ['list has 3 items', - '[0]', 'goofy', - '[1]', 'is', - '[2]', 'smart']) + substrs=['list has 3 items', + '[0]', 'goofy', + '[1]', 'is', + '[2]', 'smart']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("text_list").MightHaveChildren(), "text_list.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("text_list").MightHaveChildren(), + "text_list.MightHaveChildren() says False for non empty!") self.expect("p text_list", - substrs = ['list has 3 items', - '\"goofy\"', - '\"is\"', - '\"smart\"']) - + substrs=['list has 3 items', + '\"goofy\"', + '\"is\"', + '\"smart\"']) + self.runCmd("n") # check access-by-index self.expect("frame variable text_list[0]", - substrs = ['goofy']); + substrs=['goofy']) self.expect("frame variable text_list[3]", - substrs = ['!!!']); - + 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.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") + self.assertTrue( + countingList.GetChildAtIndex(0).GetValueAsUnsigned(0) == 3141, + "uniqued list[0] == 3141") + self.assertTrue( + countingList.GetChildAtIndex(1).GetValueAsUnsigned(0) == 3142, + "uniqued list[1] == 3142") diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py index 9e68e1dbc004..e2e082c795f7 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py @@ -6,19 +6,21 @@ corruption). from __future__ import print_function - -import os, time, re +import os +import time +import re import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LibcxxListDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet @add_test_categories(["pyapi"]) @skipIfDarwin # rdar://25499635 def test_with_run_command(self): @@ -27,29 +29,47 @@ class LibcxxListDataFormatterTestCase(TestBase): target = self.dbg.CreateTarget(exe) self.assertTrue(target and target.IsValid(), "Target is valid") - file_spec = lldb.SBFileSpec ("main.cpp", False) - breakpoint1 = target.BreakpointCreateBySourceRegex('// Set break point at this line.', file_spec) + file_spec = lldb.SBFileSpec("main.cpp", False) + breakpoint1 = target.BreakpointCreateBySourceRegex( + '// Set break point at this line.', file_spec) self.assertTrue(breakpoint1 and breakpoint1.IsValid()) - breakpoint2 = target.BreakpointCreateBySourceRegex('// Set second break point at this line.', file_spec) + breakpoint2 = target.BreakpointCreateBySourceRegex( + '// Set second break point at this line.', file_spec) self.assertTrue(breakpoint2 and breakpoint2.IsValid()) # Run the program, it should stop at breakpoint 1. - process = target.LaunchSimple(None, None, self.get_process_working_directory()) - lldbutil.skip_if_library_missing(self, target, lldbutil.PrintableRegex("libc\+\+")) + process = target.LaunchSimple( + None, None, self.get_process_working_directory()) + lldbutil.skip_if_library_missing( + self, target, lldbutil.PrintableRegex("libc\+\+")) self.assertTrue(process and process.IsValid(), PROCESS_IS_VALID) - self.assertEqual(len(lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint1)), 1) + self.assertEqual( + len(lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint1)), 1) # verify our list is displayed correctly - self.expect("frame variable *numbers_list", substrs=['[0] = 1', '[1] = 2', '[2] = 3', '[3] = 4', '[5] = 6']) + self.expect( + "frame variable *numbers_list", + substrs=[ + '[0] = 1', + '[1] = 2', + '[2] = 3', + '[3] = 4', + '[5] = 6']) # Continue to breakpoint 2. process.Continue() self.assertTrue(process and process.IsValid(), PROCESS_IS_VALID) - self.assertEqual(len(lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint2)), 1) + self.assertEqual( + len(lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint2)), 1) # The list is now inconsistent. However, we should be able to get the first three # elements at least (and most importantly, not crash). - self.expect("frame variable *numbers_list", substrs=['[0] = 1', '[1] = 2', '[2] = 3']) + self.expect( + "frame variable *numbers_list", + substrs=[ + '[0] = 1', + '[1] = 2', + '[2] = 3']) # Run to completion. process.Continue() diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py index cecc3178b318..7433a0b0da2c 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py @@ -5,34 +5,38 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LibcxxMapDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.")) + bkpt = self.target().FindBreakpointByID( + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.")) self.runCmd("run", RUN_SUCCEEDED) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -41,259 +45,269 @@ class LibcxxMapDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect('image list', substrs = self.getLibcPlusPlusLibs()) - + self.expect('image list', substrs=self.getLibcPlusPlusLibs()) + self.expect('frame variable ii', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect('frame variable ii', - substrs = ['size=2', - '[0] = ', - 'first = 0', - 'second = 0', - '[1] = ', - 'first = 1', - 'second = 1']) + substrs=['size=2', + '[0] = ', + 'first = 0', + 'second = 0', + '[1] = ', + 'first = 1', + 'second = 1']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect('frame variable ii', - substrs = ['size=4', - '[2] = ', - 'first = 2', - 'second = 0', - '[3] = ', - 'first = 3', - 'second = 1']) + substrs=['size=4', + '[2] = ', + 'first = 2', + 'second = 0', + '[3] = ', + 'first = 3', + 'second = 1']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable ii", - substrs = ['size=8', - '[5] = ', - 'first = 5', - 'second = 0', - '[7] = ', - 'first = 7', - 'second = 1']) + substrs=['size=8', + '[5] = ', + 'first = 5', + 'second = 0', + '[7] = ', + 'first = 7', + 'second = 1']) self.expect("p ii", - substrs = ['size=8', - '[5] = ', - 'first = 5', - 'second = 0', - '[7] = ', - 'first = 7', - 'second = 1']) + substrs=['size=8', + '[5] = ', + 'first = 5', + 'second = 0', + '[7] = ', + 'first = 7', + 'second = 1']) # check access-by-index self.expect("frame variable ii[0]", - substrs = ['first = 0', - 'second = 0']); + substrs=['first = 0', + 'second = 0']) self.expect("frame variable ii[3]", - substrs = ['first =', - 'second =']); + substrs=['first =', + 'second =']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("ii").MightHaveChildren(), "ii.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("ii").MightHaveChildren(), + "ii.MightHaveChildren() says False for non empty!") # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression ii[8]", matching=False, error=True, + # self.expect("expression ii[8]", matching=False, error=True, # substrs = ['1234567']) - self.runCmd("continue"); - + self.runCmd("continue") + self.expect('frame variable ii', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) self.expect('frame variable si', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) - self.runCmd("continue"); + self.runCmd("continue") self.expect('frame variable si', - substrs = ['size=1', - '[0] = ', - 'first = \"zero\"', - 'second = 0']) + substrs=['size=1', + '[0] = ', + 'first = \"zero\"', + 'second = 0']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable si", - substrs = ['size=4', - '[0] = ', - 'first = \"zero\"', - 'second = 0', - '[1] = ', - 'first = \"one\"', - 'second = 1', - '[2] = ', - 'first = \"two\"', - 'second = 2', - '[3] = ', - 'first = \"three\"', - 'second = 3']) + substrs=['size=4', + '[0] = ', + 'first = \"zero\"', + 'second = 0', + '[1] = ', + 'first = \"one\"', + 'second = 1', + '[2] = ', + 'first = \"two\"', + 'second = 2', + '[3] = ', + 'first = \"three\"', + 'second = 3']) self.expect("p si", - substrs = ['size=4', - '[0] = ', - 'first = \"zero\"', - 'second = 0', - '[1] = ', - 'first = \"one\"', - 'second = 1', - '[2] = ', - 'first = \"two\"', - 'second = 2', - '[3] = ', - 'first = \"three\"', - 'second = 3']) + substrs=['size=4', + '[0] = ', + 'first = \"zero\"', + 'second = 0', + '[1] = ', + 'first = \"one\"', + 'second = 1', + '[2] = ', + 'first = \"two\"', + 'second = 2', + '[3] = ', + 'first = \"three\"', + 'second = 3']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("si").MightHaveChildren(), "si.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("si").MightHaveChildren(), + "si.MightHaveChildren() says False for non empty!") # check access-by-index self.expect("frame variable si[0]", - substrs = ['first = ', 'one', - 'second = 1']); - + substrs=['first = ', 'one', + 'second = 1']) + # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression si[0]", matching=False, error=True, + # self.expect("expression si[0]", matching=False, error=True, # substrs = ['first = ', 'zero']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable si', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable is', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable is", - substrs = ['size=4', - '[0] = ', - 'second = \"goofy\"', - 'first = 85', - '[1] = ', - 'second = \"is\"', - 'first = 1', - '[2] = ', - 'second = \"smart\"', - 'first = 2', - '[3] = ', - 'second = \"!!!\"', - 'first = 3']) - + substrs=['size=4', + '[0] = ', + 'second = \"goofy\"', + 'first = 85', + '[1] = ', + 'second = \"is\"', + 'first = 1', + '[2] = ', + 'second = \"smart\"', + 'first = 2', + '[3] = ', + 'second = \"!!!\"', + 'first = 3']) + self.expect("p is", - substrs = ['size=4', - '[0] = ', - 'second = \"goofy\"', - 'first = 85', - '[1] = ', - 'second = \"is\"', - 'first = 1', - '[2] = ', - 'second = \"smart\"', - 'first = 2', - '[3] = ', - 'second = \"!!!\"', - 'first = 3']) + substrs=['size=4', + '[0] = ', + 'second = \"goofy\"', + 'first = 85', + '[1] = ', + 'second = \"is\"', + 'first = 1', + '[2] = ', + 'second = \"smart\"', + 'first = 2', + '[3] = ', + 'second = \"!!!\"', + 'first = 3']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("is").MightHaveChildren(), "is.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("is").MightHaveChildren(), + "is.MightHaveChildren() says False for non empty!") # check access-by-index self.expect("frame variable is[0]", - substrs = ['first = ', - 'second =']); - + substrs=['first = ', + 'second =']) + # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression is[0]", matching=False, error=True, + # self.expect("expression is[0]", matching=False, error=True, # substrs = ['first = ', 'goofy']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable is', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable ss', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable ss", - substrs = ['size=3', - '[0] = ', - 'second = \"hello\"', - 'first = \"ciao\"', - '[1] = ', - 'second = \"house\"', - 'first = \"casa\"', - '[2] = ', - 'second = \"cat\"', - 'first = \"gatto\"']) - + substrs=['size=3', + '[0] = ', + 'second = \"hello\"', + 'first = \"ciao\"', + '[1] = ', + 'second = \"house\"', + 'first = \"casa\"', + '[2] = ', + 'second = \"cat\"', + 'first = \"gatto\"']) + self.expect("p ss", - substrs = ['size=3', - '[0] = ', - 'second = \"hello\"', - 'first = \"ciao\"', - '[1] = ', - 'second = \"house\"', - 'first = \"casa\"', - '[2] = ', - 'second = \"cat\"', - 'first = \"gatto\"']) + substrs=['size=3', + '[0] = ', + 'second = \"hello\"', + 'first = \"ciao\"', + '[1] = ', + 'second = \"house\"', + 'first = \"casa\"', + '[2] = ', + 'second = \"cat\"', + 'first = \"gatto\"']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("ss").MightHaveChildren(), "ss.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("ss").MightHaveChildren(), + "ss.MightHaveChildren() says False for non empty!") # check access-by-index self.expect("frame variable ss[2]", - substrs = ['gatto', 'cat']); - + substrs=['gatto', 'cat']) + # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression ss[3]", matching=False, error=True, + # self.expect("expression ss[3]", matching=False, error=True, # substrs = ['gatto']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable ss', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py index eb74818c91f5..66091e6e113f 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py @@ -5,35 +5,39 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LibcxxMultiMapDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet @skipIf(compiler="gcc") def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - - bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.")) + + bkpt = self.target().FindBreakpointByID( + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.")) self.runCmd("run", RUN_SUCCEEDED) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -42,259 +46,269 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect('image list', substrs = self.getLibcPlusPlusLibs()) - + self.expect('image list', substrs=self.getLibcPlusPlusLibs()) + self.expect('frame variable ii', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect('frame variable ii', - substrs = ['size=2', - '[0] = ', - 'first = 0', - 'second = 0', - '[1] = ', - 'first = 1', - 'second = 1']) + substrs=['size=2', + '[0] = ', + 'first = 0', + 'second = 0', + '[1] = ', + 'first = 1', + 'second = 1']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect('frame variable ii', - substrs = ['size=4', - '[2] = ', - 'first = 2', - 'second = 0', - '[3] = ', - 'first = 3', - 'second = 1']) + substrs=['size=4', + '[2] = ', + 'first = 2', + 'second = 0', + '[3] = ', + 'first = 3', + 'second = 1']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable ii", - substrs = ['size=8', - '[5] = ', - 'first = 5', - 'second = 0', - '[7] = ', - 'first = 7', - 'second = 1']) + substrs=['size=8', + '[5] = ', + 'first = 5', + 'second = 0', + '[7] = ', + 'first = 7', + 'second = 1']) self.expect("p ii", - substrs = ['size=8', - '[5] = ', - 'first = 5', - 'second = 0', - '[7] = ', - 'first = 7', - 'second = 1']) + substrs=['size=8', + '[5] = ', + 'first = 5', + 'second = 0', + '[7] = ', + 'first = 7', + 'second = 1']) # check access-by-index self.expect("frame variable ii[0]", - substrs = ['first = 0', - 'second = 0']); + substrs=['first = 0', + 'second = 0']) self.expect("frame variable ii[3]", - substrs = ['first =', - 'second =']); + substrs=['first =', + 'second =']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("ii").MightHaveChildren(), "ii.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("ii").MightHaveChildren(), + "ii.MightHaveChildren() says False for non empty!") # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression ii[8]", matching=False, error=True, + # self.expect("expression ii[8]", matching=False, error=True, # substrs = ['1234567']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable ii', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) self.expect('frame variable si', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect('frame variable si', - substrs = ['size=1', - '[0] = ', - 'first = \"zero\"', - 'second = 0']) + substrs=['size=1', + '[0] = ', + 'first = \"zero\"', + 'second = 0']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable si", - substrs = ['size=4', - '[0] = ', - 'first = \"zero\"', - 'second = 0', - '[1] = ', - 'first = \"one\"', - 'second = 1', - '[2] = ', - 'first = \"two\"', - 'second = 2', - '[3] = ', - 'first = \"three\"', - 'second = 3']) + substrs=['size=4', + '[0] = ', + 'first = \"zero\"', + 'second = 0', + '[1] = ', + 'first = \"one\"', + 'second = 1', + '[2] = ', + 'first = \"two\"', + 'second = 2', + '[3] = ', + 'first = \"three\"', + 'second = 3']) self.expect("p si", - substrs = ['size=4', - '[0] = ', - 'first = \"zero\"', - 'second = 0', - '[1] = ', - 'first = \"one\"', - 'second = 1', - '[2] = ', - 'first = \"two\"', - 'second = 2', - '[3] = ', - 'first = \"three\"', - 'second = 3']) + substrs=['size=4', + '[0] = ', + 'first = \"zero\"', + 'second = 0', + '[1] = ', + 'first = \"one\"', + 'second = 1', + '[2] = ', + 'first = \"two\"', + 'second = 2', + '[3] = ', + 'first = \"three\"', + 'second = 3']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("si").MightHaveChildren(), "si.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("si").MightHaveChildren(), + "si.MightHaveChildren() says False for non empty!") # check access-by-index self.expect("frame variable si[0]", - substrs = ['first = ', 'one', - 'second = 1']); - + substrs=['first = ', 'one', + 'second = 1']) + # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression si[0]", matching=False, error=True, + # self.expect("expression si[0]", matching=False, error=True, # substrs = ['first = ', 'zero']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable si', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable is', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable is", - substrs = ['size=4', - '[0] = ', - 'second = \"goofy\"', - 'first = 85', - '[1] = ', - 'second = \"is\"', - 'first = 1', - '[2] = ', - 'second = \"smart\"', - 'first = 2', - '[3] = ', - 'second = \"!!!\"', - 'first = 3']) - + substrs=['size=4', + '[0] = ', + 'second = \"goofy\"', + 'first = 85', + '[1] = ', + 'second = \"is\"', + 'first = 1', + '[2] = ', + 'second = \"smart\"', + 'first = 2', + '[3] = ', + 'second = \"!!!\"', + 'first = 3']) + self.expect("p is", - substrs = ['size=4', - '[0] = ', - 'second = \"goofy\"', - 'first = 85', - '[1] = ', - 'second = \"is\"', - 'first = 1', - '[2] = ', - 'second = \"smart\"', - 'first = 2', - '[3] = ', - 'second = \"!!!\"', - 'first = 3']) + substrs=['size=4', + '[0] = ', + 'second = \"goofy\"', + 'first = 85', + '[1] = ', + 'second = \"is\"', + 'first = 1', + '[2] = ', + 'second = \"smart\"', + 'first = 2', + '[3] = ', + 'second = \"!!!\"', + 'first = 3']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("is").MightHaveChildren(), "is.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("is").MightHaveChildren(), + "is.MightHaveChildren() says False for non empty!") # check access-by-index self.expect("frame variable is[0]", - substrs = ['first = ', - 'second =']); - + substrs=['first = ', + 'second =']) + # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression is[0]", matching=False, error=True, + # self.expect("expression is[0]", matching=False, error=True, # substrs = ['first = ', 'goofy']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable is', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable ss', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable ss", - substrs = ['size=3', - '[0] = ', - 'second = \"hello\"', - 'first = \"ciao\"', - '[1] = ', - 'second = \"house\"', - 'first = \"casa\"', - '[2] = ', - 'second = \"cat\"', - 'first = \"gatto\"']) - + substrs=['size=3', + '[0] = ', + 'second = \"hello\"', + 'first = \"ciao\"', + '[1] = ', + 'second = \"house\"', + 'first = \"casa\"', + '[2] = ', + 'second = \"cat\"', + 'first = \"gatto\"']) + self.expect("p ss", - substrs = ['size=3', - '[0] = ', - 'second = \"hello\"', - 'first = \"ciao\"', - '[1] = ', - 'second = \"house\"', - 'first = \"casa\"', - '[2] = ', - 'second = \"cat\"', - 'first = \"gatto\"']) + substrs=['size=3', + '[0] = ', + 'second = \"hello\"', + 'first = \"ciao\"', + '[1] = ', + 'second = \"house\"', + 'first = \"casa\"', + '[2] = ', + 'second = \"cat\"', + 'first = \"gatto\"']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("ss").MightHaveChildren(), "ss.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("ss").MightHaveChildren(), + "ss.MightHaveChildren() says False for non empty!") # check access-by-index self.expect("frame variable ss[2]", - substrs = ['gatto', 'cat']); - + substrs=['gatto', 'cat']) + # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression ss[3]", matching=False, error=True, + # self.expect("expression ss[3]", matching=False, error=True, # substrs = ['gatto']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect('frame variable ss', - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py index cfdfd07ddec1..d40bce83e0af 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py @@ -5,34 +5,38 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LibcxxMultiSetDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - - bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.")) + + bkpt = self.target().FindBreakpointByID( + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.")) self.runCmd("run", RUN_SUCCEEDED) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -41,30 +45,78 @@ class LibcxxMultiSetDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect('image list', substrs = self.getLibcPlusPlusLibs()) + self.expect('image list', substrs=self.getLibcPlusPlusLibs()) - self.expect("frame variable ii",substrs = ["size=0","{}"]) + self.expect("frame variable ii", substrs=["size=0", "{}"]) lldbutil.continue_to_breakpoint(self.process(), bkpt) - self.expect("frame variable ii",substrs = ["size=6","[0] = 0","[1] = 1", "[2] = 2", "[3] = 3", "[4] = 4", "[5] = 5"]) + self.expect( + "frame variable ii", + substrs=[ + "size=6", + "[0] = 0", + "[1] = 1", + "[2] = 2", + "[3] = 3", + "[4] = 4", + "[5] = 5"]) lldbutil.continue_to_breakpoint(self.process(), bkpt) - self.expect("frame variable ii",substrs = ["size=7","[2] = 2", "[3] = 3", "[6] = 6"]) - self.expect("p ii",substrs = ["size=7","[2] = 2", "[3] = 3", "[6] = 6"]) - self.expect("frame variable ii[2]",substrs = [" = 2"]) + self.expect( + "frame variable ii", + substrs=[ + "size=7", + "[2] = 2", + "[3] = 3", + "[6] = 6"]) + self.expect( + "p ii", + substrs=[ + "size=7", + "[2] = 2", + "[3] = 3", + "[6] = 6"]) + self.expect("frame variable ii[2]", substrs=[" = 2"]) lldbutil.continue_to_breakpoint(self.process(), bkpt) - self.expect("frame variable ii",substrs = ["size=0","{}"]) + self.expect("frame variable ii", substrs=["size=0", "{}"]) lldbutil.continue_to_breakpoint(self.process(), bkpt) - self.expect("frame variable ii",substrs = ["size=0","{}"]) - self.expect("frame variable ss",substrs = ["size=0","{}"]) + self.expect("frame variable ii", substrs=["size=0", "{}"]) + self.expect("frame variable ss", substrs=["size=0", "{}"]) lldbutil.continue_to_breakpoint(self.process(), bkpt) - self.expect("frame variable ss",substrs = ["size=2",'[0] = "a"','[1] = "a very long string is right here"']) + self.expect( + "frame variable ss", + substrs=[ + "size=2", + '[0] = "a"', + '[1] = "a very long string is right here"']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - self.expect("frame variable ss",substrs = ["size=4",'[2] = "b"','[3] = "c"','[0] = "a"','[1] = "a very long string is right here"']) - self.expect("p ss",substrs = ["size=4",'[2] = "b"','[3] = "c"','[0] = "a"','[1] = "a very long string is right here"']) - self.expect("frame variable ss[2]",substrs = [' = "b"']) + self.expect( + "frame variable ss", + substrs=[ + "size=4", + '[2] = "b"', + '[3] = "c"', + '[0] = "a"', + '[1] = "a very long string is right here"']) + self.expect( + "p ss", + substrs=[ + "size=4", + '[2] = "b"', + '[3] = "c"', + '[0] = "a"', + '[1] = "a very long string is right here"']) + self.expect("frame variable ss[2]", substrs=[' = "b"']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - self.expect("frame variable ss",substrs = ["size=3",'[0] = "a"','[1] = "a very long string is right here"','[2] = "c"']) + self.expect( + "frame variable ss", + substrs=[ + "size=3", + '[0] = "a"', + '[1] = "a very long string is right here"', + '[2] = "c"']) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py index 00c1e548cf6b..be1547ea5d8f 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py @@ -5,24 +5,25 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LibcxxSetDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - + # bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.")) self.runCmd("run", RUN_SUCCEEDED) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py index 76eedb8c8919..b0e84121dded 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py @@ -1,4 +1,4 @@ -#coding=utf8 +# coding=utf8 """ Test lldb data formatter subsystem. """ @@ -6,13 +6,14 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LibcxxStringDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -24,22 +25,24 @@ class LibcxxStringDataFormatterTestCase(TestBase): self.line = line_number('main.cpp', '// Set break point at this line.') @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() 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) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=-1) self.runCmd("run", RUN_SUCCEEDED) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -48,40 +51,51 @@ class LibcxxStringDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect("frame variable", - substrs = ['(std::__1::wstring) s = L"hello world! מזל טוב!"', - '(std::__1::wstring) S = L"!!!!"', - '(const wchar_t *) mazeltov = 0x','L"מזל טוב"', - '(std::__1::string) q = "hello world"', - '(std::__1::string) Q = "quite a long std::strin with lots of info inside it"', - '(std::__1::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"', - '(std::__1::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"']) + self.expect( + "frame variable", + substrs=[ + '(std::__1::wstring) s = L"hello world! מזל טוב!"', + '(std::__1::wstring) S = L"!!!!"', + '(const wchar_t *) mazeltov = 0x', + 'L"מזל טוב"', + '(std::__1::string) q = "hello world"', + '(std::__1::string) Q = "quite a long std::strin with lots of info inside it"', + '(std::__1::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"', + '(std::__1::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"']) self.runCmd("n") - TheVeryLongOne = self.frame().FindVariable("TheVeryLongOne"); + TheVeryLongOne = self.frame().FindVariable("TheVeryLongOne") summaryOptions = lldb.SBTypeSummaryOptions() summaryOptions.SetCapping(lldb.eTypeSummaryUncapped) uncappedSummaryStream = lldb.SBStream() - TheVeryLongOne.GetSummary(uncappedSummaryStream,summaryOptions) + TheVeryLongOne.GetSummary(uncappedSummaryStream, summaryOptions) uncappedSummary = uncappedSummaryStream.GetData() - self.assertTrue(uncappedSummary.find("someText") > 0, "uncappedSummary does not include the full string") + self.assertTrue(uncappedSummary.find("someText") > 0, + "uncappedSummary does not include the full string") summaryOptions.SetCapping(lldb.eTypeSummaryCapped) cappedSummaryStream = lldb.SBStream() - TheVeryLongOne.GetSummary(cappedSummaryStream,summaryOptions) + TheVeryLongOne.GetSummary(cappedSummaryStream, summaryOptions) cappedSummary = cappedSummaryStream.GetData() - self.assertTrue(cappedSummary.find("someText") <= 0, "cappedSummary includes the full string") - - self.expect("frame variable", - substrs = ['(std::__1::wstring) s = L"hello world! מזל טוב!"', - '(std::__1::wstring) S = L"!!!!!"', - '(const wchar_t *) mazeltov = 0x','L"מזל טוב"', - '(std::__1::string) q = "hello world"', - '(std::__1::string) Q = "quite a long std::strin with lots of info inside it"', - '(std::__1::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"', - '(std::__1::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"']) + self.assertTrue( + cappedSummary.find("someText") <= 0, + "cappedSummary includes the full string") + + self.expect( + "frame variable", + substrs=[ + '(std::__1::wstring) s = L"hello world! מזל טוב!"', + '(std::__1::wstring) S = L"!!!!!"', + '(const wchar_t *) mazeltov = 0x', + 'L"מזל טוב"', + '(std::__1::string) q = "hello world"', + '(std::__1::string) Q = "quite a long std::strin with lots of info inside it"', + '(std::__1::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"', + '(std::__1::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"']) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py index 4765cd70f67c..8a08d38975cf 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py @@ -5,34 +5,37 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LibcxxUnorderedDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet @skipIf(compiler="gcc") def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.") + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.") self.runCmd("run", RUN_SUCCEEDED) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -41,12 +44,14 @@ class LibcxxUnorderedDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect('image list', substrs = self.getLibcPlusPlusLibs()) + self.expect('image list', substrs=self.getLibcPlusPlusLibs()) self.look_for_content_and_continue( "map", ['size=5 {', 'hello', 'world', 'this', 'is', 'me']) @@ -72,6 +77,6 @@ class LibcxxUnorderedDataFormatterTestCase(TestBase): '(\[\d\] = "world"(\\n|.)+){2}']) def look_for_content_and_continue(self, var_name, patterns): - self.expect( ("frame variable %s" % var_name), patterns=patterns) - self.expect( ("frame variable %s" % var_name), patterns=patterns) + self.expect(("frame variable %s" % var_name), patterns=patterns) + self.expect(("frame variable %s" % var_name), patterns=patterns) self.runCmd("continue") diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py index fe3b6c115e31..43d5ad4f1033 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LibcxxVBoolDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -23,22 +24,24 @@ class LibcxxVBoolDataFormatterTestCase(TestBase): self.line = line_number('main.cpp', '// Set break point at this line.') @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows. + @skipIfWindows # libc++ not ported to Windows. def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) - 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.line, num_expected_locations=-1) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -47,13 +50,33 @@ class LibcxxVBoolDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect("frame variable vBool", - substrs = ['size=49','[0] = false','[1] = true','[18] = false','[27] = true','[36] = false','[47] = true','[48] = true']) - - self.expect("expr vBool", - substrs = ['size=49','[0] = false','[1] = true','[18] = false','[27] = true','[36] = false','[47] = true','[48] = true']) + self.expect( + "frame variable vBool", + substrs=[ + 'size=49', + '[0] = false', + '[1] = true', + '[18] = false', + '[27] = true', + '[36] = false', + '[47] = true', + '[48] = true']) + + self.expect( + "expr vBool", + substrs=[ + 'size=49', + '[0] = false', + '[1] = true', + '[18] = false', + '[27] = true', + '[36] = false', + '[47] = true', + '[48] = true']) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py index 9a145fba73e8..719ed7300505 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py @@ -5,34 +5,38 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class LibcxxVectorDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @skipIf(compiler="gcc") - @skipIfWindows # libc++ not ported to Windows yet + @skipIfWindows # libc++ not ported to Windows yet def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - - lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+")) - bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "break here")) + lldbutil.skip_if_library_missing( + self, self.target(), lldbutil.PrintableRegex("libc\+\+")) + + bkpt = self.target().FindBreakpointByID( + lldbutil.run_break_set_by_source_regexp( + self, "break here")) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -41,51 +45,54 @@ class LibcxxVectorDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) # empty vectors (and storage pointers SHOULD BOTH BE NULL..) self.expect("frame variable numbers", - substrs = ['numbers = size=0']) + substrs=['numbers = size=0']) lldbutil.continue_to_breakpoint(self.process(), bkpt) - + # first value added self.expect("frame variable numbers", - substrs = ['numbers = size=1', - '[0] = 1', - '}']) + substrs=['numbers = size=1', + '[0] = 1', + '}']) # add some more data lldbutil.continue_to_breakpoint(self.process(), bkpt) - + self.expect("frame variable numbers", - substrs = ['numbers = size=4', - '[0] = 1', - '[1] = 12', - '[2] = 123', - '[3] = 1234', - '}']) + substrs=['numbers = size=4', + '[0] = 1', + '[1] = 12', + '[2] = 123', + '[3] = 1234', + '}']) self.expect("p numbers", - substrs = ['$', 'size=4', - '[0] = 1', - '[1] = 12', - '[2] = 123', - '[3] = 1234', - '}']) - - + substrs=['$', 'size=4', + '[0] = 1', + '[1] = 12', + '[2] = 123', + '[3] = 1234', + '}']) + # check access to synthetic children - self.runCmd("type summary add --summary-string \"item 0 is ${var[0]}\" std::int_vect int_vect") + self.runCmd( + "type summary add --summary-string \"item 0 is ${var[0]}\" std::int_vect int_vect") self.expect('frame variable numbers', - substrs = ['item 0 is 1']); - - self.runCmd("type summary add --summary-string \"item 0 is ${svar[0]}\" std::int_vect int_vect") + substrs=['item 0 is 1']) + + self.runCmd( + "type summary add --summary-string \"item 0 is ${svar[0]}\" std::int_vect int_vect") self.expect('frame variable numbers', - substrs = ['item 0 is 1']); + substrs=['item 0 is 1']) # move on with synths self.runCmd("type summary delete std::int_vect") self.runCmd("type summary delete int_vect") @@ -94,88 +101,89 @@ class LibcxxVectorDataFormatterTestCase(TestBase): lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable numbers", - substrs = ['numbers = size=7', - '[0] = 1', - '[1] = 12', - '[2] = 123', - '[3] = 1234', - '[4] = 12345', - '[5] = 123456', - '[6] = 1234567', - '}']) - + substrs=['numbers = size=7', + '[0] = 1', + '[1] = 12', + '[2] = 123', + '[3] = 1234', + '[4] = 12345', + '[5] = 123456', + '[6] = 1234567', + '}']) + self.expect("p numbers", - substrs = ['$', 'size=7', - '[0] = 1', - '[1] = 12', - '[2] = 123', - '[3] = 1234', - '[4] = 12345', - '[5] = 123456', - '[6] = 1234567', - '}']) + substrs=['$', 'size=7', + '[0] = 1', + '[1] = 12', + '[2] = 123', + '[3] = 1234', + '[4] = 12345', + '[5] = 123456', + '[6] = 1234567', + '}']) # check access-by-index self.expect("frame variable numbers[0]", - substrs = ['1']); + substrs=['1']) self.expect("frame variable numbers[1]", - substrs = ['12']); + substrs=['12']) self.expect("frame variable numbers[2]", - substrs = ['123']); + substrs=['123']) self.expect("frame variable numbers[3]", - substrs = ['1234']); + substrs=['1234']) # clear out the vector and see that we do the right thing once again lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable numbers", - substrs = ['numbers = size=0']) + substrs=['numbers = size=0']) lldbutil.continue_to_breakpoint(self.process(), bkpt) # first value added self.expect("frame variable numbers", - substrs = ['numbers = size=1', - '[0] = 7', - '}']) + substrs=['numbers = size=1', + '[0] = 7', + '}']) # check if we can display strings self.expect("frame variable strings", - substrs = ['goofy', - 'is', - 'smart']) + substrs=['goofy', + 'is', + 'smart']) self.expect("p strings", - substrs = ['goofy', - 'is', - 'smart']) + substrs=['goofy', + 'is', + 'smart']) # test summaries based on synthetic children - self.runCmd("type summary add std::string_vect string_vect --summary-string \"vector has ${svar%#} items\" -e") + self.runCmd( + "type summary add std::string_vect string_vect --summary-string \"vector has ${svar%#} items\" -e") self.expect("frame variable strings", - substrs = ['vector has 3 items', - 'goofy', - 'is', - 'smart']) + substrs=['vector has 3 items', + 'goofy', + 'is', + 'smart']) self.expect("p strings", - substrs = ['vector has 3 items', - 'goofy', - 'is', - 'smart']) + substrs=['vector has 3 items', + 'goofy', + 'is', + 'smart']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable strings", - substrs = ['vector has 4 items']) - + substrs=['vector has 4 items']) + # check access-by-index self.expect("frame variable strings[0]", - substrs = ['goofy']); + substrs=['goofy']) self.expect("frame variable strings[1]", - substrs = ['is']); + substrs=['is']) lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable strings", - substrs = ['vector has 0 items']) + substrs=['vector has 0 items']) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py index dbaa37daa2d1..ce5087dbc288 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class StdIteratorDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,21 +23,21 @@ class StdIteratorDataFormatterTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') - @skipIfWindows # libstdcpp not ported to Windows - @expectedFailureAll(compiler="icc", bugnumber="llvm.org/pr15301 LLDB prints incorrect sizes of STL containers") + @skipIfWindows # libstdcpp not ported to Windows def test_with_run_command(self): """Test that libstdcpp iterators format properly.""" self.build() 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) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=-1) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -45,19 +46,29 @@ class StdIteratorDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect('frame variable ivI', substrs = ['item = 3']) - self.expect('expr ivI', substrs = ['item = 3']) - - self.expect('frame variable iimI', substrs = ['first = 0','second = 12']) - self.expect('expr iimI', substrs = ['first = 0','second = 12']) - - self.expect('frame variable simI', substrs = ['first = "world"','second = 42']) - self.expect('expr simI', substrs = ['first = "world"','second = 42']) - - self.expect('frame variable svI', substrs = ['item = "hello"']) - self.expect('expr svI', substrs = ['item = "hello"']) + self.expect('frame variable ivI', substrs=['item = 3']) + self.expect('expr ivI', substrs=['item = 3']) + + self.expect( + 'frame variable iimI', + substrs=[ + 'first = 0', + 'second = 12']) + self.expect('expr iimI', substrs=['first = 0', 'second = 12']) + + self.expect( + 'frame variable simI', + substrs=[ + 'first = "world"', + 'second = 42']) + self.expect('expr simI', substrs=['first = "world"', 'second = 42']) + + self.expect('frame variable svI', substrs=['item = "hello"']) + self.expect('expr svI', substrs=['item = "hello"']) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py index 55658af1f2a3..a7f8c4b1e174 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class StdListDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -21,23 +22,26 @@ class StdListDataFormatterTestCase(TestBase): TestBase.setUp(self) # Find the line numbers to break at for the different tests. self.line = line_number('main.cpp', '// Set break point at this line.') - self.optional_line = line_number('main.cpp', '// Optional break point at this line.') - self.final_line = line_number('main.cpp', '// Set final break point at this line.') + self.optional_line = line_number( + 'main.cpp', '// Optional break point at this line.') + self.final_line = line_number( + 'main.cpp', '// Set final break point at this line.') - @skipIfWindows # libstdcpp not ported to Windows + @skipIfWindows # libstdcpp not ported to Windows def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() 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) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=-1) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -46,7 +50,9 @@ class StdListDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) @@ -56,134 +62,148 @@ class StdListDataFormatterTestCase(TestBase): self.runCmd("type format add -f hex int") self.expect("frame variable numbers_list --raw", matching=False, - substrs = ['size=0', - '{}']) - self.expect("frame variable &numbers_list._M_impl._M_node --raw", matching=False, - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) + self.expect( + "frame variable &numbers_list._M_impl._M_node --raw", + matching=False, + substrs=[ + 'size=0', + '{}']) self.expect("frame variable numbers_list", - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) self.expect("p numbers_list", - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) self.runCmd("n") self.expect("frame variable numbers_list", - substrs = ['size=1', - '[0] = ', - '0x12345678']) + substrs=['size=1', + '[0] = ', + '0x12345678']) - self.runCmd("n");self.runCmd("n");self.runCmd("n"); + self.runCmd("n") + self.runCmd("n") + self.runCmd("n") self.expect("frame variable numbers_list", - substrs = ['size=4', - '[0] = ', - '0x12345678', - '[1] =', - '0x11223344', - '[2] =', - '0xbeeffeed', - '[3] =', - '0x00abba00']) - - self.runCmd("n");self.runCmd("n"); + substrs=['size=4', + '[0] = ', + '0x12345678', + '[1] =', + '0x11223344', + '[2] =', + '0xbeeffeed', + '[3] =', + '0x00abba00']) + + self.runCmd("n") + self.runCmd("n") self.expect("frame variable numbers_list", - substrs = ['size=6', - '[0] = ', - '0x12345678', - '0x11223344', - '0xbeeffeed', - '0x00abba00', - '[4] =', - '0x0abcdef0', - '[5] =', - '0x0cab0cab']) + substrs=['size=6', + '[0] = ', + '0x12345678', + '0x11223344', + '0xbeeffeed', + '0x00abba00', + '[4] =', + '0x0abcdef0', + '[5] =', + '0x0cab0cab']) self.expect("p numbers_list", - substrs = ['size=6', - '[0] = ', - '0x12345678', - '0x11223344', - '0xbeeffeed', - '0x00abba00', - '[4] =', - '0x0abcdef0', - '[5] =', - '0x0cab0cab']) + substrs=['size=6', + '[0] = ', + '0x12345678', + '0x11223344', + '0xbeeffeed', + '0x00abba00', + '[4] =', + '0x0abcdef0', + '[5] =', + '0x0cab0cab']) # check access-by-index self.expect("frame variable numbers_list[0]", - substrs = ['0x12345678']); + substrs=['0x12345678']) self.expect("frame variable numbers_list[1]", - substrs = ['0x11223344']); - + substrs=['0x11223344']) + # but check that expression does not rely on us self.expect("expression numbers_list[0]", matching=False, error=True, - substrs = ['0x12345678']) + substrs=['0x12345678']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("numbers_list").MightHaveChildren(), "numbers_list.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("numbers_list").MightHaveChildren(), + "numbers_list.MightHaveChildren() says False for non empty!") self.runCmd("n") - + self.expect("frame variable numbers_list", - substrs = ['size=0', - '{}']) + substrs=['size=0', + '{}']) + + self.runCmd("n") + self.runCmd("n") + self.runCmd("n") + self.runCmd("n") - self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n"); - self.expect("frame variable numbers_list", - substrs = ['size=4', - '[0] = ', '1', - '[1] = ', '2', - '[2] = ', '3', - '[3] = ', '4']) + substrs=['size=4', + '[0] = ', '1', + '[1] = ', '2', + '[2] = ', '3', + '[3] = ', '4']) self.runCmd("type format delete int") self.runCmd("n") - + self.expect("frame variable text_list", - substrs = ['size=0', - '{}']) - - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.final_line, num_expected_locations=-1) + substrs=['size=0', + '{}']) + + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.final_line, num_expected_locations=-1) self.runCmd("c", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) self.expect("frame variable text_list", - substrs = ['size=4', - '[0]', 'goofy', - '[1]', 'is', - '[2]', 'smart', - '[3]', '!!!']) + substrs=['size=4', + '[0]', 'goofy', + '[1]', 'is', + '[2]', 'smart', + '[3]', '!!!']) self.expect("p text_list", - substrs = ['size=4', - '\"goofy\"', - '\"is\"', - '\"smart\"', - '\"!!!\"']) - + substrs=['size=4', + '\"goofy\"', + '\"is\"', + '\"smart\"', + '\"!!!\"']) + # check access-by-index self.expect("frame variable text_list[0]", - substrs = ['goofy']); + substrs=['goofy']) self.expect("frame variable text_list[3]", - substrs = ['!!!']); - + substrs=['!!!']) + # but check that expression does not rely on us self.expect("expression text_list[0]", matching=False, error=True, - substrs = ['goofy']) + substrs=['goofy']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("text_list").MightHaveChildren(), "text_list.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("text_list").MightHaveChildren(), + "text_list.MightHaveChildren() says False for non empty!") diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py index ff99255aec0c..cdaec8392fe0 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class StdMapDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,22 +23,22 @@ class StdMapDataFormatterTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') - @expectedFailureAll(compiler="icc", bugnumber="llvm.org/pr15301 LLDB prints incorrect sizes of STL containers") - @skipIfWindows # libstdcpp not ported to Windows + @skipIfWindows # libstdcpp not ported to Windows @skipIfFreeBSD def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.") + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.") self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -46,278 +47,289 @@ class StdMapDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) self.runCmd("frame variable ii --show-types") - - self.runCmd("type summary add -x \"std::map<\" --summary-string \"map has ${svar%#} items\" -e") - + + self.runCmd( + "type summary add -x \"std::map<\" --summary-string \"map has ${svar%#} items\" -e") + self.expect('frame variable ii', - substrs = ['map has 0 items', - '{}']) + substrs=['map has 0 items', + '{}']) - self.runCmd("c"); + self.runCmd("c") self.expect('frame variable ii', - substrs = ['map has 2 items', - '[0] = ', - 'first = 0', - 'second = 0', - '[1] = ', - 'first = 1', - 'second = 1']) + substrs=['map has 2 items', + '[0] = ', + 'first = 0', + 'second = 0', + '[1] = ', + 'first = 1', + 'second = 1']) - self.runCmd("c"); + self.runCmd("c") self.expect('frame variable ii', - substrs = ['map has 4 items', - '[2] = ', - 'first = 2', - 'second = 0', - '[3] = ', - 'first = 3', - 'second = 1']) + substrs=['map has 4 items', + '[2] = ', + 'first = 2', + 'second = 0', + '[3] = ', + 'first = 3', + 'second = 1']) - self.runCmd("c"); + self.runCmd("c") self.expect("frame variable ii", - substrs = ['map has 9 items', - '[5] = ', - 'first = 5', - 'second = 0', - '[7] = ', - 'first = 7', - 'second = 1']) - + substrs=['map has 9 items', + '[5] = ', + 'first = 5', + 'second = 0', + '[7] = ', + 'first = 7', + 'second = 1']) + self.expect("p ii", - substrs = ['map has 9 items', - '[5] = ', - 'first = 5', - 'second = 0', - '[7] = ', - 'first = 7', - 'second = 1']) + substrs=['map has 9 items', + '[5] = ', + 'first = 5', + 'second = 0', + '[7] = ', + 'first = 7', + 'second = 1']) # check access-by-index self.expect("frame variable ii[0]", - substrs = ['first = 0', - 'second = 0']); + substrs=['first = 0', + 'second = 0']) self.expect("frame variable ii[3]", - substrs = ['first =', - 'second =']); - + substrs=['first =', + 'second =']) + self.expect("frame variable ii[8]", matching=True, - substrs = ['1234567']) + substrs=['1234567']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("ii").MightHaveChildren(), "ii.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("ii").MightHaveChildren(), + "ii.MightHaveChildren() says False for non empty!") # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression ii[8]", matching=False, error=True, + # self.expect("expression ii[8]", matching=False, error=True, # substrs = ['1234567']) self.runCmd("c") - + self.expect('frame variable ii', - substrs = ['map has 0 items', - '{}']) - + substrs=['map has 0 items', + '{}']) + self.runCmd("frame variable si --show-types") self.expect('frame variable si', - substrs = ['map has 0 items', - '{}']) + substrs=['map has 0 items', + '{}']) self.runCmd("c") self.expect('frame variable si', - substrs = ['map has 1 items', - '[0] = ', - 'first = \"zero\"', - 'second = 0']) + substrs=['map has 1 items', + '[0] = ', + 'first = \"zero\"', + 'second = 0']) - self.runCmd("c"); + self.runCmd("c") self.expect("frame variable si", - substrs = ['map has 5 items', - '[0] = ', - 'first = \"zero\"', - 'second = 0', - '[1] = ', - 'first = \"one\"', - 'second = 1', - '[2] = ', - 'first = \"two\"', - 'second = 2', - '[3] = ', - 'first = \"three\"', - 'second = 3', - '[4] = ', - 'first = \"four\"', - 'second = 4']) + substrs=['map has 5 items', + '[0] = ', + 'first = \"zero\"', + 'second = 0', + '[1] = ', + 'first = \"one\"', + 'second = 1', + '[2] = ', + 'first = \"two\"', + 'second = 2', + '[3] = ', + 'first = \"three\"', + 'second = 3', + '[4] = ', + 'first = \"four\"', + 'second = 4']) self.expect("p si", - substrs = ['map has 5 items', - '[0] = ', - 'first = \"zero\"', - 'second = 0', - '[1] = ', - 'first = \"one\"', - 'second = 1', - '[2] = ', - 'first = \"two\"', - 'second = 2', - '[3] = ', - 'first = \"three\"', - 'second = 3', - '[4] = ', - 'first = \"four\"', - 'second = 4']) + substrs=['map has 5 items', + '[0] = ', + 'first = \"zero\"', + 'second = 0', + '[1] = ', + 'first = \"one\"', + 'second = 1', + '[2] = ', + 'first = \"two\"', + 'second = 2', + '[3] = ', + 'first = \"three\"', + 'second = 3', + '[4] = ', + 'first = \"four\"', + 'second = 4']) # check access-by-index self.expect("frame variable si[0]", - substrs = ['first = ', 'four', - 'second = 4']); + substrs=['first = ', 'four', + 'second = 4']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("si").MightHaveChildren(), "si.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("si").MightHaveChildren(), + "si.MightHaveChildren() says False for non empty!") # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression si[0]", matching=False, error=True, + # self.expect("expression si[0]", matching=False, error=True, # substrs = ['first = ', 'zero']) self.runCmd("c") - + self.expect('frame variable si', - substrs = ['map has 0 items', - '{}']) + substrs=['map has 0 items', + '{}']) self.runCmd("frame variable is --show-types") - + self.expect('frame variable is', - substrs = ['map has 0 items', - '{}']) + substrs=['map has 0 items', + '{}']) - self.runCmd("c"); + self.runCmd("c") self.expect("frame variable is", - substrs = ['map has 4 items', - '[0] = ', - 'second = \"goofy\"', - 'first = 85', - '[1] = ', - 'second = \"is\"', - 'first = 1', - '[2] = ', - 'second = \"smart\"', - 'first = 2', - '[3] = ', - 'second = \"!!!\"', - 'first = 3']) - + substrs=['map has 4 items', + '[0] = ', + 'second = \"goofy\"', + 'first = 85', + '[1] = ', + 'second = \"is\"', + 'first = 1', + '[2] = ', + 'second = \"smart\"', + 'first = 2', + '[3] = ', + 'second = \"!!!\"', + 'first = 3']) + self.expect("p is", - substrs = ['map has 4 items', - '[0] = ', - 'second = \"goofy\"', - 'first = 85', - '[1] = ', - 'second = \"is\"', - 'first = 1', - '[2] = ', - 'second = \"smart\"', - 'first = 2', - '[3] = ', - 'second = \"!!!\"', - 'first = 3']) + substrs=['map has 4 items', + '[0] = ', + 'second = \"goofy\"', + 'first = 85', + '[1] = ', + 'second = \"is\"', + 'first = 1', + '[2] = ', + 'second = \"smart\"', + 'first = 2', + '[3] = ', + 'second = \"!!!\"', + 'first = 3']) # check access-by-index self.expect("frame variable is[0]", - substrs = ['first = ', - 'second =']); + substrs=['first = ', + 'second =']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("is").MightHaveChildren(), "is.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("is").MightHaveChildren(), + "is.MightHaveChildren() says False for non empty!") # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression is[0]", matching=False, error=True, + # self.expect("expression is[0]", matching=False, error=True, # substrs = ['first = ', 'goofy']) self.runCmd("c") - + self.expect('frame variable is', - substrs = ['map has 0 items', - '{}']) + substrs=['map has 0 items', + '{}']) self.runCmd("frame variable ss --show-types") - + self.expect('frame variable ss', - substrs = ['map has 0 items', - '{}']) + substrs=['map has 0 items', + '{}']) - self.runCmd("c"); + self.runCmd("c") self.expect("frame variable ss", - substrs = ['map has 4 items', - '[0] = ', - 'second = \"hello\"', - 'first = \"ciao\"', - '[1] = ', - 'second = \"house\"', - 'first = \"casa\"', - '[2] = ', - 'second = \"cat\"', - 'first = \"gatto\"', - '[3] = ', - 'second = \"..is always a Mac!\"', - 'first = \"a Mac..\"']) - + substrs=['map has 4 items', + '[0] = ', + 'second = \"hello\"', + 'first = \"ciao\"', + '[1] = ', + 'second = \"house\"', + 'first = \"casa\"', + '[2] = ', + 'second = \"cat\"', + 'first = \"gatto\"', + '[3] = ', + 'second = \"..is always a Mac!\"', + 'first = \"a Mac..\"']) + self.expect("p ss", - substrs = ['map has 4 items', - '[0] = ', - 'second = \"hello\"', - 'first = \"ciao\"', - '[1] = ', - 'second = \"house\"', - 'first = \"casa\"', - '[2] = ', - 'second = \"cat\"', - 'first = \"gatto\"', - '[3] = ', - 'second = \"..is always a Mac!\"', - 'first = \"a Mac..\"']) + substrs=['map has 4 items', + '[0] = ', + 'second = \"hello\"', + 'first = \"ciao\"', + '[1] = ', + 'second = \"house\"', + 'first = \"casa\"', + '[2] = ', + 'second = \"cat\"', + 'first = \"gatto\"', + '[3] = ', + 'second = \"..is always a Mac!\"', + 'first = \"a Mac..\"']) # check access-by-index self.expect("frame variable ss[3]", - substrs = ['gatto', 'cat']); + substrs=['gatto', 'cat']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("ss").MightHaveChildren(), "ss.MightHaveChildren() says False for non empty!") - + self.assertTrue( + self.frame().FindVariable("ss").MightHaveChildren(), + "ss.MightHaveChildren() says False for non empty!") + # check that the expression parser does not make use of # synthetic children instead of running code # TOT clang has a fix for this, which makes the expression command here succeed # since this would make the test fail or succeed depending on clang version in use # this is safer commented for the time being - #self.expect("expression ss[3]", matching=False, error=True, + # self.expect("expression ss[3]", matching=False, error=True, # substrs = ['gatto']) self.runCmd("c") - + self.expect('frame variable ss', - substrs = ['map has 0 items', - '{}']) + substrs=['map has 0 items', + '{}']) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py index 20b1a3d21156..8d940c2686a0 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py @@ -4,43 +4,46 @@ Test lldb data formatter subsystem. from __future__ import print_function -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class StdSmartPtrDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @skipIfFreeBSD - @skipIfWindows # libstdcpp not ported to Windows - @skipIfDarwin # doesn't compile on Darwin + @skipIfWindows # libstdcpp not ported to Windows + @skipIfDarwin # doesn't compile on Darwin def test_with_run_command(self): self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.") + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.") self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', 'stop reason = breakpoint']) + substrs=['stopped', 'stop reason = breakpoint']) + + self.expect("frame variable nsp", substrs=['nsp = nullptr']) + self.expect("frame variable isp", substrs=['isp = 123']) + self.expect("frame variable ssp", substrs=['ssp = "foobar"']) - self.expect("frame variable nsp", substrs = ['nsp = nullptr']) - self.expect("frame variable isp", substrs = ['isp = 123']) - self.expect("frame variable ssp", substrs = ['ssp = "foobar"']) + self.expect("frame variable nwp", substrs=['nwp = nullptr']) + self.expect("frame variable iwp", substrs=['iwp = 123']) + self.expect("frame variable swp", substrs=['swp = "foobar"']) - self.expect("frame variable nwp", substrs = ['nwp = nullptr']) - self.expect("frame variable iwp", substrs = ['iwp = 123']) - self.expect("frame variable swp", substrs = ['swp = "foobar"']) - self.runCmd("continue") - self.expect("frame variable nsp", substrs = ['nsp = nullptr']) - self.expect("frame variable isp", substrs = ['isp = nullptr']) - self.expect("frame variable ssp", substrs = ['ssp = nullptr']) + self.expect("frame variable nsp", substrs=['nsp = nullptr']) + self.expect("frame variable isp", substrs=['isp = nullptr']) + self.expect("frame variable ssp", substrs=['ssp = nullptr']) - self.expect("frame variable nwp", substrs = ['nwp = nullptr']) - self.expect("frame variable iwp", substrs = ['iwp = nullptr']) - self.expect("frame variable swp", substrs = ['swp = nullptr']) + self.expect("frame variable nwp", substrs=['nwp = nullptr']) + self.expect("frame variable iwp", substrs=['iwp = nullptr']) + self.expect("frame variable swp", substrs=['swp = nullptr']) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py index fde2f791183a..67823c95f138 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py @@ -1,4 +1,4 @@ -#coding=utf8 +# coding=utf8 """ Test lldb data formatter subsystem. """ @@ -6,13 +6,14 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class StdStringDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -23,20 +24,21 @@ class StdStringDataFormatterTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') - @skipIfWindows # libstdcpp not ported to Windows + @skipIfWindows # libstdcpp not ported to Windows def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() 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) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=-1) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -45,7 +47,9 @@ class StdStringDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) @@ -56,12 +60,22 @@ class StdStringDataFormatterTestCase(TestBase): var_q = self.frame().FindVariable('q') var_Q = self.frame().FindVariable('Q') - self.assertTrue(var_s.GetSummary() == 'L"hello world! מזל טוב!"', "s summary wrong") + self.assertTrue( + var_s.GetSummary() == 'L"hello world! מזל טוב!"', + "s summary wrong") self.assertTrue(var_S.GetSummary() == 'L"!!!!"', "S summary wrong") - self.assertTrue(var_mazeltov.GetSummary() == 'L"מזל טוב"', "mazeltov summary wrong") - self.assertTrue(var_q.GetSummary() == '"hello world"', "q summary wrong") - self.assertTrue(var_Q.GetSummary() == '"quite a long std::strin with lots of info inside it"', "Q summary wrong") + self.assertTrue( + var_mazeltov.GetSummary() == 'L"מזל טוב"', + "mazeltov summary wrong") + self.assertTrue( + var_q.GetSummary() == '"hello world"', + "q summary wrong") + self.assertTrue( + var_Q.GetSummary() == '"quite a long std::strin with lots of info inside it"', + "Q summary wrong") self.runCmd("next") - self.assertTrue(var_S.GetSummary() == 'L"!!!!!"', "new S summary wrong") + self.assertTrue( + var_S.GetSummary() == 'L"!!!!!"', + "new S summary wrong") diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/Makefile new file mode 100644 index 000000000000..beb2fd583e7a --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/Makefile @@ -0,0 +1,8 @@ +LEVEL = ../../../../../make + +CXX_SOURCES := main.cpp + +USE_LIBSTDCPP := 1 +CFLAGS_EXTRAS += $(NO_LIMIT_DEBUG_INFO_FLAGS) + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/TestDataFormatterStdTuple.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/TestDataFormatterStdTuple.py new file mode 100644 index 000000000000..56e231da8522 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/TestDataFormatterStdTuple.py @@ -0,0 +1,49 @@ +""" +Test lldb data formatter subsystem. +""" + +from __future__ import print_function + +import os +import time +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class StdTupleDataFormatterTestCase(TestBase): + mydir = TestBase.compute_mydir(__file__) + + @skipIfFreeBSD + @skipIfWindows # libstdcpp not ported to Windows + @skipIfDarwin # doesn't compile on Darwin + def test_with_run_command(self): + self.build() + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.") + self.runCmd("run", RUN_SUCCEEDED) + + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs=['stopped', 'stop reason = breakpoint']) + + frame = self.frame() + self.assertTrue(frame.IsValid()) + + self.expect("frame variable ti", substrs=['[0] = 1']) + self.expect("frame variable ts", substrs=['[0] = "foobar"']) + self.expect("frame variable tt", substrs=['[0] = 1', '[1] = "baz"', '[2] = 2']) + + self.assertEqual(1, frame.GetValueForVariablePath("ti[0]").GetValueAsUnsigned()) + self.assertFalse(frame.GetValueForVariablePath("ti[1]").IsValid()) + + self.assertEqual('"foobar"', frame.GetValueForVariablePath("ts[0]").GetSummary()) + self.assertFalse(frame.GetValueForVariablePath("ts[1]").IsValid()) + + self.assertEqual(1, frame.GetValueForVariablePath("tt[0]").GetValueAsUnsigned()) + self.assertEqual('"baz"', frame.GetValueForVariablePath("tt[1]").GetSummary()) + self.assertEqual(2, frame.GetValueForVariablePath("tt[2]").GetValueAsUnsigned()) + self.assertFalse(frame.GetValueForVariablePath("tt[3]").IsValid()) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/main.cpp new file mode 100644 index 000000000000..7247742ee6bb --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/main.cpp @@ -0,0 +1,9 @@ +#include <memory> +#include <string> + +int main() { + std::tuple<int> ti{1}; + std::tuple<std::string> ts{"foobar"}; + std::tuple<int, std::string, int> tt{1, "baz", 2}; + return 0; // Set break point at this line. +} diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/Makefile b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/Makefile new file mode 100644 index 000000000000..beb2fd583e7a --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/Makefile @@ -0,0 +1,8 @@ +LEVEL = ../../../../../make + +CXX_SOURCES := main.cpp + +USE_LIBSTDCPP := 1 +CFLAGS_EXTRAS += $(NO_LIMIT_DEBUG_INFO_FLAGS) + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py new file mode 100644 index 000000000000..770d87178f50 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py @@ -0,0 +1,61 @@ +""" +Test lldb data formatter subsystem. +""" + +from __future__ import print_function + +import os +import time +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class StdUniquePtrDataFormatterTestCase(TestBase): + mydir = TestBase.compute_mydir(__file__) + + @skipIfFreeBSD + @skipIfWindows # libstdcpp not ported to Windows + @skipIfDarwin # doesn't compile on Darwin + def test_with_run_command(self): + self.build() + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.") + self.runCmd("run", RUN_SUCCEEDED) + + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs=['stopped', 'stop reason = breakpoint']) + + frame = self.frame() + self.assertTrue(frame.IsValid()) + + self.expect("frame variable nup", substrs=['nup = nullptr']) + self.expect("frame variable iup", substrs=['iup = 0x', 'object = 123']) + self.expect("frame variable sup", substrs=['sup = 0x', 'object = "foobar"']) + + self.expect("frame variable ndp", substrs=['ndp = nullptr']) + self.expect("frame variable idp", substrs=['idp = 0x', 'object = 456', 'deleter = ', 'a = 1', 'b = 2']) + self.expect("frame variable sdp", substrs=['sdp = 0x', 'object = "baz"', 'deleter = ', 'a = 3', 'b = 4']) + + self.assertEqual(123, frame.GetValueForVariablePath("iup.object").GetValueAsUnsigned()) + self.assertFalse(frame.GetValueForVariablePath("iup.deleter").IsValid()) + + self.assertEqual('"foobar"', frame.GetValueForVariablePath("sup.object").GetSummary()) + self.assertFalse(frame.GetValueForVariablePath("sup.deleter").IsValid()) + + self.assertEqual(456, frame.GetValueForVariablePath("idp.object").GetValueAsUnsigned()) + self.assertEqual('"baz"', frame.GetValueForVariablePath("sdp.object").GetSummary()) + + idp_deleter = frame.GetValueForVariablePath("idp.deleter") + self.assertTrue(idp_deleter.IsValid()) + self.assertEqual(1, idp_deleter.GetChildMemberWithName("a").GetValueAsUnsigned()) + self.assertEqual(2, idp_deleter.GetChildMemberWithName("b").GetValueAsUnsigned()) + + sdp_deleter = frame.GetValueForVariablePath("sdp.deleter") + self.assertTrue(sdp_deleter.IsValid()) + self.assertEqual(3, sdp_deleter.GetChildMemberWithName("a").GetValueAsUnsigned()) + self.assertEqual(4, sdp_deleter.GetChildMemberWithName("b").GetValueAsUnsigned()) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp new file mode 100644 index 000000000000..4a40309338c1 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp @@ -0,0 +1,22 @@ +#include <memory> +#include <string> + +struct Deleter { + void operator()(void *) {} + + int a; + int b; +}; + +int main() { + std::unique_ptr<char> nup; + std::unique_ptr<int> iup(new int{123}); + std::unique_ptr<std::string> sup(new std::string("foobar")); + + std::unique_ptr<char, Deleter> ndp; + std::unique_ptr<int, Deleter> idp(new int{456}, Deleter{1, 2}); + std::unique_ptr<std::string, Deleter> sdp(new std::string("baz"), + Deleter{3, 4}); + + return 0; // Set break point at this line. +} diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py index f5cf7c04c3a7..17b369df3e6b 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class StdVBoolDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,23 +23,25 @@ class StdVBoolDataFormatterTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') - @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr20548 fails to build on lab.llvm.org buildbot') - @expectedFailureAll(compiler="icc", bugnumber="llvm.org/pr15301 LLDB prints incorrect sizes of STL containers") - @skipIfWindows # libstdcpp not ported to Windows. + @expectedFailureAll( + oslist=['freebsd'], + bugnumber='llvm.org/pr20548 fails to build on lab.llvm.org buildbot') + @skipIfWindows # libstdcpp not ported to Windows. @skipIfDarwin def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() 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) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=-1) self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -47,13 +50,33 @@ class StdVBoolDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - self.expect("frame variable vBool", - substrs = ['size=49','[0] = false','[1] = true','[18] = false','[27] = true','[36] = false','[47] = true','[48] = true']) + self.expect( + "frame variable vBool", + substrs=[ + 'size=49', + '[0] = false', + '[1] = true', + '[18] = false', + '[27] = true', + '[36] = false', + '[47] = true', + '[48] = true']) - self.expect("expr vBool", - substrs = ['size=49','[0] = false','[1] = true','[18] = false','[27] = true','[36] = false','[47] = true','[48] = true']) + self.expect( + "expr vBool", + substrs=[ + 'size=49', + '[0] = false', + '[1] = true', + '[18] = false', + '[27] = true', + '[36] = false', + '[47] = true', + '[48] = true']) diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py index 4a352ef41c17..e4ec703495b3 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class StdVectorDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -23,21 +24,21 @@ class StdVectorDataFormatterTestCase(TestBase): self.line = line_number('main.cpp', '// Set break point at this line.') @skipIfFreeBSD - @expectedFailureAll(compiler="icc", bugnumber="llvm.org/pr15301 LLDB prints incorrect sizes of STL containers") - @skipIfWindows # libstdcpp not ported to Windows + @skipIfWindows # libstdcpp not ported to Windows def test_with_run_command(self): """Test that that file and class static variables display correctly.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line.") + lldbutil.run_break_set_by_source_regexp( + self, "Set break point at this line.") self.runCmd("run", RUN_SUCCEEDED) # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) + substrs=['stopped', + 'stop reason = breakpoint']) # This is the function to remove the custom formats in order to have a # clean slate for the next test case. @@ -46,163 +47,171 @@ class StdVectorDataFormatterTestCase(TestBase): self.runCmd('type summary clear', check=False) self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) - self.runCmd("settings set target.max-children-count 256", check=False) + self.runCmd( + "settings set target.max-children-count 256", + check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) # empty vectors (and storage pointers SHOULD BOTH BE NULL..) self.expect("frame variable numbers", - substrs = ['numbers = size=0']) + substrs=['numbers = size=0']) self.runCmd("c") - + # first value added self.expect("frame variable numbers", - substrs = ['numbers = size=1', - '[0] = 1', - '}']) + substrs=['numbers = size=1', + '[0] = 1', + '}']) # add some more data - self.runCmd("c"); - + self.runCmd("c") + self.expect("frame variable numbers", - substrs = ['numbers = size=4', - '[0] = 1', - '[1] = 12', - '[2] = 123', - '[3] = 1234', - '}']) + substrs=['numbers = size=4', + '[0] = 1', + '[1] = 12', + '[2] = 123', + '[3] = 1234', + '}']) self.expect("p numbers", - substrs = ['$', 'size=4', - '[0] = 1', - '[1] = 12', - '[2] = 123', - '[3] = 1234', - '}']) - - + substrs=['$', 'size=4', + '[0] = 1', + '[1] = 12', + '[2] = 123', + '[3] = 1234', + '}']) + # check access to synthetic children - self.runCmd("type summary add --summary-string \"item 0 is ${var[0]}\" std::int_vect int_vect") + self.runCmd( + "type summary add --summary-string \"item 0 is ${var[0]}\" std::int_vect int_vect") self.expect('frame variable numbers', - substrs = ['item 0 is 1']); - - self.runCmd("type summary add --summary-string \"item 0 is ${svar[0]}\" std::int_vect int_vect") + substrs=['item 0 is 1']) + + self.runCmd( + "type summary add --summary-string \"item 0 is ${svar[0]}\" std::int_vect int_vect") #import time - #time.sleep(19) + # time.sleep(19) self.expect('frame variable numbers', - substrs = ['item 0 is 1']); + substrs=['item 0 is 1']) # move on with synths self.runCmd("type summary delete std::int_vect") self.runCmd("type summary delete int_vect") # add some more data - self.runCmd("c"); + self.runCmd("c") self.expect("frame variable numbers", - substrs = ['numbers = size=7', - '[0] = 1', - '[1] = 12', - '[2] = 123', - '[3] = 1234', - '[4] = 12345', - '[5] = 123456', - '[6] = 1234567', - '}']) - + substrs=['numbers = size=7', + '[0] = 1', + '[1] = 12', + '[2] = 123', + '[3] = 1234', + '[4] = 12345', + '[5] = 123456', + '[6] = 1234567', + '}']) + self.expect("p numbers", - substrs = ['$', 'size=7', - '[0] = 1', - '[1] = 12', - '[2] = 123', - '[3] = 1234', - '[4] = 12345', - '[5] = 123456', - '[6] = 1234567', - '}']) + substrs=['$', 'size=7', + '[0] = 1', + '[1] = 12', + '[2] = 123', + '[3] = 1234', + '[4] = 12345', + '[5] = 123456', + '[6] = 1234567', + '}']) # check access-by-index self.expect("frame variable numbers[0]", - substrs = ['1']); + substrs=['1']) self.expect("frame variable numbers[1]", - substrs = ['12']); + substrs=['12']) self.expect("frame variable numbers[2]", - substrs = ['123']); + substrs=['123']) self.expect("frame variable numbers[3]", - substrs = ['1234']); - + substrs=['1234']) + # but check that expression does not rely on us # (when expression gets to call into STL code correctly, we will have to find # another way to check this) self.expect("expression numbers[6]", matching=False, error=True, - substrs = ['1234567']) + substrs=['1234567']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("numbers").MightHaveChildren(), "numbers.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("numbers").MightHaveChildren(), + "numbers.MightHaveChildren() says False for non empty!") # clear out the vector and see that we do the right thing once again self.runCmd("c") self.expect("frame variable numbers", - substrs = ['numbers = size=0']) + substrs=['numbers = size=0']) self.runCmd("c") # first value added self.expect("frame variable numbers", - substrs = ['numbers = size=1', - '[0] = 7', - '}']) + substrs=['numbers = size=1', + '[0] = 7', + '}']) # check if we can display strings self.runCmd("c") self.expect("frame variable strings", - substrs = ['goofy', - 'is', - 'smart']) + substrs=['goofy', + 'is', + 'smart']) self.expect("p strings", - substrs = ['goofy', - 'is', - 'smart']) + substrs=['goofy', + 'is', + 'smart']) # test summaries based on synthetic children - self.runCmd("type summary add std::string_vect string_vect --summary-string \"vector has ${svar%#} items\" -e") + self.runCmd( + "type summary add std::string_vect string_vect --summary-string \"vector has ${svar%#} items\" -e") self.expect("frame variable strings", - substrs = ['vector has 3 items', - 'goofy', - 'is', - 'smart']) + substrs=['vector has 3 items', + 'goofy', + 'is', + 'smart']) self.expect("p strings", - substrs = ['vector has 3 items', - 'goofy', - 'is', - 'smart']) + substrs=['vector has 3 items', + 'goofy', + 'is', + 'smart']) - self.runCmd("c"); + self.runCmd("c") self.expect("frame variable strings", - substrs = ['vector has 4 items']) - + substrs=['vector has 4 items']) + # check access-by-index self.expect("frame variable strings[0]", - substrs = ['goofy']); + substrs=['goofy']) self.expect("frame variable strings[1]", - substrs = ['is']); - + substrs=['is']) + # but check that expression does not rely on us # (when expression gets to call into STL code correctly, we will have to find # another way to check this) self.expect("expression strings[0]", matching=False, error=True, - substrs = ['goofy']) + substrs=['goofy']) # check that MightHaveChildren() gets it right - self.assertTrue(self.frame().FindVariable("strings").MightHaveChildren(), "strings.MightHaveChildren() says False for non empty!") + self.assertTrue( + self.frame().FindVariable("strings").MightHaveChildren(), + "strings.MightHaveChildren() says False for non empty!") self.runCmd("c") self.expect("frame variable strings", - substrs = ['vector has 0 items']) + substrs=['vector has 0 items']) |