1 """Test calling functions in static methods."""
5 from lldbsuite
.test
.decorators
import *
6 from lldbsuite
.test
.lldbtest
import *
7 from lldbsuite
.test
import lldbutil
10 class TestObjCStaticMethod(TestBase
):
12 # Call super's setUp().
14 # Find the line numbers to break inside main().
15 self
.main_source
= "static.m"
16 self
.break_line
= line_number(self
.main_source
, "// Set breakpoint here.")
18 @add_test_categories(["pyapi"])
19 # <rdar://problem/9745789> "expression" can't call functions in class methods
20 def test_with_python_api(self
):
21 """Test calling functions in static methods."""
23 exe
= self
.getBuildArtifact("a.out")
25 target
= self
.dbg
.CreateTarget(exe
)
26 self
.assertTrue(target
, VALID_TARGET
)
28 bpt
= target
.BreakpointCreateByLocation(self
.main_source
, self
.break_line
)
29 self
.assertTrue(bpt
, VALID_BREAKPOINT
)
31 # Now launch the process, and do not stop at entry point.
32 process
= target
.LaunchSimple(None, None, self
.get_process_working_directory())
34 self
.assertTrue(process
, PROCESS_IS_VALID
)
36 # The stop reason of the thread should be breakpoint.
37 thread_list
= lldbutil
.get_threads_stopped_at_breakpoint(process
, bpt
)
39 # Make sure we stopped at the first breakpoint.
40 self
.assertNotEqual(len(thread_list
), 0, "No thread stopped at our breakpoint.")
42 len(thread_list
), 1, "More than one thread stopped at our breakpoint."
45 # Now make sure we can call a function in the static method we've
47 frame
= thread_list
[0].GetFrameAtIndex(0)
48 self
.assertTrue(frame
, "Got a valid frame 0 frame.")
50 cmd_value
= frame
.EvaluateExpression("(char *) sel_getName (_cmd)")
51 self
.assertTrue(cmd_value
.IsValid())
52 sel_name
= cmd_value
.GetSummary()
55 '"doSomethingWithString:"',
56 "Got the right value for the selector as string.",
59 cmd_value
= frame
.EvaluateExpression("[self doSomethingElseWithString:string]")
60 self
.assertTrue(cmd_value
.IsValid())
61 string_length
= cmd_value
.GetValueAsUnsigned()
65 "Got the right value from another class method on the same class.",