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