1
"""Test calling functions in static methods with a stripped binary."""
9
class TestObjCStaticMethodStripped(TestBase):
11
mydir = os.path.join("lang", "objc", "objc-static-method-stripped")
13
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
15
#<rdar://problem/12042992>
17
def test_with_dsym_and_python_api(self):
18
"""Test calling functions in static methods with a stripped binary."""
19
if self.getArchitecture() == 'i386':
20
self.skipTest("requires modern objc runtime")
22
self.objc_static_method_stripped()
25
# Call super's setUp().
27
# Find the line numbers to break inside main().
28
self.main_source = "static.m"
29
self.break_line = line_number(self.main_source, '// Set breakpoint here.')
31
#<rdar://problem/12042992>
32
def objc_static_method_stripped(self):
33
"""Test calling functions in static methods with a stripped binary."""
34
exe = os.path.join(os.getcwd(), "a.out.stripped")
36
target = self.dbg.CreateTarget(exe)
37
self.assertTrue(target, VALID_TARGET)
39
bpt = target.BreakpointCreateByLocation(self.main_source, self.break_line)
40
self.assertTrue(bpt, VALID_BREAKPOINT)
42
# Now launch the process, and do not stop at entry point.
43
process = target.LaunchSimple (None, None, os.getcwd())
45
self.assertTrue(process, PROCESS_IS_VALID)
47
# The stop reason of the thread should be breakpoint.
48
thread_list = lldbutil.get_threads_stopped_at_breakpoint (process, bpt)
50
# Make sure we stopped at the first breakpoint.
51
self.assertTrue (len(thread_list) != 0, "No thread stopped at our breakpoint.")
52
self.assertTrue (len(thread_list) == 1, "More than one thread stopped at our breakpoint.")
54
# Now make sure we can call a function in the static method we've stopped in.
55
frame = thread_list[0].GetFrameAtIndex(0)
56
self.assertTrue (frame, "Got a valid frame 0 frame.")
58
cmd_value = frame.EvaluateExpression ("(char *) sel_getName (_cmd)")
59
self.assertTrue (cmd_value.IsValid())
60
sel_name = cmd_value.GetSummary()
61
self.assertTrue (sel_name == "\"doSomethingWithString:\"", "Got the right value for the selector as string.")
63
cmd_value = frame.EvaluateExpression ("[Foo doSomethingElseWithString:string]")
64
self.assertTrue (cmd_value.IsValid())
65
string_length = cmd_value.GetValueAsUnsigned()
66
self.assertTrue (string_length == 27, "Got the right value from another class method on the same class.")
68
if __name__ == '__main__':
70
lldb.SBDebugger.Initialize()
71
atexit.register(lambda: lldb.SBDebugger.Terminate())