1 """Test that hidden ivars in a shared library are visible from the main executable."""
7 from lldbsuite
.test
.decorators
import *
8 from lldbsuite
.test
.lldbtest
import *
9 from lldbsuite
.test
import lldbutil
12 class HiddenIvarsTestCase(TestBase
):
14 # Call super's setUp().
16 # Find the line number to break inside main().
17 self
.source
= "main.m"
18 self
.line
= line_number(self
.source
, "// breakpoint1")
19 # The makefile names of the shared libraries as they appear in DYLIB_NAME.
20 # The names should have no loading "lib" or extension as they will be
22 self
.shlib_names
= ["InternalDefiner"]
25 debug_info
=no_match("dsym"),
26 bugnumber
="This test requires a stripped binary and a dSYM",
28 def test_expr_stripped(self
):
29 if self
.getArchitecture() == "i386":
30 self
.skipTest("requires modern objc runtime")
36 if self
.getArchitecture() == "i386":
37 self
.skipTest("requires modern objc runtime")
43 debug_info
=no_match("dsym"),
44 bugnumber
="This test requires a stripped binary and a dSYM",
46 def test_frame_variable_stripped(self
):
47 if self
.getArchitecture() == "i386":
48 self
.skipTest("requires modern objc runtime")
53 def test_frame_variable(self
):
54 if self
.getArchitecture() == "i386":
55 self
.skipTest("requires modern objc runtime")
60 @expectedFailure("rdar://18683637")
61 def test_frame_variable_across_modules(self
):
62 if self
.getArchitecture() == "i386":
63 self
.skipTest("requires modern objc runtime")
66 self
.common_setup(False)
68 "frame variable k->bar", VARIABLES_DISPLAYED_CORRECTLY
, substrs
=["= 3"]
71 def common_setup(self
, strip
):
73 exe
= self
.getBuildArtifact("stripped/a.out")
75 exe
= self
.getBuildArtifact("a.out")
76 # Create a target by the debugger.
77 target
= self
.dbg
.CreateTarget(exe
)
78 self
.assertTrue(target
, VALID_TARGET
)
80 # Create the breakpoint inside function 'main'.
81 breakpoint
= target
.BreakpointCreateByLocation(self
.source
, self
.line
)
82 self
.assertTrue(breakpoint
, VALID_BREAKPOINT
)
84 # Register our shared libraries for remote targets so they get
85 # automatically uploaded
86 environment
= self
.registerSharedLibrariesWithTarget(target
, self
.shlib_names
)
88 # Now launch the process, and do not stop at entry point.
89 process
= target
.LaunchSimple(
90 None, environment
, self
.get_process_working_directory()
92 self
.assertTrue(process
, PROCESS_IS_VALID
)
94 self
.runCmd("file " + exe
, CURRENT_EXECUTABLE_SET
)
96 # Break inside the foo function which takes a bar_ptr argument.
97 lldbutil
.run_break_set_by_file_and_line(
98 self
, "main.m", self
.line
, num_expected_locations
=1, loc_exact
=True
101 self
.runCmd("run", RUN_SUCCEEDED
)
103 # The stop reason of the thread should be breakpoint.
106 STOPPED_DUE_TO_BREAKPOINT
,
107 substrs
=["stopped", "stop reason = breakpoint"],
110 # The breakpoint should have a hit count of 1.
111 lldbutil
.check_breakpoint(self
, bpno
=1, expected_hit_count
=1)
113 def expr(self
, strip
):
114 self
.common_setup(strip
)
116 # This should display correctly.
118 "expression (j->_definer->foo)",
119 VARIABLES_DISPLAYED_CORRECTLY
,
124 "expression (j->_definer->bar)",
125 VARIABLES_DISPLAYED_CORRECTLY
,
131 "expression *(j->_definer)",
132 VARIABLES_DISPLAYED_CORRECTLY
,
137 "expression *(j->_definer)",
138 VARIABLES_DISPLAYED_CORRECTLY
,
139 substrs
=["foo = 4", "bar = 5"],
143 "expression (k->foo)", VARIABLES_DISPLAYED_CORRECTLY
, substrs
=["= 2"]
147 "expression (k->bar)", VARIABLES_DISPLAYED_CORRECTLY
, substrs
=["= 3"]
151 "expression k.filteredDataSource",
152 VARIABLES_DISPLAYED_CORRECTLY
,
153 substrs
=[" = 0x", '"2 elements"'],
159 VARIABLES_DISPLAYED_CORRECTLY
,
160 substrs
=["foo = 2", " = 0x", '"2 elements"'],
165 VARIABLES_DISPLAYED_CORRECTLY
,
169 "_filteredDataSource = 0x",
174 def frame_var(self
, strip
):
175 self
.common_setup(strip
)
177 # This should display correctly.
179 "frame variable j->_definer->foo",
180 VARIABLES_DISPLAYED_CORRECTLY
,
186 "frame variable j->_definer->bar",
187 VARIABLES_DISPLAYED_CORRECTLY
,
193 "frame variable *j->_definer",
194 VARIABLES_DISPLAYED_CORRECTLY
,
199 "frame variable *j->_definer",
200 VARIABLES_DISPLAYED_CORRECTLY
,
201 substrs
=["foo = 4", "bar = 5"],
205 "frame variable k->foo", VARIABLES_DISPLAYED_CORRECTLY
, substrs
=["= 2"]
209 "frame variable k->_filteredDataSource",
210 VARIABLES_DISPLAYED_CORRECTLY
,
211 substrs
=[" = 0x", '"2 elements"'],
217 VARIABLES_DISPLAYED_CORRECTLY
,
218 substrs
=["foo = 2", "_filteredDataSource = 0x", '"2 elements"'],
223 VARIABLES_DISPLAYED_CORRECTLY
,
227 "_filteredDataSource = 0x",