]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/dynamic_value_child_count/TestDynamicValueChildCount.py
Vendor import of lldb trunk r256945:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / dynamic_value_child_count / TestDynamicValueChildCount.py
1 """
2 Test that dynamic values update their child count correctly
3 """
4
5 from __future__ import print_function
6
7
8
9 import os, time
10 import re
11 import lldb
12 import lldbsuite.test.lldbutil as lldbutil
13 from lldbsuite.test.lldbtest import *
14
15 class DynamicValueChildCountTestCase(TestBase):
16
17     mydir = TestBase.compute_mydir(__file__)
18
19     def setUp(self):
20         # Call super's setUp().                                                                                                           
21         TestBase.setUp(self)
22
23         # Find the line number to break for main.c.                                                                                       
24
25         self.main_third_call_line = line_number('pass-to-base.cpp',
26                                                        '// Break here and check b has 0 children')
27         self.main_fourth_call_line = line_number('pass-to-base.cpp',
28                                                        '// Break here and check b still has 0 children')
29         self.main_fifth_call_line = line_number('pass-to-base.cpp',
30                                                        '// Break here and check b has one child now')
31         self.main_sixth_call_line = line_number('pass-to-base.cpp',
32                                                        '// Break here and check b has 0 children again')
33
34     @expectedFailureLinux("llvm.org/pr23039")
35     @expectedFailureFreeBSD("llvm.org/pr19311") # continue at a breakpoint does not work
36     @expectedFailureWindows("llvm.org/pr24663")
37     @expectedFailurei386("to be figured out")
38     @add_test_categories(['pyapi'])
39     def test_get_dynamic_vals(self):
40         """Test fetching C++ dynamic values from pointers & references."""
41         """Get argument vals for the call stack when stopped on a breakpoint."""
42         self.build(dictionary=self.getBuildFlags())
43         exe = os.path.join(os.getcwd(), "a.out")
44
45         # Create a target from the debugger.
46
47         target = self.dbg.CreateTarget (exe)
48         self.assertTrue(target, VALID_TARGET)
49
50         # Set up our breakpoints:
51
52         third_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_third_call_line)
53         self.assertTrue(third_call_bpt,
54                         VALID_BREAKPOINT)
55         fourth_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_fourth_call_line)
56         self.assertTrue(fourth_call_bpt,
57                         VALID_BREAKPOINT)
58         fifth_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_fifth_call_line)
59         self.assertTrue(fifth_call_bpt,
60                         VALID_BREAKPOINT)
61         sixth_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_sixth_call_line)
62         self.assertTrue(sixth_call_bpt,
63                         VALID_BREAKPOINT)
64
65         # Now launch the process, and do not stop at the entry point.
66         process = target.LaunchSimple (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(b.GetNumChildren() == 0, "b didn't go back to 0 children")