summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2012-03-13 00:25:59 +0000
committerEnrico Granata <egranata@apple.com>2012-03-13 00:25:59 +0000
commit8c69c96dc99d91cc5a391ad026f46a30b062fbed (patch)
treefdfc56105cb45f11f20fc2cf95963494c7bd39a8
parentb1e8a53e0b65ea6ebd11620ff6d91bdf9ec5a1cb (diff)
downloadbcm5719-llvm-8c69c96dc99d91cc5a391ad026f46a30b062fbed.tar.gz
bcm5719-llvm-8c69c96dc99d91cc5a391ad026f46a30b062fbed.zip
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
-rw-r--r--lldb/examples/summaries/cocoa/CFArray.py3
-rw-r--r--lldb/examples/summaries/cocoa/CFBag.py4
-rw-r--r--lldb/examples/summaries/cocoa/CFBinaryHeap.py4
-rw-r--r--lldb/examples/summaries/cocoa/CFDictionary.py2
-rw-r--r--lldb/examples/summaries/cocoa/NSData.py20
-rw-r--r--lldb/examples/summaries/cocoa/NSDate.py15
-rw-r--r--lldb/examples/summaries/cocoa/NSException.py2
-rw-r--r--lldb/examples/summaries/cocoa/NSSet.py2
-rw-r--r--lldb/examples/summaries/cocoa/NSURL.py11
-rw-r--r--lldb/source/Core/FormatManager.cpp4
-rw-r--r--lldb/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py46
-rw-r--r--lldb/test/functionalities/data-formatter/rdar-3534688/TestFormattersOneIsSingular.py10
12 files changed, 78 insertions, 45 deletions
diff --git a/lldb/examples/summaries/cocoa/CFArray.py b/lldb/examples/summaries/cocoa/CFArray.py
index 1a78f5a5f8b..608efea7fbb 100644
--- a/lldb/examples/summaries/cocoa/CFArray.py
+++ b/lldb/examples/summaries/cocoa/CFArray.py
@@ -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 ''
diff --git a/lldb/examples/summaries/cocoa/CFBag.py b/lldb/examples/summaries/cocoa/CFBag.py
index 2e41de614b0..e0cfd3dece1 100644
--- a/lldb/examples/summaries/cocoa/CFBag.py
+++ b/lldb/examples/summaries/cocoa/CFBag.py
@@ -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 ''
diff --git a/lldb/examples/summaries/cocoa/CFBinaryHeap.py b/lldb/examples/summaries/cocoa/CFBinaryHeap.py
index d13ee876d16..60f42d3e368 100644
--- a/lldb/examples/summaries/cocoa/CFBinaryHeap.py
+++ b/lldb/examples/summaries/cocoa/CFBinaryHeap.py
@@ -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 ''
diff --git a/lldb/examples/summaries/cocoa/CFDictionary.py b/lldb/examples/summaries/cocoa/CFDictionary.py
index 3f90de259f5..39b7ac85e79 100644
--- a/lldb/examples/summaries/cocoa/CFDictionary.py
+++ b/lldb/examples/summaries/cocoa/CFDictionary.py
@@ -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 ''
diff --git a/lldb/examples/summaries/cocoa/NSData.py b/lldb/examples/summaries/cocoa/NSData.py
index f1f50fbb50c..d2d2515e48f 100644
--- a/lldb/examples/summaries/cocoa/NSData.py
+++ b/lldb/examples/summaries/cocoa/NSData.py
@@ -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")
diff --git a/lldb/examples/summaries/cocoa/NSDate.py b/lldb/examples/summaries/cocoa/NSDate.py
index 3f0273fe16e..b3c3039466a 100644
--- a/lldb/examples/summaries/cocoa/NSDate.py
+++ b/lldb/examples/summaries/cocoa/NSDate.py
@@ -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'
diff --git a/lldb/examples/summaries/cocoa/NSException.py b/lldb/examples/summaries/cocoa/NSException.py
index 3a09198f84c..0d2d9a71f00 100644
--- a/lldb/examples/summaries/cocoa/NSException.py
+++ b/lldb/examples/summaries/cocoa/NSException.py
@@ -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):
diff --git a/lldb/examples/summaries/cocoa/NSSet.py b/lldb/examples/summaries/cocoa/NSSet.py
index 4abf703e1a9..ea410cf46f2 100644
--- a/lldb/examples/summaries/cocoa/NSSet.py
+++ b/lldb/examples/summaries/cocoa/NSSet.py
@@ -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 ''
diff --git a/lldb/examples/summaries/cocoa/NSURL.py b/lldb/examples/summaries/cocoa/NSURL.py
index 4273b43abd1..d29bbc77507 100644
--- a/lldb/examples/summaries/cocoa/NSURL.py
+++ b/lldb/examples/summaries/cocoa/NSURL.py
@@ -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
diff --git a/lldb/source/Core/FormatManager.cpp b/lldb/source/Core/FormatManager.cpp
index 1cda49e6498..5465fbb37d6 100644
--- a/lldb/source/Core/FormatManager.cpp
+++ b/lldb/source/Core/FormatManager.cpp
@@ -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);
diff --git a/lldb/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py b/lldb/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py
index a047039eb62..2a3ec439a82 100644
--- a/lldb/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py
+++ b/lldb/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py
@@ -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')
diff --git a/lldb/test/functionalities/data-formatter/rdar-3534688/TestFormattersOneIsSingular.py b/lldb/test/functionalities/data-formatter/rdar-3534688/TestFormattersOneIsSingular.py
index 4128844b454..14afac35156 100644
--- a/lldb/test/functionalities/data-formatter/rdar-3534688/TestFormattersOneIsSingular.py
+++ b/lldb/test/functionalities/data-formatter/rdar-3534688/TestFormattersOneIsSingular.py
@@ -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',
OpenPOWER on IntegriCloud