2 Test lldb data formatter subsystem.
8 from lldbsuite.test.decorators import *
9 from lldbsuite.test.lldbtest import *
10 from lldbsuite.test import lldbutil
13 class LibcxxMultiSetDataFormatterTestCase(TestBase):
15 mydir = TestBase.compute_mydir(__file__)
19 ns = 'ndk' if lldbplatformutil.target_is_android() else ''
20 self.namespace = 'std::__' + ns + '1'
22 def getVariableType(self, name):
23 var = self.frame().FindVariable(name)
24 self.assertTrue(var.IsValid())
25 return var.GetType().GetCanonicalType().GetName()
27 def check_ii(self, var_name):
28 """ This checks the value of the bitset stored in ii at the call to by_ref_and_ptr.
29 We use this to make sure we get the same values for ii when we look at the object
30 directly, and when we look at a reference to the object. """
32 "frame variable " + var_name,
37 self.expect("frame variable " + var_name + "[2]", substrs=[" = 2"])
46 @add_test_categories(["libc++"])
47 def test_with_run_command(self):
48 """Test that that file and class static variables display correctly."""
50 (self.target, process, _, bkpt) = lldbutil.run_to_source_breakpoint(
51 self, "Set break point at this line.", lldb.SBFileSpec("main.cpp", False))
53 # This is the function to remove the custom formats in order to have a
54 # clean slate for the next test case.
56 self.runCmd('type format clear', check=False)
57 self.runCmd('type summary clear', check=False)
58 self.runCmd('type filter clear', check=False)
59 self.runCmd('type synth clear', check=False)
61 "settings set target.max-children-count 256",
64 # Execute the cleanup function during test case tear down.
65 self.addTearDownHook(cleanup)
67 ii_type = self.getVariableType("ii")
68 self.assertTrue(ii_type.startswith(self.namespace + "::multiset"),
71 self.expect("frame variable ii", substrs=["size=0", "{}"])
72 lldbutil.continue_to_breakpoint(process, bkpt)
83 lldbutil.continue_to_breakpoint(process, bkpt)
87 lldbutil.continue_to_breakpoint(process, bkpt)
88 self.expect("frame variable ii", substrs=["size=0", "{}"])
89 lldbutil.continue_to_breakpoint(process, bkpt)
90 self.expect("frame variable ii", substrs=["size=0", "{}"])
91 ss_type = self.getVariableType("ss")
92 self.assertTrue(ss_type.startswith(self.namespace + "::multiset"),
94 self.expect("frame variable ss", substrs=["size=0", "{}"])
95 lldbutil.continue_to_breakpoint(process, bkpt)
101 '[1] = "a very long string is right here"'])
102 lldbutil.continue_to_breakpoint(process, bkpt)
110 '[1] = "a very long string is right here"'])
118 '[1] = "a very long string is right here"'])
119 self.expect("frame variable ss[2]", substrs=[' = "b"'])
120 lldbutil.continue_to_breakpoint(process, bkpt)
126 '[1] = "a very long string is right here"',
129 @add_test_categories(["libc++"])
130 def test_ref_and_ptr(self):
131 """Test that the data formatters work on ref and ptr."""
133 (self.target, process, _, bkpt) = lldbutil.run_to_source_breakpoint(
134 self, "Stop here to check by ref and ptr.",
135 lldb.SBFileSpec("main.cpp", False))
136 # The reference should print just like the value:
139 self.expect("frame variable ptr",
140 substrs=["ptr =", "size=7"])
141 self.expect("expr ptr",