]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/list/TestDataFormatterStdList.py
Vendor import of lldb release_39 branch r276489:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / data-formatter / data-formatter-stl / libstdcpp / list / TestDataFormatterStdList.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 StdListDataFormatterTestCase(TestBase):
16
17     mydir = TestBase.compute_mydir(__file__)
18
19     def setUp(self):
20         # Call super's setUp().
21         TestBase.setUp(self)
22         # Find the line numbers to break at for the different tests.
23         self.line = line_number('main.cpp', '// Set break point at this line.')
24         self.optional_line = line_number('main.cpp', '// Optional break point at this line.')
25         self.final_line = line_number('main.cpp', '// Set final break point at this line.')
26
27     @skipIfWindows # libstdcpp not ported to Windows
28     def test_with_run_command(self):
29         """Test that that file and class static variables display correctly."""
30         self.build()
31         self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
32
33         lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1)
34
35         self.runCmd("run", RUN_SUCCEEDED)
36
37         # The stop reason of the thread should be breakpoint.
38         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
39             substrs = ['stopped',
40                        'stop reason = breakpoint'])
41
42         # This is the function to remove the custom formats in order to have a
43         # clean slate for the next test case.
44         def cleanup():
45             self.runCmd('type format clear', check=False)
46             self.runCmd('type summary clear', check=False)
47             self.runCmd('type filter clear', check=False)
48             self.runCmd('type synth clear', check=False)
49             self.runCmd("settings set target.max-children-count 256", check=False)
50
51         # Execute the cleanup function during test case tear down.
52         self.addTearDownHook(cleanup)
53
54         self.runCmd("frame variable numbers_list --show-types")
55
56         self.runCmd("type format add -f hex int")
57
58         self.expect("frame variable numbers_list --raw", matching=False,
59                     substrs = ['size=0',
60                                '{}'])
61         self.expect("frame variable &numbers_list._M_impl._M_node --raw", matching=False,
62                     substrs = ['size=0',
63                                '{}'])
64
65         self.expect("frame variable numbers_list",
66                     substrs = ['size=0',
67                                '{}'])
68
69         self.expect("p numbers_list",
70                     substrs = ['size=0',
71                                '{}'])
72
73         self.runCmd("n")
74
75         self.expect("frame variable numbers_list",
76                     substrs = ['size=1',
77                                '[0] = ',
78                                '0x12345678'])
79
80         self.runCmd("n");self.runCmd("n");self.runCmd("n");
81
82         self.expect("frame variable numbers_list",
83                     substrs = ['size=4',
84                                '[0] = ',
85                                '0x12345678',
86                                '[1] =',
87                                '0x11223344',
88                                '[2] =',
89                                '0xbeeffeed',
90                                '[3] =',
91                                '0x00abba00'])
92
93         self.runCmd("n");self.runCmd("n");
94
95         self.expect("frame variable numbers_list",
96                     substrs = ['size=6',
97                                '[0] = ',
98                                '0x12345678',
99                                '0x11223344',
100                                '0xbeeffeed',
101                                '0x00abba00',
102                                '[4] =',
103                                '0x0abcdef0',
104                                '[5] =',
105                                '0x0cab0cab'])
106
107         self.expect("p numbers_list",
108                     substrs = ['size=6',
109                                '[0] = ',
110                                '0x12345678',
111                                '0x11223344',
112                                '0xbeeffeed',
113                                '0x00abba00',
114                                '[4] =',
115                                '0x0abcdef0',
116                                '[5] =',
117                                '0x0cab0cab'])
118
119         # check access-by-index
120         self.expect("frame variable numbers_list[0]",
121                     substrs = ['0x12345678']);
122         self.expect("frame variable numbers_list[1]",
123                     substrs = ['0x11223344']);
124         
125         # but check that expression does not rely on us
126         self.expect("expression numbers_list[0]", matching=False, error=True,
127                     substrs = ['0x12345678'])
128
129         # check that MightHaveChildren() gets it right
130         self.assertTrue(self.frame().FindVariable("numbers_list").MightHaveChildren(), "numbers_list.MightHaveChildren() says False for non empty!")
131
132         self.runCmd("n")
133             
134         self.expect("frame variable numbers_list",
135                     substrs = ['size=0',
136                                '{}'])
137
138         self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n");
139             
140         self.expect("frame variable numbers_list",
141                     substrs = ['size=4',
142                                '[0] = ', '1',
143                                '[1] = ', '2',
144                                '[2] = ', '3',
145                                '[3] = ', '4'])            
146
147         self.runCmd("type format delete int")
148
149         self.runCmd("n")
150             
151         self.expect("frame variable text_list",
152             substrs = ['size=0',
153                        '{}'])
154         
155         lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.final_line, num_expected_locations=-1)
156
157         self.runCmd("c", RUN_SUCCEEDED)
158
159         # The stop reason of the thread should be breakpoint.
160         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
161             substrs = ['stopped',
162                        'stop reason = breakpoint'])
163
164         self.expect("frame variable text_list",
165                     substrs = ['size=4',
166                                '[0]', 'goofy',
167                                '[1]', 'is',
168                                '[2]', 'smart',
169                                '[3]', '!!!'])
170
171         self.expect("p text_list",
172                     substrs = ['size=4',
173                                '\"goofy\"',
174                                '\"is\"',
175                                '\"smart\"',
176                                '\"!!!\"'])
177         
178         # check access-by-index
179         self.expect("frame variable text_list[0]",
180                     substrs = ['goofy']);
181         self.expect("frame variable text_list[3]",
182                     substrs = ['!!!']);
183         
184         # but check that expression does not rely on us
185         self.expect("expression text_list[0]", matching=False, error=True,
186                     substrs = ['goofy'])
187
188         # check that MightHaveChildren() gets it right
189         self.assertTrue(self.frame().FindVariable("text_list").MightHaveChildren(), "text_list.MightHaveChildren() says False for non empty!")