[Lldb-commits] [PATCH] D115137: [formatters] Add a pointer and reference tests for a list and forward_list formatters for libstdcpp and libcxx
danilashtefan created this revision. danilashtefan requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D115137 Files: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/TestDataFormatterGenericForwardList.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/TestDataFormatterGenericList.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/main.cpp === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/main.cpp +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/main.cpp @@ -4,6 +4,12 @@ typedef std::list int_list; typedef std::list string_list; + +template void by_ref_and_ptr(T &ref, T *ptr) { + // Check ref and ptr + return; +} + int main() { int_list numbers_list; @@ -21,13 +27,16 @@ numbers_list.push_back(2); numbers_list.push_back(3); numbers_list.push_back(4); + +by_ref_and_ptr(numbers_list, &numbers_list); string_list text_list; text_list.push_back(std::string("goofy")); // Optional break point at this line. text_list.push_back(std::string("is")); text_list.push_back(std::string("smart")); - text_list.push_back(std::string("!!!")); + +by_ref_and_ptr(text_list, &text_list); return 0; // Set final break point at this line. } Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/TestDataFormatterGenericList.py === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/TestDataFormatterGenericList.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/TestDataFormatterGenericList.py @@ -205,11 +205,58 @@ self.assertTrue( self.frame().FindVariable("text_list").MightHaveChildren(), "text_list.MightHaveChildren() says False for non empty!") + +def do_test_ptr_and_ref(self, stdlib_type): +"""Test that ref and ptr to std::list is displayed correctly""" +self.build(dictionary={stdlib_type: "1"}) + +(_, process, _, bkpt) = lldbutil.run_to_source_breakpoint(self, +'Check ref and ptr', +lldb.SBFileSpec("main.cpp", False)) + +self.expect("frame variable ref", +substrs=['size=4', + '[0] = ', '1', + '[1] = ', '2', + '[2] = ', '3', + '[3] = ', '4']) + + +self.expect("frame variable *ptr", +substrs=['size=4', + '[0] = ', '1', + '[1] = ', '2', + '[2] = ', '3', + '[3] = ', '4']) + +lldbutil.continue_to_breakpoint(process, bkpt) + +self.expect("frame variable ref", +substrs=['size=4', + '[0]', 'goofy', + '[1]', 'is', + '[2]', 'smart', + '[3]', '!!!']) + +self.expect("frame variable *ptr", +substrs=['size=4', + '[0]', 'goofy', + '[1]', 'is', + '[2]', 'smart', + '[3]', '!!!']) @add_test_categories(["libstdcxx"]) def test_with_run_command_libstdcpp(self): self.do_test_with_run_command(USE_LIBSTDCPP) +@add_test_categories(["libstdcxx"]) +def test_ptr_and_ref_libstdcpp(self): +self.do_test_ptr_and_ref(USE_LIBSTDCPP) + @add_test_categories(["libc++"]) def test_with_run_command_libcpp(self): -self.do_test_with_run_command(USE_LIBCPP) \ No newline at end of file +self.do_test_with_run_command(USE_LIBCPP) + +@add_test_categories(["libc++"]) +def test_ptr_and_ref_libcpp(self): +self.do_test_ptr_and_ref(USE_LIBCPP) \ No newline at end of file Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/main.cpp === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/main.cpp +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/main.cpp @@ -1,10 +1,21 @@ #include + +void by_ref_and_ptr(std::forward_list &ref, std::fo
[Lldb-commits] [PATCH] D112180: Libcpp bitset syntethic children and tests
danilashtefan created this revision. Herald added a subscriber: mgorny. danilashtefan requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D112180 Files: lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.h lldb/source/Plugins/Language/CPlusPlus/LibStdcppBitset.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/bitset/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/bitset/TestDataFormatterStdBitset.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/bitset/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/bitset/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/bitset/main.cpp @@ -0,0 +1,29 @@ +#include +#include + +template +void fill(std::bitset &b) { + b.set(); + b[0] = b[1] = false; + for (std::size_t i = 2; i < N; ++i) { +for (std::size_t j = 2*i; j < N; j+=i) + b[j] = false; + } +} + +template +void by_ref_and_ptr(std::bitset &ref, std::bitset *ptr) { +// Check ref and ptr +return; +} + +int main() { + std::bitset<0> empty; + std::bitset<13> small; + fill(small); + std::bitset<70> large; + fill(large); + by_ref_and_ptr(small, &small); // break here + by_ref_and_ptr(large, &large); + return 0; +} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/bitset/TestDataFormatterStdBitset.py === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/bitset/TestDataFormatterStdBitset.py @@ -0,0 +1,232 @@ +""" +Test lldb data formatter subsystem. +""" + + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class StdBitsetDataFormatterTestCase(TestBase): + +mydir = TestBase.compute_mydir(__file__) + +def setUp(self): +TestBase.setUp(self) +primes = [1]*300 +primes[0] = primes[1] = 0 +for i in range(2, len(primes)): +for j in range(2*i, len(primes), i): +primes[j] = 0 +self.primes = primes + +def check(self, name, size): +var = self.frame().FindVariable(name) +self.assertTrue(var.IsValid()) +self.assertEqual(var.GetNumChildren(), size) +for i in range(size): +child = var.GetChildAtIndex(i) +self.assertEqual(child.GetValueAsUnsigned(), self.primes[i], +"variable: %s, index: %d"%(name, size)) + +@add_test_categories(["libstdcxx"]) +def test_value(self): +"""Test that std::bitset is displayed correctly""" +self.build() +lldbutil.run_to_source_breakpoint(self, '// break here', +lldb.SBFileSpec("main.cpp", False)) + +self.check("empty", 0) +self.check("small", 13) +self.check("large", 70) + +@add_test_categories(["libstdcxx"]) +def test_ptr_and_ref(self): +"""Test that ref and ptr to std::bitset is displayed correctly""" +self.build() +(_, process, _, bkpt) = lldbutil.run_to_source_breakpoint(self, +'Check ref and ptr', +lldb.SBFileSpec("main.cpp", False)) + +#self.check("ref", 13) +#self.check("ptr", 13) +self.expect("p ref", +substrs=['[0] = false', +'[1] = false', +'[2] = true', +'[3] = true', +'[4] = false', +'[5] = true', +'[6] = false', +'[7] = true', +'[8] = false', +'[9] = false', +'[10] = false', +'[11] = true', +'[12] = false']) + +self.expect("p *ptr", +substrs=['[0] = false', +'[1] = false', +'[2] = true', +'[3] = true', +'[4] = false', +'[5] = true', +'[6] = false', +'[7] = true', +'[8] = false', +'[9] = false', +'[10] = false', +'[11] = true', +'[12] = false']) + + + +lldbutil.continue_to_breakpoint(process, bkpt) + +self.expect("p ref", +substrs=['[0] = false', +'[1] = false', +'[2] = true', +'[3] = true', +'[4] =
[Lldb-commits] [PATCH] D112180: Libcpp bitset syntethic children and tests
danilashtefan updated this revision to Diff 382066. danilashtefan added a comment. I have corrected everything according to the previous comments. Wallace will kindly help me to format the code, since I have the following formatter error Stack dump: 0.Program arguments: clang-format -lines=1:149 -lines=0:0 lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp /lib/x86_64-linux-gnu/libLLVM-10.so.1(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x1f)[0x7fa7b5d204ff] /lib/x86_64-linux-gnu/libLLVM-10.so.1(_ZN4llvm3sys17RunSignalHandlersEv+0x50)[0x7fa7b5d1e7b0] /lib/x86_64-linux-gnu/libLLVM-10.so.1(+0x981ac5)[0x7fa7b5d20ac5] /lib/x86_64-linux-gnu/libpthread.so.0(+0x153c0)[0x7fa7bc4f03c0] /lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZNK5clang13SourceManager16translateLineColENS_6FileIDEjj+0xcf)[0x7fa7ba1cc83f] clang-format[0x407e10] clang-format[0x406b64] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0x7fa7b4e4e0b3] clang-format[0x40652e] error: clang-format -lines=1:149 -lines=0:0 lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp failed Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D112180/new/ https://reviews.llvm.org/D112180 Files: lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.h lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp @@ -1,29 +1,28 @@ #include #include -template -void fill(std::bitset &b) { +template void fill(std::bitset &b) { b.set(); b[0] = b[1] = false; for (std::size_t i = 2; i < N; ++i) { -for (std::size_t j = 2*i; j < N; j+=i) +for (std::size_t j = 2 * i; j < N; j += i) b[j] = false; } } -template +template void by_ref_and_ptr(std::bitset &ref, std::bitset *ptr) { -// Check ref and ptr -return; + // Check ref and ptr + return; } int main() { std::bitset<0> empty; std::bitset<13> small; fill(small); - std::bitset<200> large; + std::bitset<70> large; fill(large); by_ref_and_ptr(small, &small); // break here - by_ref_and_ptr(large, &large); + by_ref_and_ptr(large, &large); return 0; } Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py @@ -1,5 +1,5 @@ """ -Test lldb data formatter subsystem. +Test lldb data formatter subsystem for bitset for libcxx and libstdcpp. """ @@ -9,14 +9,15 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil +USE_LIBSTDCPP = "USE_LIBSTDCPP" +USE_LIBCPP = "USE_LIBCPP" -class TestDataFormatterLibcxxBitset(TestBase): +class GenericBitsetDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) def setUp(self): TestBase.setUp(self) - primes = [1]*300 primes[0] = primes[1] = 0 for i in range(2, len(primes)): @@ -33,21 +34,29 @@ self.assertEqual(child.GetValueAsUnsigned(), self.primes[i], "variable: %s, index: %d"%(name, size)) -@add_test_categories(["libc++"]) -def test_value(self): +def do_test_value(self, stdlib_type): """Test that std::bitset is displayed correctly""" -self.build() +self.build(dictionary={stdlib_type: "1"}) + lldbutil.run_to_source_breakpoint(self, '// break here', lldb.SBFileSpec("main.cpp", False)) self.check("empty", 0) self.check("small", 13) -self.check("large", 200) +self.check("large", 70) + +@add_test_categories(["libstdcxx"]) +def test_value_libstdcpp(self): +self.do_test_
[Lldb-commits] [PATCH] D112537: Set synthetic children. I have dove the generic tests for set. I have considered Libcxx tests as the one covering all the edge cases (including pointer and reference va
danilashtefan created this revision. Herald added a subscriber: mgorny. danilashtefan requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. ...properties. However, I have decided to vhange them only when applying the set summary provider, and change them back to their previous state, not to alter other summary providers' behaviour Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D112537 Files: lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.h lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp @@ -0,0 +1,55 @@ +#include +#include + +int g_the_foo = 0; + +int thefoo_rw(int arg = 1) { + if (arg < 0) +arg = 0; + if (!arg) +arg = 1; + g_the_foo += arg; + return g_the_foo; +} + +void by_ref_and_ptr(std::set &ref, std::set *ptr) { + // Stop here to check by ref and ptr + return; +} + +int main() { + std::set ii; + thefoo_rw(1); // Set break point at this line. + + ii.insert(0); + ii.insert(1); + ii.insert(2); + ii.insert(3); + ii.insert(4); + ii.insert(5); + thefoo_rw(1); // Set break point at this line. + + ii.insert(6); + thefoo_rw(1); // Set break point at this line. + + by_ref_and_ptr(ii, &ii); + + ii.clear(); + thefoo_rw(1); // Set break point at this line. + + std::set ss; + thefoo_rw(1); // Set break point at this line. + + ss.insert("a"); + ss.insert("a very long string is right here"); + thefoo_rw(1); // Set break point at this line. + + ss.insert("b"); + ss.insert("c"); + thefoo_rw(1); // Set break point at this line. + + ss.erase("b"); + thefoo_rw(1); // Set break point at this line. + + return 0; +} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py @@ -0,0 +1,157 @@ +""" +Test lldb data formatter subsystem. +""" + + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +USE_LIBSTDCPP = "USE_LIBSTDCPP" +USE_LIBCPP = "USE_LIBCPP" + +class LibcxxSetDataFormatterTestCase(TestBase): + +mydir = TestBase.compute_mydir(__file__) + +def setUp(self): +TestBase.setUp(self) +self.namespace = 'std' + +def getVariableType(self, name): +var = self.frame().FindVariable(name) +self.assertTrue(var.IsValid()) +return var.GetType().GetDisplayTypeName() + +def check_ii(self, var_name): +""" This checks the value of the bitset stored in ii at the call to by_ref_and_ptr. +We use this to make sure we get the same values for ii when we look at the object +directly, and when we look at a reference to the object. """ +self.expect( +"frame variable " + var_name, +substrs=["size=7", + "[2] = 2", + "[3] = 3", + "[6] = 6"]) +self.expect("frame variable " + var_name + "[2]", substrs=[" = 2"]) +self.expect( +"p " + var_name, +substrs=[ +"size=7", +"[2] = 2", +"[3] = 3", +"[6] = 6"]) + + +def do_test_with_run_command(self,stdlib_type): +"""Test that that file and class static variables display correctly.""" +self.build(dictionary={stdlib_type: "1"}) +(self.target, process, _, bkpt) = lldbutil.run_to_source_breakpoint( +self, "Set break point at this line.", lldb.SBFileSpec("main.cpp", False)) + +# This is the function to remove the custom formats in order to have a +# clean slate for the next test case. +def cleanup(): +self.runCmd('type format clear', check=False) +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) + +# Execute the cleanup function during test case tear down. +self.addTearDownHook(cleanup) + +ii_type = self.getVariableType("ii") +self.assertT
[Lldb-commits] [PATCH] D112180: Libcpp bitset syntethic children and tests
danilashtefan updated this revision to Diff 382325. danilashtefan added a comment. Minor corrections Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D112180/new/ https://reviews.llvm.org/D112180 Files: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp @@ -0,0 +1,55 @@ +#include +#include + +int g_the_foo = 0; + +int thefoo_rw(int arg = 1) { + if (arg < 0) +arg = 0; + if (!arg) +arg = 1; + g_the_foo += arg; + return g_the_foo; +} + +void by_ref_and_ptr(std::set &ref, std::set *ptr) { + // Stop here to check by ref and ptr + return; +} + +int main() { + std::set ii; + thefoo_rw(1); // Set break point at this line. + + ii.insert(0); + ii.insert(1); + ii.insert(2); + ii.insert(3); + ii.insert(4); + ii.insert(5); + thefoo_rw(1); // Set break point at this line. + + ii.insert(6); + thefoo_rw(1); // Set break point at this line. + + by_ref_and_ptr(ii, &ii); + + ii.clear(); + thefoo_rw(1); // Set break point at this line. + + std::set ss; + thefoo_rw(1); // Set break point at this line. + + ss.insert("a"); + ss.insert("a very long string is right here"); + thefoo_rw(1); // Set break point at this line. + + ss.insert("b"); + ss.insert("c"); + thefoo_rw(1); // Set break point at this line. + + ss.erase("b"); + thefoo_rw(1); // Set break point at this line. + + return 0; +} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py @@ -0,0 +1,157 @@ +""" +Test lldb data formatter subsystem. +""" + + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +USE_LIBSTDCPP = "USE_LIBSTDCPP" +USE_LIBCPP = "USE_LIBCPP" + +class LibcxxSetDataFormatterTestCase(TestBase): + +mydir = TestBase.compute_mydir(__file__) + +def setUp(self): +TestBase.setUp(self) +self.namespace = 'std' + +def getVariableType(self, name): +var = self.frame().FindVariable(name) +self.assertTrue(var.IsValid()) +return var.GetType().GetDisplayTypeName() + +def check_ii(self, var_name): +""" This checks the value of the bitset stored in ii at the call to by_ref_and_ptr. +We use this to make sure we get the same values for ii when we look at the object +directly, and when we look at a reference to the object. """ +self.expect( +"frame variable " + var_name, +substrs=["size=7", + "[2] = 2", + "[3] = 3", + "[6] = 6"]) +self.expect("frame variable " + var_name + "[2]", substrs=[" = 2"]) +self.expect( +"p " + var_name, +substrs=[ +"size=7", +"[2] = 2", +"[3] = 3", +"[6] = 6"]) + + +def do_test_with_run_command(self,stdlib_type): +"""Test that that file and class static variables display correctly.""" +self.build(dictionary={stdlib_type: "1"}) +(self.target, process, _, bkpt) = lldbutil.run_to_source_breakpoint( +self, "Set break point at this line.", lldb.SBFileSpec("main.cpp", False)) + +# This is the function to remove the custom formats in order to have a +# clean slate for the next test case. +def cleanup(): +self.runCmd('type format clear', check=False) +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) + +# Execute the cleanup function during test case tear down. +self.addTearDownHook(cleanup) + +ii_type = self.getVariableType("ii") +self.assertTrue(ii_type.startswith(self.namespace + "::set"), +"Type: " + ii_type) + +self.expect("frame variable ii", substrs=["size=0", "{}"]) +lldbutil.continue_to_breakpoint(process, bkpt) +self.expect( +"frame variable ii", +substrs=["size=6", +
[Lldb-commits] [PATCH] D112537: Set synthetic children. I have dove the generic tests for set. I have considered Libcxx tests as the one covering all the edge cases (including pointer and reference va
danilashtefan updated this revision to Diff 382330. danilashtefan added a comment. Set synthetic children Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D112537/new/ https://reviews.llvm.org/D112537 Files: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp @@ -0,0 +1,55 @@ +#include +#include + +int g_the_foo = 0; + +int thefoo_rw(int arg = 1) { + if (arg < 0) +arg = 0; + if (!arg) +arg = 1; + g_the_foo += arg; + return g_the_foo; +} + +void by_ref_and_ptr(std::set &ref, std::set *ptr) { + // Stop here to check by ref and ptr + return; +} + +int main() { + std::set ii; + thefoo_rw(1); // Set break point at this line. + + ii.insert(0); + ii.insert(1); + ii.insert(2); + ii.insert(3); + ii.insert(4); + ii.insert(5); + thefoo_rw(1); // Set break point at this line. + + ii.insert(6); + thefoo_rw(1); // Set break point at this line. + + by_ref_and_ptr(ii, &ii); + + ii.clear(); + thefoo_rw(1); // Set break point at this line. + + std::set ss; + thefoo_rw(1); // Set break point at this line. + + ss.insert("a"); + ss.insert("a very long string is right here"); + thefoo_rw(1); // Set break point at this line. + + ss.insert("b"); + ss.insert("c"); + thefoo_rw(1); // Set break point at this line. + + ss.erase("b"); + thefoo_rw(1); // Set break point at this line. + + return 0; +} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py @@ -0,0 +1,157 @@ +""" +Test lldb data formatter subsystem. +""" + + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +USE_LIBSTDCPP = "USE_LIBSTDCPP" +USE_LIBCPP = "USE_LIBCPP" + +class LibcxxSetDataFormatterTestCase(TestBase): + +mydir = TestBase.compute_mydir(__file__) + +def setUp(self): +TestBase.setUp(self) +self.namespace = 'std' + +def getVariableType(self, name): +var = self.frame().FindVariable(name) +self.assertTrue(var.IsValid()) +return var.GetType().GetDisplayTypeName() + +def check_ii(self, var_name): +""" This checks the value of the bitset stored in ii at the call to by_ref_and_ptr. +We use this to make sure we get the same values for ii when we look at the object +directly, and when we look at a reference to the object. """ +self.expect( +"frame variable " + var_name, +substrs=["size=7", + "[2] = 2", + "[3] = 3", + "[6] = 6"]) +self.expect("frame variable " + var_name + "[2]", substrs=[" = 2"]) +self.expect( +"p " + var_name, +substrs=[ +"size=7", +"[2] = 2", +"[3] = 3", +"[6] = 6"]) + + +def do_test_with_run_command(self,stdlib_type): +"""Test that that file and class static variables display correctly.""" +self.build(dictionary={stdlib_type: "1"}) +(self.target, process, _, bkpt) = lldbutil.run_to_source_breakpoint( +self, "Set break point at this line.", lldb.SBFileSpec("main.cpp", False)) + +# This is the function to remove the custom formats in order to have a +# clean slate for the next test case. +def cleanup(): +self.runCmd('type format clear', check=False) +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) + +# Execute the cleanup function during test case tear down. +self.addTearDownHook(cleanup) + +ii_type = self.getVariableType("ii") +self.assertTrue(ii_type.startswith(self.namespace + "::set"), +"Type: " + ii_type) + +self.expect("frame variable ii", substrs=["size=0", "{}"]) +lldbutil.continue_to_breakpoint(process, bkpt) +self.expect( +"frame variable ii", +substrs=["size=6", +
[Lldb-commits] [PATCH] D112537: Set synthetic children. I have dove the generic tests for set. I have considered Libcxx tests as the one covering all the edge cases (including pointer and reference va
danilashtefan updated this revision to Diff 382336. danilashtefan added a comment. Set synthetic child Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D112537/new/ https://reviews.llvm.org/D112537 Files: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp @@ -0,0 +1,55 @@ +#include +#include + +int g_the_foo = 0; + +int thefoo_rw(int arg = 1) { + if (arg < 0) +arg = 0; + if (!arg) +arg = 1; + g_the_foo += arg; + return g_the_foo; +} + +void by_ref_and_ptr(std::set &ref, std::set *ptr) { + // Stop here to check by ref and ptr + return; +} + +int main() { + std::set ii; + thefoo_rw(1); // Set break point at this line. + + ii.insert(0); + ii.insert(1); + ii.insert(2); + ii.insert(3); + ii.insert(4); + ii.insert(5); + thefoo_rw(1); // Set break point at this line. + + ii.insert(6); + thefoo_rw(1); // Set break point at this line. + + by_ref_and_ptr(ii, &ii); + + ii.clear(); + thefoo_rw(1); // Set break point at this line. + + std::set ss; + thefoo_rw(1); // Set break point at this line. + + ss.insert("a"); + ss.insert("a very long string is right here"); + thefoo_rw(1); // Set break point at this line. + + ss.insert("b"); + ss.insert("c"); + thefoo_rw(1); // Set break point at this line. + + ss.erase("b"); + thefoo_rw(1); // Set break point at this line. + + return 0; +} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py @@ -0,0 +1,157 @@ +""" +Test lldb data formatter subsystem. +""" + + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +USE_LIBSTDCPP = "USE_LIBSTDCPP" +USE_LIBCPP = "USE_LIBCPP" + +class LibcxxSetDataFormatterTestCase(TestBase): + +mydir = TestBase.compute_mydir(__file__) + +def setUp(self): +TestBase.setUp(self) +self.namespace = 'std' + +def getVariableType(self, name): +var = self.frame().FindVariable(name) +self.assertTrue(var.IsValid()) +return var.GetType().GetDisplayTypeName() + +def check_ii(self, var_name): +""" This checks the value of the bitset stored in ii at the call to by_ref_and_ptr. +We use this to make sure we get the same values for ii when we look at the object +directly, and when we look at a reference to the object. """ +self.expect( +"frame variable " + var_name, +substrs=["size=7", + "[2] = 2", + "[3] = 3", + "[6] = 6"]) +self.expect("frame variable " + var_name + "[2]", substrs=[" = 2"]) +self.expect( +"p " + var_name, +substrs=[ +"size=7", +"[2] = 2", +"[3] = 3", +"[6] = 6"]) + + +def do_test_with_run_command(self,stdlib_type): +"""Test that that file and class static variables display correctly.""" +self.build(dictionary={stdlib_type: "1"}) +(self.target, process, _, bkpt) = lldbutil.run_to_source_breakpoint( +self, "Set break point at this line.", lldb.SBFileSpec("main.cpp", False)) + +# This is the function to remove the custom formats in order to have a +# clean slate for the next test case. +def cleanup(): +self.runCmd('type format clear', check=False) +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) + +# Execute the cleanup function during test case tear down. +self.addTearDownHook(cleanup) + +ii_type = self.getVariableType("ii") +self.assertTrue(ii_type.startswith(self.namespace + "::set"), +"Type: " + ii_type) + +self.expect("frame variable ii", substrs=["size=0", "{}"]) +lldbutil.continue_to_breakpoint(process, bkpt) +self.expect( +"frame variable ii", +substrs=["size=6", +
[Lldb-commits] [PATCH] D112537: Set synthetic children
danilashtefan updated this revision to Diff 382348. danilashtefan added a comment. Deleted libcxx tests Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D112537/new/ https://reviews.llvm.org/D112537 Files: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/main.cpp === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/main.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include -#include - -int g_the_foo = 0; - -int thefoo_rw(int arg = 1) -{ - if (arg < 0) - arg = 0; - if (!arg) - arg = 1; - g_the_foo += arg; - return g_the_foo; -} - -void by_ref_and_ptr(std::set &ref, std::set *ptr) -{ -// Stop here to check by ref and ptr -return; -} - -int main() -{ -std::set ii; -thefoo_rw(1); // Set break point at this line. - - ii.insert(0); - ii.insert(1); - ii.insert(2); - ii.insert(3); - ii.insert(4); - ii.insert(5); -thefoo_rw(1); // Set break point at this line. - - ii.insert(6); - thefoo_rw(1); // Set break point at this line. - -by_ref_and_ptr(ii, &ii); - - ii.clear(); - thefoo_rw(1); // Set break point at this line. - - std::set ss; - thefoo_rw(1); // Set break point at this line. - - ss.insert("a"); - ss.insert("a very long string is right here"); - thefoo_rw(1); // Set break point at this line. - - ss.insert("b"); - ss.insert("c"); - thefoo_rw(1); // Set break point at this line. - - ss.erase("b"); - thefoo_rw(1); // Set break point at this line. - -return 0; -} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp @@ -0,0 +1,55 @@ +#include +#include + +int g_the_foo = 0; + +int thefoo_rw(int arg = 1) { + if (arg < 0) +arg = 0; + if (!arg) +arg = 1; + g_the_foo += arg; + return g_the_foo; +} + +void by_ref_and_ptr(std::set &ref, std::set *ptr) { + // Stop here to check by ref and ptr + return; +} + +int main() { + std::set ii; + thefoo_rw(1); // Set break point at this line. + + ii.insert(0); + ii.insert(1); + ii.insert(2); + ii.insert(3); + ii.insert(4); + ii.insert(5); + thefoo_rw(1); // Set break point at this line. + + ii.insert(6); + thefoo_rw(1); // Set break point at this line. + + by_ref_and_ptr(ii, &ii); + + ii.clear(); + thefoo_rw(1); // Set break point at this line. + + std::set ss; + thefoo_rw(1); // Set break point at this line. + + ss.insert("a"); + ss.insert("a very long string is right here"); + thefoo_rw(1); // Set break point at this line. + + ss.insert("b"); + ss.insert("c"); + thefoo_rw(1); // Set break point at this line. + + ss.erase("b"); + thefoo_rw(1); // Set break point at this line. + + return 0; +} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py @@ -9,6 +9,8 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil +USE_LIBSTDCPP = "USE_LIBSTDCPP" +USE_LIBCPP = "USE_LIBCPP" class LibcxxSetDataFormatterTestCase(TestBase): @@ -42,10 +44,10 @@ "[3] = 3", "[6] = 6"]) -@add_test_categories(["libc++"]) -def test_with_run_command(self): + +def do_test_with_run_command(self,stdlib_type): """Test that that file and class static variables display correctly.""" -self.build() +self.build(dictionary={stdlib_type: "1"}) (self.target, process, _, bkpt) = lldbutil.run_to_source_breakpoint( self, "Set break point at this line.", lldb.SBFileSpec("main.cpp", False)) @@ -121,8 +123,16 @@ '[1] = "a very long string is right here"', '[2] = "c"']) +@add_test_categories(["libstdcxx"]) +def test_with_run_command_libstdcpp(self): +self.do_test_with_run_command(USE_LIBSTDCPP) + @add_test_c
[Lldb-commits] [PATCH] D112180: [formatters] Add a libstdcpp formatter for set and unify tests across stdlibs
danilashtefan updated this revision to Diff 382370. danilashtefan added a comment. Fixing Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D112180/new/ https://reviews.llvm.org/D112180 Files: lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.h lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp @@ -1,29 +1,28 @@ #include #include -template -void fill(std::bitset &b) { +template void fill(std::bitset &b) { b.set(); b[0] = b[1] = false; for (std::size_t i = 2; i < N; ++i) { -for (std::size_t j = 2*i; j < N; j+=i) +for (std::size_t j = 2 * i; j < N; j += i) b[j] = false; } } -template +template void by_ref_and_ptr(std::bitset &ref, std::bitset *ptr) { -// Check ref and ptr -return; + // Check ref and ptr + return; } int main() { std::bitset<0> empty; std::bitset<13> small; fill(small); - std::bitset<200> large; + std::bitset<70> large; fill(large); by_ref_and_ptr(small, &small); // break here - by_ref_and_ptr(large, &large); + by_ref_and_ptr(large, &large); return 0; } Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py @@ -1,5 +1,5 @@ """ -Test lldb data formatter subsystem. +Test lldb data formatter subsystem for bitset for libcxx and libstdcpp. """ @@ -9,14 +9,15 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil +USE_LIBSTDCPP = "USE_LIBSTDCPP" +USE_LIBCPP = "USE_LIBCPP" -class TestDataFormatterLibcxxBitset(TestBase): +class GenericBitsetDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) def setUp(self): TestBase.setUp(self) - primes = [1]*300 primes[0] = primes[1] = 0 for i in range(2, len(primes)): @@ -33,21 +34,29 @@ self.assertEqual(child.GetValueAsUnsigned(), self.primes[i], "variable: %s, index: %d"%(name, size)) -@add_test_categories(["libc++"]) -def test_value(self): +def do_test_value(self, stdlib_type): """Test that std::bitset is displayed correctly""" -self.build() +self.build(dictionary={stdlib_type: "1"}) + lldbutil.run_to_source_breakpoint(self, '// break here', lldb.SBFileSpec("main.cpp", False)) self.check("empty", 0) self.check("small", 13) -self.check("large", 200) +self.check("large", 70) + +@add_test_categories(["libstdcxx"]) +def test_value_libstdcpp(self): +self.do_test_value(USE_LIBSTDCPP) @add_test_categories(["libc++"]) -def test_ptr_and_ref(self): +def test_value_libcpp(self): +self.do_test_value(USE_LIBCPP) + +def do_test_ptr_and_ref(self, stdlib_type): """Test that ref and ptr to std::bitset is displayed correctly""" -self.build() +self.build(dictionary={stdlib_type: "1"}) + (_, process, _, bkpt) = lldbutil.run_to_source_breakpoint(self, 'Check ref and ptr', lldb.SBFileSpec("main.cpp", False)) @@ -57,5 +66,13 @@ lldbutil.continue_to_breakpoint(process, bkpt) -self.check("ref", 200) -self.check("ptr", 200) +self.check("ref", 70) +self.check("ptr", 70) + +@add_test_categories(["libstdcxx"]) +def test_ptr_and_ref_libstdcpp(self): +self.do_test_ptr_and_ref(USE_LIBSTDCPP) + +@add_test_categories(["libc++"]) +def test_ptr_and_ref_libcpp(self): +self.do_test_ptr_and_ref
[Lldb-commits] [PATCH] D112180: [formatters] Add a libstdcpp formatter for set and unify tests across stdlibs
danilashtefan updated this revision to Diff 382453. danilashtefan added a comment. With this changes I substitute the verbose long printed check with ValueCheck approach Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D112180/new/ https://reviews.llvm.org/D112180 Files: lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.h lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py +++ /dev/null @@ -1,61 +0,0 @@ -""" -Test lldb data formatter subsystem. -""" - - - -import lldb -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - - -class TestDataFormatterLibcxxBitset(TestBase): - -mydir = TestBase.compute_mydir(__file__) - -def setUp(self): -TestBase.setUp(self) - -primes = [1]*300 -primes[0] = primes[1] = 0 -for i in range(2, len(primes)): -for j in range(2*i, len(primes), i): -primes[j] = 0 -self.primes = primes - -def check(self, name, size): -var = self.frame().FindVariable(name) -self.assertTrue(var.IsValid()) -self.assertEqual(var.GetNumChildren(), size) -for i in range(size): -child = var.GetChildAtIndex(i) -self.assertEqual(child.GetValueAsUnsigned(), self.primes[i], -"variable: %s, index: %d"%(name, size)) - -@add_test_categories(["libc++"]) -def test_value(self): -"""Test that std::bitset is displayed correctly""" -self.build() -lldbutil.run_to_source_breakpoint(self, '// break here', -lldb.SBFileSpec("main.cpp", False)) - -self.check("empty", 0) -self.check("small", 13) -self.check("large", 200) - -@add_test_categories(["libc++"]) -def test_ptr_and_ref(self): -"""Test that ref and ptr to std::bitset is displayed correctly""" -self.build() -(_, process, _, bkpt) = lldbutil.run_to_source_breakpoint(self, -'Check ref and ptr', -lldb.SBFileSpec("main.cpp", False)) - -self.check("ref", 13) -self.check("ptr", 13) - -lldbutil.continue_to_breakpoint(process, bkpt) - -self.check("ref", 200) -self.check("ptr", 200) Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp @@ -1,29 +1,28 @@ #include #include -template -void fill(std::bitset &b) { +template void fill(std::bitset &b) { b.set(); b[0] = b[1] = false; for (std::size_t i = 2; i < N; ++i) { -for (std::size_t j = 2*i; j < N; j+=i) +for (std::size_t j = 2 * i; j < N; j += i) b[j] = false; } } -template +template void by_ref_and_ptr(std::bitset &ref, std::bitset *ptr) { -// Check ref and ptr -return; + // Check ref and ptr + return; } int main() { std::bitset<0> empty; std::bitset<13> small; fill(small); - std::bitset<200> large; + std::bitset<70> large; fill(large); by_ref_and_ptr(small, &small); // break here - by_ref_and_ptr(large, &large); + by_ref_and_ptr(large, &large); return 0; } Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py @@ -0,0 +1,89 @@ +""" +Test lldb data formatter subsystem for bitset for libcxx and libstdcpp. +""" + + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from l
[Lldb-commits] [PATCH] D112180: [formatters] Add a libstdcpp formatter for bitset and unify tests across stdlibs
danilashtefan updated this revision to Diff 382456. danilashtefan added a comment. Refactoring Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D112180/new/ https://reviews.llvm.org/D112180 Files: lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.h lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py +++ /dev/null @@ -1,61 +0,0 @@ -""" -Test lldb data formatter subsystem. -""" - - - -import lldb -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - - -class TestDataFormatterLibcxxBitset(TestBase): - -mydir = TestBase.compute_mydir(__file__) - -def setUp(self): -TestBase.setUp(self) - -primes = [1]*300 -primes[0] = primes[1] = 0 -for i in range(2, len(primes)): -for j in range(2*i, len(primes), i): -primes[j] = 0 -self.primes = primes - -def check(self, name, size): -var = self.frame().FindVariable(name) -self.assertTrue(var.IsValid()) -self.assertEqual(var.GetNumChildren(), size) -for i in range(size): -child = var.GetChildAtIndex(i) -self.assertEqual(child.GetValueAsUnsigned(), self.primes[i], -"variable: %s, index: %d"%(name, size)) - -@add_test_categories(["libc++"]) -def test_value(self): -"""Test that std::bitset is displayed correctly""" -self.build() -lldbutil.run_to_source_breakpoint(self, '// break here', -lldb.SBFileSpec("main.cpp", False)) - -self.check("empty", 0) -self.check("small", 13) -self.check("large", 200) - -@add_test_categories(["libc++"]) -def test_ptr_and_ref(self): -"""Test that ref and ptr to std::bitset is displayed correctly""" -self.build() -(_, process, _, bkpt) = lldbutil.run_to_source_breakpoint(self, -'Check ref and ptr', -lldb.SBFileSpec("main.cpp", False)) - -self.check("ref", 13) -self.check("ptr", 13) - -lldbutil.continue_to_breakpoint(process, bkpt) - -self.check("ref", 200) -self.check("ptr", 200) Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp @@ -1,29 +1,28 @@ #include #include -template -void fill(std::bitset &b) { +template void fill(std::bitset &b) { b.set(); b[0] = b[1] = false; for (std::size_t i = 2; i < N; ++i) { -for (std::size_t j = 2*i; j < N; j+=i) +for (std::size_t j = 2 * i; j < N; j += i) b[j] = false; } } -template +template void by_ref_and_ptr(std::bitset &ref, std::bitset *ptr) { -// Check ref and ptr -return; + // Check ref and ptr + return; } int main() { std::bitset<0> empty; std::bitset<13> small; fill(small); - std::bitset<200> large; + std::bitset<70> large; fill(large); by_ref_and_ptr(small, &small); // break here - by_ref_and_ptr(large, &large); + by_ref_and_ptr(large, &large); return 0; } Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py @@ -0,0 +1,93 @@ +""" +Test lldb data formatter subsystem for bitset for libcxx and libstdcpp. +""" + + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +USE_LIBSTDCPP = "USE_LIBSTDCPP" +USE_LIBCPP
[Lldb-commits] [PATCH] D112180: [formatters] Add a libstdcpp formatter for bitset and unify tests across stdlibs
danilashtefan updated this revision to Diff 382463. danilashtefan added a comment. Reactoring Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D112180/new/ https://reviews.llvm.org/D112180 Files: lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.h lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py +++ /dev/null @@ -1,61 +0,0 @@ -""" -Test lldb data formatter subsystem. -""" - - - -import lldb -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - - -class TestDataFormatterLibcxxBitset(TestBase): - -mydir = TestBase.compute_mydir(__file__) - -def setUp(self): -TestBase.setUp(self) - -primes = [1]*300 -primes[0] = primes[1] = 0 -for i in range(2, len(primes)): -for j in range(2*i, len(primes), i): -primes[j] = 0 -self.primes = primes - -def check(self, name, size): -var = self.frame().FindVariable(name) -self.assertTrue(var.IsValid()) -self.assertEqual(var.GetNumChildren(), size) -for i in range(size): -child = var.GetChildAtIndex(i) -self.assertEqual(child.GetValueAsUnsigned(), self.primes[i], -"variable: %s, index: %d"%(name, size)) - -@add_test_categories(["libc++"]) -def test_value(self): -"""Test that std::bitset is displayed correctly""" -self.build() -lldbutil.run_to_source_breakpoint(self, '// break here', -lldb.SBFileSpec("main.cpp", False)) - -self.check("empty", 0) -self.check("small", 13) -self.check("large", 200) - -@add_test_categories(["libc++"]) -def test_ptr_and_ref(self): -"""Test that ref and ptr to std::bitset is displayed correctly""" -self.build() -(_, process, _, bkpt) = lldbutil.run_to_source_breakpoint(self, -'Check ref and ptr', -lldb.SBFileSpec("main.cpp", False)) - -self.check("ref", 13) -self.check("ptr", 13) - -lldbutil.continue_to_breakpoint(process, bkpt) - -self.check("ref", 200) -self.check("ptr", 200) Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp @@ -1,29 +1,28 @@ #include #include -template -void fill(std::bitset &b) { +template void fill(std::bitset &b) { b.set(); b[0] = b[1] = false; for (std::size_t i = 2; i < N; ++i) { -for (std::size_t j = 2*i; j < N; j+=i) +for (std::size_t j = 2 * i; j < N; j += i) b[j] = false; } } -template +template void by_ref_and_ptr(std::bitset &ref, std::bitset *ptr) { -// Check ref and ptr -return; + // Check ref and ptr + return; } int main() { std::bitset<0> empty; std::bitset<13> small; fill(small); - std::bitset<200> large; + std::bitset<70> large; fill(large); by_ref_and_ptr(small, &small); // break here - by_ref_and_ptr(large, &large); + by_ref_and_ptr(large, &large); return 0; } Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py @@ -0,0 +1,93 @@ +""" +Test lldb data formatter subsystem for bitset for libcxx and libstdcpp. +""" + + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +USE_LIBSTDCPP = "USE_LIBSTDCPP" +USE_LIBCPP
[Lldb-commits] [PATCH] D112537: [formatters] Add a libstdcpp formatter for set and unify tests across stdlibs
danilashtefan updated this revision to Diff 382665. danilashtefan edited the summary of this revision. danilashtefan added a comment. Update Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D112537/new/ https://reviews.llvm.org/D112537 Files: lldb/examples/synthetic/gnu_libstdcpp.py lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/main.cpp === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/main.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include -#include - -int g_the_foo = 0; - -int thefoo_rw(int arg = 1) -{ - if (arg < 0) - arg = 0; - if (!arg) - arg = 1; - g_the_foo += arg; - return g_the_foo; -} - -void by_ref_and_ptr(std::set &ref, std::set *ptr) -{ -// Stop here to check by ref and ptr -return; -} - -int main() -{ -std::set ii; -thefoo_rw(1); // Set break point at this line. - - ii.insert(0); - ii.insert(1); - ii.insert(2); - ii.insert(3); - ii.insert(4); - ii.insert(5); -thefoo_rw(1); // Set break point at this line. - - ii.insert(6); - thefoo_rw(1); // Set break point at this line. - -by_ref_and_ptr(ii, &ii); - - ii.clear(); - thefoo_rw(1); // Set break point at this line. - - std::set ss; - thefoo_rw(1); // Set break point at this line. - - ss.insert("a"); - ss.insert("a very long string is right here"); - thefoo_rw(1); // Set break point at this line. - - ss.insert("b"); - ss.insert("c"); - thefoo_rw(1); // Set break point at this line. - - ss.erase("b"); - thefoo_rw(1); // Set break point at this line. - -return 0; -} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp @@ -0,0 +1,55 @@ +#include +#include + +int g_the_foo = 0; + +int thefoo_rw(int arg = 1) { + if (arg < 0) +arg = 0; + if (!arg) +arg = 1; + g_the_foo += arg; + return g_the_foo; +} + +void by_ref_and_ptr(std::set &ref, std::set *ptr) { + // Stop here to check by ref and ptr + return; +} + +int main() { + std::set ii; + thefoo_rw(1); // Set break point at this line. + + ii.insert(0); + ii.insert(1); + ii.insert(2); + ii.insert(3); + ii.insert(4); + ii.insert(5); + thefoo_rw(1); // Set break point at this line. + + ii.insert(6); + thefoo_rw(1); // Set break point at this line. + + by_ref_and_ptr(ii, &ii); + + ii.clear(); + thefoo_rw(1); // Set break point at this line. + + std::set ss; + thefoo_rw(1); // Set break point at this line. + + ss.insert("a"); + ss.insert("a very long string is right here"); + thefoo_rw(1); // Set break point at this line. + + ss.insert("b"); + ss.insert("c"); + thefoo_rw(1); // Set break point at this line. + + ss.erase("b"); + thefoo_rw(1); // Set break point at this line. + + return 0; +} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py @@ -9,6 +9,9 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil +USE_LIBSTDCPP = "USE_LIBSTDCPP" +USE_LIBCPP = "USE_LIBCPP" + class LibcxxSetDataFormatterTestCase(TestBase): @@ -18,34 +21,29 @@ TestBase.setUp(self) self.namespace = 'std' -def getVariableType(self, name): +def findVariable(self, name): var = self.frame().FindVariable(name) self.assertTrue(var.IsValid()) +return var + +def getVariableType(self, name): +var = self.findVariable(name) return var.GetType().GetDisplayTypeName() -def check_ii(self, var_name): -""" This checks the value of the bitset stored in ii at the call to by_ref_and_ptr. -We use this to make sure we get the same values for ii when we look at the object -directly, and when we look at a reference to the object. """ -self.expect( -"frame variable "
[Lldb-commits] [PATCH] D112537: [formatters] Add a libstdcpp formatter for set and unify tests across stdlibs
danilashtefan added inline comments. Comment at: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py:45 "[3] = 3", "[6] = 6"]) wallace wrote: > can you add additional assertions like the one you did in > https://reviews.llvm.org/D112180 that uses ValueCheck? I have made check method more generic and less verbose. Before it was specifically checking the "ii" variable, that was a set of size 7. With value check approach we can now test set and others. I guess, that I can delete all of the ``` self.expect() ``` and simply call check method with the expected size. Please, let me know if I should do it or leave it as it is. Thanks Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D112537/new/ https://reviews.llvm.org/D112537 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D112537: [formatters] Add a libstdcpp formatter for set and unify tests across stdlibs
danilashtefan updated this revision to Diff 382668. danilashtefan added a comment. Small formatting Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D112537/new/ https://reviews.llvm.org/D112537 Files: lldb/examples/synthetic/gnu_libstdcpp.py lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/main.cpp === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/main.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include -#include - -int g_the_foo = 0; - -int thefoo_rw(int arg = 1) -{ - if (arg < 0) - arg = 0; - if (!arg) - arg = 1; - g_the_foo += arg; - return g_the_foo; -} - -void by_ref_and_ptr(std::set &ref, std::set *ptr) -{ -// Stop here to check by ref and ptr -return; -} - -int main() -{ -std::set ii; -thefoo_rw(1); // Set break point at this line. - - ii.insert(0); - ii.insert(1); - ii.insert(2); - ii.insert(3); - ii.insert(4); - ii.insert(5); -thefoo_rw(1); // Set break point at this line. - - ii.insert(6); - thefoo_rw(1); // Set break point at this line. - -by_ref_and_ptr(ii, &ii); - - ii.clear(); - thefoo_rw(1); // Set break point at this line. - - std::set ss; - thefoo_rw(1); // Set break point at this line. - - ss.insert("a"); - ss.insert("a very long string is right here"); - thefoo_rw(1); // Set break point at this line. - - ss.insert("b"); - ss.insert("c"); - thefoo_rw(1); // Set break point at this line. - - ss.erase("b"); - thefoo_rw(1); // Set break point at this line. - -return 0; -} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp @@ -0,0 +1,55 @@ +#include +#include + +int g_the_foo = 0; + +int thefoo_rw(int arg = 1) { + if (arg < 0) +arg = 0; + if (!arg) +arg = 1; + g_the_foo += arg; + return g_the_foo; +} + +void by_ref_and_ptr(std::set &ref, std::set *ptr) { + // Stop here to check by ref and ptr + return; +} + +int main() { + std::set ii; + thefoo_rw(1); // Set break point at this line. + + ii.insert(0); + ii.insert(1); + ii.insert(2); + ii.insert(3); + ii.insert(4); + ii.insert(5); + thefoo_rw(1); // Set break point at this line. + + ii.insert(6); + thefoo_rw(1); // Set break point at this line. + + by_ref_and_ptr(ii, &ii); + + ii.clear(); + thefoo_rw(1); // Set break point at this line. + + std::set ss; + thefoo_rw(1); // Set break point at this line. + + ss.insert("a"); + ss.insert("a very long string is right here"); + thefoo_rw(1); // Set break point at this line. + + ss.insert("b"); + ss.insert("c"); + thefoo_rw(1); // Set break point at this line. + + ss.erase("b"); + thefoo_rw(1); // Set break point at this line. + + return 0; +} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py @@ -9,6 +9,8 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil +USE_LIBSTDCPP = "USE_LIBSTDCPP" +USE_LIBCPP = "USE_LIBCPP" class LibcxxSetDataFormatterTestCase(TestBase): @@ -18,34 +20,29 @@ TestBase.setUp(self) self.namespace = 'std' -def getVariableType(self, name): +def findVariable(self, name): var = self.frame().FindVariable(name) self.assertTrue(var.IsValid()) +return var + +def getVariableType(self, name): +var = self.findVariable(name) return var.GetType().GetDisplayTypeName() -def check_ii(self, var_name): -""" This checks the value of the bitset stored in ii at the call to by_ref_and_ptr. -We use this to make sure we get the same values for ii when we look at the object -directly, and when we look at a reference to the object. """ -self.expect( -"frame variable " + var_name, -substrs=["size=7",
[Lldb-commits] [PATCH] D112537: [formatters] Add a libstdcpp formatter for set and unify tests across stdlibs
danilashtefan updated this revision to Diff 382729. danilashtefan added a comment. Refactoring Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D112537/new/ https://reviews.llvm.org/D112537 Files: lldb/examples/synthetic/gnu_libstdcpp.py lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/main.cpp === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/main.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include -#include - -int g_the_foo = 0; - -int thefoo_rw(int arg = 1) -{ - if (arg < 0) - arg = 0; - if (!arg) - arg = 1; - g_the_foo += arg; - return g_the_foo; -} - -void by_ref_and_ptr(std::set &ref, std::set *ptr) -{ -// Stop here to check by ref and ptr -return; -} - -int main() -{ -std::set ii; -thefoo_rw(1); // Set break point at this line. - - ii.insert(0); - ii.insert(1); - ii.insert(2); - ii.insert(3); - ii.insert(4); - ii.insert(5); -thefoo_rw(1); // Set break point at this line. - - ii.insert(6); - thefoo_rw(1); // Set break point at this line. - -by_ref_and_ptr(ii, &ii); - - ii.clear(); - thefoo_rw(1); // Set break point at this line. - - std::set ss; - thefoo_rw(1); // Set break point at this line. - - ss.insert("a"); - ss.insert("a very long string is right here"); - thefoo_rw(1); // Set break point at this line. - - ss.insert("b"); - ss.insert("c"); - thefoo_rw(1); // Set break point at this line. - - ss.erase("b"); - thefoo_rw(1); // Set break point at this line. - -return 0; -} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp @@ -0,0 +1,55 @@ +#include +#include + +int g_the_foo = 0; + +int thefoo_rw(int arg = 1) { + if (arg < 0) +arg = 0; + if (!arg) +arg = 1; + g_the_foo += arg; + return g_the_foo; +} + +void by_ref_and_ptr(std::set &ref, std::set *ptr) { + // Stop here to check by ref and ptr + return; +} + +int main() { + std::set ii; + thefoo_rw(1); // Set break point at this line. + + ii.insert(0); + ii.insert(1); + ii.insert(2); + ii.insert(3); + ii.insert(4); + ii.insert(5); + thefoo_rw(1); // Set break point at this line. + + ii.insert(6); + thefoo_rw(1); // Set break point at this line. + + by_ref_and_ptr(ii, &ii); + + ii.clear(); + thefoo_rw(1); // Set break point at this line. + + std::set ss; + thefoo_rw(1); // Set break point at this line. + + ss.insert("a"); + ss.insert("a very long string is right here"); + thefoo_rw(1); // Set break point at this line. + + ss.insert("b"); + ss.insert("c"); + thefoo_rw(1); // Set break point at this line. + + ss.erase("b"); + thefoo_rw(1); // Set break point at this line. + + return 0; +} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py @@ -9,6 +9,8 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil +USE_LIBSTDCPP = "USE_LIBSTDCPP" +USE_LIBCPP = "USE_LIBCPP" class LibcxxSetDataFormatterTestCase(TestBase): @@ -18,34 +20,29 @@ TestBase.setUp(self) self.namespace = 'std' -def getVariableType(self, name): +def findVariable(self, name): var = self.frame().FindVariable(name) self.assertTrue(var.IsValid()) +return var + +def getVariableType(self, name): +var = self.findVariable(name) return var.GetType().GetDisplayTypeName() -def check_ii(self, var_name): -""" This checks the value of the bitset stored in ii at the call to by_ref_and_ptr. -We use this to make sure we get the same values for ii when we look at the object -directly, and when we look at a reference to the object. """ -self.expect( -"frame variable " + var_name, -substrs=["size=7", -
[Lldb-commits] [PATCH] D112537: [formatters] Add a libstdcpp formatter for set and unify tests across stdlibs
danilashtefan updated this revision to Diff 382734. danilashtefan added a comment. Last thing corrected :) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D112537/new/ https://reviews.llvm.org/D112537 Files: lldb/examples/synthetic/gnu_libstdcpp.py lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/main.cpp === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/main.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include -#include - -int g_the_foo = 0; - -int thefoo_rw(int arg = 1) -{ - if (arg < 0) - arg = 0; - if (!arg) - arg = 1; - g_the_foo += arg; - return g_the_foo; -} - -void by_ref_and_ptr(std::set &ref, std::set *ptr) -{ -// Stop here to check by ref and ptr -return; -} - -int main() -{ -std::set ii; -thefoo_rw(1); // Set break point at this line. - - ii.insert(0); - ii.insert(1); - ii.insert(2); - ii.insert(3); - ii.insert(4); - ii.insert(5); -thefoo_rw(1); // Set break point at this line. - - ii.insert(6); - thefoo_rw(1); // Set break point at this line. - -by_ref_and_ptr(ii, &ii); - - ii.clear(); - thefoo_rw(1); // Set break point at this line. - - std::set ss; - thefoo_rw(1); // Set break point at this line. - - ss.insert("a"); - ss.insert("a very long string is right here"); - thefoo_rw(1); // Set break point at this line. - - ss.insert("b"); - ss.insert("c"); - thefoo_rw(1); // Set break point at this line. - - ss.erase("b"); - thefoo_rw(1); // Set break point at this line. - -return 0; -} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp @@ -0,0 +1,55 @@ +#include +#include + +int g_the_foo = 0; + +int thefoo_rw(int arg = 1) { + if (arg < 0) +arg = 0; + if (!arg) +arg = 1; + g_the_foo += arg; + return g_the_foo; +} + +void by_ref_and_ptr(std::set &ref, std::set *ptr) { + // Stop here to check by ref and ptr + return; +} + +int main() { + std::set ii; + thefoo_rw(1); // Set break point at this line. + + ii.insert(0); + ii.insert(1); + ii.insert(2); + ii.insert(3); + ii.insert(4); + ii.insert(5); + thefoo_rw(1); // Set break point at this line. + + ii.insert(6); + thefoo_rw(1); // Set break point at this line. + + by_ref_and_ptr(ii, &ii); + + ii.clear(); + thefoo_rw(1); // Set break point at this line. + + std::set ss; + thefoo_rw(1); // Set break point at this line. + + ss.insert("a"); + ss.insert("a very long string is right here"); + thefoo_rw(1); // Set break point at this line. + + ss.insert("b"); + ss.insert("c"); + thefoo_rw(1); // Set break point at this line. + + ss.erase("b"); + thefoo_rw(1); // Set break point at this line. + + return 0; +} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py @@ -9,6 +9,8 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil +USE_LIBSTDCPP = "USE_LIBSTDCPP" +USE_LIBCPP = "USE_LIBCPP" class LibcxxSetDataFormatterTestCase(TestBase): @@ -18,34 +20,29 @@ TestBase.setUp(self) self.namespace = 'std' -def getVariableType(self, name): +def findVariable(self, name): var = self.frame().FindVariable(name) self.assertTrue(var.IsValid()) +return var + +def getVariableType(self, name): +var = self.findVariable(name) return var.GetType().GetDisplayTypeName() -def check_ii(self, var_name): -""" This checks the value of the bitset stored in ii at the call to by_ref_and_ptr. -We use this to make sure we get the same values for ii when we look at the object -directly, and when we look at a reference to the object. """ -self.expect( -"frame variable " + var_name, -substrs=["s
[Lldb-commits] [PATCH] D112752: [formatters] Add a libstdcpp formatter for multimap and unify tests across stdlibs
danilashtefan created this revision. danilashtefan requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D112752 Files: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/TestDataFormatterGenericMultiMap.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/main.cpp @@ -1,77 +0,0 @@ -#include -#include - -#define intint_map std::multimap -#define strint_map std::multimap -#define intstr_map std::multimap -#define strstr_map std::multimap - -int g_the_foo = 0; - -int thefoo_rw(int arg = 1) -{ - if (arg < 0) - arg = 0; - if (!arg) - arg = 1; - g_the_foo += arg; - return g_the_foo; -} - -int main() -{ -intint_map ii; - -ii.emplace(0,0); // Set break point at this line. -ii.emplace(1,1); - thefoo_rw(1); // Set break point at this line. -ii.emplace(2,0); - ii.emplace(3,1); - thefoo_rw(1); // Set break point at this line. - ii.emplace(4,0); - ii.emplace(5,1); - ii.emplace(6,0); - ii.emplace(7,1); -thefoo_rw(1); // Set break point at this line. -ii.emplace(85,1234567); - -ii.clear(); - -strint_map si; -thefoo_rw(1); // Set break point at this line. - -si.emplace("zero",0); - thefoo_rw(1); // Set break point at this line. - si.emplace("one",1); - si.emplace("two",2); - si.emplace("three",3); - thefoo_rw(1); // Set break point at this line. - si.emplace("four",4); - -si.clear(); -thefoo_rw(1); // Set break point at this line. - -intstr_map is; -thefoo_rw(1); // Set break point at this line. -is.emplace(85,"goofy"); -is.emplace(1,"is"); -is.emplace(2,"smart"); -is.emplace(3,"!!!"); -thefoo_rw(1); // Set break point at this line. - -is.clear(); -thefoo_rw(1); // Set break point at this line. - -strstr_map ss; -thefoo_rw(1); // Set break point at this line. - -ss.emplace("ciao","hello"); -ss.emplace("casa","house"); -ss.emplace("gatto","cat"); -thefoo_rw(1); // Set break point at this line. -ss.emplace("a Mac..","..is always a Mac!"); - -ss.clear(); -thefoo_rw(1); // Set break point at this line. -return 0; -} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/TestDataFormatterGenericMultiMap.py === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/TestDataFormatterGenericMultiMap.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/TestDataFormatterGenericMultiMap.py @@ -10,19 +10,38 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil +USE_LIBSTDCPP = "USE_LIBSTDCPP" +USE_LIBCPP = "USE_LIBCPP" -class LibcxxMultiMapDataFormatterTestCase(TestBase): +class GenericMultiMapDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) def setUp(self): TestBase.setUp(self) self.namespace = 'std' - -@add_test_categories(["libc++"]) -def test_with_run_command(self): + +def findVariable(self, name): +var = self.frame().FindVariable(name) +self.assertTrue(var.IsValid()) +return var + +def getVariableType(self, name): +var = self.findVariable(name) +return var.GetType().GetDisplayTypeName() + +def check(self, var_name, size): +var = self.findVariable(var_name) +self.assertEqual(var.GetNumChildren(), size) +children = [] +for i in range(size): +child = var.GetChildAtIndex(i) +children.append(ValueCheck(value=child.GetValue())) +self.expect_var_path(var_name, type=self.getVariableType(var_name), children=children) + +def do_test_with_run_command(self, stdlib_type): """Test that that file and class static variables display correctly.""" -self.build() +self.build(dictionary={stdlib_type: "1"}) self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) bkpt = self.target().FindBreakpointByID( @@ -65,6 +84,8 @@ '[0] = (first =
[Lldb-commits] [PATCH] D112785: Summary:
danilashtefan created this revision. danilashtefan requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D112785 Files: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/main.cpp === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/main.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include -#include - -int g_the_foo = 0; - -int thefoo_rw(int arg = 1) -{ - if (arg < 0) - arg = 0; - if (!arg) - arg = 1; - g_the_foo += arg; - return g_the_foo; -} - -void by_ref_and_ptr(std::multiset &ref, std::multiset *ptr) -{ -// Stop here to check by ref and ptr -return; -} - -int main() -{ -std::multiset ii; -thefoo_rw(1); // Set break point at this line. - - ii.insert(0); - ii.insert(1); - ii.insert(2); - ii.insert(3); - ii.insert(4); - ii.insert(5); -thefoo_rw(1); // Set break point at this line. - - ii.insert(6); - thefoo_rw(1); // Set break point at this line. - -by_ref_and_ptr(ii, &ii); - - ii.clear(); - thefoo_rw(1); // Set break point at this line. - - std::multiset ss; - thefoo_rw(1); // Set break point at this line. - - ss.insert("a"); - ss.insert("a very long string is right here"); - thefoo_rw(1); // Set break point at this line. - - ss.insert("b"); - ss.insert("c"); - thefoo_rw(1); // Set break point at this line. - - ss.erase("b"); - thefoo_rw(1); // Set break point at this line. - -return 0; -} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py @@ -12,7 +12,7 @@ USE_LIBSTDCPP = "USE_LIBSTDCPP" USE_LIBCPP = "USE_LIBCPP" -class LibcxxSetDataFormatterTestCase(TestBase): +class GenericSetDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/main.cpp @@ -0,0 +1,55 @@ +#include +#include + +int g_the_foo = 0; + +int thefoo_rw(int arg = 1) { + if (arg < 0) +arg = 0; + if (!arg) +arg = 1; + g_the_foo += arg; + return g_the_foo; +} + +void by_ref_and_ptr(std::multiset &ref, std::multiset *ptr) { + // Stop here to check by ref and ptr + return; +} + +int main() { + std::multiset ii; + thefoo_rw(1); // Set break point at this line. + + ii.insert(0); + ii.insert(1); + ii.insert(2); + ii.insert(3); + ii.insert(4); + ii.insert(5); + thefoo_rw(1); // Set break point at this line. + + ii.insert(6); + thefoo_rw(1); // Set break point at this line. + + by_ref_and_ptr(ii, &ii); + + ii.clear(); + thefoo_rw(1); // Set break point at this line. + + std::multiset ss; + thefoo_rw(1); // Set break point at this line. + + ss.insert("a"); + ss.insert("a very long string is right here"); + thefoo_rw(1); // Set break point at this line. + + ss.insert("b"); + ss.insert("c"); + thefoo_rw(1); // Set break point at this line. + + ss.erase("b"); + thefoo_rw(1); // Set break point at this line. + + return 0; +} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py @@ -9,8 +9,10 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil +USE_LIBSTDCPP = "USE_LIBSTDCPP" +USE_LIBCPP = "USE_LIBCPP" -class LibcxxMultiSet
[Lldb-commits] [PATCH] D112752: [formatters] Add a libstdcpp formatter for multimap and unify modify tests across stdlibs
danilashtefan updated this revision to Diff 383587. danilashtefan added a comment. All the above specified parts are changed. Thank you! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D112752/new/ https://reviews.llvm.org/D112752 Files: lldb/examples/synthetic/gnu_libstdcpp.py lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/TestDataFormatterGenericMultiMap.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/main.cpp @@ -1,77 +0,0 @@ -#include -#include - -#define intint_map std::multimap -#define strint_map std::multimap -#define intstr_map std::multimap -#define strstr_map std::multimap - -int g_the_foo = 0; - -int thefoo_rw(int arg = 1) -{ - if (arg < 0) - arg = 0; - if (!arg) - arg = 1; - g_the_foo += arg; - return g_the_foo; -} - -int main() -{ -intint_map ii; - -ii.emplace(0,0); // Set break point at this line. -ii.emplace(1,1); - thefoo_rw(1); // Set break point at this line. -ii.emplace(2,0); - ii.emplace(3,1); - thefoo_rw(1); // Set break point at this line. - ii.emplace(4,0); - ii.emplace(5,1); - ii.emplace(6,0); - ii.emplace(7,1); -thefoo_rw(1); // Set break point at this line. -ii.emplace(85,1234567); - -ii.clear(); - -strint_map si; -thefoo_rw(1); // Set break point at this line. - -si.emplace("zero",0); - thefoo_rw(1); // Set break point at this line. - si.emplace("one",1); - si.emplace("two",2); - si.emplace("three",3); - thefoo_rw(1); // Set break point at this line. - si.emplace("four",4); - -si.clear(); -thefoo_rw(1); // Set break point at this line. - -intstr_map is; -thefoo_rw(1); // Set break point at this line. -is.emplace(85,"goofy"); -is.emplace(1,"is"); -is.emplace(2,"smart"); -is.emplace(3,"!!!"); -thefoo_rw(1); // Set break point at this line. - -is.clear(); -thefoo_rw(1); // Set break point at this line. - -strstr_map ss; -thefoo_rw(1); // Set break point at this line. - -ss.emplace("ciao","hello"); -ss.emplace("casa","house"); -ss.emplace("gatto","cat"); -thefoo_rw(1); // Set break point at this line. -ss.emplace("a Mac..","..is always a Mac!"); - -ss.clear(); -thefoo_rw(1); // Set break point at this line. -return 0; -} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/TestDataFormatterGenericMultiMap.py === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/TestDataFormatterGenericMultiMap.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multimap/TestDataFormatterGenericMultiMap.py @@ -10,19 +10,38 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil +USE_LIBSTDCPP = "USE_LIBSTDCPP" +USE_LIBCPP = "USE_LIBCPP" -class LibcxxMultiMapDataFormatterTestCase(TestBase): +class GenericMultiMapDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) def setUp(self): TestBase.setUp(self) self.namespace = 'std' - -@add_test_categories(["libc++"]) -def test_with_run_command(self): + +def findVariable(self, name): +var = self.frame().FindVariable(name) +self.assertTrue(var.IsValid()) +return var + +def getVariableType(self, name): +var = self.findVariable(name) +return var.GetType().GetDisplayTypeName() + +def check(self, var_name, size): +var = self.findVariable(var_name) +self.assertEqual(var.GetNumChildren(), size) +children = [] +for i in range(size): +child = var.GetChildAtIndex(i) +children.append(ValueCheck(value=child.GetValue())) +self.expect_var_path(var_name, type=self.getVariableType(var_name), children=children) + +def do_test_with_run_command(self, stdlib_type): """Test that that file and class static variables display correctly.""" -self.build() +self.build(dictionary={stdlib_type: "1"}) self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
[Lldb-commits] [PATCH] D112752: [formatters] Add a libstdcpp formatter for multimap and unify modify tests across stdlibs
danilashtefan added a comment. I thought that you misprinted the name and wanted to call the formatter MapLikeSynth provider. Please, correct me if I am wrong and I will change names accordingly Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D112752/new/ https://reviews.llvm.org/D112752 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D112785: [formatters] Add a libstdcpp formatter for multiset and unify tests across stdlibs
danilashtefan updated this revision to Diff 383619. danilashtefan added a comment. rebased Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D112785/new/ https://reviews.llvm.org/D112785 Files: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/main.cpp === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/main.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include -#include - -int g_the_foo = 0; - -int thefoo_rw(int arg = 1) -{ - if (arg < 0) - arg = 0; - if (!arg) - arg = 1; - g_the_foo += arg; - return g_the_foo; -} - -void by_ref_and_ptr(std::multiset &ref, std::multiset *ptr) -{ -// Stop here to check by ref and ptr -return; -} - -int main() -{ -std::multiset ii; -thefoo_rw(1); // Set break point at this line. - - ii.insert(0); - ii.insert(1); - ii.insert(2); - ii.insert(3); - ii.insert(4); - ii.insert(5); -thefoo_rw(1); // Set break point at this line. - - ii.insert(6); - thefoo_rw(1); // Set break point at this line. - -by_ref_and_ptr(ii, &ii); - - ii.clear(); - thefoo_rw(1); // Set break point at this line. - - std::multiset ss; - thefoo_rw(1); // Set break point at this line. - - ss.insert("a"); - ss.insert("a very long string is right here"); - thefoo_rw(1); // Set break point at this line. - - ss.insert("b"); - ss.insert("c"); - thefoo_rw(1); // Set break point at this line. - - ss.erase("b"); - thefoo_rw(1); // Set break point at this line. - -return 0; -} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py @@ -12,7 +12,7 @@ USE_LIBSTDCPP = "USE_LIBSTDCPP" USE_LIBCPP = "USE_LIBCPP" -class LibcxxSetDataFormatterTestCase(TestBase): +class GenericSetDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/main.cpp @@ -0,0 +1,55 @@ +#include +#include + +int g_the_foo = 0; + +int thefoo_rw(int arg = 1) { + if (arg < 0) +arg = 0; + if (!arg) +arg = 1; + g_the_foo += arg; + return g_the_foo; +} + +void by_ref_and_ptr(std::multiset &ref, std::multiset *ptr) { + // Stop here to check by ref and ptr + return; +} + +int main() { + std::multiset ii; + thefoo_rw(1); // Set break point at this line. + + ii.insert(0); + ii.insert(1); + ii.insert(2); + ii.insert(3); + ii.insert(4); + ii.insert(5); + thefoo_rw(1); // Set break point at this line. + + ii.insert(6); + thefoo_rw(1); // Set break point at this line. + + by_ref_and_ptr(ii, &ii); + + ii.clear(); + thefoo_rw(1); // Set break point at this line. + + std::multiset ss; + thefoo_rw(1); // Set break point at this line. + + ss.insert("a"); + ss.insert("a very long string is right here"); + thefoo_rw(1); // Set break point at this line. + + ss.insert("b"); + ss.insert("c"); + thefoo_rw(1); // Set break point at this line. + + ss.erase("b"); + thefoo_rw(1); // Set break point at this line. + + return 0; +} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py @@ -9,8 +9,10 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil +USE_LIBSTDCPP = "USE_LIBSTDCPP" +USE_LIBCPP = "USE_LIBCPP" -class LibcxxMulti
[Lldb-commits] [PATCH] D112785: [formatters] Add a libstdcpp formatter for multiset and unify tests across stdlibs
danilashtefan updated this revision to Diff 383621. danilashtefan added a comment. refactoring Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D112785/new/ https://reviews.llvm.org/D112785 Files: lldb/examples/synthetic/gnu_libstdcpp.py lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/main.cpp === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/main.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include -#include - -int g_the_foo = 0; - -int thefoo_rw(int arg = 1) -{ - if (arg < 0) - arg = 0; - if (!arg) - arg = 1; - g_the_foo += arg; - return g_the_foo; -} - -void by_ref_and_ptr(std::multiset &ref, std::multiset *ptr) -{ -// Stop here to check by ref and ptr -return; -} - -int main() -{ -std::multiset ii; -thefoo_rw(1); // Set break point at this line. - - ii.insert(0); - ii.insert(1); - ii.insert(2); - ii.insert(3); - ii.insert(4); - ii.insert(5); -thefoo_rw(1); // Set break point at this line. - - ii.insert(6); - thefoo_rw(1); // Set break point at this line. - -by_ref_and_ptr(ii, &ii); - - ii.clear(); - thefoo_rw(1); // Set break point at this line. - - std::multiset ss; - thefoo_rw(1); // Set break point at this line. - - ss.insert("a"); - ss.insert("a very long string is right here"); - thefoo_rw(1); // Set break point at this line. - - ss.insert("b"); - ss.insert("c"); - thefoo_rw(1); // Set break point at this line. - - ss.erase("b"); - thefoo_rw(1); // Set break point at this line. - -return 0; -} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py @@ -12,7 +12,7 @@ USE_LIBSTDCPP = "USE_LIBSTDCPP" USE_LIBCPP = "USE_LIBCPP" -class LibcxxSetDataFormatterTestCase(TestBase): +class GenericSetDataFormatterTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/main.cpp @@ -0,0 +1,55 @@ +#include +#include + +int g_the_foo = 0; + +int thefoo_rw(int arg = 1) { + if (arg < 0) +arg = 0; + if (!arg) +arg = 1; + g_the_foo += arg; + return g_the_foo; +} + +void by_ref_and_ptr(std::multiset &ref, std::multiset *ptr) { + // Stop here to check by ref and ptr + return; +} + +int main() { + std::multiset ii; + thefoo_rw(1); // Set break point at this line. + + ii.insert(0); + ii.insert(1); + ii.insert(2); + ii.insert(3); + ii.insert(4); + ii.insert(5); + thefoo_rw(1); // Set break point at this line. + + ii.insert(6); + thefoo_rw(1); // Set break point at this line. + + by_ref_and_ptr(ii, &ii); + + ii.clear(); + thefoo_rw(1); // Set break point at this line. + + std::multiset ss; + thefoo_rw(1); // Set break point at this line. + + ss.insert("a"); + ss.insert("a very long string is right here"); + thefoo_rw(1); // Set break point at this line. + + ss.insert("b"); + ss.insert("c"); + thefoo_rw(1); // Set break point at this line. + + ss.erase("b"); + thefoo_rw(1); // Set break point at this line. + + return 0; +} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/multiset/TestDataFormatterGenericMultiSet.py @@ -9,8 +9,10 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil +USE_LIBSTDCPP = "USE_LIBSTDCPP"
[Lldb-commits] [PATCH] D113362: Summary:
danilashtefan created this revision. danilashtefan requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D113362 Files: lldb/examples/synthetic/gnu_libstdcpp.py lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/TestDataFormatterStdForwardList.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/main.cpp @@ -0,0 +1,7 @@ +#include + +int main() { + std::forward_list empty{}, one_elt{47}, + five_elts{1, 22, 333, , 5}; + return 0; // break here +} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/TestDataFormatterStdForwardList.py === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/TestDataFormatterStdForwardList.py @@ -0,0 +1,51 @@ +""" +Test lldb data formatter subsystem. +""" + + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestDataFormatterLibcxxForwardList(TestBase): + +mydir = TestBase.compute_mydir(__file__) + +def setUp(self): +TestBase.setUp(self) +self.line = line_number('main.cpp', '// break here') +self.namespace = 'std' + +@add_test_categories(["libstdcxx"]) +def test(self): +"""Test that std::forward_list is displayed correctly""" +self.build() +lldbutil.run_to_source_breakpoint(self, '// break here', +lldb.SBFileSpec("main.cpp", False)) + +forward_list = self.namespace + '::forward_list' +self.expect("frame variable empty", +substrs=[forward_list, + 'size=0', + '{}']) + +self.expect("frame variable one_elt", +substrs=[forward_list, + 'size=1', + '{', + '[0] = 47', + '}']) + +self.expect("frame variable five_elts", +substrs=[forward_list, + 'size=5', + '{', + '[0] = 1', + '[1] = 22', + '[2] = 333', + '[3] = ', + '[4] = 5', + '}']) Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/Makefile === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/Makefile @@ -0,0 +1,4 @@ +CXX_SOURCES := main.cpp + +USE_LIBSTDCPP := 1 +include Makefile.rules Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp === --- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -923,6 +923,11 @@ SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_synth_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdListSynthProvider"))); + cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add( + RegularExpression("^std::(__cxx11::)?forward_list<.+>(( )?&)?$"), + SyntheticChildrenSP(new ScriptedSyntheticChildren( + stl_synth_flags, + "lldb.formatters.cpp.gnu_libstdcpp.StdForwardListSynthProvider"))); stl_summary_flags.SetDontShowChildren(false); stl_summary_flags.SetSkipPointers(false); cpp_category_sp->GetRegexTypeSummariesContainer()->Add( @@ -953,6 +958,10 @@ RegularExpression("^std::(__cxx11::)?list<.+>(( )?&)?$"), TypeSummaryImplSP( new StringSummaryFormat(stl_summary_flags, "size=${svar%#}"))); + cpp_category_sp->GetRegexTypeSummariesContainer()->Add( + RegularExpression("^std::(__cxx11::)?forward_list<.+>(( )?&)?$"), + TypeSummaryImplSP( + new StringSummaryFormat(stl_summary_flags, "size=${svar%#}"))); AddCXXSynthetic( cpp_category_sp, Index: lldb/examples/synthetic/gnu_libstdcpp.py === --- lldb/examples/synthetic/gnu_libstdcpp.py +++ lldb/examples/synthetic/gnu_libstdcpp.py @@ -2,15 +2
[Lldb-commits] [PATCH] D113362: [formatters] Add a libstdcpp formatter for forward_list and refactor list formatter
danilashtefan added a comment. Hi Walter:) Please, could you advise what can I change/do more? As a next step, I will unify the tests across the libcxx and libstdcpp formatters. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D113362/new/ https://reviews.llvm.org/D113362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D113362: [formatters] Add a libstdcpp formatter for forward_list and refactor list formatter
danilashtefan updated this revision to Diff 385526. danilashtefan marked 8 inline comments as done. danilashtefan added a comment. All of the requested changes are done. Please, let me know if any other corrections are needed Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D113362/new/ https://reviews.llvm.org/D113362 Files: lldb/examples/synthetic/gnu_libstdcpp.py lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/TestDataFormatterStdForwardList.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/main.cpp @@ -0,0 +1,7 @@ +#include + +int main() { + std::forward_list empty{}, one_elt{47}, + five_elts{1, 22, 333, , 5}; + return 0; // break here +} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/TestDataFormatterStdForwardList.py === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/TestDataFormatterStdForwardList.py @@ -0,0 +1,51 @@ +""" +Test lldb data formatter subsystem. +""" + + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestDataFormatterLibcxxForwardList(TestBase): + +mydir = TestBase.compute_mydir(__file__) + +def setUp(self): +TestBase.setUp(self) +self.line = line_number('main.cpp', '// break here') +self.namespace = 'std' + +@add_test_categories(["libstdcxx"]) +def test(self): +"""Test that std::forward_list is displayed correctly""" +self.build() +lldbutil.run_to_source_breakpoint(self, '// break here', +lldb.SBFileSpec("main.cpp", False)) + +forward_list = self.namespace + '::forward_list' +self.expect("frame variable empty", +substrs=[forward_list, + 'size=0', + '{}']) + +self.expect("frame variable one_elt", +substrs=[forward_list, + 'size=1', + '{', + '[0] = 47', + '}']) + +self.expect("frame variable five_elts", +substrs=[forward_list, + 'size=5', + '{', + '[0] = 1', + '[1] = 22', + '[2] = 333', + '[3] = ', + '[4] = 5', + '}']) Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/Makefile === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/Makefile @@ -0,0 +1,4 @@ +CXX_SOURCES := main.cpp + +USE_LIBSTDCPP := 1 +include Makefile.rules Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp === --- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -923,6 +923,11 @@ SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_synth_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdListSynthProvider"))); + cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add( + RegularExpression("^std::(__cxx11::)?forward_list<.+>(( )?&)?$"), + SyntheticChildrenSP(new ScriptedSyntheticChildren( + stl_synth_flags, + "lldb.formatters.cpp.gnu_libstdcpp.StdForwardListSynthProvider"))); stl_summary_flags.SetDontShowChildren(false); stl_summary_flags.SetSkipPointers(false); cpp_category_sp->GetRegexTypeSummariesContainer()->Add( @@ -953,6 +958,10 @@ RegularExpression("^std::(__cxx11::)?list<.+>(( )?&)?$"), TypeSummaryImplSP( new StringSummaryFormat(stl_summary_flags, "size=${svar%#}"))); + cpp_category_sp->GetRegexTypeSummariesContainer()->Add( + RegularExpression("^std::(__cxx11::)?forward_list<.+>(( )?&)?$"), + TypeSummaryImplSP( + new StringSummaryFormat(stl_summary_flags, "size=${svar%#}"))); AddCXXSynthetic( cpp_category_sp, Index: lldb/examples/synthetic/gnu_libstdcpp.py ==
[Lldb-commits] [PATCH] D113362: [formatters] Add a libstdcpp formatter for forward_list and refactor list formatter
danilashtefan updated this revision to Diff 385744. danilashtefan marked 10 inline comments as done. danilashtefan added a comment. All the requested changes are done :) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D113362/new/ https://reviews.llvm.org/D113362 Files: lldb/examples/synthetic/gnu_libstdcpp.py lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/TestDataFormatterStdForwardList.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/main.cpp @@ -0,0 +1,7 @@ +#include + +int main() { + std::forward_list empty{}, one_elt{47}, + five_elts{1, 22, 333, , 5}; + return 0; // break here +} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/TestDataFormatterStdForwardList.py === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/TestDataFormatterStdForwardList.py @@ -0,0 +1,51 @@ +""" +Test lldb data formatter subsystem. +""" + + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestDataFormatterLibcxxForwardList(TestBase): + +mydir = TestBase.compute_mydir(__file__) + +def setUp(self): +TestBase.setUp(self) +self.line = line_number('main.cpp', '// break here') +self.namespace = 'std' + +@add_test_categories(["libstdcxx"]) +def test(self): +"""Test that std::forward_list is displayed correctly""" +self.build() +lldbutil.run_to_source_breakpoint(self, '// break here', +lldb.SBFileSpec("main.cpp", False)) + +forward_list = self.namespace + '::forward_list' +self.expect("frame variable empty", +substrs=[forward_list, + 'size=0', + '{}']) + +self.expect("frame variable one_elt", +substrs=[forward_list, + 'size=1', + '{', + '[0] = 47', + '}']) + +self.expect("frame variable five_elts", +substrs=[forward_list, + 'size=5', + '{', + '[0] = 1', + '[1] = 22', + '[2] = 333', + '[3] = ', + '[4] = 5', + '}']) Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/Makefile === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/Makefile @@ -0,0 +1,4 @@ +CXX_SOURCES := main.cpp + +USE_LIBSTDCPP := 1 +include Makefile.rules Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp === --- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -923,6 +923,11 @@ SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_synth_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdListSynthProvider"))); + cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add( + RegularExpression("^std::(__cxx11::)?forward_list<.+>(( )?&)?$"), + SyntheticChildrenSP(new ScriptedSyntheticChildren( + stl_synth_flags, + "lldb.formatters.cpp.gnu_libstdcpp.StdForwardListSynthProvider"))); stl_summary_flags.SetDontShowChildren(false); stl_summary_flags.SetSkipPointers(false); cpp_category_sp->GetRegexTypeSummariesContainer()->Add( @@ -953,6 +958,10 @@ RegularExpression("^std::(__cxx11::)?list<.+>(( )?&)?$"), TypeSummaryImplSP( new StringSummaryFormat(stl_summary_flags, "size=${svar%#}"))); + cpp_category_sp->GetRegexTypeSummariesContainer()->Add( + RegularExpression("^std::(__cxx11::)?forward_list<.+>(( )?&)?$"), + TypeSummaryImplSP( + new StringSummaryFormat(stl_summary_flags, "size=${svar%#}"))); AddCXXSynthetic( cpp_category_sp, Index: lldb/examples/synthetic/gnu_libstdcpp.py === --- lldb/examples/s
[Lldb-commits] [PATCH] D113362: [formatters] Add a libstdcpp formatter for forward_list and refactor list formatter
danilashtefan added inline comments. Comment at: lldb/examples/synthetic/gnu_libstdcpp.py:92 +return 1 +size = self.node_value_pointer_offset current = self.next wallace wrote: > let's better initialize this with a simpler value Initial size does also depend on the has_prev value, so I decided to initialize it is this simple way Comment at: lldb/examples/synthetic/gnu_libstdcpp.py:95 current = current.GetChildMemberWithName('_M_next') -return (size - 1) +return (size - size_correction) except: wallace wrote: > what is this? try to come up with a better name with documentation to make > this easier to understand Size to return also depends on the has_prev. I have simplified the previously introduced if case Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D113362/new/ https://reviews.llvm.org/D113362 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D113362: [formatters] Add a libstdcpp formatter for forward_list and refactor list formatter
danilashtefan updated this revision to Diff 385904. danilashtefan added a comment. Right size is returned and tests are unified! :) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D113362/new/ https://reviews.llvm.org/D113362 Files: lldb/examples/synthetic/gnu_libstdcpp.py lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/TestDataFormatterGenericForwardList.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/forward_list/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/forward_list/TestDataFormatterLibcxxForwardList.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/forward_list/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/forward_list/main.cpp === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/forward_list/main.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include - -int main() -{ - std::forward_list empty{}, one_elt{47}, five_elts{1,22,333,,5}; - return 0; // break here -} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/main.cpp @@ -0,0 +1,7 @@ +#include + +int main() { + std::forward_list empty{}, one_elt{47}, + five_elts{1, 22, 333, , 5}; + return 0; // break here +} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/TestDataFormatterGenericForwardList.py === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/TestDataFormatterGenericForwardList.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/TestDataFormatterGenericForwardList.py @@ -9,8 +9,10 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil +USE_LIBSTDCPP = "USE_LIBSTDCPP" +USE_LIBCPP = "USE_LIBCPP" -class TestDataFormatterLibcxxForwardList(TestBase): +class TestDataFormatterGenericForwardList(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -19,10 +21,10 @@ self.line = line_number('main.cpp', '// break here') self.namespace = 'std' -@add_test_categories(["libc++"]) -def test(self): + +def do_test(self, stdlib_type): """Test that std::forward_list is displayed correctly""" -self.build() +self.build(dictionary={stdlib_type: "1"}) lldbutil.run_to_source_breakpoint(self, '// break here', lldb.SBFileSpec("main.cpp", False)) @@ -49,3 +51,12 @@ '[3] = ', '[4] = 5', '}']) + +@add_test_categories(["libstdcxx"]) +def test_libstdcpp(self): +self.do_test(USE_LIBSTDCPP) + +@add_test_categories(["libc++"]) +def test_libcpp(self): + self.do_test(USE_LIBCPP) + Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/Makefile === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/Makefile +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/Makefile @@ -1,4 +1,3 @@ CXX_SOURCES := main.cpp -USE_LIBCPP := 1 include Makefile.rules Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp === --- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -923,6 +923,11 @@ SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_synth_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdListSynthProvider"))); + cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add( + RegularExpression("^std::(__cxx11::)?forward_list<.+>(( )?&)?$"), + SyntheticChildrenSP(new ScriptedSyntheticChildren( + stl_synth_flags, + "lldb.formatters.cpp.gnu_libstdcpp.StdForwardListSynthProvider"))); stl_summary_flags.SetDontShowChildren(false); stl_summary_flags.SetSkipPointers(false); cpp_category_sp->GetRegexTypeSummariesContainer()->Add( @@ -953,6 +958,10 @@ RegularExpression("^std::(__cxx11::)?list<.+>(( )?&)?$"), TypeSummaryImplSP( new StringSummaryFormat(s
[Lldb-commits] [PATCH] D113760: next
danilashtefan created this revision. danilashtefan requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D113760 Files: lldb/examples/synthetic/gnu_libstdcpp.py lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp === --- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -918,6 +918,11 @@ SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); + cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add( + RegularExpression("^std::unordered_(multi)?(map|set)<.+> >$"), + SyntheticChildrenSP(new ScriptedSyntheticChildren( + stl_deref_flags, + "lldb.formatters.cpp.gnu_libstdcpp.StdUnorderedMapSynthProvider"))); cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add( RegularExpression("^std::(__cxx11::)?list<.+>(( )?&)?$"), SyntheticChildrenSP(new ScriptedSyntheticChildren( @@ -949,6 +954,10 @@ RegularExpression("^std::multiset<.+> >(( )?&)?$"), TypeSummaryImplSP( new StringSummaryFormat(stl_summary_flags, "size=${svar%#}"))); + cpp_category_sp->GetRegexTypeSummariesContainer()->Add( + RegularExpression("^std::unordered_(multi)?(map|set)<.+> >$"), + TypeSummaryImplSP( + new StringSummaryFormat(stl_summary_flags, "size=${svar%#}"))); cpp_category_sp->GetRegexTypeSummariesContainer()->Add( RegularExpression("^std::(__cxx11::)?list<.+>(( )?&)?$"), TypeSummaryImplSP( Index: lldb/examples/synthetic/gnu_libstdcpp.py === --- lldb/examples/synthetic/gnu_libstdcpp.py +++ lldb/examples/synthetic/gnu_libstdcpp.py @@ -7,6 +7,94 @@ # as it ships with Mac OS X 10.6.8 thru 10.8.0 # You are encouraged to look at the STL implementation for your platform # before relying on these formatters to do the right thing for your setup +class StdUnorderedMapSynthProvider: +def __init__(self, valobj, dict): +self.valobj = valobj +self.count = None + +def extract_type(self): +logger = lldb.formatters.Logger.Logger() +list_type = self.valobj.GetType().GetUnqualifiedType() +if list_type.IsReferenceType(): +list_type = list_type.GetDereferencedType() +if list_type.GetNumberOfTemplateArguments() > 0: +data_type = list_type.GetTemplateArgumentType(0) +else: +data_type = None +return data_type + +def update(self): +logger = lldb.formatters.Logger.Logger() +# preemptively setting this to None - we might end up changing our mind +# later +self.count = None +try: +self.head = self.valobj.GetChildMemberWithName('_M_h') +self.before_begin = self.head.GetChildMemberWithName('_M_before_begin') +self.next = self.before_begin.GetChildMemberWithName('_M_nxt') +self.data_type = self.extract_type() +self.skip_size = self.head.GetType().GetByteSize() +logger >> "Data type is this: " + str(self.data_type) +self.data_size = self.data_type.GetByteSize() +except: +pass +return False + +def get_child_index(self, name): +logger = lldb.formatters.Logger.Logger() +try: +return int(name.lstrip('[').rstrip(']')) +except: +return -1 + +def get_child_key(self, index): +try: +logger = lldb.formatters.Logger.Logger() +offset = self.count - index - 1 +current = self.next +while offset > 0: +current = current.GetChildMemberWithName('_M_nxt') +offset = offset - 1 +return current.CreateChildAtOffset('[' + str(index) + ']', self.next.GetType().GetByteSize(), self.data_type) +except: +logger >> "Error in get_child_key" +return None + +def get_child_at_index(self, index): +logger = lldb.formatters.Logger.Logger() +logger >> "Being asked to fetch child[" + str(index) + "]" +if index < 0: +return None +if index >= self.num_children(): +return None +try: +offset = self.count - index - 1 +current = self.next +while offset > 0: +current = current.GetChildMemberWithName('_M_nxt') +offset = offset - 1 +key = self.get_child_key(index) +return current.CreateChildAtOffset('[' + str(key.GetValue()) + ']', self.next.GetType().GetByteSize() + 9, self.data_type) +
[Lldb-commits] [PATCH] D113760: [formatters] Draft diff for unordered_map libstdcpp formatter
danilashtefan updated this revision to Diff 386824. danilashtefan added a comment. Small cosmetic change Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D113760/new/ https://reviews.llvm.org/D113760 Files: lldb/examples/synthetic/gnu_libstdcpp.py lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp === --- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -918,6 +918,11 @@ SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); + cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add( + RegularExpression("^std::unordered_(multi)?(map|set)<.+> >$"), + SyntheticChildrenSP(new ScriptedSyntheticChildren( + stl_deref_flags, + "lldb.formatters.cpp.gnu_libstdcpp.StdUnorderedMapSynthProvider"))); cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add( RegularExpression("^std::(__cxx11::)?list<.+>(( )?&)?$"), SyntheticChildrenSP(new ScriptedSyntheticChildren( @@ -949,6 +954,10 @@ RegularExpression("^std::multiset<.+> >(( )?&)?$"), TypeSummaryImplSP( new StringSummaryFormat(stl_summary_flags, "size=${svar%#}"))); + cpp_category_sp->GetRegexTypeSummariesContainer()->Add( + RegularExpression("^std::unordered_(multi)?(map|set)<.+> >$"), + TypeSummaryImplSP( + new StringSummaryFormat(stl_summary_flags, "size=${svar%#}"))); cpp_category_sp->GetRegexTypeSummariesContainer()->Add( RegularExpression("^std::(__cxx11::)?list<.+>(( )?&)?$"), TypeSummaryImplSP( Index: lldb/examples/synthetic/gnu_libstdcpp.py === --- lldb/examples/synthetic/gnu_libstdcpp.py +++ lldb/examples/synthetic/gnu_libstdcpp.py @@ -7,6 +7,94 @@ # as it ships with Mac OS X 10.6.8 thru 10.8.0 # You are encouraged to look at the STL implementation for your platform # before relying on these formatters to do the right thing for your setup +class StdUnorderedMapSynthProvider: +def __init__(self, valobj, dict): +self.valobj = valobj +self.count = None + +def extract_type(self): +logger = lldb.formatters.Logger.Logger() +list_type = self.valobj.GetType().GetUnqualifiedType() +if list_type.IsReferenceType(): +list_type = list_type.GetDereferencedType() +if list_type.GetNumberOfTemplateArguments() > 0: +data_type = list_type.GetTemplateArgumentType(0) +else: +data_type = None +return data_type + +def update(self): +logger = lldb.formatters.Logger.Logger() +# preemptively setting this to None - we might end up changing our mind +# later +self.count = None +try: +self.head = self.valobj.GetChildMemberWithName('_M_h') +self.before_begin = self.head.GetChildMemberWithName('_M_before_begin') +self.next = self.before_begin.GetChildMemberWithName('_M_nxt') +self.data_type = self.extract_type() +self.skip_size = self.head.GetType().GetByteSize() +logger >> "Data type is this: " + str(self.data_type) +self.data_size = self.data_type.GetByteSize() +except: +pass +return False + +def get_child_index(self, name): +logger = lldb.formatters.Logger.Logger() +try: +return int(name.lstrip('[').rstrip(']')) +except: +return -1 + +def get_child_key(self, index): +try: +logger = lldb.formatters.Logger.Logger() +offset = self.count - index - 1 +current = self.next +while offset > 0: +current = current.GetChildMemberWithName('_M_nxt') +offset = offset - 1 +return current.CreateChildAtOffset('[' + str(index) + ']', self.next.GetType().GetByteSize(), self.data_type) +except: +logger >> "Error in get_child_key" +return None + +def get_child_at_index(self, index): +logger = lldb.formatters.Logger.Logger() +logger >> "Being asked to fetch child[" + str(index) + "]" +if index < 0: +return None +if index >= self.num_children(): +return None +try: +offset = self.count - index - 1 +current = self.next +while offset > 0: +current = current.GetChildMemberWithName('_M_nxt') +offset = offset - 1 +key = self.get_child_key(index) +return current.CreateChildAtOffset('[' + str(key.GetValue()) + ']', self.next.GetType().GetByteSize() + self.data_si
[Lldb-commits] [PATCH] D113760: [formatters] Draft diff for unordered_map libstdcpp formatter
danilashtefan added a comment. Hi Walter :) This is the Draft PR for the unordered_map/set data formatter. Currently it works well in case both key and values are of the same primitive data types (except string). Unfortunately, the following problems are encountered: 1. When key and value are of different types value is detected wrong (some garbage). I will leave the separate comment with the details 2)Currently I print the unordered_map in the following form [key] = [value]. However, the right from would be: [index] = (first = key, second = value). I am struggling through finding the way to do so 3)Whether key and/or value are of the string type, formatter cannot read the data. Is the string formatter issue. Many thanks for your help in advance Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D113760/new/ https://reviews.llvm.org/D113760 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D113760: [formatters] Draft diff for unordered_map libstdcpp formatter
danilashtefan added inline comments. Comment at: lldb/examples/synthetic/gnu_libstdcpp.py:77 +key = self.get_child_key(index) +return current.CreateChildAtOffset('[' + str(key.GetValue()) + ']', self.next.GetType().GetByteSize() + self.data_size, self.data_type) + I assume that the cause of the first issue (different key value type) is located here. self.next.GetType().GetByteSize() + self.data_size does not work in this case. Key is read, however value - not. It means that we cannot always add self.data_size. I tried to manually figure out on the unordered_map case what can I add instead of self.data_size (which is 1 in this case), but got no success Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D113760/new/ https://reviews.llvm.org/D113760 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D113760: [formatters] Draft diff for unordered_map libstdcpp formatter
danilashtefan updated this revision to Diff 387020. danilashtefan added a comment. All the changes are done and tests pass Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D113760/new/ https://reviews.llvm.org/D113760 Files: lldb/examples/synthetic/gnu_libstdcpp.py lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp @@ -0,0 +1,78 @@ +#include +#include +#include + +using std::string; + +#define intstr_map std::unordered_map +#define intstr_mmap std::unordered_multimap + +#define int_set std::unordered_set +#define str_set std::unordered_set +#define int_mset std::unordered_multiset +#define str_mset std::unordered_multiset + +int g_the_foo = 0; + +int thefoo_rw(int arg = 1) { + if (arg < 0) +arg = 0; + if (!arg) +arg = 1; + g_the_foo += arg; + return g_the_foo; +} + +int main() { + intstr_map map; + map.emplace(1, "hello"); + map.emplace(2, "world"); + map.emplace(3, "this"); + map.emplace(4, "is"); + map.emplace(5, "me"); + thefoo_rw(); // Set break point at this line. + + intstr_mmap mmap; + mmap.emplace(1, "hello"); + mmap.emplace(2, "hello"); + mmap.emplace(2, "world"); + mmap.emplace(3, "this"); + mmap.emplace(3, "this"); + mmap.emplace(3, "this"); + thefoo_rw(); // Set break point at this line. + + int_set iset; + iset.emplace(1); + iset.emplace(2); + iset.emplace(3); + iset.emplace(4); + iset.emplace(5); + thefoo_rw(); // Set break point at this line. + + str_set sset; + sset.emplace("hello"); + sset.emplace("world"); + sset.emplace("this"); + sset.emplace("is"); + sset.emplace("me"); + thefoo_rw(); // Set break point at this line. + + int_mset imset; + imset.emplace(1); + imset.emplace(2); + imset.emplace(2); + imset.emplace(3); + imset.emplace(3); + imset.emplace(3); + thefoo_rw(); // Set break point at this line. + + str_mset smset; + smset.emplace("hello"); + smset.emplace("world"); + smset.emplace("world"); + smset.emplace("is"); + smset.emplace("is"); + thefoo_rw(); // Set break point at this line. + + return 0; +} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py @@ -0,0 +1,78 @@ +""" +Test lldb data formatter subsystem. +""" + + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class GenericUnorderedDataFormatterTestCase(TestBase): + +mydir = TestBase.compute_mydir(__file__) + +def setUp(self): +TestBase.setUp(self) +self.namespace = 'std' + +@add_test_categories(["libstdcxx"]) +def test_with_run_command(self): +self.build() +self.runCmd("file " + self.getBuildArtifact("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']) + +# This is the function to remove the custom formats in order to have a +# clean slate for the next test case. +def cleanup(): +self.runCmd('type format clear', check=False) +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) + +# Execute the cleanup function during test case tear down. +self.addTearDownHook(cleanup) + +ns = self.namespace +self.look_for_content_and_continue( +"map", ['%s::unordered_map' % +ns, 'size=5 {', 'hello', 'world', 'this', 'is', 'me']) + +self.look_for_content_and_continue( +"mmap", ['%s::unordered_multimap' % ns, 'size=6 {', 'first = 3', 'second = "this"', + 'first = 2', 'second = "hello"']) + +self.look_for_c
[Lldb-commits] [PATCH] D113760: [formatters] Add a libstdcpp formatter for for unordered_map, unordered_set, unordered_multimap, unordered_multiset
danilashtefan added a comment. Hi Walter, Thank you for the hints. Everything works now, including the string case. There was a small difficulty with set case, but then I figured out that for set case I need to take not the 5th, but 4th template argument. I will be waiting for your comments. After this I will unify the tests across platforms. Thank you! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D113760/new/ https://reviews.llvm.org/D113760 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D113760: [formatters] Add a libstdcpp formatter for for unordered_map, unordered_set, unordered_multimap, unordered_multiset
danilashtefan updated this revision to Diff 387022. danilashtefan added a comment. Cosmetic change Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D113760/new/ https://reviews.llvm.org/D113760 Files: lldb/examples/synthetic/gnu_libstdcpp.py lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp @@ -0,0 +1,78 @@ +#include +#include +#include + +using std::string; + +#define intstr_map std::unordered_map +#define intstr_mmap std::unordered_multimap + +#define int_set std::unordered_set +#define str_set std::unordered_set +#define int_mset std::unordered_multiset +#define str_mset std::unordered_multiset + +int g_the_foo = 0; + +int thefoo_rw(int arg = 1) { + if (arg < 0) +arg = 0; + if (!arg) +arg = 1; + g_the_foo += arg; + return g_the_foo; +} + +int main() { + intstr_map map; + map.emplace(1, "hello"); + map.emplace(2, "world"); + map.emplace(3, "this"); + map.emplace(4, "is"); + map.emplace(5, "me"); + thefoo_rw(); // Set break point at this line. + + intstr_mmap mmap; + mmap.emplace(1, "hello"); + mmap.emplace(2, "hello"); + mmap.emplace(2, "world"); + mmap.emplace(3, "this"); + mmap.emplace(3, "this"); + mmap.emplace(3, "this"); + thefoo_rw(); // Set break point at this line. + + int_set iset; + iset.emplace(1); + iset.emplace(2); + iset.emplace(3); + iset.emplace(4); + iset.emplace(5); + thefoo_rw(); // Set break point at this line. + + str_set sset; + sset.emplace("hello"); + sset.emplace("world"); + sset.emplace("this"); + sset.emplace("is"); + sset.emplace("me"); + thefoo_rw(); // Set break point at this line. + + int_mset imset; + imset.emplace(1); + imset.emplace(2); + imset.emplace(2); + imset.emplace(3); + imset.emplace(3); + imset.emplace(3); + thefoo_rw(); // Set break point at this line. + + str_mset smset; + smset.emplace("hello"); + smset.emplace("world"); + smset.emplace("world"); + smset.emplace("is"); + smset.emplace("is"); + thefoo_rw(); // Set break point at this line. + + return 0; +} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py @@ -0,0 +1,78 @@ +""" +Test lldb data formatter subsystem. +""" + + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class GenericUnorderedDataFormatterTestCase(TestBase): + +mydir = TestBase.compute_mydir(__file__) + +def setUp(self): +TestBase.setUp(self) +self.namespace = 'std' + +@add_test_categories(["libstdcxx"]) +def test_with_run_command(self): +self.build() +self.runCmd("file " + self.getBuildArtifact("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']) + +# This is the function to remove the custom formats in order to have a +# clean slate for the next test case. +def cleanup(): +self.runCmd('type format clear', check=False) +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) + +# Execute the cleanup function during test case tear down. +self.addTearDownHook(cleanup) + +ns = self.namespace +self.look_for_content_and_continue( +"map", ['%s::unordered_map' % +ns, 'size=5 {', 'hello', 'world', 'this', 'is', 'me']) + +self.look_for_content_and_continue( +"mmap", ['%s::unordered_multimap' % ns, 'size=6 {', 'first = 3', 'second = "this"', + 'first = 2', 'second = "hello"']) + +self.look_for_content_and_continue( +
[Lldb-commits] [PATCH] D113760: [formatters] Add a libstdcpp formatter for for unordered_map, unordered_set, unordered_multimap, unordered_multiset
danilashtefan updated this revision to Diff 387084. danilashtefan added a comment. Some naming corrections Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D113760/new/ https://reviews.llvm.org/D113760 Files: lldb/examples/synthetic/gnu_libstdcpp.py lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp @@ -0,0 +1,78 @@ +#include +#include +#include + +using std::string; + +#define intstr_map std::unordered_map +#define intstr_mmap std::unordered_multimap + +#define int_set std::unordered_set +#define str_set std::unordered_set +#define int_mset std::unordered_multiset +#define str_mset std::unordered_multiset + +int g_the_foo = 0; + +int thefoo_rw(int arg = 1) { + if (arg < 0) +arg = 0; + if (!arg) +arg = 1; + g_the_foo += arg; + return g_the_foo; +} + +int main() { + intstr_map map; + map.emplace(1, "hello"); + map.emplace(2, "world"); + map.emplace(3, "this"); + map.emplace(4, "is"); + map.emplace(5, "me"); + thefoo_rw(); // Set break point at this line. + + intstr_mmap mmap; + mmap.emplace(1, "hello"); + mmap.emplace(2, "hello"); + mmap.emplace(2, "world"); + mmap.emplace(3, "this"); + mmap.emplace(3, "this"); + mmap.emplace(3, "this"); + thefoo_rw(); // Set break point at this line. + + int_set iset; + iset.emplace(1); + iset.emplace(2); + iset.emplace(3); + iset.emplace(4); + iset.emplace(5); + thefoo_rw(); // Set break point at this line. + + str_set sset; + sset.emplace("hello"); + sset.emplace("world"); + sset.emplace("this"); + sset.emplace("is"); + sset.emplace("me"); + thefoo_rw(); // Set break point at this line. + + int_mset imset; + imset.emplace(1); + imset.emplace(2); + imset.emplace(2); + imset.emplace(3); + imset.emplace(3); + imset.emplace(3); + thefoo_rw(); // Set break point at this line. + + str_mset smset; + smset.emplace("hello"); + smset.emplace("world"); + smset.emplace("world"); + smset.emplace("is"); + smset.emplace("is"); + thefoo_rw(); // Set break point at this line. + + return 0; +} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py @@ -0,0 +1,78 @@ +""" +Test lldb data formatter subsystem. +""" + + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class GenericUnorderedDataFormatterTestCase(TestBase): + +mydir = TestBase.compute_mydir(__file__) + +def setUp(self): +TestBase.setUp(self) +self.namespace = 'std' + +@add_test_categories(["libstdcxx"]) +def test_with_run_command(self): +self.build() +self.runCmd("file " + self.getBuildArtifact("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']) + +# This is the function to remove the custom formats in order to have a +# clean slate for the next test case. +def cleanup(): +self.runCmd('type format clear', check=False) +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) + +# Execute the cleanup function during test case tear down. +self.addTearDownHook(cleanup) + +ns = self.namespace +self.look_for_content_and_continue( +"map", ['%s::unordered_map' % +ns, 'size=5 {', 'hello', 'world', 'this', 'is', 'me']) + +self.look_for_content_and_continue( +"mmap", ['%s::unordered_multimap' % ns, 'size=6 {', 'first = 3', 'second = "this"', + 'first = 2', 'second = "hello"']) + +self.look_for_content_and_conti
[Lldb-commits] [PATCH] D114008: Draft PR for the deque, stack, queue lldb data formatters
danilashtefan created this revision. danilashtefan requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D114008 Files: lldb/examples/synthetic/gnu_libstdcpp.py lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp === --- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -918,6 +918,11 @@ SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); + cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add( + RegularExpression("^std::deque<.+>(( )?&)?$"), + SyntheticChildrenSP(new ScriptedSyntheticChildren( + stl_deref_flags, + "lldb.formatters.cpp.gnu_libstdcpp.StdDequeSynthProvider"))); cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add( RegularExpression("^std::(__cxx11::)?list<.+>(( )?&)?$"), SyntheticChildrenSP(new ScriptedSyntheticChildren( @@ -946,6 +951,10 @@ RegularExpression("^std::set<.+> >(( )?&)?$"), TypeSummaryImplSP( new StringSummaryFormat(stl_summary_flags, "size=${svar%#}"))); + cpp_category_sp->GetRegexTypeSummariesContainer()->Add( + RegularExpression("^std::deque<.+>(( )?&)?$"), + TypeSummaryImplSP( + new StringSummaryFormat(stl_summary_flags, "size=${svar%#}"))); cpp_category_sp->GetRegexTypeSummariesContainer()->Add( RegularExpression("^std::multimap<.+> >(( )?&)?$"), TypeSummaryImplSP( Index: lldb/examples/synthetic/gnu_libstdcpp.py === --- lldb/examples/synthetic/gnu_libstdcpp.py +++ lldb/examples/synthetic/gnu_libstdcpp.py @@ -8,6 +8,80 @@ # You are encouraged to look at the STL implementation for your platform # before relying on these formatters to do the right thing for your setup +class StdDequeSynthProvider: +def __init__(self, valobj, dict): +print("Init called") +self.valobj = valobj +self.count = None + +def update(self): +# preemptively setting this to None - we might end up changing our mind +# later +self.count = None +try: +print("Update called") +self.impl = self.valobj.GetChildMemberWithName('_M_impl') +self.start = self.impl.GetChildMemberWithName("_M_start") +self.start_cur = self.start.GetChildMemberWithName('_M_cur') +self.finish = self.impl.GetChildMemberWithName("_M_finish") +self.finish_cur = self.finish.GetChildMemberWithName('_M_cur') +self.data_type = self.valobj.GetType().GetUnqualifiedType().GetTemplateArgumentType(0) +self.data_size = self.data_type.GetByteSize() +except: +pass + +def get_child_index(self, name): +try: +return int(name.lstrip('[').rstrip(']')) +except: +return -1 + +def get_child_at_index(self, index): +print("Get child at index called") +logger = lldb.formatters.Logger.Logger() +logger >> "Being asked to fetch child[" + str(index) + "]" +if index < 0: +return None +if index >= self.num_children(): +return None +try: +offset = index * self.data_size +return self.start_cur.CreateChildAtOffset( '[' + str(index) + ']', offset, self.data_type) +except: +logger >> "Cannot get child" +return None + +def num_children(self): +print("Number of children called") +if self.count is None: +self.count = self.num_children_impl() +return self.count + +def num_children_impl(self): +# logger = lldb.formatters.Logger.Logger() +# try: +# start_val = self.start_cur.GetValueAsUnsigned(0) +# print("Start value is: " + str(start_val)) +# finish_val = self.finish_cur.GetValueAsUnsigned(0) +# print("Finish value is: " + str(finish_val)) +# if start_val == 0 or finish_val == 0: +# print("Start of Finish val's are 0") +# return 0 +# if start_val >= finish_val: +# print("Start is greater than finish") +# return 0 + +# num_children = (finish_val - start_val) +# if (num_children % self.data_size) != 0: +# return 0 +# else: +# num_children = num_children // self.data_size +# return num_children +# except: +# print("Cannot determine the size") +# logger >> "Could not determine the size" +
[Lldb-commits] [PATCH] D114008: Draft PR for the deque, stack, queue lldb data formatters
danilashtefan added inline comments. Comment at: lldb/examples/synthetic/gnu_libstdcpp.py:60 + +def num_children_impl(self): +# logger = lldb.formatters.Logger.Logger() This method does not currently work. I simply tried to calculate the size from start and finish pointers. When it did not, I investigated further and this was my founding: This is when we get the iterator value this comes out: `_Deque_iterator(const _Deque_iterator& __x) noexcept 169 : _M_cur(__x._M_cur), _M_first(__x._M_first), 170 _M_last(__x._M_last), _M_node(__x._M_node) { }` And when it++ is done this is what happens behind: operator++() 189 { 190++_M_cur; 191if (_M_cur == _M_last) 192 { 193_M_set_node(_M_node + 1); 194_M_cur = _M_first; 195 } 196return *this; 197} Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D114008/new/ https://reviews.llvm.org/D114008 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D114008: Draft PR for the deque, stack, queue lldb data formatters
danilashtefan added a comment. When I mocked the num_children to return 4, formatter works for any structure with size <= 4. here is the example: std::deque d; d.push_front(7); d.push_front(5); d.push_front(13); d.push_front(25); (std::deque >) $0 = size=4 { [0] = 25 [1] = 13 [2] = 5 [3] = 7 } Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D114008/new/ https://reviews.llvm.org/D114008 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D113760: [formatters] Add a libstdcpp formatter for for unordered_map, unordered_set, unordered_multimap, unordered_multiset
danilashtefan updated this revision to Diff 388012. danilashtefan marked 9 inline comments as done. danilashtefan added a comment. All the above-mentioned is changed. Thank you! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D113760/new/ https://reviews.llvm.org/D113760 Files: lldb/examples/synthetic/gnu_libstdcpp.py lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/main.cpp === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/main.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include -#include -#include - -using std::string; - -#define intstr_map std::unordered_map -#define intstr_mmap std::unordered_multimap - -#define int_set std::unordered_set -#define str_set std::unordered_set -#define int_mset std::unordered_multiset -#define str_mset std::unordered_multiset - -int g_the_foo = 0; - -int thefoo_rw(int arg = 1) -{ - if (arg < 0) - arg = 0; - if (!arg) - arg = 1; - g_the_foo += arg; - return g_the_foo; -} - -int main() -{ - intstr_map map; - map.emplace(1,"hello"); - map.emplace(2,"world"); - map.emplace(3,"this"); - map.emplace(4,"is"); - map.emplace(5,"me"); - thefoo_rw(); // Set break point at this line. - - intstr_mmap mmap; - mmap.emplace(1,"hello"); - mmap.emplace(2,"hello"); - mmap.emplace(2,"world"); - mmap.emplace(3,"this"); - mmap.emplace(3,"this"); - mmap.emplace(3,"this"); - thefoo_rw(); // Set break point at this line. - - int_set iset; - iset.emplace(1); - iset.emplace(2); - iset.emplace(3); - iset.emplace(4); - iset.emplace(5); - thefoo_rw(); // Set break point at this line. - - str_set sset; - sset.emplace("hello"); - sset.emplace("world"); - sset.emplace("this"); - sset.emplace("is"); - sset.emplace("me"); - thefoo_rw(); // Set break point at this line. - - int_mset imset; - imset.emplace(1); - imset.emplace(2); - imset.emplace(2); - imset.emplace(3); - imset.emplace(3); - imset.emplace(3); - thefoo_rw(); // Set break point at this line. - - str_mset smset; - smset.emplace("hello"); - smset.emplace("world"); - smset.emplace("world"); - smset.emplace("is"); - smset.emplace("is"); - thefoo_rw(); // Set break point at this line. - -return 0; -} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/Makefile === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -CXX_SOURCES := main.cpp - -# Work around "exception specification in declaration does not match previous -# declaration" errors present in older libc++ releases. This error was fixed in -# the 3.8 release. -CFLAGS_EXTRAS := -fno-exceptions - -USE_LIBCPP := 1 -include Makefile.rules Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp @@ -0,0 +1,68 @@ +#include +#include +#include + +int g_the_foo = 0; + +int thefoo_rw(int arg = 1) { + if (arg < 0) +arg = 0; + if (!arg) +arg = 1; + g_the_foo += arg; + return g_the_foo; +} + +int main() { + std::unordered_map map; + map.emplace(1, "hello"); + map.emplace(2, "world"); + map.emplace(3, "this"); + map.emplace(4, "is"); + map.emplace(5, "me"); + thefoo_rw(); // Set break point at this line. + + std::unordered_multimap mmap; + mmap.emplace(1, "hello"); + mmap.emplace(2, "hello"); + mmap.emplace(2, "world"); + mmap.emplace(3, "this"); + mmap.emplace(3, "this"); + mmap.emplace(3, "this"); + thefoo_rw(); // Set break point at this line. + + std::unordered_set iset; + iset.emplace(1); + iset.emplace(2); + iset.emplace(3); + iset.emplace(4); + iset.emplace(5); + thefoo_rw(); // Set break point at this line. + + std::unordered_set sset; + sset.emplace("hello"); + sset.emplace("world"); + sset.emplace("this"); + sset.emplace("is"); + sset.emplace("me"); + thefoo_rw(); // Set break point at this line. + + std::unordered_multiset imset; + imset.emplace(1); + imset.emplace(2); + imset.emplace(2); + i
[Lldb-commits] [PATCH] D113760: [formatters] Add a libstdcpp formatter for for unordered_map, unordered_set, unordered_multimap, unordered_multiset
danilashtefan updated this revision to Diff 388016. danilashtefan added a comment. Done! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D113760/new/ https://reviews.llvm.org/D113760 Files: lldb/examples/synthetic/gnu_libstdcpp.py lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/main.cpp === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/main.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include -#include -#include - -using std::string; - -#define intstr_map std::unordered_map -#define intstr_mmap std::unordered_multimap - -#define int_set std::unordered_set -#define str_set std::unordered_set -#define int_mset std::unordered_multiset -#define str_mset std::unordered_multiset - -int g_the_foo = 0; - -int thefoo_rw(int arg = 1) -{ - if (arg < 0) - arg = 0; - if (!arg) - arg = 1; - g_the_foo += arg; - return g_the_foo; -} - -int main() -{ - intstr_map map; - map.emplace(1,"hello"); - map.emplace(2,"world"); - map.emplace(3,"this"); - map.emplace(4,"is"); - map.emplace(5,"me"); - thefoo_rw(); // Set break point at this line. - - intstr_mmap mmap; - mmap.emplace(1,"hello"); - mmap.emplace(2,"hello"); - mmap.emplace(2,"world"); - mmap.emplace(3,"this"); - mmap.emplace(3,"this"); - mmap.emplace(3,"this"); - thefoo_rw(); // Set break point at this line. - - int_set iset; - iset.emplace(1); - iset.emplace(2); - iset.emplace(3); - iset.emplace(4); - iset.emplace(5); - thefoo_rw(); // Set break point at this line. - - str_set sset; - sset.emplace("hello"); - sset.emplace("world"); - sset.emplace("this"); - sset.emplace("is"); - sset.emplace("me"); - thefoo_rw(); // Set break point at this line. - - int_mset imset; - imset.emplace(1); - imset.emplace(2); - imset.emplace(2); - imset.emplace(3); - imset.emplace(3); - imset.emplace(3); - thefoo_rw(); // Set break point at this line. - - str_mset smset; - smset.emplace("hello"); - smset.emplace("world"); - smset.emplace("world"); - smset.emplace("is"); - smset.emplace("is"); - thefoo_rw(); // Set break point at this line. - -return 0; -} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/Makefile === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -CXX_SOURCES := main.cpp - -# Work around "exception specification in declaration does not match previous -# declaration" errors present in older libc++ releases. This error was fixed in -# the 3.8 release. -CFLAGS_EXTRAS := -fno-exceptions - -USE_LIBCPP := 1 -include Makefile.rules Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp @@ -0,0 +1,68 @@ +#include +#include +#include + +int g_the_foo = 0; + +int thefoo_rw(int arg = 1) { + if (arg < 0) +arg = 0; + if (!arg) +arg = 1; + g_the_foo += arg; + return g_the_foo; +} + +int main() { + std::unordered_map map; + map.emplace(1, "hello"); + map.emplace(2, "world"); + map.emplace(3, "this"); + map.emplace(4, "is"); + map.emplace(5, "me"); + thefoo_rw(); // Set break point at this line. + + std::unordered_multimap mmap; + mmap.emplace(1, "hello"); + mmap.emplace(2, "hello"); + mmap.emplace(2, "world"); + mmap.emplace(3, "this"); + mmap.emplace(3, "this"); + mmap.emplace(3, "this"); + thefoo_rw(); // Set break point at this line. + + std::unordered_set iset; + iset.emplace(1); + iset.emplace(2); + iset.emplace(3); + iset.emplace(4); + iset.emplace(5); + thefoo_rw(); // Set break point at this line. + + std::unordered_set sset; + sset.emplace("hello"); + sset.emplace("world"); + sset.emplace("this"); + sset.emplace("is"); + sset.emplace("me"); + thefoo_rw(); // Set break point at this line. + + std::unordered_multiset imset; + imset.emplace(1); + imset.emplace(2); + imset.emplace(2); + imset.emplace(3); + imset.emplace(3); + imset.emplace(3); + thefoo_rw(); // Set break p
[Lldb-commits] [PATCH] D114266: [formatters] Draft Optional PR
danilashtefan created this revision. danilashtefan requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D114266 Files: lldb/examples/synthetic/gnu_libstdcpp.py lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp === --- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -913,6 +913,11 @@ SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); + cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add( + RegularExpression("^std::optional<.+>(( )?&)?$"), + SyntheticChildrenSP(new ScriptedSyntheticChildren( + stl_synth_flags, + "lldb.formatters.cpp.gnu_libstdcpp.StdOptionalSynthProvider"))); cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add( RegularExpression("^std::multiset<.+> >(( )?&)?$"), SyntheticChildrenSP(new ScriptedSyntheticChildren( Index: lldb/examples/synthetic/gnu_libstdcpp.py === --- lldb/examples/synthetic/gnu_libstdcpp.py +++ lldb/examples/synthetic/gnu_libstdcpp.py @@ -8,6 +8,46 @@ # You are encouraged to look at the STL implementation for your platform # before relying on these formatters to do the right thing for your setup +class StdOptionalSynthProvider: +def __init__(self, valobj, dict): +self.valobj = valobj + +def update(self): +try: +self.payload = self.valobj.GetChildMemberWithName('_M_payload') +self.engaged = self.payload.GetChildMemberWithName('_M_engaged') +self.payload_payload= self.payload.GetChildMemberWithName('_M_payload') +except: +pass +return False + +def has_value(self): +logger = lldb.formatters.Logger.Logger() +try: +return self.engaged.GetValueAsUnsigned(0) == 1 +except: +logger >> "Error determining engaged value" +return False + +def num_children(self): +logger = lldb.formatters.Logger.Logger() +try: +num_children = 1 if self.has_value() else 0 +return num_children +except: +logger >> "Error determining number of children" + +def get_child_index(self, name): +try: +return int(name.lstrip('[').rstrip(']')) +except: +return -1 + +def get_child_at_index(self, index): +self.payload_value = self.payload_payload.GetChildMemberWithName("_M_value").GetValue() +if (self.has_value() == False): +pass +return self.payload_value class AbstractListSynthProvider: def __init__(self, valobj, dict, has_prev): Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp === --- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -913,6 +913,11 @@ SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); + cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add( + RegularExpression("^std::optional<.+>(( )?&)?$"), + SyntheticChildrenSP(new ScriptedSyntheticChildren( + stl_synth_flags, + "lldb.formatters.cpp.gnu_libstdcpp.StdOptionalSynthProvider"))); cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add( RegularExpression("^std::multiset<.+> >(( )?&)?$"), SyntheticChildrenSP(new ScriptedSyntheticChildren( Index: lldb/examples/synthetic/gnu_libstdcpp.py === --- lldb/examples/synthetic/gnu_libstdcpp.py +++ lldb/examples/synthetic/gnu_libstdcpp.py @@ -8,6 +8,46 @@ # You are encouraged to look at the STL implementation for your platform # before relying on these formatters to do the right thing for your setup +class StdOptionalSynthProvider: +def __init__(self, valobj, dict): +self.valobj = valobj + +def update(self): +try: +self.payload = self.valobj.GetChildMemberWithName('_M_payload') +self.engaged = self.payload.GetChildMemberWithName('_M_engaged') +self.payload_payload= self.payload.GetChildMemberWithName('_M_payload') +except: +pass +return False + +def has_value(self): +logger = lldb.formatters.Logger.Logger() +try: +return self.engaged.GetValueAsUnsigned(0) == 1 +except: +logger >> "Error determining engaged value" +
[Lldb-commits] [PATCH] D114008: Draft PR for the deque, stack, queue lldb data formatters
danilashtefan updated this revision to Diff 388745. danilashtefan added a comment. Size determined Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D114008/new/ https://reviews.llvm.org/D114008 Files: lldb/examples/synthetic/gnu_libstdcpp.py lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp === --- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -918,6 +918,11 @@ SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); + cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add( + RegularExpression("^std::deque<.+>(( )?&)?$"), + SyntheticChildrenSP(new ScriptedSyntheticChildren( + stl_deref_flags, + "lldb.formatters.cpp.gnu_libstdcpp.StdDequeSynthProvider"))); cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add( RegularExpression("^std::(__cxx11::)?list<.+>(( )?&)?$"), SyntheticChildrenSP(new ScriptedSyntheticChildren( @@ -946,6 +951,10 @@ RegularExpression("^std::set<.+> >(( )?&)?$"), TypeSummaryImplSP( new StringSummaryFormat(stl_summary_flags, "size=${svar%#}"))); + cpp_category_sp->GetRegexTypeSummariesContainer()->Add( + RegularExpression("^std::deque<.+>(( )?&)?$"), + TypeSummaryImplSP( + new StringSummaryFormat(stl_summary_flags, "size=${svar%#}"))); cpp_category_sp->GetRegexTypeSummariesContainer()->Add( RegularExpression("^std::multimap<.+> >(( )?&)?$"), TypeSummaryImplSP( Index: lldb/examples/synthetic/gnu_libstdcpp.py === --- lldb/examples/synthetic/gnu_libstdcpp.py +++ lldb/examples/synthetic/gnu_libstdcpp.py @@ -8,6 +8,108 @@ # You are encouraged to look at the STL implementation for your platform # before relying on these formatters to do the right thing for your setup +class StdDequeSynthProvider: +def __init__(self, valobj, dict): +self.valobj = valobj +self.count = None + +def update(self): +# preemptively setting this to None - we might end up changing our mind +# later +self.count = None +try: +self.impl = self.valobj.GetChildMemberWithName('_M_impl') +self.start = self.impl.GetChildMemberWithName("_M_start") +self.start_cur = self.start.GetChildMemberWithName('_M_cur') +self.start_cur_val = self.start_cur.GetValueAsUnsigned(0) +self.start_first = self.start.GetChildMemberWithName('_M_first') +self.start_last = self.start.GetChildMemberWithName('_M_last') +self.start_node = self.start.GetChildMemberWithName("_M_node") +self.start_node_val = self.start_node.GetValueAsUnsigned(0) +self.finish = self.impl.GetChildMemberWithName("_M_finish") +self.finish_cur = self.finish.GetChildMemberWithName('_M_cur') +self.finish_last = self.finish.GetChildMemberWithName('_M_last') +self.finish_first = self.finish.GetChildMemberWithName('_M_first') +self.finish_node = self.finish.GetChildMemberWithName('_M_node') +self.data_type = self.valobj.GetType().GetUnqualifiedType().GetTemplateArgumentType(0) +self.data_size = self.data_type.GetByteSize() +except: +pass +return False + +def get_child_index(self, name): +try: +return int(name.lstrip('[').rstrip(']')) +except: +return -1 + +# def set_node(self): +# try: +# self.start_node = self.start.GetChildMemberWithName("_M_node") +# print("Self_node: " + str(self.start_node)) +# self.start_node_data = self.start_node.GetData() +# print("Self_node_data: " + str(self.start_node_data)) +# self.start_node_data = self.start_node_data + 8 +# print("Next self_node_data: " + str(self.start_node_data)) +# except: +# print("Cannot set node") +# return None + + + +def get_child_at_index(self, index): +logger = lldb.formatters.Logger.Logger() +logger >> "Being asked to fetch child[" + str(index) + "]" +if index < 0: +return None +if index >= self.num_children(): +return None +try: +offset = index * self.data_size +# # while offset > 0: +# while self.start_cur_val != self.start_last.GetValueAsUnsigned(0): +# self.start_cur_val = self.start_cur_val + self.data_size +# print("Reached end") +return self.start_cur.CreateChildAtOffset( '[' + str(index) + '
[Lldb-commits] [PATCH] D114433: [formatters] Draft PR for the list nad forward_list capping_size
danilashtefan created this revision. danilashtefan requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D114433 Files: lldb/bindings/interface/SBTarget.i lldb/examples/synthetic/gnu_libstdcpp.py lldb/include/lldb/API/SBTarget.h lldb/source/API/SBTarget.cpp lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/TestDataFormatterGenericForwardList.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/main.cpp === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/main.cpp +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/main.cpp @@ -2,6 +2,9 @@ int main() { std::forward_list empty{}, one_elt{47}, - five_elts{1, 22, 333, , 5}; + five_elts{1, 22, 333, , 5}, thousand_elts{}; + for(int i = 0; i<1000;i++){ +thousand_elts.push_front(i); + } return 0; // break here } Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/TestDataFormatterGenericForwardList.py === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/TestDataFormatterGenericForwardList.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/TestDataFormatterGenericForwardList.py @@ -52,6 +52,19 @@ '[4] = 5', '}']) +self.expect("settings show target.max-children-count", matching=True, +substrs=['target.max-children-count (int) = 256']) + +self.expect("frame variable thousand_elts",matching=False, +substrs=[ + '[256] = 256', + '[333] = 333', + '[444] = 444', + '[555] = 555', + '[666] = 666', + '...' + ]) + @add_test_categories(["libstdcxx"]) def test_libstdcpp(self): self.do_test(USE_LIBSTDCPP) Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp === --- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -961,7 +961,7 @@ cpp_category_sp->GetRegexTypeSummariesContainer()->Add( RegularExpression("^std::(__cxx11::)?forward_list<.+>(( )?&)?$"), TypeSummaryImplSP( - new StringSummaryFormat(stl_summary_flags, "size=${svar%#}"))); + new ScriptSummaryFormat(stl_summary_flags, "lldb.formatters.cpp.gnu_libstdcpp.ForwardListSummaryProvider"))); AddCXXSynthetic( cpp_category_sp, Index: lldb/source/API/SBTarget.cpp === --- lldb/source/API/SBTarget.cpp +++ lldb/source/API/SBTarget.cpp @@ -1745,6 +1745,16 @@ return 0; } +uint32_t SBTarget::GetMaximumNumberOfChildrenToDisplay() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBTarget, GetMaximumNumberOfChildrenToDisplay); + + TargetSP target_sp(GetSP()); + if(target_sp){ + return target_sp->GetMaximumNumberOfChildrenToDisplay(); + } + return 0; +} + uint32_t SBTarget::GetAddressByteSize() { LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTarget, GetAddressByteSize); @@ -2679,6 +2689,7 @@ LLDB_REGISTER_METHOD(const char *, SBTarget, GetTriple, ()); LLDB_REGISTER_METHOD(uint32_t, SBTarget, GetDataByteSize, ()); LLDB_REGISTER_METHOD(uint32_t, SBTarget, GetCodeByteSize, ()); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget, GetMaximumNumberOfChildrenToDisplay,()); LLDB_REGISTER_METHOD(uint32_t, SBTarget, GetAddressByteSize, ()); LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, GetModuleAtIndex, (uint32_t)); Index: lldb/include/lldb/API/SBTarget.h === --- lldb/include/lldb/API/SBTarget.h +++ lldb/include/lldb/API/SBTarget.h @@ -336,6 +336,11 @@ /// unit from the Architecture's code bus uint32_t GetCodeByteSize(); + /// Gets the target.max-children-count value + /// It should be used to limit the number of + /// children of large data structures to be displayed. + uint32_t GetMaximumNumberOfChildrenToDisplay() const; + /// Set the base load address for a module section. /// /// \param[in] section Index: lldb/examples/synthetic/gnu_libstdcpp.py =
[Lldb-commits] [PATCH] D114433: [formatters] Draft PR for the list nad forward_list capping_size
danilashtefan added inline comments. Comment at: lldb/examples/synthetic/gnu_libstdcpp.py:66-69 if not _list_uses_loop_detector: logger >> "Asked not to use loop detection" +_list_uses_loop_detector = True return False I will change this to the following: `if not _list_uses_loop_detector of self.has_prev: logger >> "Asked not to use loop detection return False"` Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D114433/new/ https://reviews.llvm.org/D114433 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D114433: [formatters] Draft PR for the list nad forward_list capping_size
danilashtefan updated this revision to Diff 389249. danilashtefan marked 3 inline comments as done. danilashtefan added a comment. Done! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D114433/new/ https://reviews.llvm.org/D114433 Files: lldb/bindings/interface/SBTarget.i lldb/examples/synthetic/gnu_libstdcpp.py lldb/include/lldb/API/SBTarget.h lldb/source/API/SBTarget.cpp lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/TestDataFormatterGenericForwardList.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/main.cpp === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/main.cpp +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/main.cpp @@ -2,6 +2,9 @@ int main() { std::forward_list empty{}, one_elt{47}, - five_elts{1, 22, 333, , 5}; + five_elts{1, 22, 333, , 5}, thousand_elts{}; + for(int i = 0; i<1000;i++){ +thousand_elts.push_front(i); + } return 0; // break here } Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/TestDataFormatterGenericForwardList.py === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/TestDataFormatterGenericForwardList.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/TestDataFormatterGenericForwardList.py @@ -52,6 +52,38 @@ '[4] = 5', '}']) +self.expect("settings show target.max-children-count", matching=True, +substrs=['target.max-children-count (int) = 256']) + +self.expect("frame variable thousand_elts",matching=False, +substrs=[ + '[256]', + '[333]', + '[444]', + '[555]', + '[666]', + '...' + ]) +self.runCmd( +"settings set target.max-children-count 3", +check=False) + +self.expect("frame variable thousand_elts",matching=False, +substrs=[ + '[3]', + '[4]', + '[5]', + ]) + +self.expect("frame variable thousand_elts",matching=True, +substrs=[ + 'size=256', + '[0]', + '[1]', + '[2]', + '...' + ]) + @add_test_categories(["libstdcxx"]) def test_libstdcpp(self): self.do_test(USE_LIBSTDCPP) Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp === --- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -961,7 +961,7 @@ cpp_category_sp->GetRegexTypeSummariesContainer()->Add( RegularExpression("^std::(__cxx11::)?forward_list<.+>(( )?&)?$"), TypeSummaryImplSP( - new StringSummaryFormat(stl_summary_flags, "size=${svar%#}"))); + new ScriptSummaryFormat(stl_summary_flags, "lldb.formatters.cpp.gnu_libstdcpp.ForwardListSummaryProvider"))); AddCXXSynthetic( cpp_category_sp, Index: lldb/source/API/SBTarget.cpp === --- lldb/source/API/SBTarget.cpp +++ lldb/source/API/SBTarget.cpp @@ -1745,6 +1745,16 @@ return 0; } +uint32_t SBTarget::GetMaximumNumberOfChildrenToDisplay() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBTarget, GetMaximumNumberOfChildrenToDisplay); + + TargetSP target_sp(GetSP()); + if(target_sp){ + return target_sp->GetMaximumNumberOfChildrenToDisplay(); + } + return 0; +} + uint32_t SBTarget::GetAddressByteSize() { LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTarget, GetAddressByteSize); @@ -2679,6 +2689,7 @@ LLDB_REGISTER_METHOD(const char *, SBTarget, GetTriple, ()); LLDB_REGISTER_METHOD(uint32_t, SBTarget, GetDataByteSize, ()); LLDB_REGISTER_METHOD(uint32_t, SBTarget, GetCodeByteSize, ()); + LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget, GetMaximumNumberOfChildrenToDisplay,()); LLDB_REGISTER_METHOD(uint32_t, SBTarget, GetAddressByteSize, ()); LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, GetModuleAtIndex,
[Lldb-commits] [PATCH] D114461: Draft PR for the bitset capping size limitation avoidance
danilashtefan created this revision. danilashtefan requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D114461 Files: lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp @@ -20,9 +20,12 @@ std::bitset<0> empty; std::bitset<13> small; fill(small); - std::bitset<70> large; + std::bitset<70> medium; + fill(medium); + std::bitset<1000> large; fill(large); by_ref_and_ptr(small, &small); // break here + by_ref_and_ptr(medium, &medium); by_ref_and_ptr(large, &large); return 0; } Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py @@ -21,7 +21,7 @@ def setUp(self): TestBase.setUp(self) -primes = [1]*300 +primes = [1]*1000 primes[0] = primes[1] = 0 for i in range(2, len(primes)): for j in range(2*i, len(primes), i): @@ -58,7 +58,8 @@ self.check("empty", 0, VALUE) self.check("small", 13, VALUE) -self.check("large", 70, VALUE) +self.check("medium", 70, VALUE) +self.check("large", 1000, VALUE) @add_test_categories(["libstdcxx"]) def test_value_libstdcpp(self): @@ -84,6 +85,11 @@ self.check("ref", 70, REFERENCE) self.check("ptr", 70, POINTER) +lldbutil.continue_to_breakpoint(process, bkpt) + +self.check("ref", 1000, REFERENCE) +self.check("ptr", 1000, POINTER) + @add_test_categories(["libstdcxx"]) def test_ptr_and_ref_libstdcpp(self): self.do_test_ptr_and_ref(USE_LIBSTDCPP) Index: lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp === --- lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp +++ lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp @@ -86,7 +86,7 @@ size_t size = 0; if (auto arg = m_backend.GetCompilerType().GetIntegralTemplateArgument(0)) -size = arg->value.getLimitedValue(capping_size); +size = arg->value.getLimitedValue(); m_elements.assign(size, ValueObjectSP()); m_first = m_backend.GetChildMemberWithName(GetDataContainerMemberName(), true) Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp @@ -20,9 +20,12 @@ std::bitset<0> empty; std::bitset<13> small; fill(small); - std::bitset<70> large; + std::bitset<70> medium; + fill(medium); + std::bitset<1000> large; fill(large); by_ref_and_ptr(small, &small); // break here + by_ref_and_ptr(medium, &medium); by_ref_and_ptr(large, &large); return 0; } Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py @@ -21,7 +21,7 @@ def setUp(self): TestBase.setUp(self) -primes = [1]*300 +primes = [1]*1000 primes[0] = primes[1] = 0 for i in range(2, len(primes)): for j in range(2*i, len(primes), i): @@ -58,7 +58,8 @@ self.check("empty", 0, VALUE) self.check("small", 13, VALUE) -self.check("large", 70, VALUE) +self.check("medium", 70, VALUE) +self.check("large", 1000, VALUE) @add_test_categories(["libstdcxx"]) def test_value_libstdcpp(self): @@ -84,6 +85,11 @@ self.check("ref", 70, REFERENCE) self.check("ptr", 70, POINTER) +lldbutil.continue_to_breakpoint(process, bkpt) + +self.check("ref", 1000,
[Lldb-commits] [PATCH] D114433: [formatters] Draft PR for the list nad forward_list capping_size
danilashtefan updated this revision to Diff 389300. danilashtefan added a comment. List tests unification for libcxx and libstdcpp Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D114433/new/ https://reviews.llvm.org/D114433 Files: lldb/bindings/interface/SBTarget.i lldb/examples/synthetic/gnu_libstdcpp.py lldb/include/lldb/API/SBTarget.h lldb/source/API/SBTarget.cpp lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/TestDataFormatterGenericForwardList.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/TestDataFormatterGenericList.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/loop/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/loop/TestDataFormatterGenericListLoop.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/loop/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/main.cpp @@ -0,0 +1,34 @@ +#include +#include + +typedef std::list int_list; +typedef std::list string_list; + +int main() +{ +int_list numbers_list; + +numbers_list.push_back(0x12345678); // Set break point at this line. +numbers_list.push_back(0x11223344); +numbers_list.push_back(0xBEEFFEED); +numbers_list.push_back(0x00ABBA00); +numbers_list.push_back(0x0ABCDEF0); +numbers_list.push_back(0x0CAB0CAB); + +numbers_list.clear(); + +numbers_list.push_back(1); +numbers_list.push_back(2); +numbers_list.push_back(3); +numbers_list.push_back(4); + +string_list text_list; +text_list.push_back(std::string("goofy")); // Optional break point at this line. +text_list.push_back(std::string("is")); +text_list.push_back(std::string("smart")); + +text_list.push_back(std::string("!!!")); + +return 0; // Set final break point at this line. +} + Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/loop/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/loop/main.cpp @@ -0,0 +1,28 @@ +// Evil hack: To simulate memory corruption, we want to fiddle with some internals of std::list. +// Make those accessible to us. +#define private public +#define protected public + +#include +#include +#include + +int main() +{ +std::list numbers_list{1,2,3,4,5,6,7,8,9,10}; +printf("// Set break point at this line."); +std::list::iterator it1=numbers_list.begin(); +while (it1 != numbers_list.end()){ + *it1++; +} +*it1++; +*it1++; +*it1++; +assert(*it1 == 3); +*it1++; +*it1++; +assert(*it1 == 5); + +// Any attempt to free the list will probably crash the program. Let's just leak it. +return 0; // Set second break point at this line. +} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/loop/TestDataFormatterGenericListLoop.py === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/loop/TestDataFormatterGenericListLoop.py @@ -0,0 +1,77 @@ +""" +Test that the debugger handles loops in std::list (which can appear as a result of e.g. memory +corruption). +""" + + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +USE_LIBSTDCPP = "USE_LIBSTDCPP" +USE_LIBCPP = "USE_LIBCPP" + +class GenericListDataFormatterTestCase(TestBase): + +mydir = TestBase.compute_mydir(__file__) +NO_DEBUG_INFO_TESTCASE = True + +def do_test_with_run_command(self, stdlib_type): +self.build(dictionary={stdlib_type: "1"}) +exe = self.getBuildArtifact("a.out") +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) +self.assertTrue(breakpoint1 and breakpoint1.IsValid()) +breakpoint2 = target.BreakpointCreateBySourceRegex( +'// Set second break point at this line.', file_spec) +self.assertTrue(breakpoint2 and br
[Lldb-commits] [PATCH] D114433: [formatters] Draft PR for the list nad forward_list capping_size
danilashtefan updated this revision to Diff 389303. danilashtefan added a comment. Deleted duplicated tests from both platforms Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D114433/new/ https://reviews.llvm.org/D114433 Files: lldb/bindings/interface/SBTarget.i lldb/examples/synthetic/gnu_libstdcpp.py lldb/include/lldb/API/SBTarget.h lldb/source/API/SBTarget.cpp lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/TestDataFormatterGenericForwardList.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/TestDataFormatterGenericList.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/loop/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/loop/TestDataFormatterGenericListLoop.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/loop/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/list/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/list/TestDataFormatterLibcxxList.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/TestDataFormatterLibcxxListLoop.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/list/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/Makefile === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -CXX_SOURCES := main.cpp - -CFLAGS_EXTRAS := -O0 -USE_LIBSTDCPP := 1 - -include Makefile.rules Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/list/main.cpp === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/list/main.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include -#include -#include - -typedef std::list int_list; -typedef std::list string_list; - -int main() -{ -int_list numbers_list; -std::list* list_ptr = &numbers_list; - -printf("// Set break point at this line."); -(numbers_list.push_back(0x12345678)); -(numbers_list.push_back(0x11223344)); -(numbers_list.push_back(0xBEEFFEED)); -(numbers_list.push_back(0x00ABBA00)); -(numbers_list.push_back(0x0ABCDEF0)); -(numbers_list.push_back(0x0CAB0CAB)); - -numbers_list.clear(); - -(numbers_list.push_back(1)); -(numbers_list.push_back(2)); -(numbers_list.push_back(3)); -(numbers_list.push_back(4)); - -string_list text_list; -(text_list.push_back(std::string("goofy"))); -(text_list.push_back(std::string("is"))); -(text_list.push_back(std::string("smart"))); - -printf("// Set second break point at this line."); -(text_list.push_back(std::string("!!!"))); - -std::list countingList = {3141, 3142, 3142,3142,3142, 3142, 3142, 3141}; -countingList.sort(); -printf("// Set third break point at this line."); -countingList.unique(); -printf("// Set fourth break point at this line."); -countingList.size(); - -return 0; -} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/main.cpp === --- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/main.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// Evil hack: To simulate memory corruption, we want to fiddle with some internals of std::list. -// Make those accessible to us. -#define private public -#define protected public - -#include -#include -#include - -typedef std::list int_list; - -int main() -{ -#ifdef LLDB_USING_LIBCPP -int_list *numbers_list = new int_list{1,2,3,4,5,6,7,8,9,10}; - -printf("// Set break point at this line."); - -#if _LIBCPP_VERSION >= 3800 -auto *third_elem = numbers_list->__end_.__next_->__next_->__next_; -assert(third_elem->__as_node()->__value_ == 3); -auto *fifth_elem = third_elem->__
[Lldb-commits] [PATCH] D114008: Draft PR for the deque, stack, queue lldb data formatters
danilashtefan updated this revision to Diff 389597. danilashtefan added a comment. Unified tests added Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D114008/new/ https://reviews.llvm.org/D114008 Files: lldb/examples/synthetic/gnu_libstdcpp.py lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/deque/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/deque/TestDataFormatterGenericDeque.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/deque/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/deque/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/deque/main.cpp @@ -0,0 +1,40 @@ +#include + +struct Foo_small { + int a; + int b; + int c; + + Foo_small(int a, int b, int c) : a(a), b(b), c(c) {} +}; + +struct Foo_large { + int a; + int b; + int c; + char d[1000] = {0}; + + Foo_large(int a, int b, int c) : a(a), b(b), c(c) {} +}; + +template T fill(T deque) { + for (int i = 0; i < 100; i++) { +deque.push_back({i, i + 1, i + 2}); +deque.push_front({-i, -(i + 1), -(i + 2)}); + } + return deque; +} + +int main() { + std::deque empty; + std::deque deque_1 = {1}; + std::deque deque_3 = {3, 1, 2}; + + std::deque deque_200_small; + deque_200_small = fill>(deque_200_small); + + std::deque deque_200_large; + deque_200_large = fill>(deque_200_large); + + return empty.size() + deque_1.front() + deque_3.front(); // break here +} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/deque/TestDataFormatterGenericDeque.py === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/deque/TestDataFormatterGenericDeque.py @@ -0,0 +1,55 @@ +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +USE_LIBSTDCPP = "USE_LIBSTDCPP" +USE_LIBCPP = "USE_LIBCPP" + +class GenericDequeDataFormatterTestCase(TestBase): + +mydir = TestBase.compute_mydir(__file__) + +def findVariable(self, name): +var = self.frame().FindVariable(name) +self.assertTrue(var.IsValid()) +return var + +def getVariableType(self, name): +var = self.findVariable(name) +return var.GetType().GetDisplayTypeName() + +def check(self, var_name, size): +var = self.findVariable(var_name) +self.assertEqual(var.GetNumChildren(), size) +children = [] +for i in range(size): +child = var.GetChildAtIndex(i) +children.append(ValueCheck(value=child.GetValue())) +self.expect_var_path(var_name, type=self.getVariableType(var_name), children=children) + +def do_test(self, stdlib_type): +self.build() +lldbutil.run_to_source_breakpoint(self, "break here", + lldb.SBFileSpec("main.cpp")) + +self.expect_expr("empty", result_children=[]) +self.expect_expr("deque_1", result_children=[ +ValueCheck(name="[0]", value="1"), +]) +self.expect_expr("deque_3", result_children=[ +ValueCheck(name="[0]", value="3"), +ValueCheck(name="[1]", value="1"), +ValueCheck(name="[2]", value="2") +]) + +self.check("deque_200_small", 200) +self.check("deque_200_large", 200) + +@add_test_categories(["libstdcxx"]) +def test_libstdcpp(self): +self.do_test(USE_LIBSTDCPP) + +@add_test_categories(["libc++"]) +def test_libcpp(self): + self.do_test(USE_LIBCPP) \ No newline at end of file Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/deque/Makefile === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/deque/Makefile @@ -0,0 +1,3 @@ +CXX_SOURCES := main.cpp + +include Makefile.rules Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp === --- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -918,6 +918,11 @@ SyntheticChildrenSP(new ScriptedSyntheticChildren( stl_deref_flags, "lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider"))); + cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add( + RegularExpression("^std::deque<.+>(( )?&)?$"), + SyntheticChildrenSP(new ScriptedSyntheticChildren( + stl_deref_flags, + "lldb.formatters.cpp.gnu_libstdcpp.StdDequeSynthProvider"))); cpp_category_s
[Lldb-commits] [PATCH] D114008: Draft PR for the deque, stack, queue lldb data formatters
danilashtefan updated this revision to Diff 389700. danilashtefan added a comment. As we discussed offline, I add the print tests, since SBValue.GetValue() doesn't work for complex structures Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D114008/new/ https://reviews.llvm.org/D114008 Files: lldb/examples/synthetic/gnu_libstdcpp.py lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/deque/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/deque/TestDataFormatterGenericDeque.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/deque/main.cpp Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/deque/main.cpp === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/deque/main.cpp @@ -0,0 +1,40 @@ +#include + +struct Foo_small { + int a; + int b; + int c; + + Foo_small(int a, int b, int c) : a(a), b(b), c(c) {} +}; + +struct Foo_large { + int a; + int b; + int c; + char d[1000] = {0}; + + Foo_large(int a, int b, int c) : a(a), b(b), c(c) {} +}; + +template T fill(T deque) { + for (int i = 0; i < 100; i++) { +deque.push_back({i, i + 1, i + 2}); +deque.push_front({-i, -(i + 1), -(i + 2)}); + } + return deque; +} + +int main() { + std::deque empty; + std::deque deque_1 = {1}; + std::deque deque_3 = {3, 1, 2}; + + std::deque deque_200_small; + deque_200_small = fill>(deque_200_small); + + std::deque deque_200_large; + deque_200_large = fill>(deque_200_large); + + return empty.size() + deque_1.front() + deque_3.front(); // break here +} Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/deque/TestDataFormatterGenericDeque.py === --- /dev/null +++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/deque/TestDataFormatterGenericDeque.py @@ -0,0 +1,204 @@ +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +USE_LIBSTDCPP = "USE_LIBSTDCPP" +USE_LIBCPP = "USE_LIBCPP" + +class GenericDequeDataFormatterTestCase(TestBase): + +mydir = TestBase.compute_mydir(__file__) + +def findVariable(self, name): +var = self.frame().FindVariable(name) +self.assertTrue(var.IsValid()) +return var + +def getVariableType(self, name): +var = self.findVariable(name) +return var.GetType().GetDisplayTypeName() + +def check_size(self, var_name, size): +var = self.findVariable(var_name) +self.assertEqual(var.GetNumChildren(), size) + + +def do_test(self, stdlib_type): +self.build() +lldbutil.run_to_source_breakpoint(self, "break here", + lldb.SBFileSpec("main.cpp")) + +self.expect_expr("empty", result_children=[]) +self.expect_expr("deque_1", result_children=[ +ValueCheck(name="[0]", value="1"), +]) +self.expect_expr("deque_3", result_children=[ +ValueCheck(name="[0]", value="3"), +ValueCheck(name="[1]", value="1"), +ValueCheck(name="[2]", value="2") +]) + +self.check_size("deque_200_small", 200) + +# SBValue.GetValue() doesn't work for complex structures, so the only way to test formatter is printing +children = "[0] = (a = -99, b = -100, c = -101)\n[1] = (a = -98, b = -99, c = -100)\n[2] = (a = -97, b = -98, c = -99)\n[3] = (a = -96, b = -97, c = -98)\n" \ +"[4] = (a = -95, b = -96, c = -97)\n[5] = (a = -94, b = -95, c = -96)\n[6] = (a = -93, b = -94, c = -95)\n"\ +"[7] = (a = -92, b = -93, c = -94)\n[8] = (a = -91, b = -92, c = -93)\n[9] = (a = -90, b = -91, c = -92)\n"\ +"[10] = (a = -89, b = -90, c = -91)\n[11] = (a = -88, b = -89, c = -90)\n[12] = (a = -87, b = -88, c = -89)\n"\ +"[13] = (a = -86, b = -87, c = -88)\n[14] = (a = -85, b = -86, c = -87)\n[15] = (a = -84, b = -85, c = -86)\n"\ +"[16] = (a = -83, b = -84, c = -85)\n[17] = (a = -82, b = -83, c = -84)\n[18] = (a = -81, b = -82, c = -83)\n"\ +"[19] = (a = -80, b = -81, c = -82)\n[20] = (a = -79, b = -80, c = -81)\n[21] = (a = -78, b = -79, c = -80)\n"\ +"[22] = (a = -77, b = -78, c = -79)\n[23] = (a = -76, b = -77, c = -78)\n[24] = (a = -75, b = -76, c = -77)\n"\ +"[25] = (a = -74, b = -75, c = -76)\n[26] = (a = -73, b = -74, c = -75)\n[27] = (a = -72, b = -73, c = -74)\n"\ +"[28] = (a = -71, b = -72, c = -73)\n[29] = (a = -70, b = -71, c = -72)\n[30] = (a = -69, b = -70, c = -71)\n"\ +"[31] = (a = -68, b = -69, c = -70)\n[32] = (a = -67, b = -68, c = -69)\n[33] = (a = -66, b = -67, c = -68)\n"\ +"[34] = (a = -
[Lldb-commits] [PATCH] D114008: Draft PR for the deque, stack, queue lldb data formatters
danilashtefan added a comment. Hi @labath, Thank you so much for your comment and correction. The initial version of the test was the following, with array of ValueCheck objects: `def check(self, var_name, size): var = self.findVariable(var_name) self.assertEqual(var.GetNumChildren(), size) children = [] for i in range(100): children.insert(0,ValueCheck(value={i, i + 1, i + 2})) children.append(ValueCheck(value={-i, -(i + 1), -(i + 2)})) self.expect_var_path(var_name, type=self.getVariableType(var_name), children=children)` However, the following error pops up in the `expected_var_path`: `AssertionError: {99, 100, 101} != None : Checking child with index 0:`. The reason is that `child.GetValue()`that is invoked inside gives None in case it is a complex structure. This is why me and @wallace decided to go with a printing test. If I did not get you right, I would be glad if you could describe your solution more, so I can implement it. Many thanks! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D114008/new/ https://reviews.llvm.org/D114008 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits