]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/lang/cpp/incomplete-types/TestCppIncompleteTypes.py
Vendor import of lldb release_39 branch r276489:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / lang / cpp / incomplete-types / TestCppIncompleteTypes.py
1 import lldb
2 from lldbsuite.test.decorators import *
3 from lldbsuite.test.lldbtest import *
4 from lldbsuite.test import lldbutil
5
6 class TestCppIncompleteTypes(TestBase):
7
8     mydir = TestBase.compute_mydir(__file__)
9
10     @skipIf(compiler="gcc")
11     def test_limit_debug_info(self):
12         self.build()
13         frame = self.get_test_frame('limit')
14
15         value_f = frame.EvaluateExpression("f")
16         self.assertTrue(value_f.IsValid(), "'expr f' results in a valid SBValue object")
17         self.assertTrue(value_f.GetError().Success(), "'expr f' is successful")
18
19         value_a = frame.EvaluateExpression("a")
20         self.assertTrue(value_a.IsValid(), "'expr a' results in a valid SBValue object")
21         self.assertTrue(value_a.GetError().Success(), "'expr a' is successful")
22
23     @skipIf(compiler="gcc")
24     @skipIfWindows # Clang on Windows asserts in external record layout in this case.
25     def test_partial_limit_debug_info(self):
26         self.build()
27         frame = self.get_test_frame('nolimit')
28
29         value_f = frame.EvaluateExpression("f")
30         self.assertTrue(value_f.IsValid(), "'expr f' results in a valid SBValue object")
31         self.assertTrue(value_f.GetError().Success(), "'expr f' is successful")
32
33         value_a = frame.EvaluateExpression("a")
34         self.assertTrue(value_a.IsValid(), "'expr a' results in a valid SBValue object")
35         self.assertTrue(value_a.GetError().Success(), "'expr a' is successful")
36
37     def get_test_frame(self, exe):
38         # Get main source file
39         src_file = "main.cpp"
40         src_file_spec = lldb.SBFileSpec(src_file)
41         self.assertTrue(src_file_spec.IsValid(), "Main source file")
42
43         # Get the path of the executable
44         cwd = os.getcwd()
45         exe_path  = os.path.join(cwd, exe)
46
47         # Load the executable
48         target = self.dbg.CreateTarget(exe_path)
49         self.assertTrue(target.IsValid(), VALID_TARGET)
50
51         # Break on main function
52         main_breakpoint = target.BreakpointCreateBySourceRegex("break here", src_file_spec)
53         self.assertTrue(main_breakpoint.IsValid() and main_breakpoint.GetNumLocations() >= 1, VALID_BREAKPOINT)
54
55         # Launch the process
56         args = None
57         env = None
58         process = target.LaunchSimple(args, env, self.get_process_working_directory())
59         self.assertTrue(process.IsValid(), PROCESS_IS_VALID)
60
61         # Get the thread of the process
62         self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED)
63         thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
64
65         # Get frame for current thread
66         return thread.GetSelectedFrame()