3 Test lldb data formatter subsystem.
9 from lldbsuite.test.decorators import *
10 from lldbsuite.test.lldbtest import *
11 from lldbsuite.test import lldbutil
14 class LibcxxStringDataFormatterTestCase(TestBase):
16 mydir = TestBase.compute_mydir(__file__)
19 # Call super's setUp().
21 # Find the line number to break at.
22 self.line = line_number('main.cpp', '// Set break point at this line.')
23 ns = 'ndk' if lldbplatformutil.target_is_android() else ''
24 self.namespace = 'std::__' + ns + '1'
26 @add_test_categories(["libc++"])
27 @expectedFailureAll(bugnumber="llvm.org/pr36109", debug_info="gmodules", triple=".*-android")
28 def test_with_run_command(self):
29 """Test that that file and class static variables display correctly."""
31 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
33 lldbutil.run_break_set_by_file_and_line(
34 self, "main.cpp", self.line, num_expected_locations=-1)
36 self.runCmd("run", RUN_SUCCEEDED)
38 # The stop reason of the thread should be breakpoint.
39 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
41 'stop reason = breakpoint'])
43 # This is the function to remove the custom formats in order to have a
44 # clean slate for the next test case.
46 self.runCmd('type format clear', check=False)
47 self.runCmd('type summary clear', check=False)
48 self.runCmd('type filter clear', check=False)
49 self.runCmd('type synth clear', check=False)
51 "settings set target.max-children-count 256",
54 # Execute the cleanup function during test case tear down.
55 self.addTearDownHook(cleanup)
61 '(%s::wstring) wempty = L""'%ns,
62 '(%s::wstring) s = L"hello world! מזל טוב!"'%ns,
63 '(%s::wstring) S = L"!!!!"'%ns,
64 '(const wchar_t *) mazeltov = 0x',
66 '(%s::string) empty = ""'%ns,
67 '(%s::string) q = "hello world"'%ns,
68 '(%s::string) Q = "quite a long std::strin with lots of info inside it"'%ns,
69 '(%s::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"'%ns,
70 '(%s::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"'%ns,
71 '(%s::u16string) u16_string = u"ß水氶"'%ns,
72 # FIXME: This should have a 'u' prefix.
73 '(%s::u16string) u16_empty = ""'%ns,
74 '(%s::u32string) u32_string = U"🍄🍅🍆🍌"'%ns,
75 # FIXME: This should have a 'U' prefix.
76 '(%s::u32string) u32_empty = ""'%ns,
77 '(%s::basic_string<unsigned char, %s::char_traits<unsigned char>, '
78 '%s::allocator<unsigned char> >) uchar = "aaaaa"'%(ns,ns,ns),
83 TheVeryLongOne = self.frame().FindVariable("TheVeryLongOne")
84 summaryOptions = lldb.SBTypeSummaryOptions()
85 summaryOptions.SetCapping(lldb.eTypeSummaryUncapped)
86 uncappedSummaryStream = lldb.SBStream()
87 TheVeryLongOne.GetSummary(uncappedSummaryStream, summaryOptions)
88 uncappedSummary = uncappedSummaryStream.GetData()
89 self.assertTrue(uncappedSummary.find("someText") > 0,
90 "uncappedSummary does not include the full string")
91 summaryOptions.SetCapping(lldb.eTypeSummaryCapped)
92 cappedSummaryStream = lldb.SBStream()
93 TheVeryLongOne.GetSummary(cappedSummaryStream, summaryOptions)
94 cappedSummary = cappedSummaryStream.GetData()
96 cappedSummary.find("someText") <= 0,
97 "cappedSummary includes the full string")
99 self.expect_expr("s", result_type=ns+"::wstring", result_summary='L"hello world! מזל טוב!"')
104 '(%s::wstring) S = L"!!!!!"'%ns,
105 '(const wchar_t *) mazeltov = 0x',
107 '(%s::string) q = "hello world"'%ns,
108 '(%s::string) Q = "quite a long std::strin with lots of info inside it"'%ns,
109 '(%s::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"'%ns,
110 '(%s::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"'%ns,
111 '(%s::u16string) u16_string = u"ß水氶"'%ns,
112 '(%s::u32string) u32_string = U"🍄🍅🍆🍌"'%ns,
113 '(%s::u32string) u32_empty = ""'%ns,
114 '(%s::basic_string<unsigned char, %s::char_traits<unsigned char>, '
115 '%s::allocator<unsigned char> >) uchar = "aaaaa"'%(ns,ns,ns),