77 lines · python
1"""2Test that dynamic values update their child count correctly3"""4 5 6import lldb7from lldbsuite.test.decorators import *8from lldbsuite.test.lldbtest import *9from lldbsuite.test import lldbutil10 11 12class DynamicValueChildCountTestCase(TestBase):13 def setUp(self):14 # Call super's setUp().15 TestBase.setUp(self)16 17 # Find the line number to break for main.c.18 19 self.main_third_call_line = line_number(20 "pass-to-base.cpp", "// Break here and check b has 0 children"21 )22 self.main_fourth_call_line = line_number(23 "pass-to-base.cpp", "// Break here and check b still has 0 children"24 )25 self.main_fifth_call_line = line_number(26 "pass-to-base.cpp", "// Break here and check b has one child now"27 )28 self.main_sixth_call_line = line_number(29 "pass-to-base.cpp", "// Break here and check b has 0 children again"30 )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()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_line49 )50 self.assertTrue(third_call_bpt, VALID_BREAKPOINT)51 fourth_call_bpt = target.BreakpointCreateByLocation(52 "pass-to-base.cpp", self.main_fourth_call_line53 )54 self.assertTrue(fourth_call_bpt, VALID_BREAKPOINT)55 fifth_call_bpt = target.BreakpointCreateByLocation(56 "pass-to-base.cpp", self.main_fifth_call_line57 )58 self.assertTrue(fifth_call_bpt, VALID_BREAKPOINT)59 sixth_call_bpt = target.BreakpointCreateByLocation(60 "pass-to-base.cpp", self.main_sixth_call_line61 )62 self.assertTrue(sixth_call_bpt, VALID_BREAKPOINT)63 64 # Now launch the process, and do not stop at the entry point.65 process = target.LaunchSimple(None, None, self.get_process_working_directory())66 67 self.assertState(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED)68 69 b = self.frame().FindVariable("b").GetDynamicValue(lldb.eDynamicCanRunTarget)70 self.assertEqual(b.GetNumChildren(), 0, "b has 0 children")71 self.runCmd("continue")72 self.assertEqual(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")77