]> 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 trunk r256945:
[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.lldbtest import *
12 import lldbsuite.test.lldbutil as lldbutil
13
14 class StdListDataFormatterTestCase(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 numbers to break at for the different tests.
22         self.line = line_number('main.cpp', '// Set break point at this line.')
23         self.optional_line = line_number('main.cpp', '// Optional break point at this line.')
24         self.final_line = line_number('main.cpp', '// Set final break point at this line.')
25
26     @skipIfWindows # libstdcpp not ported to Windows
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_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1)
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 numbers_list --show-types")
54
55         self.runCmd("type format add -f hex int")
56
57         self.expect("frame variable numbers_list --raw", matching=False,
58                     substrs = ['size=0',
59                                '{}'])
60         self.expect("frame variable &numbers_list._M_impl._M_node --raw", matching=False,
61                     substrs = ['size=0',
62                                '{}'])
63
64         self.expect("frame variable numbers_list",
65                     substrs = ['size=0',
66                                '{}'])
67
68         self.expect("p numbers_list",
69                     substrs = ['size=0',
70                                '{}'])
71
72         self.runCmd("n")
73
74         self.expect("frame variable numbers_list",
75                     substrs = ['size=1',
76                                '[0] = ',
77                                '0x12345678'])
78
79         self.runCmd("n");self.runCmd("n");self.runCmd("n");
80
81         self.expect("frame variable numbers_list",
82                     substrs = ['size=4',
83                                '[0] = ',
84                                '0x12345678',
85                                '[1] =',
86                                '0x11223344',
87                                '[2] =',
88                                '0xbeeffeed',
89                                '[3] =',
90                                '0x00abba00'])
91
92         self.runCmd("n");self.runCmd("n");
93
94         self.expect("frame variable numbers_list",
95                     substrs = ['size=6',
96                                '[0] = ',
97                                '0x12345678',
98                                '0x11223344',
99                                '0xbeeffeed',
100                                '0x00abba00',
101                                '[4] =',
102                                '0x0abcdef0',
103                                '[5] =',
104                                '0x0cab0cab'])
105
106         self.expect("p numbers_list",
107                     substrs = ['size=6',
108                                '[0] = ',
109                                '0x12345678',
110                                '0x11223344',
111                                '0xbeeffeed',
112                                '0x00abba00',
113                                '[4] =',
114                                '0x0abcdef0',
115                                '[5] =',
116                                '0x0cab0cab'])
117
118         # check access-by-index
119         self.expect("frame variable numbers_list[0]",
120                     substrs = ['0x12345678']);
121         self.expect("frame variable numbers_list[1]",
122                     substrs = ['0x11223344']);
123         
124         # but check that expression does not rely on us
125         self.expect("expression numbers_list[0]", matching=False, error=True,
126                     substrs = ['0x12345678'])
127
128         # check that MightHaveChildren() gets it right
129         self.assertTrue(self.frame().FindVariable("numbers_list").MightHaveChildren(), "numbers_list.MightHaveChildren() says False for non empty!")
130
131         self.runCmd("n")
132             
133         self.expect("frame variable numbers_list",
134                     substrs = ['size=0',
135                                '{}'])
136
137         self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n");
138             
139         self.expect("frame variable numbers_list",
140                     substrs = ['size=4',
141                                '[0] = ', '1',
142                                '[1] = ', '2',
143                                '[2] = ', '3',
144                                '[3] = ', '4'])            
145
146         self.runCmd("type format delete int")
147
148         self.runCmd("n")
149             
150         self.expect("frame variable text_list",
151             substrs = ['size=0',
152                        '{}'])
153         
154         lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.final_line, num_expected_locations=-1)
155
156         self.runCmd("c", RUN_SUCCEEDED)
157
158         # The stop reason of the thread should be breakpoint.
159         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
160             substrs = ['stopped',
161                        'stop reason = breakpoint'])
162
163         self.expect("frame variable text_list",
164                     substrs = ['size=4',
165                                '[0]', 'goofy',
166                                '[1]', 'is',
167                                '[2]', 'smart',
168                                '[3]', '!!!'])
169
170         self.expect("p text_list",
171                     substrs = ['size=4',
172                                '\"goofy\"',
173                                '\"is\"',
174                                '\"smart\"',
175                                '\"!!!\"'])
176         
177         # check access-by-index
178         self.expect("frame variable text_list[0]",
179                     substrs = ['goofy']);
180         self.expect("frame variable text_list[3]",
181                     substrs = ['!!!']);
182         
183         # but check that expression does not rely on us
184         self.expect("expression text_list[0]", matching=False, error=True,
185                     substrs = ['goofy'])
186
187         # check that MightHaveChildren() gets it right
188         self.assertTrue(self.frame().FindVariable("text_list").MightHaveChildren(), "text_list.MightHaveChildren() says False for non empty!")