]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/lang/objc/foundation/TestRuntimeTypes.py
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / lang / objc / foundation / TestRuntimeTypes.py
1 """
2 Test that Objective-C methods from the runtime work correctly.
3 """
4
5 from __future__ import print_function
6
7
8 import os
9 import time
10 import lldb
11 from lldbsuite.test.decorators import *
12 from lldbsuite.test.lldbtest import *
13 from lldbsuite.test import lldbutil
14
15
16 @skipUnlessDarwin
17 class RuntimeTypesTestCase(TestBase):
18
19     mydir = TestBase.compute_mydir(__file__)
20
21     @expectedFailureAll(
22         oslist=["macosx"],
23         debug_info="gmodules",
24         bugnumber="llvm.org/pr27862")
25     def test_break(self):
26         """Test setting objc breakpoints using '_regexp-break' and 'breakpoint set'."""
27         if self.getArchitecture() != 'x86_64':
28             self.skipTest("This only applies to the v2 runtime")
29
30         self.build()
31         exe = os.path.join(os.getcwd(), "a.out")
32         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
33
34         # Stop at -[MyString description].
35         lldbutil.run_break_set_by_symbol(
36             self,
37             '-[MyString description]',
38             num_expected_locations=1,
39             sym_exact=True)
40
41         self.runCmd("run", RUN_SUCCEEDED)
42
43         # The backtrace should show we stop at -[MyString description].
44         self.expect("thread backtrace", "Stop at -[MyString description]",
45                     substrs=["a.out`-[MyString description]"])
46
47         # Use runtime information about NSString.
48
49         # The length property should be usable.
50         self.expect("expression str.length", VARIABLES_DISPLAYED_CORRECTLY,
51                     patterns=[r"(\(unsigned long long\))|\(NSUInteger\)"])
52
53         # Static methods on NSString should work.
54         self.expect(
55             "expr [NSString stringWithCString:\"foo\" encoding:1]",
56             VALID_TYPE,
57             substrs=[
58                 "(id)",
59                 "$1"])
60
61         self.expect("po $1", VARIABLES_DISPLAYED_CORRECTLY,
62                     substrs=["foo"])