1 """Test calling functions in static methods with a stripped binary."""
6 from lldbsuite.test.decorators import *
7 from lldbsuite.test.lldbtest import *
8 from lldbsuite.test import lldbutil
11 class TestObjCStaticMethodStripped(TestBase):
13 mydir = TestBase.compute_mydir(__file__)
16 # Call super's setUp().
18 # Find the line numbers to break inside main().
19 self.main_source = "static.m"
20 self.break_line = line_number(
21 self.main_source, '// Set breakpoint here.')
24 @add_test_categories(['pyapi'])
26 debug_info=no_match("dsym"),
27 bugnumber="This test requires a stripped binary and a dSYM")
28 #<rdar://problem/12042992>
29 def test_with_python_api(self):
30 """Test calling functions in static methods with a stripped binary."""
31 if self.getArchitecture() == 'i386':
32 self.skipTest("requires modern objc runtime")
34 exe = self.getBuildArtifact("a.out")
36 target = self.dbg.CreateTarget(exe)
37 self.assertTrue(target, VALID_TARGET)
39 bpt = target.BreakpointCreateByLocation(
40 self.main_source, self.break_line)
41 self.assertTrue(bpt, VALID_BREAKPOINT)
43 # Now launch the process, and do not stop at entry point.
44 process = target.LaunchSimple(
45 None, None, self.get_process_working_directory())
47 self.assertTrue(process, PROCESS_IS_VALID)
49 # The stop reason of the thread should be breakpoint.
50 thread_list = lldbutil.get_threads_stopped_at_breakpoint(process, bpt)
52 # Make sure we stopped at the first breakpoint.
54 len(thread_list) != 0,
55 "No thread stopped at our breakpoint.")
56 self.assertTrue(len(thread_list) == 1,
57 "More than one thread stopped at our breakpoint.")
59 # Now make sure we can call a function in the static method we've
61 frame = thread_list[0].GetFrameAtIndex(0)
62 self.assertTrue(frame, "Got a valid frame 0 frame.")
64 cmd_value = frame.EvaluateExpression("(char *) sel_getName (_cmd)")
65 self.assertTrue(cmd_value.IsValid())
66 sel_name = cmd_value.GetSummary()
68 sel_name == "\"doSomethingWithString:\"",
69 "Got the right value for the selector as string.")
71 cmd_value = frame.EvaluateExpression(
72 "[Foo doSomethingElseWithString:string]")
73 self.assertTrue(cmd_value.IsValid())
74 string_length = cmd_value.GetValueAsUnsigned()
77 "Got the right value from another class method on the same class.")