1 """Test calling functions in class methods."""
3 from __future__ import print_function
9 from lldbsuite.test.decorators import *
10 from lldbsuite.test.lldbtest import *
11 from lldbsuite.test import lldbutil
14 class TestObjCClassMethod(TestBase):
16 mydir = TestBase.compute_mydir(__file__)
19 # Call super's setUp().
21 # Find the line numbers to break inside main().
22 self.main_source = "test.m"
23 self.break_line = line_number(
24 self.main_source, '// Set breakpoint here.')
27 @add_test_categories(['pyapi'])
28 def test_with_python_api(self):
29 """Test calling functions in class methods."""
31 exe = os.path.join(os.getcwd(), "a.out")
33 target = self.dbg.CreateTarget(exe)
34 self.assertTrue(target, VALID_TARGET)
36 bpt = target.BreakpointCreateByLocation(
37 self.main_source, self.break_line)
38 self.assertTrue(bpt, VALID_BREAKPOINT)
40 # Now launch the process, and do not stop at entry point.
41 process = target.LaunchSimple(
42 None, None, self.get_process_working_directory())
44 self.assertTrue(process, PROCESS_IS_VALID)
46 # The stop reason of the thread should be breakpoint.
47 thread_list = lldbutil.get_threads_stopped_at_breakpoint(process, bpt)
49 # Make sure we stopped at the first breakpoint.
51 len(thread_list) != 0,
52 "No thread stopped at our breakpoint.")
53 self.assertTrue(len(thread_list) == 1,
54 "More than one thread stopped at our breakpoint.")
56 frame = thread_list[0].GetFrameAtIndex(0)
57 self.assertTrue(frame, "Got a valid frame 0 frame.")
59 # Now make sure we can call a method that returns a struct without
61 cmd_value = frame.EvaluateExpression("[provider getRange]")
62 self.assertTrue(cmd_value.IsValid())