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 LibcxxSetDataFormatterTestCase(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 + "::set"),
71 self.expect("frame variable ii", substrs=["size=0", "{}"])
72 lldbutil.continue_to_breakpoint(process, bkpt)
82 lldbutil.continue_to_breakpoint(process, bkpt)
85 lldbutil.continue_to_breakpoint(process, bkpt)
86 self.expect("frame variable ii", substrs=["size=0", "{}"])
87 lldbutil.continue_to_breakpoint(process, bkpt)
88 self.expect("frame variable ii", substrs=["size=0", "{}"])
90 ss_type = self.getVariableType("ss")
91 self.assertTrue(ii_type.startswith(self.namespace + "::set"),
94 self.expect("frame variable ss", substrs=["size=0", "{}"])
95 lldbutil.continue_to_breakpoint(process, bkpt)
100 '[1] = "a very long string is right here"'])
101 lldbutil.continue_to_breakpoint(process, bkpt)
108 '[1] = "a very long string is right here"'])
115 '[1] = "a very long string is right here"'])
116 self.expect("frame variable ss[2]", substrs=[' = "b"'])
117 lldbutil.continue_to_breakpoint(process, bkpt)
122 '[1] = "a very long string is right here"',
125 @add_test_categories(["libc++"])
126 def test_ref_and_ptr(self):
127 """Test that the data formatters work on ref and ptr."""
129 (self.target, process, _, bkpt) = lldbutil.run_to_source_breakpoint(
130 self, "Stop here to check by ref and ptr.",
131 lldb.SBFileSpec("main.cpp", False))
132 # The reference should print just like the value:
135 self.expect("frame variable ptr",
136 substrs=["ptr =", "size=7"])
137 self.expect("expr ptr",