blob: 70cb513f9b7f13a2d71b35046432257e0d215eff [file] [log] [blame]
Sean Callananfc89c142011-11-01 23:38:03 +00001"""Test calling functions in class methods."""
2
Zachary Turner77db4a82015-10-22 20:06:20 +00003import lldb_shared
4
Sean Callananfc89c142011-11-01 23:38:03 +00005import os, time
Sean Callananfc89c142011-11-01 23:38:03 +00006import lldb
7import lldbutil
8from lldbtest import *
9
Johnny Chen14c62c82011-11-17 18:47:38 +000010class TestObjCClassMethod(TestBase):
Sean Callananfc89c142011-11-01 23:38:03 +000011
Greg Clayton4570d3e2013-12-10 23:19:29 +000012 mydir = TestBase.compute_mydir(__file__)
Sean Callananfc89c142011-11-01 23:38:03 +000013
Sean Callananfc89c142011-11-01 23:38:03 +000014 def setUp(self):
15 # Call super's setUp().
16 TestBase.setUp(self)
17 # Find the line numbers to break inside main().
18 self.main_source = "class.m"
19 self.break_line = line_number(self.main_source, '// Set breakpoint here.')
20
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000021 @skipUnlessDarwin
22 @expectedFailurei386
23 @python_api_test
Sean Callananfc89c142011-11-01 23:38:03 +000024 #rdar://problem/9745789 "expression" can't call functions in class methods
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000025 def test_with_python_api(self):
26 """Test calling functions in class methods."""
27 self.build()
Sean Callananfc89c142011-11-01 23:38:03 +000028 exe = os.path.join(os.getcwd(), "a.out")
29
30 target = self.dbg.CreateTarget(exe)
31 self.assertTrue(target, VALID_TARGET)
32
33 bpt = target.BreakpointCreateByLocation(self.main_source, self.break_line)
34 self.assertTrue(bpt, VALID_BREAKPOINT)
35
36 # Now launch the process, and do not stop at entry point.
Greg Claytonc6947512013-12-13 19:18:59 +000037 process = target.LaunchSimple (None, None, self.get_process_working_directory())
Sean Callananfc89c142011-11-01 23:38:03 +000038
39 self.assertTrue(process, PROCESS_IS_VALID)
40
41 # The stop reason of the thread should be breakpoint.
42 thread_list = lldbutil.get_threads_stopped_at_breakpoint (process, bpt)
43
44 # Make sure we stopped at the first breakpoint.
45 self.assertTrue (len(thread_list) != 0, "No thread stopped at our breakpoint.")
46 self.assertTrue (len(thread_list) == 1, "More than one thread stopped at our breakpoint.")
47
48 # Now make sure we can call a function in the class method we've stopped in.
49 frame = thread_list[0].GetFrameAtIndex(0)
50 self.assertTrue (frame, "Got a valid frame 0 frame.")
51
52 cmd_value = frame.EvaluateExpression ("(int)[Foo doSomethingWithString:@\"Hello\"]")
53 self.assertTrue (cmd_value.IsValid())
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000054 self.assertTrue (cmd_value.GetValueAsUnsigned() == 5)