]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
Vendor import of lldb release_39 branch r276489:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / data-formatter / data-formatter-stl / libcxx / map / TestDataFormatterLibccMap.py
1 """
2 Test lldb data formatter subsystem.
3 """
4
5 from __future__ import print_function
6
7
8
9 import os, time
10 import lldb
11 from lldbsuite.test.decorators import *
12 from lldbsuite.test.lldbtest import *
13 from lldbsuite.test import lldbutil
14
15 class LibcxxMapDataFormatterTestCase(TestBase):
16
17     mydir = TestBase.compute_mydir(__file__)
18
19     @skipIf(compiler="gcc")
20     @skipIfWindows # libc++ not ported to Windows yet
21     def test_with_run_command(self):
22         """Test that that file and class static variables display correctly."""
23         self.build()
24         self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
25
26         bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "Set break point at this line."))
27
28         self.runCmd("run", RUN_SUCCEEDED)
29
30         lldbutil.skip_if_library_missing(self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
31
32         # The stop reason of the thread should be breakpoint.
33         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
34             substrs = ['stopped',
35                        'stop reason = breakpoint'])
36
37         # This is the function to remove the custom formats in order to have a
38         # clean slate for the next test case.
39         def cleanup():
40             self.runCmd('type format clear', check=False)
41             self.runCmd('type summary clear', check=False)
42             self.runCmd('type filter clear', check=False)
43             self.runCmd('type synth clear', check=False)
44             self.runCmd("settings set target.max-children-count 256", check=False)
45
46         # Execute the cleanup function during test case tear down.
47         self.addTearDownHook(cleanup)
48
49         self.expect('image list', substrs = self.getLibcPlusPlusLibs())
50                 
51         self.expect('frame variable ii',
52             substrs = ['size=0',
53                        '{}'])
54
55         lldbutil.continue_to_breakpoint(self.process(), bkpt)
56
57         self.expect('frame variable ii',
58                     substrs = ['size=2',
59                                '[0] = ',
60                                'first = 0',
61                                'second = 0',
62                                '[1] = ',
63                                'first = 1',
64                                'second = 1'])
65
66         lldbutil.continue_to_breakpoint(self.process(), bkpt)
67
68         self.expect('frame variable ii',
69                     substrs = ['size=4',
70                                '[2] = ',
71                                'first = 2',
72                                'second = 0',
73                                '[3] = ',
74                                'first = 3',
75                                'second = 1'])
76
77         lldbutil.continue_to_breakpoint(self.process(), bkpt)
78
79         self.expect("frame variable ii",
80                     substrs = ['size=8',
81                                '[5] = ',
82                                'first = 5',
83                                'second = 0',
84                                '[7] = ',
85                                'first = 7',
86                                'second = 1'])
87
88         self.expect("p ii",
89                     substrs = ['size=8',
90                                '[5] = ',
91                                'first = 5',
92                                'second = 0',
93                                '[7] = ',
94                                'first = 7',
95                                'second = 1'])
96
97         # check access-by-index
98         self.expect("frame variable ii[0]",
99                     substrs = ['first = 0',
100                                'second = 0']);
101         self.expect("frame variable ii[3]",
102                     substrs = ['first =',
103                                'second =']);
104
105         # check that MightHaveChildren() gets it right
106         self.assertTrue(self.frame().FindVariable("ii").MightHaveChildren(), "ii.MightHaveChildren() says False for non empty!")
107
108         # check that the expression parser does not make use of
109         # synthetic children instead of running code
110         # TOT clang has a fix for this, which makes the expression command here succeed
111         # since this would make the test fail or succeed depending on clang version in use
112         # this is safer commented for the time being
113         #self.expect("expression ii[8]", matching=False, error=True,
114         #            substrs = ['1234567'])
115
116         self.runCmd("continue");
117         
118         self.expect('frame variable ii',
119                     substrs = ['size=0',
120                                '{}'])
121
122         self.expect('frame variable si',
123                     substrs = ['size=0',
124                                '{}'])
125
126         self.runCmd("continue");
127
128         self.expect('frame variable si',
129                     substrs = ['size=1',
130                                '[0] = ',
131                                'first = \"zero\"',
132                                'second = 0'])
133
134         lldbutil.continue_to_breakpoint(self.process(), bkpt)
135
136         self.expect("frame variable si",
137                     substrs = ['size=4',
138                                '[0] = ',
139                                'first = \"zero\"',
140                                'second = 0',
141                                 '[1] = ',
142                                 'first = \"one\"',
143                                 'second = 1',
144                                 '[2] = ',
145                                 'first = \"two\"',
146                                 'second = 2',
147                                 '[3] = ',
148                                 'first = \"three\"',
149                                 'second = 3'])
150
151         self.expect("p si",
152                     substrs = ['size=4',
153                                '[0] = ',
154                                'first = \"zero\"',
155                                'second = 0',
156                                '[1] = ',
157                                'first = \"one\"',
158                                'second = 1',
159                                '[2] = ',
160                                'first = \"two\"',
161                                'second = 2',
162                                '[3] = ',
163                                'first = \"three\"',
164                                'second = 3'])
165
166         # check that MightHaveChildren() gets it right
167         self.assertTrue(self.frame().FindVariable("si").MightHaveChildren(), "si.MightHaveChildren() says False for non empty!")
168
169         # check access-by-index
170         self.expect("frame variable si[0]",
171                     substrs = ['first = ', 'one',
172                                'second = 1']);
173         
174         # check that the expression parser does not make use of
175         # synthetic children instead of running code
176         # TOT clang has a fix for this, which makes the expression command here succeed
177         # since this would make the test fail or succeed depending on clang version in use
178         # this is safer commented for the time being
179         #self.expect("expression si[0]", matching=False, error=True,
180         #            substrs = ['first = ', 'zero'])
181
182         lldbutil.continue_to_breakpoint(self.process(), bkpt)
183         
184         self.expect('frame variable si',
185                     substrs = ['size=0',
186                                '{}'])
187
188         lldbutil.continue_to_breakpoint(self.process(), bkpt)
189         
190         self.expect('frame variable is',
191                     substrs = ['size=0',
192                                '{}'])
193
194         lldbutil.continue_to_breakpoint(self.process(), bkpt)
195
196         self.expect("frame variable is",
197                     substrs = ['size=4',
198                                '[0] = ',
199                                'second = \"goofy\"',
200                                'first = 85',
201                                '[1] = ',
202                                'second = \"is\"',
203                                'first = 1',
204                                '[2] = ',
205                                'second = \"smart\"',
206                                'first = 2',
207                                '[3] = ',
208                                'second = \"!!!\"',
209                                'first = 3'])
210         
211         self.expect("p is",
212                     substrs = ['size=4',
213                                '[0] = ',
214                                'second = \"goofy\"',
215                                'first = 85',
216                                '[1] = ',
217                                'second = \"is\"',
218                                'first = 1',
219                                '[2] = ',
220                                'second = \"smart\"',
221                                'first = 2',
222                                '[3] = ',
223                                'second = \"!!!\"',
224                                'first = 3'])
225
226         # check that MightHaveChildren() gets it right
227         self.assertTrue(self.frame().FindVariable("is").MightHaveChildren(), "is.MightHaveChildren() says False for non empty!")
228
229         # check access-by-index
230         self.expect("frame variable is[0]",
231                     substrs = ['first = ',
232                                'second =']);
233         
234         # check that the expression parser does not make use of
235         # synthetic children instead of running code
236         # TOT clang has a fix for this, which makes the expression command here succeed
237         # since this would make the test fail or succeed depending on clang version in use
238         # this is safer commented for the time being
239         #self.expect("expression is[0]", matching=False, error=True,
240         #            substrs = ['first = ', 'goofy'])
241
242         lldbutil.continue_to_breakpoint(self.process(), bkpt)
243         
244         self.expect('frame variable is',
245                     substrs = ['size=0',
246                                '{}'])
247
248         lldbutil.continue_to_breakpoint(self.process(), bkpt)
249         
250         self.expect('frame variable ss',
251                     substrs = ['size=0',
252                                '{}'])
253
254         lldbutil.continue_to_breakpoint(self.process(), bkpt)
255
256         self.expect("frame variable ss",
257                     substrs = ['size=3',
258                                '[0] = ',
259                                'second = \"hello\"',
260                                'first = \"ciao\"',
261                                '[1] = ',
262                                'second = \"house\"',
263                                'first = \"casa\"',
264                                '[2] = ',
265                                'second = \"cat\"',
266                                'first = \"gatto\"'])
267         
268         self.expect("p ss",
269                     substrs = ['size=3',
270                                '[0] = ',
271                                'second = \"hello\"',
272                                'first = \"ciao\"',
273                                '[1] = ',
274                                'second = \"house\"',
275                                'first = \"casa\"',
276                                '[2] = ',
277                                'second = \"cat\"',
278                                'first = \"gatto\"'])
279
280         # check that MightHaveChildren() gets it right
281         self.assertTrue(self.frame().FindVariable("ss").MightHaveChildren(), "ss.MightHaveChildren() says False for non empty!")
282
283         # check access-by-index
284         self.expect("frame variable ss[2]",
285                     substrs = ['gatto', 'cat']);
286         
287         # check that the expression parser does not make use of
288         # synthetic children instead of running code
289         # TOT clang has a fix for this, which makes the expression command here succeed
290         # since this would make the test fail or succeed depending on clang version in use
291         # this is safer commented for the time being
292         #self.expect("expression ss[3]", matching=False, error=True,
293         #            substrs = ['gatto'])
294
295         lldbutil.continue_to_breakpoint(self.process(), bkpt)
296         
297         self.expect('frame variable ss',
298                     substrs = ['size=0',
299                                '{}'])