Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / lang / objc / objc-ivar-stripped / TestObjCIvarStripped.py
blob128468d7add4146a7b605f57ba3f1c2b97553f20
1 """Test printing ObjC objects that use unbacked properties - so that the static ivar offsets are incorrect."""
4 import lldb
5 from lldbsuite.test.decorators import *
6 from lldbsuite.test.lldbtest import *
7 from lldbsuite.test import lldbutil
10 class TestObjCIvarStripped(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 = "main.m"
16 self.stop_line = line_number(self.main_source, "// Set breakpoint here.")
18 @skipIf(
19 debug_info=no_match("dsym"),
20 bugnumber="This test requires a stripped binary and a dSYM",
22 @add_test_categories(["pyapi"])
23 def test_with_python_api(self):
24 """Test that we can find stripped Objective-C ivars in the runtime"""
25 self.build()
26 exe = self.getBuildArtifact("a.out.stripped")
28 target = self.dbg.CreateTarget(exe)
29 self.assertTrue(target, VALID_TARGET)
31 self.dbg.HandleCommand("add-dsym " + self.getBuildArtifact("a.out.dSYM"))
33 breakpoint = target.BreakpointCreateByLocation(self.main_source, self.stop_line)
34 self.assertTrue(
35 breakpoint.IsValid() and breakpoint.GetNumLocations() > 0, VALID_BREAKPOINT
38 process = target.LaunchSimple(None, None, self.get_process_working_directory())
39 self.assertTrue(process, "Created a process.")
40 self.assertEqual(process.GetState(), lldb.eStateStopped, "Stopped it too.")
42 thread_list = lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint)
43 self.assertEquals(len(thread_list), 1)
44 thread = thread_list[0]
46 frame = thread.GetFrameAtIndex(0)
47 self.assertTrue(frame, "frame 0 is valid")
49 # Test the expression for mc->_foo
51 error = lldb.SBError()
53 ivar = frame.EvaluateExpression("(mc->_foo)")
54 self.assertTrue(ivar, "Got result for mc->_foo")
55 ivar_value = ivar.GetValueAsSigned(error)
56 self.assertSuccess(error)
57 self.assertEquals(ivar_value, 3)