]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/lang/cpp/limit-debug-info/TestWithLimitDebugInfo.py
Vendor import of lldb release_39 branch r276489:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / lang / cpp / limit-debug-info / TestWithLimitDebugInfo.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 TestWithLimitDebugInfo(TestBase):
7
8     mydir = TestBase.compute_mydir(__file__)
9
10     @skipIf(debug_info=no_match(["dwarf"]))
11     def test_limit_debug_info(self):
12         self.build()
13
14         cwd = os.getcwd()
15
16         src_file = os.path.join(cwd, "main.cpp")
17         src_file_spec = lldb.SBFileSpec(src_file)
18         self.assertTrue(src_file_spec.IsValid(), "breakpoint file")
19
20         # Get the path of the executable
21         exe_path  = os.path.join(cwd, 'a.out')
22
23         # Load the executable
24         target = self.dbg.CreateTarget(exe_path)
25         self.assertTrue(target.IsValid(), VALID_TARGET)
26
27         # Break on main function
28         breakpoint = target.BreakpointCreateBySourceRegex("break here", src_file_spec)
29         self.assertTrue(breakpoint.IsValid() and breakpoint.GetNumLocations() >= 1, VALID_BREAKPOINT)
30
31         # Launch the process
32         process = target.LaunchSimple(None, None, self.get_process_working_directory())
33         self.assertTrue(process.IsValid(), PROCESS_IS_VALID)
34
35         # Get the thread of the process
36         self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED)
37         thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
38         thread.StepInto()
39
40         # Get frame for current thread
41         frame = thread.GetSelectedFrame()
42
43         v1 = frame.EvaluateExpression("1")
44         self.assertTrue(v1.IsValid(), "'expr 1' results in a valid SBValue object")
45         self.assertTrue(v1.GetError().Success(), "'expr 1' succeeds without an error.")
46
47         v2 = frame.EvaluateExpression("this")
48         self.assertTrue(v2.IsValid(), "'expr this' results in a valid SBValue object")
49         self.assertTrue(v2.GetError().Success(), "'expr this' succeeds without an error.")