1 """Test that types defined in shared libraries with stripped symbols work correctly."""
6 from lldbsuite
.test
.decorators
import *
7 from lldbsuite
.test
.lldbtest
import *
8 from lldbsuite
.test
import lldbutil
11 class SharedLibStrippedTestCase(TestBase
):
12 @expectedFailureAll(oslist
=["windows"])
13 # Sometimes fails with:
14 # error: Couldn't allocate space for materialized struct: Couldn't malloc: address space is full
15 # On 32 bit Arm Linux.
16 @skipIf(archs
=["arm"])
18 """Test that types work when defined in a shared library and forward-declared in the main executable"""
19 if "clang" in self
.getCompiler() and "3.4" in self
.getCompilerVersion():
21 "llvm.org/pr16214 -- clang emits partial DWARF for structures referenced via typedef"
27 # This should display correctly.
29 "expression --show-types -- *my_foo_ptr",
30 VARIABLES_DISPLAYED_CORRECTLY
,
31 substrs
=["(foo)", "(sub_foo)", "other_element = 3"],
34 @expectedFailureAll(oslist
=["windows"])
35 @unittest.expectedFailure
# llvm.org/PR36712
36 def test_frame_variable(self
):
37 """Test that types work when defined in a shared library and forward-declared in the main executable"""
41 # This should display correctly.
43 "frame variable --show-types -- *my_foo_ptr",
44 VARIABLES_DISPLAYED_CORRECTLY
,
45 substrs
=["(foo)", "(sub_foo)", "other_element = 3"],
49 # Call super's setUp().
51 # Find the line number to break inside main().
52 self
.source
= "main.c"
53 self
.line
= line_number(self
.source
, "// Set breakpoint 0 here.")
54 self
.shlib_names
= ["foo"]
56 def common_setup(self
):
57 # Run in synchronous mode
58 self
.dbg
.SetAsync(False)
60 # Create a target by the debugger.
61 target
= self
.dbg
.CreateTarget(self
.getBuildArtifact("a.out"))
62 self
.assertTrue(target
, VALID_TARGET
)
64 # Break inside the foo function which takes a bar_ptr argument.
65 lldbutil
.run_break_set_by_file_and_line(
66 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(target
, self
.shlib_names
)
73 # Now launch the process, and do not stop at entry point.
74 process
= target
.LaunchSimple(
75 None, environment
, self
.get_process_working_directory()
77 self
.assertTrue(process
, PROCESS_IS_VALID
)
79 # The stop reason of the thread should be breakpoint.
82 STOPPED_DUE_TO_BREAKPOINT
,
83 substrs
=["stopped", "stop reason = breakpoint"],
86 # The breakpoint should have a hit count of 1.
87 lldbutil
.check_breakpoint(self
, bpno
=1, expected_hit_count
=1)