53df271fdcb11c4b1c3d476c01fa0a09c42fc993
[openbsd] /
1 """
2 Check for an issue where capping does not work because the Target pointer appears to be changing behind our backs
3 """
4
5
6
7 import lldb
8 from lldbsuite.test.decorators import *
9 from lldbsuite.test.lldbtest import *
10 from lldbsuite.test import lldbutil
11
12
13 class SyntheticCappingTestCase(TestBase):
14
15     mydir = TestBase.compute_mydir(__file__)
16
17     def setUp(self):
18         # Call super's setUp().
19         TestBase.setUp(self)
20         # Find the line number to break at.
21         self.line = line_number('main.cpp', '// Set break point at this line.')
22
23     def test_with_run_command(self):
24         """Check for an issue where capping does not work because the Target pointer appears to be changing behind our backs."""
25         self.build()
26         self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
27
28         lldbutil.run_break_set_by_file_and_line(
29             self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
30
31         self.runCmd("run", RUN_SUCCEEDED)
32
33         process = self.dbg.GetSelectedTarget().GetProcess()
34
35         # The stop reason of the thread should be breakpoint.
36         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
37                     substrs=['stopped',
38                              'stop reason = breakpoint'])
39
40         # This is the function to remove the custom formats in order to have a
41         # clean slate for the next test case.
42         def cleanup():
43             self.runCmd('type format clear', check=False)
44             self.runCmd('type summary clear', check=False)
45             self.runCmd('type filter clear', check=False)
46             self.runCmd('type synth clear', check=False)
47             self.runCmd(
48                 "settings set target.max-children-count 256",
49                 check=False)
50
51         # Execute the cleanup function during test case tear down.
52         self.addTearDownHook(cleanup)
53
54         # set up the synthetic children provider
55         self.runCmd("script from fooSynthProvider import *")
56         self.runCmd("type synth add -l fooSynthProvider foo")
57
58         # note that the value of fake_a depends on target byte order
59         if process.GetByteOrder() == lldb.eByteOrderLittle:
60             fake_a_val = 0x02000000
61         else:
62             fake_a_val = 0x00000100
63
64         # check that the synthetic children work, so we know we are doing the
65         # right thing
66         self.expect("frame variable f00_1",
67                     substrs=['r = 34',
68                              'fake_a = %d' % fake_a_val,
69                              'a = 1'])
70
71         # check that capping works
72         self.runCmd("settings set target.max-children-count 2", check=False)
73
74         self.expect("frame variable f00_1",
75                     substrs=['...',
76                              'fake_a = %d' % fake_a_val,
77                              'a = 1'])
78
79         self.expect("frame variable f00_1", matching=False,
80                     substrs=['r = 34'])
81
82         self.runCmd("settings set target.max-children-count 256", check=False)
83
84         self.expect("frame variable f00_1", matching=True,
85                     substrs=['r = 34'])