]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/lang/objc/objc-ivar-stripped/TestObjCIvarStripped.py
Vendor import of lldb trunk r256945:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / lang / objc / objc-ivar-stripped / TestObjCIvarStripped.py
1 """Test printing ObjC objects that use unbacked properties - so that the static ivar offsets are incorrect."""
2
3 from __future__ import print_function
4
5
6
7 import os, time
8 import lldb
9 from lldbsuite.test.lldbtest import *
10 import lldbsuite.test.lldbutil as lldbutil
11
12 class TestObjCIvarStripped(TestBase):
13
14     mydir = TestBase.compute_mydir(__file__)
15
16     def setUp(self):
17         # Call super's setUp().
18         TestBase.setUp(self)
19         # Find the line numbers to break inside main().
20         self.main_source = "main.m"
21         self.stop_line = line_number(self.main_source, '// Set breakpoint here.')
22
23     @skipUnlessDarwin
24     @skipIfDwarf    # This test requires a stripped binary and a dSYM
25     @skipIfDWO      # This test requires a stripped binary and a dSYM
26     @add_test_categories(['pyapi'])
27     def test_with_python_api(self):
28         """Test that we can find stripped Objective-C ivars in the runtime"""
29         self.build()
30         exe = os.path.join(os.getcwd(), "a.out.stripped")
31
32         target = self.dbg.CreateTarget(exe)
33         self.assertTrue(target, VALID_TARGET)
34
35         self.dbg.HandleCommand("add-dsym a.out.dSYM")
36
37         breakpoint = target.BreakpointCreateByLocation(self.main_source, self.stop_line)
38         self.assertTrue(breakpoint.IsValid() and breakpoint.GetNumLocations() > 0, VALID_BREAKPOINT)
39
40         process = target.LaunchSimple (None, None, self.get_process_working_directory())
41         self.assertTrue (process, "Created a process.")
42         self.assertTrue (process.GetState() == lldb.eStateStopped, "Stopped it too.")
43
44         thread_list = lldbutil.get_threads_stopped_at_breakpoint (process, breakpoint)
45         self.assertTrue (len(thread_list) == 1)
46         thread = thread_list[0]
47         
48         frame = thread.GetFrameAtIndex(0)
49         self.assertTrue (frame, "frame 0 is valid")
50         
51         # Test the expression for mc->_foo
52
53         error = lldb.SBError()
54
55         ivar = frame.EvaluateExpression ("(mc->_foo)")
56         self.assertTrue(ivar, "Got result for mc->_foo")
57         ivar_value = ivar.GetValueAsSigned (error)
58         self.assertTrue (error.Success())
59         self.assertTrue (ivar_value == 3)