1 """Test that hidden ivars in a shared library are visible from the main executable."""
8 from lldbsuite
.test
.decorators
import *
9 from lldbsuite
.test
.lldbtest
import *
10 from lldbsuite
.test
import lldbutil
13 class HiddenIvarsTestCase(TestBase
):
15 # Call super's setUp().
17 # Find the line number to break inside main().
18 self
.source
= "main.m"
19 self
.line
= line_number(self
.source
, "// breakpoint1")
20 # The makefile names of the shared libraries as they appear in DYLIB_NAME.
21 # The names should have no loading "lib" or extension as they will be
23 self
.shlib_names
= ["InternalDefiner"]
26 debug_info
=no_match("dsym"),
27 bugnumber
="This test requires a stripped binary and a dSYM",
29 def test_expr_stripped(self
):
30 if self
.getArchitecture() == "i386":
31 self
.skipTest("requires modern objc runtime")
37 if self
.getArchitecture() == "i386":
38 self
.skipTest("requires modern objc runtime")
44 debug_info
=no_match("dsym"),
45 bugnumber
="This test requires a stripped binary and a dSYM",
47 def test_frame_variable_stripped(self
):
48 if self
.getArchitecture() == "i386":
49 self
.skipTest("requires modern objc runtime")
54 def test_frame_variable(self
):
55 if self
.getArchitecture() == "i386":
56 self
.skipTest("requires modern objc runtime")
61 @unittest.expectedFailure
# rdar://18683637
62 def test_frame_variable_across_modules(self
):
63 if self
.getArchitecture() == "i386":
64 self
.skipTest("requires modern objc runtime")
67 self
.common_setup(False)
69 "frame variable k->bar", VARIABLES_DISPLAYED_CORRECTLY
, substrs
=["= 3"]
72 def common_setup(self
, strip
):
74 exe
= self
.getBuildArtifact("stripped/a.out")
76 exe
= self
.getBuildArtifact("a.out")
77 # Create a target by the debugger.
78 target
= self
.dbg
.CreateTarget(exe
)
79 self
.assertTrue(target
, VALID_TARGET
)
81 # Create the breakpoint inside function 'main'.
82 breakpoint
= target
.BreakpointCreateByLocation(self
.source
, self
.line
)
83 self
.assertTrue(breakpoint
, VALID_BREAKPOINT
)
85 # Register our shared libraries for remote targets so they get
86 # automatically uploaded
87 environment
= self
.registerSharedLibrariesWithTarget(target
, self
.shlib_names
)
89 # Now launch the process, and do not stop at entry point.
90 process
= target
.LaunchSimple(
91 None, environment
, self
.get_process_working_directory()
93 self
.assertTrue(process
, PROCESS_IS_VALID
)
95 self
.runCmd("file " + exe
, CURRENT_EXECUTABLE_SET
)
97 # Break inside the foo function which takes a bar_ptr argument.
98 lldbutil
.run_break_set_by_file_and_line(
99 self
, "main.m", self
.line
, num_expected_locations
=1, loc_exact
=True
102 self
.runCmd("run", RUN_SUCCEEDED
)
104 # The stop reason of the thread should be breakpoint.
107 STOPPED_DUE_TO_BREAKPOINT
,
108 substrs
=["stopped", "stop reason = breakpoint"],
111 # The breakpoint should have a hit count of 1.
112 lldbutil
.check_breakpoint(self
, bpno
=1, expected_hit_count
=1)
114 def expr(self
, strip
):
115 self
.common_setup(strip
)
117 # This should display correctly.
119 "expression (j->_definer->foo)",
120 VARIABLES_DISPLAYED_CORRECTLY
,
125 "expression (j->_definer->bar)",
126 VARIABLES_DISPLAYED_CORRECTLY
,
132 "expression *(j->_definer)",
133 VARIABLES_DISPLAYED_CORRECTLY
,
138 "expression *(j->_definer)",
139 VARIABLES_DISPLAYED_CORRECTLY
,
140 substrs
=["foo = 4", "bar = 5"],
144 "expression (k->foo)", VARIABLES_DISPLAYED_CORRECTLY
, substrs
=["= 2"]
148 "expression (k->bar)", VARIABLES_DISPLAYED_CORRECTLY
, substrs
=["= 3"]
152 "expression k.filteredDataSource",
153 VARIABLES_DISPLAYED_CORRECTLY
,
154 substrs
=[" = 0x", '"2 elements"'],
160 VARIABLES_DISPLAYED_CORRECTLY
,
161 substrs
=["foo = 2", " = 0x", '"2 elements"'],
166 VARIABLES_DISPLAYED_CORRECTLY
,
170 "_filteredDataSource = 0x",
175 def frame_var(self
, strip
):
176 self
.common_setup(strip
)
178 # This should display correctly.
180 "frame variable j->_definer->foo",
181 VARIABLES_DISPLAYED_CORRECTLY
,
187 "frame variable j->_definer->bar",
188 VARIABLES_DISPLAYED_CORRECTLY
,
194 "frame variable *j->_definer",
195 VARIABLES_DISPLAYED_CORRECTLY
,
200 "frame variable *j->_definer",
201 VARIABLES_DISPLAYED_CORRECTLY
,
202 substrs
=["foo = 4", "bar = 5"],
206 "frame variable k->foo", VARIABLES_DISPLAYED_CORRECTLY
, substrs
=["= 2"]
210 "frame variable k->_filteredDataSource",
211 VARIABLES_DISPLAYED_CORRECTLY
,
212 substrs
=[" = 0x", '"2 elements"'],
218 VARIABLES_DISPLAYED_CORRECTLY
,
219 substrs
=["foo = 2", "_filteredDataSource = 0x", '"2 elements"'],
224 VARIABLES_DISPLAYED_CORRECTLY
,
228 "_filteredDataSource = 0x",