]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/lang/c/shared_lib/TestSharedLib.py
Vendor import of lldb trunk r256945:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / lang / c / shared_lib / TestSharedLib.py
1 """Test that types defined in shared libraries work correctly."""
2
3 from __future__ import print_function
4
5
6
7 import unittest2
8 import lldb
9 from lldbsuite.test.lldbtest import *
10 import lldbsuite.test.lldbutil as lldbutil
11
12 class SharedLibTestCase(TestBase):
13
14     mydir = TestBase.compute_mydir(__file__)
15
16     def test_expr(self):
17         """Test that types work when defined in a shared library and forward-declared in the main executable"""
18         if "clang" in self.getCompiler() and "3.4" in self.getCompilerVersion():
19             self.skipTest("llvm.org/pr16214 -- clang emits partial DWARF for structures referenced via typedef")
20
21         self.build()
22         self.common_setup()
23
24         # This should display correctly.
25         self.expect("expression --show-types -- *my_foo_ptr", VARIABLES_DISPLAYED_CORRECTLY,
26             substrs = ["(foo)", "(sub_foo)", "other_element = 3"])
27
28     @unittest2.expectedFailure("rdar://problem/10704639")
29     def test_frame_variable(self):
30         """Test that types work when defined in a shared library and forward-declared in the main executable"""
31         self.build()
32         self.common_setup()
33
34         # This should display correctly.
35         self.expect("frame variable --show-types -- *my_foo_ptr", VARIABLES_DISPLAYED_CORRECTLY,
36             substrs = ["(foo)", "(sub_foo)", "other_element = 3"])
37
38     def setUp(self):
39         # Call super's setUp().
40         TestBase.setUp(self)
41         # Find the line number to break inside main().
42         self.source = 'main.c'
43         self.line = line_number(self.source, '// Set breakpoint 0 here.')
44         self.shlib_names = ["foo"]
45     
46     def common_setup(self):
47         # Run in synchronous mode
48         self.dbg.SetAsync(False)
49
50         # Create a target by the debugger.
51         target = self.dbg.CreateTarget("a.out")
52         self.assertTrue(target, VALID_TARGET)
53
54         # Break inside the foo function which takes a bar_ptr argument.
55         lldbutil.run_break_set_by_file_and_line (self, self.source, self.line, num_expected_locations=1, loc_exact=True)
56
57         # Register our shared libraries for remote targets so they get automatically uploaded
58         environment = self.registerSharedLibrariesWithTarget(target, self.shlib_names)
59
60         # Now launch the process, and do not stop at entry point.
61         process = target.LaunchSimple (None, environment, self.get_process_working_directory())
62         self.assertTrue(process, PROCESS_IS_VALID)
63
64         # The stop reason of the thread should be breakpoint.
65         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
66             substrs = ['stopped',
67                        'stop reason = breakpoint'])
68
69         # The breakpoint should have a hit count of 1.
70         self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
71             substrs = [' resolved, hit count = 1'])