1 """Test that types defined in shared libraries work correctly."""
3 from __future__ import print_function
8 from lldbsuite.test.lldbtest import *
9 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():
20 "llvm.org/pr16214 -- clang emits partial DWARF for structures referenced via typedef")
25 # This should display correctly.
27 "expression --show-types -- *my_foo_ptr",
28 VARIABLES_DISPLAYED_CORRECTLY,
34 @unittest2.expectedFailure("rdar://problem/10704639")
35 def test_frame_variable(self):
36 """Test that types work when defined in a shared library and forward-declared in the main executable"""
40 # This should display correctly.
42 "frame variable --show-types -- *my_foo_ptr",
43 VARIABLES_DISPLAYED_CORRECTLY,
50 # Call super's setUp().
52 # Find the line number to break inside main().
53 self.source = 'main.c'
54 self.line = line_number(self.source, '// Set breakpoint 0 here.')
55 self.shlib_names = ["foo"]
57 def common_setup(self):
58 # Run in synchronous mode
59 self.dbg.SetAsync(False)
61 # Create a target by the debugger.
62 target = self.dbg.CreateTarget("a.out")
63 self.assertTrue(target, VALID_TARGET)
65 # Break inside the foo function which takes a bar_ptr argument.
66 lldbutil.run_break_set_by_file_and_line(
67 self, self.source, self.line, num_expected_locations=1, loc_exact=True)
69 # Register our shared libraries for remote targets so they get
70 # automatically uploaded
71 environment = self.registerSharedLibrariesWithTarget(
72 target, self.shlib_names)
74 # Now launch the process, and do not stop at entry point.
75 process = target.LaunchSimple(
76 None, environment, self.get_process_working_directory())
77 self.assertTrue(process, PROCESS_IS_VALID)
79 # The stop reason of the thread should be breakpoint.
80 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
82 'stop reason = breakpoint'])
84 # The breakpoint should have a hit count of 1.
85 self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
86 substrs=[' resolved, hit count = 1'])