Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / functionalities / dynamic_value_child_count / TestDynamicValueChildCount.py
blob6e19006f00448ba5670482d00d64e9318cc3bbbc
1 """
2 Test that dynamic values update their child count correctly
3 """
6 import lldb
7 from lldbsuite.test.decorators import *
8 from lldbsuite.test.lldbtest import *
9 from lldbsuite.test import lldbutil
12 class DynamicValueChildCountTestCase(TestBase):
13 def setUp(self):
14 # Call super's setUp().
15 TestBase.setUp(self)
17 # Find the line number to break for main.c.
19 self.main_third_call_line = line_number(
20 "pass-to-base.cpp", "// Break here and check b has 0 children"
22 self.main_fourth_call_line = line_number(
23 "pass-to-base.cpp", "// Break here and check b still has 0 children"
25 self.main_fifth_call_line = line_number(
26 "pass-to-base.cpp", "// Break here and check b has one child now"
28 self.main_sixth_call_line = line_number(
29 "pass-to-base.cpp", "// Break here and check b has 0 children again"
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()
38 exe = self.getBuildArtifact("a.out")
40 # Create a target from the debugger.
42 target = self.dbg.CreateTarget(exe)
43 self.assertTrue(target, VALID_TARGET)
45 # Set up our breakpoints:
47 third_call_bpt = target.BreakpointCreateByLocation(
48 "pass-to-base.cpp", self.main_third_call_line
50 self.assertTrue(third_call_bpt, VALID_BREAKPOINT)
51 fourth_call_bpt = target.BreakpointCreateByLocation(
52 "pass-to-base.cpp", self.main_fourth_call_line
54 self.assertTrue(fourth_call_bpt, VALID_BREAKPOINT)
55 fifth_call_bpt = target.BreakpointCreateByLocation(
56 "pass-to-base.cpp", self.main_fifth_call_line
58 self.assertTrue(fifth_call_bpt, VALID_BREAKPOINT)
59 sixth_call_bpt = target.BreakpointCreateByLocation(
60 "pass-to-base.cpp", self.main_sixth_call_line
62 self.assertTrue(sixth_call_bpt, VALID_BREAKPOINT)
64 # Now launch the process, and do not stop at the entry point.
65 process = target.LaunchSimple(None, None, self.get_process_working_directory())
67 self.assertState(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED)
69 b = self.frame().FindVariable("b").GetDynamicValue(lldb.eDynamicCanRunTarget)
70 self.assertEquals(b.GetNumChildren(), 0, "b has 0 children")
71 self.runCmd("continue")
72 self.assertEquals(b.GetNumChildren(), 0, "b still has 0 children")
73 self.runCmd("continue")
74 self.assertNotEqual(b.GetNumChildren(), 0, "b now has 1 child")
75 self.runCmd("continue")
76 self.assertEqual(b.GetNumChildren(), 0, "b didn't go back to 0 children")