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