1# encoding: utf-8 2""" 3Test lldb data formatter subsystem. 4""" 5 6 7import lldb 8from lldbsuite.test.decorators import * 9from lldbsuite.test.lldbtest import * 10from lldbsuite.test import lldbutil 11 12from ObjCDataFormatterTestCase import ObjCDataFormatterTestCase 13 14 15class ObjCDataFormatterNSContainer(ObjCDataFormatterTestCase): 16 def test_nscontainers_with_run_command(self): 17 """Test formatters for NS container classes.""" 18 self.appkit_tester_impl(self.nscontainers_data_formatter_commands, False) 19 20 def nscontainers_data_formatter_commands(self): 21 self.runCmd("settings set target.prefer-dynamic-value no-dynamic-values") 22 23 self.expect( 24 "frame variable newArray nsDictionary newDictionary nscfDictionary cfDictionaryRef newMutableDictionary copyDictionary newMutableDictionaryRef cfarray_ref mutable_array_ref", 25 substrs=[ 26 "(NSArray *) newArray = ", 27 ' @"50 elements"', 28 "(NSDictionary *) nsDictionary = ", 29 " 2 key/value pairs", 30 "(NSDictionary *) newDictionary = ", 31 " 12 key/value pairs", 32 "(NSDictionary *) nscfDictionary = ", 33 " 4 key/value pairs", 34 "(CFDictionaryRef) cfDictionaryRef = ", 35 " 2 key/value pairs", 36 "(NSDictionary *) newMutableDictionary = ", 37 " 21 key/value pairs", 38 "(NSMutableDictionary *) copyDictionary = ", 39 " 21 key/value pairs", 40 "(CFMutableDictionaryRef) newMutableDictionaryRef = ", 41 " 21 key/value pairs", 42 "(CFArrayRef) cfarray_ref = ", 43 ' @"3 elements"', 44 "(CFMutableArrayRef) mutable_array_ref = ", 45 ' @"11 elements"', 46 ], 47 ) 48 49 self.expect( 50 "frame var -d run-target copyDictionary[10]", substrs=['@"bar9"', '@"foo"'] 51 ) 52 53 self.expect( 54 "frame variable -d run-target *nscfDictionary", 55 patterns=[ 56 "\(__NSCFDictionary\) \*nscfDictionary =", 57 'key = 0x.* @"foo"', 58 'value = 0x.* @"foo"', 59 'key = 0x.* @"bar"', 60 'value = 0x.* @"bar"', 61 'key = 0x.* @"baz"', 62 'value = 0x.* @"baz"', 63 'key = 0x.* @"quux"', 64 'value = 0x.* @"quux"', 65 ], 66 ) 67 68 self.expect( 69 "frame variable -d run-target *cfDictionaryRef", 70 patterns=[ 71 "\(const __CFDictionary\) \*cfDictionaryRef =", 72 'key = 0x.* @"foo"', 73 'value = 0x.* @"foo"', 74 'key = 0x.* @"bar"', 75 'value = 0x.* @"bar"', 76 ], 77 ) 78 79 self.expect( 80 "frame var nscfSet cfSetRef", 81 substrs=[ 82 "(NSSet *) nscfSet = ", 83 "2 elements", 84 "(CFSetRef) cfSetRef = ", 85 "2 elements", 86 ], 87 ) 88 89 self.expect( 90 "frame variable -d run-target *nscfSet", 91 patterns=[ 92 "\(__NSCFSet\) \*nscfSet =", 93 '\[0\] = 0x.* @".*"', 94 '\[1\] = 0x.* @".*"', 95 ], 96 ) 97 98 self.expect( 99 "frame variable -d run-target *cfSetRef", 100 patterns=[ 101 "\(const __CFSet\) \*cfSetRef =", 102 '\[0\] = 0x.* @".*"', 103 '\[1\] = 0x.* @".*"', 104 ], 105 ) 106 107 self.expect( 108 "frame variable iset1 iset2 imset", 109 substrs=["4 indexes", "512 indexes", "10 indexes"], 110 ) 111 112 self.expect( 113 "frame variable binheap_ref", 114 substrs=["(CFBinaryHeapRef) binheap_ref = ", '@"21 items"'], 115 ) 116 117 self.expect( 118 "expression -d run -- (NSArray*)[NSArray new]", substrs=['@"0 elements"'] 119 ) 120