Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / lang / objc / objc-static-method-stripped / TestObjCStaticMethodStripped.py
blobdb575e60e1a1163484a86da6c5f706b87de9ecd5
1 """Test calling functions in static methods with a stripped binary."""
4 import lldb
5 from lldbsuite.test.decorators import *
6 from lldbsuite.test.lldbtest import *
7 from lldbsuite.test import lldbutil
10 class TestObjCStaticMethodStripped(TestBase):
11 def setUp(self):
12 # Call super's setUp().
13 TestBase.setUp(self)
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 @skipIf(
20 debug_info=no_match("dsym"),
21 bugnumber="This test requires a stripped binary and a dSYM",
23 # <rdar://problem/12042992>
24 def test_with_python_api(self):
25 """Test calling functions in static methods with a stripped binary."""
26 if self.getArchitecture() == "i386":
27 self.skipTest("requires modern objc runtime")
28 self.build()
29 exe = self.getBuildArtifact("a.out")
31 target = self.dbg.CreateTarget(exe)
32 self.assertTrue(target, VALID_TARGET)
34 bpt = target.BreakpointCreateByLocation(self.main_source, self.break_line)
35 self.assertTrue(bpt, VALID_BREAKPOINT)
37 # Now launch the process, and do not stop at entry point.
38 process = target.LaunchSimple(None, None, self.get_process_working_directory())
40 self.assertTrue(process, PROCESS_IS_VALID)
42 # The stop reason of the thread should be breakpoint.
43 thread_list = lldbutil.get_threads_stopped_at_breakpoint(process, bpt)
45 # Make sure we stopped at the first breakpoint.
46 self.assertNotEqual(len(thread_list), 0, "No thread stopped at our breakpoint.")
47 self.assertEquals(
48 len(thread_list), 1, "More than one thread stopped at our breakpoint."
51 # Now make sure we can call a function in the static method we've
52 # stopped in.
53 frame = thread_list[0].GetFrameAtIndex(0)
54 self.assertTrue(frame, "Got a valid frame 0 frame.")
56 cmd_value = frame.EvaluateExpression("(char *) sel_getName (_cmd)")
57 self.assertTrue(cmd_value.IsValid())
58 sel_name = cmd_value.GetSummary()
59 self.assertEqual(
60 sel_name,
61 '"doSomethingWithString:"',
62 "Got the right value for the selector as string.",
65 cmd_value = frame.EvaluateExpression("[Foo doSomethingElseWithString:string]")
66 self.assertTrue(cmd_value.IsValid())
67 string_length = cmd_value.GetValueAsUnsigned()
68 self.assertEqual(
69 string_length,
70 27,
71 "Got the right value from another class method on the same class.",