1 """Test passing structs to Objective-C methods."""
5 from lldbsuite
.test
.decorators
import *
6 from lldbsuite
.test
.lldbtest
import *
7 from lldbsuite
.test
import lldbutil
10 class TestObjCStructArgument(TestBase
):
12 # Call super's setUp().
14 # Find the line numbers to break inside main().
15 self
.main_source
= "test.m"
16 self
.break_line
= line_number(self
.main_source
, "// Set breakpoint here.")
18 # this test program only builds for ios with -gmodules
19 @add_test_categories(["gmodules", "pyapi"])
20 @skipIf(oslist
=["ios", "watchos", "tvos", "bridgeos"], archs
=["armv7", "arm64"])
21 def test_with_python_api(self
):
22 """Test passing structs to Objective-C methods."""
24 exe
= self
.getBuildArtifact("a.out")
26 target
= self
.dbg
.CreateTarget(exe
)
27 self
.assertTrue(target
, VALID_TARGET
)
29 bpt
= target
.BreakpointCreateByLocation(self
.main_source
, self
.break_line
)
30 self
.assertTrue(bpt
, VALID_BREAKPOINT
)
32 # Now launch the process, and do not stop at entry point.
33 process
= target
.LaunchSimple(None, None, self
.get_process_working_directory())
35 self
.assertTrue(process
, PROCESS_IS_VALID
)
37 # The stop reason of the thread should be breakpoint.
38 thread_list
= lldbutil
.get_threads_stopped_at_breakpoint(process
, bpt
)
40 # Make sure we stopped at the first breakpoint.
41 self
.assertNotEqual(len(thread_list
), 0, "No thread stopped at our breakpoint.")
43 len(thread_list
), 1, "More than one thread stopped at our breakpoint."
46 frame
= thread_list
[0].GetFrameAtIndex(0)
47 self
.assertTrue(frame
, "Got a valid frame 0 frame.")
49 self
.expect("expression [summer sumThings:tts]", substrs
=["9"])
52 "po [NSValue valueWithRect:rect]", substrs
=["NSRect: {{0, 0}, {10, 20}}"]
55 # Now make sure we can call a method that returns a struct without
57 cmd_value
= frame
.EvaluateExpression("[provider getRange]")
58 self
.assertTrue(cmd_value
.IsValid())