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    def test_NSString_expr_commands(self):
16        """Test expression commands for NSString."""
17        self.build()
18        self.target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
19                self, '// Break here for NSString tests',
20                lldb.SBFileSpec('main.m', False))
21
22        # Test_NSString:
23        self.runCmd("thread backtrace")
24        self.expect("expression (int)[str length]",
25                    patterns=["\(int\) \$.* ="])
26        self.expect("expression (int)[str_id length]",
27                    patterns=["\(int\) \$.* ="])
28        self.expect("expression (id)[str description]",
29                    patterns=["\(id\) \$.* = 0x"])
30        self.expect("expression (id)[str_id description]",
31                    patterns=["\(id\) \$.* = 0x"])
32        self.expect("expression str.length")
33        self.expect('expression str = @"new"')
34        self.runCmd("image lookup -t NSString")
35        self.expect('expression str = (id)[NSString stringWithCString: "new"]')
36        self.runCmd("process continue")
37
38    @expectedFailureAll(archs=["i[3-6]86"], bugnumber="<rdar://problem/28814052>")
39    def test_MyString_dump_with_runtime(self):
40        """Test dump of a known Objective-C object by dereferencing it."""
41        self.build()
42        self.target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
43                self, '// Set break point at this line',
44                lldb.SBFileSpec('main.m', False))
45        self.expect(
46            "expression --show-types -- *my",
47            patterns=[
48                "\(MyString\) \$.* = ",
49                "\(MyBase\)"])
50        self.runCmd("process continue")
51