e7f984081ea2fa02123fece229ca2f1df2f94088
[openbsd] /
1 """
2 Test that dynamic values update their child count correctly
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 DynamicValueChildCountTestCase(TestBase):
14
15     mydir = TestBase.compute_mydir(__file__)
16
17     def setUp(self):
18         # Call super's setUp().
19         TestBase.setUp(self)
20
21         # Find the line number to break for main.c.
22
23         self.main_third_call_line = line_number(
24             'pass-to-base.cpp', '// Break here and check b has 0 children')
25         self.main_fourth_call_line = line_number(
26             'pass-to-base.cpp', '// Break here and check b still has 0 children')
27         self.main_fifth_call_line = line_number(
28             'pass-to-base.cpp', '// Break here and check b has one child now')
29         self.main_sixth_call_line = line_number(
30             'pass-to-base.cpp', '// Break here and check b has 0 children again')
31
32     @add_test_categories(['pyapi'])
33     @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24663")
34     def test_get_dynamic_vals(self):
35         """Test fetching C++ dynamic values from pointers & references."""
36         """Get argument vals for the call stack when stopped on a breakpoint."""
37         self.build(dictionary=self.getBuildFlags())
38         exe = self.getBuildArtifact("a.out")
39
40         # Create a target from the debugger.
41
42         target = self.dbg.CreateTarget(exe)
43         self.assertTrue(target, VALID_TARGET)
44
45         # Set up our breakpoints:
46
47         third_call_bpt = target.BreakpointCreateByLocation(
48             'pass-to-base.cpp', self.main_third_call_line)
49         self.assertTrue(third_call_bpt,
50                         VALID_BREAKPOINT)
51         fourth_call_bpt = target.BreakpointCreateByLocation(
52             'pass-to-base.cpp', self.main_fourth_call_line)
53         self.assertTrue(fourth_call_bpt,
54                         VALID_BREAKPOINT)
55         fifth_call_bpt = target.BreakpointCreateByLocation(
56             'pass-to-base.cpp', self.main_fifth_call_line)
57         self.assertTrue(fifth_call_bpt,
58                         VALID_BREAKPOINT)
59         sixth_call_bpt = target.BreakpointCreateByLocation(
60             'pass-to-base.cpp', self.main_sixth_call_line)
61         self.assertTrue(sixth_call_bpt,
62                         VALID_BREAKPOINT)
63
64         # Now launch the process, and do not stop at the entry point.
65         process = target.LaunchSimple(
66             None, None, self.get_process_working_directory())
67
68         self.assertTrue(process.GetState() == lldb.eStateStopped,
69                         PROCESS_STOPPED)
70
71         b = self.frame().FindVariable("b").GetDynamicValue(lldb.eDynamicCanRunTarget)
72         self.assertTrue(b.GetNumChildren() == 0, "b has 0 children")
73         self.runCmd("continue")
74         self.assertTrue(b.GetNumChildren() == 0, "b still has 0 children")
75         self.runCmd("continue")
76         self.assertTrue(b.GetNumChildren() != 0, "b now has 1 child")
77         self.runCmd("continue")
78         self.assertTrue(
79             b.GetNumChildren() == 0,
80             "b didn't go back to 0 children")