https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/147355
>From 78533da4cfb0c5d5f9f142cce19609810e630dd7 Mon Sep 17 00:00:00 2001 From: Michael Buch <michaelbuc...@gmail.com> Date: Mon, 7 Jul 2025 18:36:57 +0100 Subject: [PATCH 1/2] [lldb][test] Combine libstdc++ and libc++ std::string tests into generic test This combines the libc++ and libstdc++ test cases. The main difference was that the libstdcpp tests had additional tests for references/pointers to std::string. I moved those over. Split out from https://github.com/llvm/llvm-project/pull/146740 --- .../{libstdcpp => generic}/string/Makefile | 3 - .../string/TestDataFormatterStdString.py} | 54 +++++++-- .../generic/string/main.cpp | 104 ++++++++++++++++++ .../data-formatter-stl/libcxx/string/Makefile | 6 - .../data-formatter-stl/libcxx/string/main.cpp | 31 ------ .../string/TestDataFormatterStdString.py | 93 ---------------- .../libstdcpp/string/main.cpp | 16 --- 7 files changed, 147 insertions(+), 160 deletions(-) rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libstdcpp => generic}/string/Makefile (53%) rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libcxx/string/TestDataFormatterLibcxxString.py => generic/string/TestDataFormatterStdString.py} (80%) create mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/main.cpp delete mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/Makefile delete mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp delete mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py delete mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/Makefile similarity index 53% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/Makefile rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/Makefile index c825977b1a5dc..99998b20bcb05 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/Makefile +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/Makefile @@ -1,6 +1,3 @@ CXX_SOURCES := main.cpp -CFLAGS_EXTRAS := -O0 -USE_LIBSTDCPP := 1 - include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py similarity index 80% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py index 2f7fc88e0f449..c19429e67c5c6 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py @@ -10,7 +10,7 @@ from lldbsuite.test import lldbutil -class LibcxxStringDataFormatterTestCase(TestBase): +class StdStringDataFormatterTestCase(TestBase): def setUp(self): # Call super's setUp(). TestBase.setUp(self) @@ -18,17 +18,8 @@ def setUp(self): self.main_spec = lldb.SBFileSpec("main.cpp") self.namespace = "std" - @add_test_categories(["libc++"]) - @expectedFailureAll( - bugnumber="llvm.org/pr36109", debug_info="gmodules", triple=".*-android" - ) - # Inline namespace is randomly ignored as Clang due to broken lookup inside - # the std namespace. - @expectedFailureAll(debug_info="gmodules") - def test_with_run_command(self): + def do_test(self): """Test that that file and class static variables display correctly.""" - self.build() - (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( self, "Set break point at this line.", self.main_spec ) @@ -124,6 +115,25 @@ def cleanup(): ], ) + # Test references and pointers to std::string. + var_rq = self.frame().FindVariable("rq") + var_rQ = self.frame().FindVariable("rQ") + var_pq = self.frame().FindVariable("pq") + var_pQ = self.frame().FindVariable("pQ") + + self.assertEqual(var_rq.GetSummary(), '"hello world"', "rq summary wrong") + self.assertEqual( + var_rQ.GetSummary(), + '"quite a long std::strin with lots of info inside it"', + "rQ summary wrong", + ) + self.assertEqual(var_pq.GetSummary(), '"hello world"', "pq summary wrong") + self.assertEqual( + var_pQ.GetSummary(), + '"quite a long std::strin with lots of info inside it"', + "pQ summary wrong", + ) + # Finally, make sure that if the string is not readable, we give an error: bkpt_2 = target.BreakpointCreateBySourceRegex( "Break here to look at bad string", self.main_spec @@ -136,3 +146,25 @@ def cleanup(): self.assertTrue(var.GetError().Success(), "Made variable") summary = var.GetSummary() self.assertEqual(summary, "Summary Unavailable", "No summary for bad value") + + @expectedFailureAll( + bugnumber="llvm.org/pr36109", debug_info="gmodules", triple=".*-android" + ) + # Inline namespace is randomly ignored as Clang due to broken lookup inside + # the std namespace. + @expectedFailureAll(debug_info="gmodules") + @add_test_categories(["libc++"]) + def test_libcxx(self): + self.build(dictionary={"USE_LIBCPP": 1}) + self.do_test() + + @expectedFailureAll( + bugnumber="llvm.org/pr36109", debug_info="gmodules", triple=".*-android" + ) + # Inline namespace is randomly ignored as Clang due to broken lookup inside + # the std namespace. + @expectedFailureAll(debug_info="gmodules") + @add_test_categories(["libstdcxx"]) + def test_libstdcxx(self): + self.build(dictionary={"USE_LIBSTDCPP": 1}) + self.do_test() diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/main.cpp new file mode 100644 index 0000000000000..db695ed06f015 --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/main.cpp @@ -0,0 +1,104 @@ +#include <stdint.h> +#include <string> + +size_t touch_string(std::string &in_str) { + return in_str.size(); // Break here to look at bad string +} + +int main() { + std::wstring wempty(L""); + std::wstring s(L"hello world! מזל טוב!"); + std::wstring S(L"!!!!"); + const wchar_t *mazeltov = L"מזל טוב"; + std::string empty(""); + std::string q("hello world"); + std::string Q("quite a long std::strin with lots of info inside it"); + std::string TheVeryLongOne( + "123456789012345678901234567890123456789012345678901234567890123456789012" + "345678901234567890123456789012345678901234567890123456789012345678901234" + "567890123456789012345678901234567890123456789012345678901234567890123456" + "789012345678901234567890123456789012345678901234567890123456789012345678" + "901234567890123456789012345678901234567890123456789012345678901234567890" + "123456789012345678901234567890123456789012345678901234567890123456789012" + "345678901234567890123456789012345678901234567890123456789012345678901234" + "567890123456789012345678901234567890123456789012345678901234567890123456" + "789012345678901234567890123456789012345678901234567890123456789012345678" + "901234567890123456789012345678901234567890123456789012345678901234567890" + "123456789012345678901234567890123456789012345678901234567890123456789012" + "345678901234567890123456789012345678901234567890123456789012345678901234" + "567890123456789012345678901234567890123456789012345678901234567890123456" + "789012345678901234567890123456789012345678901234567890123456789012345678" + "901234567890123456789012345678901234567890123456789012345678901234567890" + "123456789012345678901234567890123456789012345678901234567890123456789012" + "345678901234567890123456789012345678901234567890123456789012345678901234" + "567890123456789012345678901234567890123456789012345678901234567890123456" + "789012345678901234567890123456789012345678901234567890123456789012345678" + "901234567890123456789012345678901234567890123456789012345678901234567890" + "123456789012345678901234567890123456789012345678901234567890123456789012" + "345678901234567890123456789012345678901234567890123456789012345678901234" + "567890123456789012345678901234567890123456789012345678901234567890123456" + "789012345678901234567890123456789012345678901234567890123456789012345678" + "901234567890123456789012345678901234567890123456789012345678901234567890" + "123456789012345678901234567890123456789012345678901234567890123456789012" + "345678901234567890123456789012345678901234567890123456789012345678901234" + "567890123456789012345678901234567890123456789012345678901234567890123456" + "789012345678901234567890123456789012345678901234567890123456789012345678" + "901234567890123456789012345678901234567890123456789012345678901234567890" + "123456789012345678901234567890123456789012345678901234567890123456789012" + "345678901234567890123456789012345678901234567890123456789012345678901234" + "567890123456789012345678901234567890123456789012345678901234567890123456" + "789012345678901234567890123456789012345678901234567890123456789012345678" + "9012345678901234567890123456789012345678901234567890someText123456789012" + "345678901234567890123456789012345678901234567890123456789012345678901234" + "567890123456789012345678901234567890123456789012345678901234567890123456" + "789012345678901234567890123456789012345678901234567890123456789012345678" + "901234567890123456789012345678901234567890123456789012345678901234567890" + "123456789012345678901234567890123456789012345678901234567890123456789012" + "345678901234567890123456789012345678901234567890123456789012345678901234" + "567890123456789012345678901234567890123456789012345678901234567890123456" + "789012345678901234567890123456789012345678901234567890123456789012345678" + "901234567890123456789012345678901234567890123456789012345678901234567890" + "123456789012345678901234567890123456789012345678901234567890123456789012" + "345678901234567890123456789012345678901234567890123456789012345678901234" + "567890123456789012345678901234567890123456789012345678901234567890123456" + "789012345678901234567890123456789012345678901234567890123456789012345678" + "901234567890123456789012345678901234567890123456789012345678901234567890" + "123456789012345678901234567890123456789012345678901234567890123456789012" + "345678901234567890123456789012345678901234567890123456789012345678901234" + "567890123456789012345678901234567890123456789012345678901234567890123456" + "789012345678901234567890123456789012345678901234567890123456789012345678" + "901234567890123456789012345678901234567890123456789012345678901234567890" + "123456789012345678901234567890123456789012345678901234567890123456789012" + "345678901234567890123456789012345678901234567890123456789012345678901234" + "567890123456789012345678901234567890123456789012345678901234567890123456" + "789012345678901234567890123456789012345678901234567890123456789012345678" + "901234567890123456789012345678901234567890123456789012345678901234567890" + "123456789012345678901234567890123456789012345678901234567890123456789012" + "345678901234567890123456789012345678901234567890123456789012345678901234" + "567890123456789012345678901234567890123456789012345678901234567890123456" + "789012345678901234567890123456789012345678901234567890123456789012345678" + "901234567890123456789012345678901234567890123456789012345678901234567890" + "123456789012345678901234567890123456789012345678901234567890123456789012" + "345678901234567890123456789012345678901234567890123456789012345678901234" + "567890123456789012345678901234567890123456789012345678901234567890123456" + "789012345678901234567890123456789012345678901234567890123456789012345678" + "901234567890123456789012345678901234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890"); + std::string IHaveEmbeddedZeros("a\0b\0c\0d", 7); + std::wstring IHaveEmbeddedZerosToo( + L"hello world!\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監", 38); + std::u16string u16_string(u"ß水氶"); + std::u16string u16_empty(u""); + std::u32string u32_string(U"🍄🍅🍆🍌"); + std::u32string u32_empty(U""); + std::string *null_str = nullptr; + auto &rq = q; + auto &rQ = Q; + std::string *pq = &q; + std::string *pQ = &Q; + + S.assign(L"!!!!!"); // Set break point at this line. + std::string *not_a_string = (std::string *)0x0; + touch_string(*not_a_string); + return 0; +} diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/Makefile deleted file mode 100644 index c7c91da728d1e..0000000000000 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -CXX_SOURCES := main.cpp - -USE_LIBCPP := 1 - -CXXFLAGS_EXTRAS := -std=c++11 -O0 -include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp deleted file mode 100644 index 373f817a80f7d..0000000000000 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include <string> -#include <stdint.h> - -size_t touch_string(std::string &in_str) -{ - return in_str.size(); // Break here to look at bad string -} - -int main() -{ - std::wstring wempty(L""); - std::wstring s(L"hello world! מזל טוב!"); - std::wstring S(L"!!!!"); - const wchar_t *mazeltov = L"מזל טוב"; - std::string empty(""); - std::string q("hello world"); - std::string Q("quite a long std::strin with lots of info inside it"); - std::string TheVeryLongOne("1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890someText1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"); - std::string IHaveEmbeddedZeros("a\0b\0c\0d",7); - std::wstring IHaveEmbeddedZerosToo(L"hello world!\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監", 38); - std::u16string u16_string(u"ß水氶"); - std::u16string u16_empty(u""); - std::u32string u32_string(U"🍄🍅🍆🍌"); - std::u32string u32_empty(U""); - std::string *null_str = nullptr; - - S.assign(L"!!!!!"); // Set break point at this line. - std::string *not_a_string = (std::string *) 0x0; - touch_string(*not_a_string); - return 0; -} diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py deleted file mode 100644 index 0f66fe89e67b3..0000000000000 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py +++ /dev/null @@ -1,93 +0,0 @@ -# coding=utf8 -""" -Test lldb data formatter subsystem. -""" - - -import lldb -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - - -class StdStringDataFormatterTestCase(TestBase): - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) - # Find the line number to break at. - self.line = line_number("main.cpp", "// Set break point at this line.") - - @add_test_categories(["libstdcxx"]) - @expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc") - def test_with_run_command(self): - """Test that that file and class static variables display correctly.""" - self.build() - self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) - - lldbutil.run_break_set_by_file_and_line( - self, "main.cpp", self.line, num_expected_locations=-1 - ) - - self.runCmd("run", RUN_SUCCEEDED) - - # The stop reason of the thread should be breakpoint. - self.expect( - "thread list", - STOPPED_DUE_TO_BREAKPOINT, - substrs=["stopped", "stop reason = breakpoint"], - ) - - # 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) - - # Execute the cleanup function during test case tear down. - self.addTearDownHook(cleanup) - - var_wempty = self.frame().FindVariable("wempty") - var_s = self.frame().FindVariable("s") - var_S = self.frame().FindVariable("S") - var_mazeltov = self.frame().FindVariable("mazeltov") - var_empty = self.frame().FindVariable("empty") - var_q = self.frame().FindVariable("q") - var_Q = self.frame().FindVariable("Q") - var_rq = self.frame().FindVariable("rq") - var_rQ = self.frame().FindVariable("rQ") - var_pq = self.frame().FindVariable("pq") - var_pQ = self.frame().FindVariable("pQ") - - self.assertEqual(var_wempty.GetSummary(), 'L""', "wempty summary wrong") - self.assertEqual( - var_s.GetSummary(), 'L"hello world! מזל טוב!"', "s summary wrong" - ) - self.assertEqual(var_S.GetSummary(), 'L"!!!!"', "S summary wrong") - self.assertEqual( - var_mazeltov.GetSummary(), 'L"מזל טוב"', "mazeltov summary wrong" - ) - self.assertEqual(var_empty.GetSummary(), '""', "empty summary wrong") - self.assertEqual(var_q.GetSummary(), '"hello world"', "q summary wrong") - self.assertEqual( - var_Q.GetSummary(), - '"quite a long std::strin with lots of info inside it"', - "Q summary wrong", - ) - self.assertEqual(var_rq.GetSummary(), '"hello world"', "rq summary wrong") - self.assertEqual( - var_rQ.GetSummary(), - '"quite a long std::strin with lots of info inside it"', - "rQ summary wrong", - ) - self.assertEqual(var_pq.GetSummary(), '"hello world"', "pq summary wrong") - self.assertEqual( - var_pQ.GetSummary(), - '"quite a long std::strin with lots of info inside it"', - "pQ summary wrong", - ) - - self.runCmd("next") - - self.assertEqual(var_S.GetSummary(), 'L"!!!!!"', "new S summary wrong") diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp deleted file mode 100644 index eefb96c4573e4..0000000000000 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include <string> - -int main() -{ - std::wstring wempty(L""); - std::wstring s(L"hello world! מזל טוב!"); - std::wstring S(L"!!!!"); - const wchar_t *mazeltov = L"מזל טוב"; - std::string empty(""); - std::string q("hello world"); - std::string Q("quite a long std::strin with lots of info inside it"); - auto &rq = q, &rQ = Q; - std::string *pq = &q, *pQ = &Q; - S.assign(L"!!!!!"); // Set break point at this line. - return 0; -} >From 9224bfcebce8f7d41044b533ec2d50ad5e219296 Mon Sep 17 00:00:00 2001 From: Michael Buch <michaelbuc...@gmail.com> Date: Mon, 7 Jul 2025 22:57:41 +0100 Subject: [PATCH 2/2] fixup! move utf-16/utf-32 to separate test-case --- .../string/TestDataFormatterStdString.py | 61 ++++++++++++------- 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py index c19429e67c5c6..93f49dda3fbf3 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py @@ -38,28 +38,8 @@ def cleanup(): ns = self.namespace - self.expect( - "frame variable", - substrs=[ - '(%s::wstring) wempty = L""' % ns, - '(%s::wstring) s = L"hello world! מזל טוב!"' % ns, - '(%s::wstring) S = L"!!!!"' % ns, - "(const wchar_t *) mazeltov = 0x", - 'L"מזל טוב"', - '(%s::string) empty = ""' % ns, - '(%s::string) q = "hello world"' % ns, - '(%s::string) Q = "quite a long std::strin with lots of info inside it"' - % ns, - '(%s::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"' % ns, - '(%s::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"' - % ns, - '(%s::u16string) u16_string = u"ß水氶"' % ns, - '(%s::u16string) u16_empty = u""' % ns, - '(%s::u32string) u32_string = U"🍄🍅🍆🍌"' % ns, - '(%s::u32string) u32_empty = U""' % ns, - "(%s::string *) null_str = nullptr" % ns, - ], - ) + # Check 'S' pre-assignment. + self.expect("frame variable S", substrs=['(%s::wstring) S = L"!!!!"' % ns]) thread.StepOver() @@ -99,9 +79,12 @@ def cleanup(): self.expect( "frame variable", substrs=[ + '(%s::wstring) wempty = L""' % ns, + '(%s::wstring) s = L"hello world! מזל טוב!"' % ns, '(%s::wstring) S = L"!!!!!"' % ns, "(const wchar_t *) mazeltov = 0x", 'L"מזל טוב"', + '(%s::string) empty = ""' % ns, '(%s::string) q = "hello world"' % ns, '(%s::string) Q = "quite a long std::strin with lots of info inside it"' % ns, @@ -109,6 +92,7 @@ def cleanup(): '(%s::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"' % ns, '(%s::u16string) u16_string = u"ß水氶"' % ns, + '(%s::u16string) u16_empty = u""' % ns, '(%s::u32string) u32_string = U"🍄🍅🍆🍌"' % ns, '(%s::u32string) u32_empty = U""' % ns, "(%s::string *) null_str = nullptr" % ns, @@ -168,3 +152,36 @@ def test_libcxx(self): def test_libstdcxx(self): self.build(dictionary={"USE_LIBSTDCPP": 1}) self.do_test() + + def do_test_multibyte(self): + lldbutil.run_to_source_breakpoint( + self, "Set break point at this line.", self.main_spec + ) + + ns = self.namespace + + self.expect( + "frame variable", + substrs=[ + '(%s::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"' % ns, + '(%s::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"' + % ns, + '(%s::u16string) u16_string = u"ß水氶"' % ns, + '(%s::u16string) u16_empty = u""' % ns, + '(%s::u32string) u32_string = U"🍄🍅🍆🍌"' % ns, + '(%s::u32string) u32_empty = U""' % ns, + ], + ) + + @add_test_categories(["libc++"]) + def test_multibyte_libcxx(self): + self.build(dictionary={"USE_LIBCPP": 1}) + self.do_test_multibyte() + + @expectedFailureAll( + bugnumber="libstdc++ formatters don't support UTF-16/UTF-32 strings yet." + ) + @add_test_categories(["libstdcxx"]) + def test_multibyte_libstdcxx(self): + self.build(dictionary={"USE_LIBSTDCPP": 1}) + self.do_test_multibyte() _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits