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