Changed several of the Cocoa formatters to match the output style that Xcode uses internally to provide summaries
This has been done for those summaries where the difference is only cosmetic (e.g. naming things as items instead of values, ...) The LLDB output style has been preserved when it provides more information (e.g. telling the type as well as the value of an NSNumber) Test cases have been updated to reflect the updated output style where necessary llvm-svn: 152592
This commit is contained in:
parent
b1e8a53e0b
commit
8c69c96dc9
|
@ -166,7 +166,8 @@ def CFArray_SummaryProvider (valobj,dict):
|
|||
if summary == None:
|
||||
summary = 'no valid array here'
|
||||
else:
|
||||
summary = str(summary) + (" objects" if summary > 1 else " object")
|
||||
# we format it like it were a CFString to make it look the same as the summary from Xcode
|
||||
summary = '@"' + str(summary) + (" objects" if summary > 1 else " object") + '"'
|
||||
return summary
|
||||
return ''
|
||||
|
||||
|
|
|
@ -120,9 +120,9 @@ def CFBag_SummaryProvider (valobj,dict):
|
|||
if provider.sys_params.is_64_bit:
|
||||
summary = summary & ~0x1fff000000000000
|
||||
if summary == 1:
|
||||
summary = '1 item'
|
||||
summary = '@"1 value"'
|
||||
else:
|
||||
summary = str(summary) + ' items'
|
||||
summary = '@"' + str(summary) + ' values"'
|
||||
return summary
|
||||
return ''
|
||||
|
||||
|
|
|
@ -114,9 +114,9 @@ def CFBinaryHeap_SummaryProvider (valobj,dict):
|
|||
if provider.sys_params.is_64_bit:
|
||||
summary = summary & ~0x1fff000000000000
|
||||
if summary == 1:
|
||||
return '1 item'
|
||||
return '@"1 item"'
|
||||
else:
|
||||
summary = str(summary) + ' items'
|
||||
summary = '@"' + str(summary) + ' items"'
|
||||
return summary
|
||||
return ''
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ def CFDictionary_SummaryProvider2 (valobj,dict):
|
|||
# needed on OSX Mountain Lion
|
||||
if provider.sys_params.is_64_bit:
|
||||
summary = summary & ~0x0f1f000000000000
|
||||
summary = str(summary) + (" key/value pairs" if summary > 1 else " key/value pair")
|
||||
summary = '@"' + str(summary) + (' entries"' if summary > 1 else ' entry"')
|
||||
return summary
|
||||
return ''
|
||||
|
||||
|
|
|
@ -111,5 +111,23 @@ def NSData_SummaryProvider (valobj,dict):
|
|||
return summary
|
||||
return ''
|
||||
|
||||
def NSData_SummaryProvider2 (valobj,dict):
|
||||
provider = GetSummary_Impl(valobj);
|
||||
if provider != None:
|
||||
try:
|
||||
summary = provider.length();
|
||||
except:
|
||||
summary = None
|
||||
if summary == None:
|
||||
summary = 'no valid data here'
|
||||
else:
|
||||
if summary == 1:
|
||||
summary = '@"1 byte"'
|
||||
else:
|
||||
summary = '@"' + str(summary) + ' bytes"'
|
||||
return summary
|
||||
return ''
|
||||
|
||||
def __lldb_init_module(debugger,dict):
|
||||
debugger.HandleCommand("type summary add -F NSData.NSData_SummaryProvider NSData CFDataRef CFMutableDataRef")
|
||||
debugger.HandleCommand("type summary add -F NSData.NSData_SummaryProvider NSData")
|
||||
debugger.HandleCommand("type summary add -F NSData.NSData_SummaryProvider2 CFDataRef CFMutableDataRef")
|
||||
|
|
|
@ -31,6 +31,13 @@ def osx_to_python_time(osx):
|
|||
else:
|
||||
return osx - osx_epoch
|
||||
|
||||
# represent a struct_time as a string in the format used by Xcode
|
||||
def xcode_format_time(X):
|
||||
return time.strftime('%Y-%m-%d %H:%M:%S %Z',X)
|
||||
|
||||
# represent a count-since-epoch as a string in the format used by Xcode
|
||||
def xcode_format_count(X):
|
||||
return xcode_format_time(time.localtime(X))
|
||||
|
||||
# despite the similary to synthetic children providers, these classes are not
|
||||
# trying to provide anything but the summary for NSDate, so they need not
|
||||
|
@ -56,7 +63,7 @@ class NSTaggedDate_SummaryProvider:
|
|||
# while all Python knows about is the "epoch", which is a platform-dependent
|
||||
# year (1970 of *nix) whose Jan 1 at midnight is taken as reference
|
||||
value_double = struct.unpack('d', struct.pack('Q', self.data))[0]
|
||||
return time.ctime(osx_to_python_time(value_double))
|
||||
return xcode_format_count(osx_to_python_time(value_double))
|
||||
|
||||
|
||||
class NSUntaggedDate_SummaryProvider:
|
||||
|
@ -81,7 +88,7 @@ class NSUntaggedDate_SummaryProvider:
|
|||
self.offset(),
|
||||
self.sys_params.types_cache.double)
|
||||
value_double = struct.unpack('d', struct.pack('Q', value.GetValueAsUnsigned(0)))[0]
|
||||
return time.ctime(osx_to_python_time(value_double))
|
||||
return xcode_format_count(osx_to_python_time(value_double))
|
||||
|
||||
class NSCalendarDate_SummaryProvider:
|
||||
def adjust_for_architecture(self):
|
||||
|
@ -105,7 +112,7 @@ class NSCalendarDate_SummaryProvider:
|
|||
self.offset(),
|
||||
self.sys_params.types_cache.double)
|
||||
value_double = struct.unpack('d', struct.pack('Q', value.GetValueAsUnsigned(0)))[0]
|
||||
return time.ctime(osx_to_python_time(value_double))
|
||||
return xcode_format_count(osx_to_python_time(value_double))
|
||||
|
||||
class NSTimeZoneClass_SummaryProvider:
|
||||
def adjust_for_architecture(self):
|
||||
|
@ -215,7 +222,7 @@ def NSTimeZone_SummaryProvider (valobj,dict):
|
|||
def CFAbsoluteTime_SummaryProvider (valobj,dict):
|
||||
try:
|
||||
value_double = struct.unpack('d', struct.pack('Q', valobj.GetValueAsUnsigned(0)))[0]
|
||||
return time.ctime(osx_to_python_time(value_double))
|
||||
return xcode_format_count(osx_to_python_time(value_double))
|
||||
except:
|
||||
return 'unable to provide a summary'
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ class NSKnownException_SummaryProvider:
|
|||
reason_ptr = self.valobj.CreateChildAtOffset("reason",
|
||||
self.offset_reason(),
|
||||
self.sys_params.types_cache.id)
|
||||
return CFString.CFString_SummaryProvider(name_ptr,None) + " " + CFString.CFString_SummaryProvider(reason_ptr,None)
|
||||
return 'name:' + CFString.CFString_SummaryProvider(name_ptr,None) + ' reason:' + CFString.CFString_SummaryProvider(reason_ptr,None)
|
||||
|
||||
class NSUnknownException_SummaryProvider:
|
||||
def adjust_for_architecture(self):
|
||||
|
|
|
@ -225,7 +225,7 @@ def NSSet_SummaryProvider2 (valobj,dict):
|
|||
else:
|
||||
if provider.sys_params.is_64_bit:
|
||||
summary = summary & ~0x1fff000000000000
|
||||
summary = str(summary) + (' objects' if summary > 1 else ' object')
|
||||
summary = '@"' + str(summary) + (' values"' if summary > 1 else ' value"')
|
||||
return summary
|
||||
return ''
|
||||
|
||||
|
|
|
@ -47,8 +47,15 @@ class NSURLKnown_SummaryProvider:
|
|||
self.offset_base(),
|
||||
self.sys_params.types_cache.NSURL)
|
||||
my_string = CFString.CFString_SummaryProvider(text,None)
|
||||
if base.GetValueAsUnsigned(0) != 0:
|
||||
my_string = my_string + " (base path: " + NSURL_SummaryProvider(base,None) + ")"
|
||||
if len(my_string) > 0 and base.GetValueAsUnsigned(0) != 0:
|
||||
# remove final " from myself
|
||||
my_string = my_string[0:len(my_string)-1]
|
||||
my_string = my_string + ' -- '
|
||||
my_base_string = NSURL_SummaryProvider(base,None)
|
||||
if len(my_base_string) > 2:
|
||||
# remove @" marker from base URL string
|
||||
my_base_string = my_base_string[2:]
|
||||
my_string = my_string + my_base_string
|
||||
return my_string
|
||||
|
||||
|
||||
|
|
|
@ -906,8 +906,8 @@ FormatManager::LoadObjCFormatters()
|
|||
AddScriptSummary(appkit_category_sp, "NSBundle.NSBundle_SummaryProvider", ConstString("NSBundle"), appkit_flags);
|
||||
|
||||
AddScriptSummary(appkit_category_sp, "NSData.NSData_SummaryProvider", ConstString("NSData"), appkit_flags);
|
||||
AddScriptSummary(appkit_category_sp, "NSData.NSData_SummaryProvider", ConstString("CFDataRef"), appkit_flags);
|
||||
AddScriptSummary(appkit_category_sp, "NSData.NSData_SummaryProvider", ConstString("CFMutableDataRef"), appkit_flags);
|
||||
AddScriptSummary(appkit_category_sp, "NSData.NSData_SummaryProvider2", ConstString("CFDataRef"), appkit_flags);
|
||||
AddScriptSummary(appkit_category_sp, "NSData.NSData_SummaryProvider2", ConstString("CFMutableDataRef"), appkit_flags);
|
||||
|
||||
AddScriptSummary(appkit_category_sp, "NSException.NSException_SummaryProvider", ConstString("NSException"), appkit_flags);
|
||||
|
||||
|
|
|
@ -218,13 +218,13 @@ class ObjCDataFormatterTestCase(TestBase):
|
|||
'(NSString *) str12 = ',' @"Process Name: a.out Process Id:'])
|
||||
|
||||
self.expect('frame variable newArray newDictionary newMutableDictionary cfdict_ref mutable_dict_ref cfarray_ref mutable_array_ref',
|
||||
substrs = ['(NSArray *) newArray = ',' 50 objects',
|
||||
substrs = ['(NSArray *) newArray = ','@"50 objects"',
|
||||
'(NSDictionary *) newDictionary = ',' 12 key/value pairs',
|
||||
'(NSDictionary *) newMutableDictionary = ',' 21 key/value pairs',
|
||||
'(CFDictionaryRef) cfdict_ref = ',' 3 key/value pairs',
|
||||
'(CFMutableDictionaryRef) mutable_dict_ref = ',' 12 key/value pairs',
|
||||
'(CFArrayRef) cfarray_ref = ',' 3 objects',
|
||||
'(CFMutableArrayRef) mutable_array_ref = ',' 11 objects'])
|
||||
'(CFDictionaryRef) cfdict_ref = ','@"3 entries"',
|
||||
'(CFMutableDictionaryRef) mutable_dict_ref = ','@"12 entries"',
|
||||
'(CFArrayRef) cfarray_ref = ','@"3 objects"',
|
||||
'(CFMutableArrayRef) mutable_array_ref = ','@"11 objects"'])
|
||||
|
||||
self.expect('frame variable attrString mutableAttrString mutableGetConst',
|
||||
substrs = ['(NSAttributedString *) attrString = ',' @"hello world from foo"',
|
||||
|
@ -234,24 +234,24 @@ class ObjCDataFormatterTestCase(TestBase):
|
|||
self.expect('frame variable immutableData mutableData data_ref mutable_data_ref mutable_string_ref',
|
||||
substrs = ['(NSData *) immutableData = ',' 4 bytes',
|
||||
'(NSData *) mutableData = ',' 14 bytes',
|
||||
'(CFDataRef) data_ref = ',' 5 bytes',
|
||||
'(CFMutableDataRef) mutable_data_ref = ',' 5 bytes',
|
||||
'(CFDataRef) data_ref = ','@"5 bytes"',
|
||||
'(CFMutableDataRef) mutable_data_ref = ','@"5 bytes"',
|
||||
'(CFMutableStringRef) mutable_string_ref = ',' @"Wish ya knew"'])
|
||||
|
||||
self.expect('frame variable mutable_bag_ref cfbag_ref binheap_ref',
|
||||
substrs = ['(CFMutableBagRef) mutable_bag_ref = ',' 17 items',
|
||||
'(CFBagRef) cfbag_ref = ',' 15 items',
|
||||
'(CFBinaryHeapRef) binheap_ref = ',' 21 items'])
|
||||
substrs = ['(CFMutableBagRef) mutable_bag_ref = ','@"17 values"',
|
||||
'(CFBagRef) cfbag_ref = ','@"15 values"',
|
||||
'(CFBinaryHeapRef) binheap_ref = ','@"21 items"'])
|
||||
|
||||
self.expect('frame variable cfurl_ref cfchildurl_ref cfgchildurl_ref',
|
||||
substrs = ['(CFURLRef) cfurl_ref = ',' @"http://www.foo.bar/"',
|
||||
'cfchildurl_ref = ',' @"page.html" (base path: @"http://www.foo.bar/")',
|
||||
'(CFURLRef) cfgchildurl_ref = ',' @"?whatever" (base path: @"http://www.foo.bar/page.html")'])
|
||||
substrs = ['(CFURLRef) cfurl_ref = ','@"http://www.foo.bar',
|
||||
'cfchildurl_ref = ','@"page.html -- http://www.foo.bar',
|
||||
'(CFURLRef) cfgchildurl_ref = ','@"?whatever -- http://www.foo.bar/page.html"'])
|
||||
|
||||
self.expect('frame variable nsurl nsurl2 nsurl3',
|
||||
substrs = ['(NSURL *) nsurl = ',' @"http://www.foo.bar"',
|
||||
'(NSURL *) nsurl2 =',' @"page.html" (base path: @"http://www.foo.bar")',
|
||||
'(NSURL *) nsurl3 = ',' @"?whatever" (base path: @"http://www.foo.bar/page.html")'])
|
||||
substrs = ['(NSURL *) nsurl = ','@"http://www.foo.bar',
|
||||
'(NSURL *) nsurl2 =','@"page.html -- http://www.foo.bar',
|
||||
'(NSURL *) nsurl3 = ','@"?whatever -- http://www.foo.bar/page.html"'])
|
||||
|
||||
self.expect('frame variable bundle_string bundle_url main_bundle',
|
||||
substrs = ['(NSBundle *) bundle_string = ',' @"/System/Library/Frameworks/Accelerate.framework"',
|
||||
|
@ -259,16 +259,16 @@ class ObjCDataFormatterTestCase(TestBase):
|
|||
'(NSBundle *) main_bundle = ','test/functionalities/data-formatter/data-formatter-objc'])
|
||||
|
||||
self.expect('frame variable except0 except1 except2 except3',
|
||||
substrs = ['(NSException *) except0 = ',' @"TheGuyWhoHasNoName" @"cuz it\'s funny"',
|
||||
'(NSException *) except1 = ',' @"TheGuyWhoHasNoName~1" @"cuz it\'s funny"',
|
||||
'(NSException *) except2 = ',' @"TheGuyWhoHasNoName`2" @"cuz it\'s funny"',
|
||||
'(NSException *) except3 = ',' @"TheGuyWhoHasNoName/3" @"cuz it\'s funny"'])
|
||||
substrs = ['(NSException *) except0 = ','name:@"TheGuyWhoHasNoName" reason:@"cuz it\'s funny"',
|
||||
'(NSException *) except1 = ','name:@"TheGuyWhoHasNoName~1" reason:@"cuz it\'s funny"',
|
||||
'(NSException *) except2 = ','name:@"TheGuyWhoHasNoName`2" reason:@"cuz it\'s funny"',
|
||||
'(NSException *) except3 = ','name:@"TheGuyWhoHasNoName/3" reason:@"cuz it\'s funny"'])
|
||||
|
||||
self.expect('frame variable port',
|
||||
substrs = ['(NSMachPort *) port = ',' mach port: '])
|
||||
|
||||
self.expect('frame variable date1 date2',
|
||||
substrs = ['10','1985','1','2011'])
|
||||
substrs = ['1985-04','2011-01'])
|
||||
|
||||
# this test might fail if we hit the breakpoint late on December 31st of some given year
|
||||
# and midnight comes between hitting the breakpoint and running this line of code
|
||||
|
@ -279,7 +279,7 @@ class ObjCDataFormatterTestCase(TestBase):
|
|||
substrs = [now_year,'1970'])
|
||||
|
||||
self.expect('frame variable date1_abs date2_abs',
|
||||
substrs = ['10','1985','1','2011'])
|
||||
substrs = ['1985-04','2011-01'])
|
||||
|
||||
self.expect('frame variable date3_abs date4_abs',
|
||||
substrs = [now_year,'1970'])
|
||||
|
@ -417,7 +417,7 @@ class ObjCDataFormatterTestCase(TestBase):
|
|||
'(Point *) point_ptr = (v=7, h=12)',
|
||||
'(HIPoint) hi_point = (x=7, y=12)',
|
||||
'(HIRect) hi_rect = origin=(x=3, y=5) size=(width=4, height=6)',
|
||||
'@"TheGuyWhoHasNoName" @"cuz it\'s funny"',
|
||||
'name:@"TheGuyWhoHasNoName" reason:@"cuz it\'s funny"',
|
||||
'1985',
|
||||
'foo_selector_impl'])
|
||||
self.runCmd('log timers dump')
|
||||
|
|
|
@ -63,11 +63,11 @@ class DataFormatterOneIsSingularTestCase(TestBase):
|
|||
# Now enable AppKit and check we are displaying Cocoa classes correctly
|
||||
self.runCmd("type category enable AppKit")
|
||||
self.expect('frame variable key',
|
||||
substrs = ['1 object'])
|
||||
substrs = ['@"1 object"'])
|
||||
self.expect('frame variable key', matching=False,
|
||||
substrs = ['1 objects'])
|
||||
self.expect('frame variable value',
|
||||
substrs = ['1 object'])
|
||||
substrs = ['@"1 object"'])
|
||||
self.expect('frame variable value', matching=False,
|
||||
substrs = ['1 objects'])
|
||||
self.expect('frame variable dict',
|
||||
|
@ -75,9 +75,9 @@ class DataFormatterOneIsSingularTestCase(TestBase):
|
|||
self.expect('frame variable dict', matching=False,
|
||||
substrs = ['1 key/value pairs'])
|
||||
self.expect('frame variable mutable_bag_ref',
|
||||
substrs = ['1 item'])
|
||||
substrs = ['@"1 value"'])
|
||||
self.expect('frame variable mutable_bag_ref', matching=False,
|
||||
substrs = ['1 items'])
|
||||
substrs = ['1 values'])
|
||||
self.expect('frame variable nscounted_set',
|
||||
substrs = ['1 object'])
|
||||
self.expect('frame variable nscounted_set', matching=False,
|
||||
|
@ -87,7 +87,7 @@ class DataFormatterOneIsSingularTestCase(TestBase):
|
|||
self.expect('frame variable imset', matching=False,
|
||||
substrs = ['1 objects'])
|
||||
self.expect('frame variable binheap_ref',
|
||||
substrs = ['1 item'])
|
||||
substrs = ['@"1 item"'])
|
||||
self.expect('frame variable binheap_ref', matching=False,
|
||||
substrs = ['1 items'])
|
||||
self.expect('frame variable nsset',
|
||||
|
|
Loading…
Reference in New Issue