1"""
2Test more expression command sequences with objective-c.
3"""
4
5
6
7import lldb
8from lldbsuite.test.decorators import *
9from lldbsuite.test.lldbtest import *
10from lldbsuite.test import lldbutil
11
12
13class FoundationTestCaseString(TestBase):
14
15    mydir = TestBase.compute_mydir(__file__)
16
17    def test_NSString_expr_commands(self):
18        """Test expression commands for NSString."""
19        self.build()
20        self.target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
21                self, '// Break here for NSString tests',
22                lldb.SBFileSpec('main.m', False))
23
24        # Test_NSString:
25        self.runCmd("thread backtrace")
26        self.expect("expression (int)[str length]",
27                    patterns=["\(int\) \$.* ="])
28        self.expect("expression (int)[str_id length]",
29                    patterns=["\(int\) \$.* ="])
30        self.expect("expression (id)[str description]",
31                    patterns=["\(id\) \$.* = 0x"])
32        self.expect("expression (id)[str_id description]",
33                    patterns=["\(id\) \$.* = 0x"])
34        self.expect("expression str.length")
35        self.expect('expression str = @"new"')
36        self.runCmd("image lookup -t NSString")
37        self.expect('expression str = (id)[NSString stringWithCString: "new"]')
38        self.runCmd("process continue")
39
40    @expectedFailureAll(archs=["i[3-6]86"], bugnumber="<rdar://problem/28814052>")
41    def test_MyString_dump_with_runtime(self):
42        """Test dump of a known Objective-C object by dereferencing it."""
43        self.build()
44        self.target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
45                self, '// Set break point at this line',
46                lldb.SBFileSpec('main.m', False))
47        self.expect(
48            "expression --show-types -- *my",
49            patterns=[
50                "\(MyString\) \$.* = ",
51                "\(MyBase\)"])
52        self.runCmd("process continue")
53