Home | History | Annotate | Download | only in data-formatter-objc
      1 # encoding: utf-8
      2 """
      3 Test lldb data formatter subsystem.
      4 """
      5 
      6 import os, time
      7 import unittest2
      8 import lldb
      9 from lldbtest import *
     10 import datetime
     11 import lldbutil
     12 
     13 class ObjCDataFormatterTestCase(TestBase):
     14 
     15     mydir = os.path.join("functionalities", "data-formatter", "data-formatter-objc")
     16 
     17     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
     18     @dsym_test
     19     def test_plain_objc_with_dsym_and_run_command(self):
     20         """Test basic ObjC formatting behavior."""
     21         self.buildDsym()
     22         self.plain_data_formatter_commands()
     23 
     24     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
     25     @dwarf_test
     26     def test_plain_objc_with_dwarf_and_run_command(self):
     27         """Test basic ObjC formatting behavior."""
     28         self.buildDwarf()
     29         self.plain_data_formatter_commands()
     30 
     31     def appkit_tester_impl(self,builder,commands):
     32         builder()
     33         self.appkit_common_data_formatters_command()
     34         commands()
     35 
     36     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
     37     @dsym_test
     38     def test_nsnumber_with_dsym_and_run_command(self):
     39         """Test formatters for NSNumber."""
     40         self.appkit_tester_impl(self.buildDsym,self.nsnumber_data_formatter_commands)
     41 
     42     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
     43     @dwarf_test
     44     def test_nsnumber_with_dwarf_and_run_command(self):
     45         """Test formatters for NSNumber."""
     46         self.appkit_tester_impl(self.buildDwarf,self.nsnumber_data_formatter_commands)
     47 
     48 
     49     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
     50     @dsym_test
     51     def test_nsstring_with_dsym_and_run_command(self):
     52         """Test formatters for NSString."""
     53         self.appkit_tester_impl(self.buildDsym,self.nsstring_data_formatter_commands)
     54 
     55     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
     56     @dwarf_test
     57     def test_nsstring_with_dwarf_and_run_command(self):
     58         """Test formatters for NSString."""
     59         self.appkit_tester_impl(self.buildDwarf,self.nsstring_data_formatter_commands)
     60 
     61 
     62     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
     63     @dsym_test
     64     def test_nscontainers_with_dsym_and_run_command(self):
     65         """Test formatters for NS container classes."""
     66         self.appkit_tester_impl(self.buildDsym,self.nscontainers_data_formatter_commands)
     67 
     68     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
     69     @dwarf_test
     70     def test_nscontainers_with_dwarf_and_run_command(self):
     71         """Test formatters for  NS container classes."""
     72         self.appkit_tester_impl(self.buildDwarf,self.nscontainers_data_formatter_commands)
     73 
     74 
     75     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
     76     @dsym_test
     77     def test_nsdata_with_dsym_and_run_command(self):
     78         """Test formatters for NSData."""
     79         self.appkit_tester_impl(self.buildDsym,self.nsdata_data_formatter_commands)
     80 
     81     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
     82     @dwarf_test
     83     def test_nsdata_with_dwarf_and_run_command(self):
     84         """Test formatters for  NSData."""
     85         self.appkit_tester_impl(self.buildDwarf,self.nsdata_data_formatter_commands)
     86 
     87 
     88     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
     89     @dsym_test
     90     def test_nsurl_with_dsym_and_run_command(self):
     91         """Test formatters for NSURL."""
     92         self.appkit_tester_impl(self.buildDsym,self.nsurl_data_formatter_commands)
     93 
     94     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
     95     @dwarf_test
     96     def test_nsurl_with_dwarf_and_run_command(self):
     97         """Test formatters for NSURL."""
     98         self.appkit_tester_impl(self.buildDwarf,self.nsurl_data_formatter_commands)
     99 
    100 
    101     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
    102     @dsym_test
    103     def test_nserror_with_dsym_and_run_command(self):
    104         """Test formatters for NSError."""
    105         self.appkit_tester_impl(self.buildDsym,self.nserror_data_formatter_commands)
    106 
    107     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
    108     @dwarf_test
    109     def test_nserror_with_dwarf_and_run_command(self):
    110         """Test formatters for NSError."""
    111         self.appkit_tester_impl(self.buildDwarf,self.nserror_data_formatter_commands)
    112 
    113 
    114     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
    115     @dsym_test
    116     def test_nsbundle_with_dsym_and_run_command(self):
    117         """Test formatters for NSBundle."""
    118         self.appkit_tester_impl(self.buildDsym,self.nsbundle_data_formatter_commands)
    119 
    120     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
    121     @dwarf_test
    122     def test_nsbundle_with_dwarf_and_run_command(self):
    123         """Test formatters for NSBundle."""
    124         self.appkit_tester_impl(self.buildDwarf,self.nsbundle_data_formatter_commands)
    125 
    126 
    127     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
    128     @dsym_test
    129     def test_nsexception_with_dsym_and_run_command(self):
    130         """Test formatters for NSException."""
    131         self.appkit_tester_impl(self.buildDsym,self.nsexception_data_formatter_commands)
    132 
    133     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
    134     @dwarf_test
    135     def test_nsexception_with_dwarf_and_run_command(self):
    136         """Test formatters for NSException."""
    137         self.appkit_tester_impl(self.buildDwarf,self.nsexception_data_formatter_commands)
    138 
    139 
    140     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
    141     @dsym_test
    142     def test_nsmisc_with_dsym_and_run_command(self):
    143         """Test formatters for misc NS classes."""
    144         self.appkit_tester_impl(self.buildDsym,self.nsmisc_data_formatter_commands)
    145 
    146     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
    147     @dwarf_test
    148     def test_nsmisc_with_dwarf_and_run_command(self):
    149         """Test formatters for misc NS classes."""
    150         self.appkit_tester_impl(self.buildDwarf,self.nsmisc_data_formatter_commands)
    151 
    152 
    153     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
    154     @dsym_test
    155     def test_nsdate_with_dsym_and_run_command(self):
    156         """Test formatters for NSDate."""
    157         self.appkit_tester_impl(self.buildDsym,self.nsdate_data_formatter_commands)
    158 
    159     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
    160     @dwarf_test
    161     def test_nsdate_with_dwarf_and_run_command(self):
    162         """Test formatters for NSDate."""
    163         self.appkit_tester_impl(self.buildDwarf,self.nsdate_data_formatter_commands)
    164 
    165 
    166     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
    167     @dsym_test
    168     def test_coreframeworks_with_dsym_and_run_command(self):
    169         """Test formatters for Core OSX frameworks."""
    170         self.buildDsym()
    171         self.cf_data_formatter_commands()
    172 
    173     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
    174     @dwarf_test
    175     def test_coreframeworks_with_dwarf_and_run_command(self):
    176         """Test formatters for Core OSX frameworks."""
    177         self.buildDwarf()
    178         self.cf_data_formatter_commands()
    179 
    180     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
    181     @dsym_test
    182     def test_kvo_with_dsym_and_run_command(self):
    183         """Test the behavior of formatters when KVO is in use."""
    184         self.buildDsym()
    185         self.kvo_data_formatter_commands()
    186 
    187     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
    188     @dwarf_test
    189     def test_kvo_with_dwarf_and_run_command(self):
    190         """Test the behavior of formatters when KVO is in use."""
    191         self.buildDwarf()
    192         self.kvo_data_formatter_commands()
    193 
    194     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
    195     @dsym_test
    196     def test_rdar11106605_with_dsym_and_run_command(self):
    197         """Check that Unicode characters come out of CFString summary correctly."""
    198         self.buildDsym()
    199         self.rdar11106605_commands()
    200 
    201     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
    202     @dwarf_test
    203     def test_rdar11106605_with_dwarf_and_run_command(self):
    204         """Check that Unicode characters come out of CFString summary correctly."""
    205         self.buildDwarf()
    206         self.rdar11106605_commands()
    207 
    208     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
    209     @dsym_test
    210     def test_expr_with_dsym_and_run_command(self):
    211         """Test common cases of expression parser <--> formatters interaction."""
    212         self.buildDsym()
    213         self.expr_objc_data_formatter_commands()
    214 
    215     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
    216     @dwarf_test
    217     def test_expr_with_dwarf_and_run_command(self):
    218         """Test common cases of expression parser <--> formatters interaction."""
    219         self.buildDwarf()
    220         self.expr_objc_data_formatter_commands()
    221 
    222     def setUp(self):
    223         # Call super's setUp().
    224         TestBase.setUp(self)
    225         # Find the line number to break at.
    226         self.line = line_number('main.m', '// Set break point at this line.')
    227 
    228     def rdar11106605_commands(self):
    229         """Check that Unicode characters come out of CFString summary correctly."""
    230         self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
    231 
    232         lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
    233 
    234         self.runCmd("run", RUN_SUCCEEDED)
    235 
    236         # The stop reason of the thread should be breakpoint.
    237         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
    238             substrs = ['stopped',
    239                        'stop reason = breakpoint'])
    240 
    241         # This is the function to remove the custom formats in order to have a
    242         # clean slate for the next test case.
    243         def cleanup():
    244             self.runCmd('type format clear', check=False)
    245             self.runCmd('type summary clear', check=False)
    246             self.runCmd('type synth clear', check=False)
    247 
    248 
    249         # Execute the cleanup function during test case tear down.
    250         self.addTearDownHook(cleanup)
    251 
    252         self.expect('frame variable italian', substrs = ['L\'Italia  una Repubblica democratica, fondata sul lavoro. La sovranit appartiene al popolo, che la esercita nelle forme e nei limiti della Costituzione.'])
    253         self.expect('frame variable french', substrs = ['Que veut cette horde d\'esclaves, De tratres, de rois conjurs?'])
    254         self.expect('frame variable german', substrs = ['ber-Ich und aus den Ansprchen der sozialen Umwelt'])
    255         self.expect('frame variable japanese', substrs = [''])
    256         self.expect('frame variable hebrew', substrs = [' '])
    257 
    258 
    259     def plain_data_formatter_commands(self):
    260         """Test basic ObjC formatting behavior."""
    261         self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
    262 
    263         lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
    264 
    265         self.runCmd("run", RUN_SUCCEEDED)
    266 
    267         # The stop reason of the thread should be breakpoint.
    268         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
    269             substrs = ['stopped',
    270                        'stop reason = breakpoint'])
    271 
    272         # This is the function to remove the custom formats in order to have a
    273         # clean slate for the next test case.
    274         def cleanup():
    275             self.runCmd('type format clear', check=False)
    276             self.runCmd('type summary clear', check=False)
    277             self.runCmd('type synth clear', check=False)
    278 
    279         # Execute the cleanup function during test case tear down.
    280         self.addTearDownHook(cleanup)
    281 
    282         self.runCmd("type summary add --summary-string \"${var%@}\" MyClass")
    283 
    284         self.expect("frame variable object2",
    285             substrs = ['MyOtherClass']);
    286         
    287         self.expect("frame variable *object2",
    288             substrs = ['MyOtherClass']);
    289 
    290         # Now let's delete the 'MyClass' custom summary.
    291         self.runCmd("type summary delete MyClass")
    292 
    293         # The type format list should not show 'MyClass' at this point.
    294         self.expect("type summary list", matching=False,
    295             substrs = ['MyClass'])
    296 
    297         self.runCmd("type summary add --summary-string \"a test\" MyClass")
    298         
    299         self.expect("frame variable *object2",
    300                     substrs = ['*object2 = {',
    301                                'MyClass = a test',
    302                                'backup = ']);
    303         
    304         self.expect("frame variable object2", matching=False,
    305                     substrs = ['a test']);
    306         
    307         self.expect("frame variable object",
    308                     substrs = ['a test']);
    309         
    310         self.expect("frame variable *object",
    311                     substrs = ['a test']);
    312 
    313         self.expect('frame variable myclass',
    314                     substrs = ['(Class) myclass = NSValue'])
    315         self.expect('frame variable myclass2',
    316                     substrs = ['(Class) myclass2 = __NSCFConstantString'])
    317         self.expect('frame variable myclass3',
    318                     substrs = ['(Class) myclass3 = Molecule'])
    319         self.expect('frame variable myclass4',
    320                     substrs = ['(Class) myclass4 = NSMutableArray'])
    321         self.expect('frame variable myclass5',
    322                     substrs = ['(Class) myclass5 = nil'])
    323 
    324     def appkit_common_data_formatters_command(self):
    325         """Test formatters for AppKit classes."""
    326         self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
    327 
    328         lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
    329 
    330         self.runCmd("run", RUN_SUCCEEDED)
    331 
    332         # The stop reason of the thread should be breakpoint.
    333         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
    334             substrs = ['stopped',
    335                        'stop reason = breakpoint'])
    336 
    337         # This is the function to remove the custom formats in order to have a
    338         # clean slate for the next test case.
    339         def cleanup():
    340             self.runCmd('type format clear', check=False)
    341             self.runCmd('type summary clear', check=False)
    342             self.runCmd('type synth clear', check=False)
    343 
    344         # Execute the cleanup function during test case tear down.
    345         self.addTearDownHook(cleanup)
    346     
    347     def nsnumber_data_formatter_commands(self):
    348         # Now enable AppKit and check we are displaying Cocoa classes correctly
    349         self.expect('frame variable num1 num2 num3 num4 num5 num6 num7 num8_Y num8_N num9',
    350                     substrs = ['(NSNumber *) num1 = ',' (int)5',
    351                     '(NSNumber *) num2 = ',' (float)3.1',
    352                     '(NSNumber *) num3 = ',' (double)3.14',
    353                     '(NSNumber *) num4 = ',' (long)-2',
    354                     '(NSNumber *) num5 = ',' (char)65',
    355                     '(NSNumber *) num6 = ',' (long)255',
    356                     '(NSNumber *) num7 = ','2000000',
    357                     '(NSNumber *) num8_Y = ',' @"1"',
    358                     '(NSNumber *) num8_N = ',' @"0"',
    359                     '(NSNumber *) num9 = ',' (short)-31616'])
    360 
    361         self.expect('frame variable decimal_one',
    362                     substrs = ['(NSDecimalNumber *) decimal_one = 0x','1'])
    363 
    364         self.expect('frame variable num_at1 num_at2 num_at3 num_at4',
    365                     substrs = ['(NSNumber *) num_at1 = ',' (int)12',
    366                     '(NSNumber *) num_at2 = ',' (int)-12',
    367                     '(NSNumber *) num_at3 = ',' (double)12.5',
    368                     '(NSNumber *) num_at4 = ',' (double)-12.5'])
    369 
    370     def nsstring_data_formatter_commands(self):
    371         self.expect('frame variable str0 str1 str2 str3 str4 str5 str6 str8 str9 str10 str11 label1 label2 processName str12',
    372                     substrs = ['(NSString *) str1 = ',' @"A rather short ASCII NSString object is here"',
    373                     '(NSString *) str0 = ',' @"255"',
    374                     '(NSString *) str1 = ',' @"A rather short ASCII NSString object is here"',
    375                     '(NSString *) str2 = ',' @"A rather short UTF8 NSString object is here"',
    376                     '(NSString *) str3 = ',' @"A string made with the at sign is here"',
    377                     '(NSString *) str4 = ',' @"This is string number 4 right here"',
    378                     '(NSString *) str5 = ',' @"{{1, 1}, {5, 5}}"',
    379                     '(NSString *) str6 = ',' @"1ST"',
    380                     '(NSString *) str8 = ',' @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime',
    381                     '(NSString *) str9 = ',' @"a very much boring task to write a string this way!!',
    382                     '(NSString *) str10 = ',' @"This is a Unicode string  number 4 right here"',
    383                     '(NSString *) str11 = ',' @"__NSCFString"',
    384                     '(NSString *) label1 = ',' @"Process Name: "',
    385                     '(NSString *) label2 = ',' @"Process Id: "',
    386                     '(NSString *) str12 = ',' @"Process Name:  a.out Process Id:'])
    387         self.expect('frame variable attrString mutableAttrString mutableGetConst',
    388                     substrs = ['(NSAttributedString *) attrString = ',' @"hello world from foo"',
    389                     '(NSAttributedString *) mutableAttrString = ',' @"hello world from foo"',
    390                     '(NSString *) mutableGetConst = ',' @"foo said this string needs to be very long so much longer than whatever other string has been seen ever before by anyone of the mankind that of course this is still not long enough given what foo our friend foo our lovely dearly friend foo desired of us so i am adding more stuff here for the sake of it and for the joy of our friend who is named guess what just foo. hence, dear friend foo, stay safe, your string is now  long enough to accommodate your testing need and I will make sure that if not we extend it with even more fuzzy random meaningless words pasted one after the other from a long tiresome friday evening spent working in my office. my office mate went home but I am still randomly typing just for the fun of seeing what happens of the length of a Mutable String in Cocoa if it goes beyond one byte.. so be it, dear foo"'])
    391 
    392         self.expect('expr -d run-target -- path',substrs = ['usr/blah/stuff'])
    393         self.expect('frame variable path',substrs = ['usr/blah/stuff'])
    394 
    395 
    396     def nscontainers_data_formatter_commands(self):
    397         self.expect('frame variable newArray newDictionary newMutableDictionary cfdict_ref mutable_dict_ref cfarray_ref mutable_array_ref',
    398                     substrs = ['(NSArray *) newArray = ','@"50 objects"',
    399                     '(NSDictionary *) newDictionary = ',' 12 key/value pairs',
    400                     '(NSDictionary *) newMutableDictionary = ',' 21 key/value pairs',
    401                     '(CFDictionaryRef) cfdict_ref = ','@"3 entries"',
    402                     '(CFMutableDictionaryRef) mutable_dict_ref = ','@"12 entries"',
    403                     '(CFArrayRef) cfarray_ref = ','@"3 objects"',
    404                     '(CFMutableArrayRef) mutable_array_ref = ','@"11 objects"'])
    405 
    406         self.expect('frame variable nscounted_set',
    407                     substrs = ['(NSCountedSet *) nscounted_set = ','5 objects'])
    408 
    409         self.expect('frame variable iset1 iset2 imset',
    410                     substrs = ['4 indexes','512 indexes','10 indexes'])
    411 
    412         self.expect('frame variable mutable_bag_ref cfbag_ref binheap_ref',
    413                     substrs = ['(CFMutableBagRef) mutable_bag_ref = ','@"17 values"',
    414                     '(CFBagRef) cfbag_ref = ','@"15 values"',
    415                     '(CFBinaryHeapRef) binheap_ref = ','@"21 items"'])
    416 
    417     def nsdata_data_formatter_commands(self):
    418         self.expect('frame variable immutableData mutableData data_ref mutable_data_ref mutable_string_ref',
    419                     substrs = ['(NSData *) immutableData = ',' 4 bytes',
    420                     '(NSData *) mutableData = ',' 14 bytes',
    421                     '(CFDataRef) data_ref = ','@"5 bytes"',
    422                     '(CFMutableDataRef) mutable_data_ref = ','@"5 bytes"',
    423                     '(CFMutableStringRef) mutable_string_ref = ',' @"Wish ya knew"'])
    424 
    425     def nsurl_data_formatter_commands(self):
    426         self.expect('frame variable cfurl_ref cfchildurl_ref cfgchildurl_ref',
    427                     substrs = ['(CFURLRef) cfurl_ref = ','@"http://www.foo.bar',
    428                     'cfchildurl_ref = ','@"page.html -- http://www.foo.bar',
    429                     '(CFURLRef) cfgchildurl_ref = ','@"?whatever -- http://www.foo.bar/page.html"'])
    430 
    431         self.expect('frame variable nsurl nsurl2 nsurl3',
    432                     substrs = ['(NSURL *) nsurl = ','@"http://www.foo.bar',
    433                     '(NSURL *) nsurl2 =','@"page.html -- http://www.foo.bar',
    434                     '(NSURL *) nsurl3 = ','@"?whatever -- http://www.foo.bar/page.html"'])
    435 
    436     def nserror_data_formatter_commands(self):
    437         self.expect('frame variable nserror',
    438                     substrs = ['domain: @"Foobar" - code: 12'])
    439 
    440         self.expect('frame variable nserror->_userInfo',
    441                     substrs = ['2 key/value pairs'])
    442 
    443         self.expect('frame variable nserror->_userInfo --ptr-depth 1 -d run-target',
    444                     substrs = ['@"a"','@"b"',"1","2"])
    445 
    446     def nsbundle_data_formatter_commands(self):
    447         self.expect('frame variable bundle_string bundle_url main_bundle',
    448                     substrs = ['(NSBundle *) bundle_string = ',' @"/System/Library/Frameworks/Accelerate.framework"',
    449                     '(NSBundle *) bundle_url = ',' @"/System/Library/Frameworks/Cocoa.framework"',
    450                     '(NSBundle *) main_bundle = ','test/functionalities/data-formatter/data-formatter-objc'])
    451 
    452     def nsexception_data_formatter_commands(self):
    453         self.expect('frame variable except0 except1 except2 except3',
    454                     substrs = ['(NSException *) except0 = ','name:@"TheGuyWhoHasNoName" reason:@"cuz it\'s funny"',
    455                     '(NSException *) except1 = ','name:@"TheGuyWhoHasNoName~1" reason:@"cuz it\'s funny"',
    456                     '(NSException *) except2 = ','name:@"TheGuyWhoHasNoName`2" reason:@"cuz it\'s funny"',
    457                     '(NSException *) except3 = ','name:@"TheGuyWhoHasNoName/3" reason:@"cuz it\'s funny"'])
    458 
    459     def nsmisc_data_formatter_commands(self):
    460         self.expect('frame variable localhost',
    461                     substrs = ['<NSHost ','> localhost ((','"127.0.0.1"'])
    462 
    463         self.expect('frame variable my_task',
    464                     substrs = ['<NS','Task: 0x'])
    465 
    466         self.expect('frame variable range_value',
    467                     substrs = ['NSRange: {4, 4}'])
    468 
    469         self.expect('frame variable port',
    470                     substrs = ['(NSMachPort *) port = ',' mach port: '])
    471 
    472     def nsdate_data_formatter_commands(self):
    473         self.expect('frame variable date1 date2',
    474                     substrs = ['1985-04','2011-01'])
    475 
    476         # this test might fail if we hit the breakpoint late on December 31st of some given year
    477         # and midnight comes between hitting the breakpoint and running this line of code
    478         # hopefully the output will be revealing enough in that case :-)
    479         now_year = str(datetime.datetime.now().year)
    480 
    481         self.expect('frame variable date3 date4',
    482                     substrs = [now_year,'1970'])
    483 
    484         self.expect('frame variable date1_abs date2_abs',
    485                     substrs = ['1985-04','2011-01'])
    486 
    487         self.expect('frame variable date3_abs date4_abs',
    488                     substrs = [now_year,'1970'])
    489 
    490         self.expect('frame variable cupertino home europe',
    491                     substrs = ['@"America/Los_Angeles"',
    492                     '@"Europe/Rome"',
    493                     '@"Europe/Paris"'])
    494 
    495         self.expect('frame variable cupertino_ns home_ns europe_ns',
    496                     substrs = ['@"America/Los_Angeles"',
    497                     '@"Europe/Rome"',
    498                     '@"Europe/Paris"'])
    499 
    500         self.expect('frame variable mut_bv',
    501                     substrs = ['(CFMutableBitVectorRef) mut_bv = ', '1110 0110 1011 0000 1101 1010 1000 1111 0011 0101 1101 0001 00'])
    502 
    503 
    504     def expr_objc_data_formatter_commands(self):
    505         """Test common cases of expression parser <--> formatters interaction."""
    506         self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
    507 
    508         lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
    509 
    510         self.runCmd("run", RUN_SUCCEEDED)
    511 
    512         # The stop reason of the thread should be breakpoint.
    513         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
    514             substrs = ['stopped',
    515                        'stop reason = breakpoint'])
    516 
    517         # This is the function to remove the custom formats in order to have a
    518         # clean slate for the next test case.
    519         def cleanup():
    520             self.runCmd('type format clear', check=False)
    521             self.runCmd('type summary clear', check=False)
    522             self.runCmd('type synth clear', check=False)
    523 
    524         # Execute the cleanup function during test case tear down.
    525         self.addTearDownHook(cleanup)
    526 
    527         # check that the formatters are able to deal safely and correctly
    528         # with ValueObjects that the expression parser returns
    529         self.expect('expression ((id)@"Hello")', matching=False,
    530                     substrs = ['Hello'])
    531 
    532         self.expect('expression -d run -- ((id)@"Hello")',
    533         substrs = ['Hello'])
    534 
    535         self.expect('expr -d run -- label1',
    536             substrs = ['Process Name'])
    537 
    538         self.expect('expr -d run -- @"Hello"',
    539             substrs = ['Hello'])
    540 
    541         self.expect('expr -d run --object-description -- @"Hello"',
    542             substrs = ['Hello'])
    543         self.expect('expr -d run --object-description -- @"Hello"', matching=False,
    544             substrs = ['@"Hello" Hello'])
    545 
    546 
    547     def cf_data_formatter_commands(self):
    548         """Test formatters for Core OSX frameworks."""
    549         self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
    550 
    551         lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
    552 
    553         self.runCmd("run", RUN_SUCCEEDED)
    554 
    555         # The stop reason of the thread should be breakpoint.
    556         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
    557             substrs = ['stopped',
    558                        'stop reason = breakpoint'])
    559 
    560         # This is the function to remove the custom formats in order to have a
    561         # clean slate for the next test case.
    562         def cleanup():
    563             self.runCmd('type format clear', check=False)
    564             self.runCmd('type summary clear', check=False)
    565             self.runCmd('type synth clear', check=False)
    566             self.runCmd('log timers disable', check=False)
    567 
    568 
    569         # Execute the cleanup function during test case tear down.
    570         self.addTearDownHook(cleanup)
    571 
    572         # check formatters for common Objective-C types
    573         self.runCmd("log timers enable")
    574         self.expect("frame variable",
    575              substrs = ['(CFGregorianUnits) cf_greg_units = 1 years, 3 months, 5 days, 12 hours, 5 minutes 7 seconds',
    576              '(CFRange) cf_range = location=4 length=4',
    577              '(NSPoint) ns_point = (x=4, y=4)',
    578              '(NSRange) ns_range = location=4, length=4',
    579              '(NSRect *) ns_rect_ptr = (x=1, y=1), (width=5, height=5)',
    580              '(NSRect) ns_rect = (x=1, y=1), (width=5, height=5)',
    581              '(NSRectArray) ns_rect_arr = ((x=1, y=1), (width=5, height=5)), ...',
    582              '(NSSize) ns_size = (width=5, height=7)',
    583              '(NSSize *) ns_size_ptr = (width=5, height=7)',
    584              '(CGSize) cg_size = (width=1, height=6)',
    585              '(CGPoint) cg_point = (x=2, y=7)',
    586              '(CGRect) cg_rect = origin=(x=1, y=2) size=(width=7, height=7)',
    587              '(RGBColor) rgb_color = red=3 green=56 blue=35',
    588              '(RGBColor *) rgb_color_ptr = red=3 green=56 blue=35',
    589              '(Rect) rect = (t=4, l=8, b=4, r=7)',
    590              '(Rect *) rect_ptr = (t=4, l=8, b=4, r=7)',
    591              '(Point) point = (v=7, h=12)',
    592              '(Point *) point_ptr = (v=7, h=12)',
    593              '(HIPoint) hi_point = (x=7, y=12)',
    594              '(HIRect) hi_rect = origin=(x=3, y=5) size=(width=4, height=6)',
    595              'name:@"TheGuyWhoHasNoName" reason:@"cuz it\'s funny"',
    596              '1985',
    597              'foo_selector_impl'])
    598         self.runCmd('log timers dump')
    599 
    600 
    601     def kvo_data_formatter_commands(self):
    602         """Test the behavior of formatters when KVO is in use."""
    603         self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
    604 
    605         lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
    606 
    607         self.runCmd("run", RUN_SUCCEEDED)
    608 
    609         # The stop reason of the thread should be breakpoint.
    610         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
    611             substrs = ['stopped',
    612                        'stop reason = breakpoint'])
    613 
    614         # This is the function to remove the custom formats in order to have a
    615         # clean slate for the next test case.
    616         def cleanup():
    617             self.runCmd('type format clear', check=False)
    618             self.runCmd('type summary clear', check=False)
    619             self.runCmd('type synth clear', check=False)
    620 
    621         # Execute the cleanup function during test case tear down.
    622         self.addTearDownHook(cleanup)
    623 
    624         # as long as KVO is implemented by subclassing, this test should succeed
    625         # we should be able to dynamically figure out that the KVO implementor class
    626         # is a subclass of Molecule, and use the appropriate summary for it
    627         self.runCmd("type summary add -s JustAMoleculeHere Molecule")
    628         self.expect('frame variable molecule', substrs = ['JustAMoleculeHere'])
    629         self.runCmd("next")
    630         self.expect("thread list",
    631             substrs = ['stopped',
    632                        'step over'])
    633         self.expect('frame variable molecule', substrs = ['JustAMoleculeHere'])
    634 
    635         self.runCmd("next")
    636         # check that NSMutableDictionary's formatter is not confused when dealing with a KVO'd dictionary
    637         self.expect('frame variable newMutableDictionary', substrs = ['(NSDictionary *) newMutableDictionary = ',' 21 key/value pairs'])
    638 
    639         lldbutil.run_break_set_by_regexp (self, 'setAtoms')
    640 
    641         self.runCmd("continue")
    642         self.expect("frame variable _cmd",substrs = ['setAtoms:'])
    643 
    644 if __name__ == '__main__':
    645     import atexit
    646     lldb.SBDebugger.Initialize()
    647     atexit.register(lambda: lldb.SBDebugger.Terminate())
    648     unittest2.main()
    649