3 Test lldb data formatter subsystem.
6 from __future__ import print_function
12 from lldbsuite.test.decorators import *
13 from lldbsuite.test.lldbtest import *
14 from lldbsuite.test import lldbutil
17 class LibcxxStringDataFormatterTestCase(TestBase):
19 mydir = TestBase.compute_mydir(__file__)
22 # Call super's setUp().
24 # Find the line number to break at.
25 self.line = line_number('main.cpp', '// Set break point at this line.')
27 @skipIf(compiler="gcc")
28 @skipIfWindows # libc++ not ported to Windows yet
29 def test_with_run_command(self):
30 """Test that that file and class static variables display correctly."""
32 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
34 lldbutil.run_break_set_by_file_and_line(
35 self, "main.cpp", self.line, num_expected_locations=-1)
37 self.runCmd("run", RUN_SUCCEEDED)
39 lldbutil.skip_if_library_missing(
40 self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
42 # The stop reason of the thread should be breakpoint.
43 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
45 'stop reason = breakpoint'])
47 # This is the function to remove the custom formats in order to have a
48 # clean slate for the next test case.
50 self.runCmd('type format clear', check=False)
51 self.runCmd('type summary clear', check=False)
52 self.runCmd('type filter clear', check=False)
53 self.runCmd('type synth clear', check=False)
55 "settings set target.max-children-count 256",
58 # Execute the cleanup function during test case tear down.
59 self.addTearDownHook(cleanup)
64 '(std::__1::wstring) s = L"hello world! מזל טוב!"',
65 '(std::__1::wstring) S = L"!!!!"',
66 '(const wchar_t *) mazeltov = 0x',
68 '(std::__1::string) q = "hello world"',
69 '(std::__1::string) Q = "quite a long std::strin with lots of info inside it"',
70 '(std::__1::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"',
71 '(std::__1::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"'])
75 TheVeryLongOne = self.frame().FindVariable("TheVeryLongOne")
76 summaryOptions = lldb.SBTypeSummaryOptions()
77 summaryOptions.SetCapping(lldb.eTypeSummaryUncapped)
78 uncappedSummaryStream = lldb.SBStream()
79 TheVeryLongOne.GetSummary(uncappedSummaryStream, summaryOptions)
80 uncappedSummary = uncappedSummaryStream.GetData()
81 self.assertTrue(uncappedSummary.find("someText") > 0,
82 "uncappedSummary does not include the full string")
83 summaryOptions.SetCapping(lldb.eTypeSummaryCapped)
84 cappedSummaryStream = lldb.SBStream()
85 TheVeryLongOne.GetSummary(cappedSummaryStream, summaryOptions)
86 cappedSummary = cappedSummaryStream.GetData()
88 cappedSummary.find("someText") <= 0,
89 "cappedSummary includes the full string")
94 '(std::__1::wstring) s = L"hello world! מזל טוב!"',
95 '(std::__1::wstring) S = L"!!!!!"',
96 '(const wchar_t *) mazeltov = 0x',
98 '(std::__1::string) q = "hello world"',
99 '(std::__1::string) Q = "quite a long std::strin with lots of info inside it"',
100 '(std::__1::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"',
101 '(std::__1::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"'])