1 """Test that types defined in shared libraries work correctly."""
3 from __future__ import print_function
9 from lldbsuite.test.lldbtest import *
10 import lldbsuite.test.lldbutil as lldbutil
12 class SharedLibTestCase(TestBase):
14 mydir = TestBase.compute_mydir(__file__)
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")
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"])
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"""
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"])
39 # Call super's setUp().
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"]
46 def common_setup(self):
47 # Run in synchronous mode
48 self.dbg.SetAsync(False)
50 # Create a target by the debugger.
51 target = self.dbg.CreateTarget("a.out")
52 self.assertTrue(target, VALID_TARGET)
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)
57 # Register our shared libraries for remote targets so they get automatically uploaded
58 environment = self.registerSharedLibrariesWithTarget(target, self.shlib_names)
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)
64 # The stop reason of the thread should be breakpoint.
65 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
67 'stop reason = breakpoint'])
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'])