summaryrefslogtreecommitdiff
path: root/lldb/test/API/functionalities/data-formatter/data-formatter-objc/nsstring
diff options
context:
space:
mode:
authorRaphael Isemann <teemperor@gmail.com>2020-03-19 12:20:18 +0100
committerRaphael Isemann <teemperor@gmail.com>2020-03-19 18:50:26 +0100
commit7b2442584e40f97693c38c0d79b83f770d557039 (patch)
treee9959b3c23180a35491013b3e6a67f160adb8ab4 /lldb/test/API/functionalities/data-formatter/data-formatter-objc/nsstring
parent74494d9992bdf266259f8add410f346971471c46 (diff)
Reland [lldb] Fix string summary of an empty NSPathStore2
(This is D68010 but I also set the new parameter in LibStdcpp.cpp to fix the Debian tests). Summary: Printing a summary for an empty NSPathStore2 string currently prints random bytes behind the empty string pointer from memory (rdar://55575888). It seems the reason for this is that the SourceSize parameter in the `ReadStringAndDumpToStreamOptions` - which is supposed to contain the string length - actually uses the length 0 as a magic value for saying "read as much as possible from the buffer" which is clearly wrong for empty strings. This patch adds another flag that indicates if we have know the string length or not and makes this behaviour dependent on that (which seemingly was the original purpose of this magic value). Reviewers: aprantl, JDevlieghere, shafik Reviewed By: aprantl Subscribers: christof, abidh, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D68010
Diffstat (limited to 'lldb/test/API/functionalities/data-formatter/data-formatter-objc/nsstring')
-rw-r--r--lldb/test/API/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py6
-rw-r--r--lldb/test/API/functionalities/data-formatter/data-formatter-objc/nsstring/main.m2
2 files changed, 6 insertions, 2 deletions
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py b/lldb/test/API/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py
index 4ef0a5957503..5b323f5614b2 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py
@@ -76,8 +76,8 @@ class NSStringDataFormatterTestCase(TestBase):
self.expect('frame variable hebrew', substrs=['לילה טוב'])
def nsstring_data_formatter_commands(self):
- self.expect('frame variable str0 str1 str2 str3 str4 str5 str6 str8 str9 str10 str11 label1 label2 processName str12',
- substrs=[
+ self.expect('frame variable empty str0 str1 str2 str3 str4 str5 str6 str8 str9 str10 str11 label1 label2 processName str12',
+ substrs=['(NSString *) empty = ', ' @""',
# '(NSString *) str0 = ',' @"255"',
'(NSString *) str1 = ', ' @"A rather short ASCII NSString object is here"',
'(NSString *) str2 = ', ' @"A rather short UTF8 NSString object is here"',
@@ -104,6 +104,8 @@ class NSStringDataFormatterTestCase(TestBase):
self.expect('expr -d run-target -- path', substrs=['usr/blah/stuff'])
self.expect('frame variable path', substrs=['usr/blah/stuff'])
+ self.expect('expr -d run-target -- empty_path', substrs=['@""'])
+ self.expect('frame variable empty_path', substrs=['@""'])
def nsstring_withNULs_commands(self):
"""Check that the NSString formatter supports embedded NULs in the text"""
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-objc/nsstring/main.m b/lldb/test/API/functionalities/data-formatter/data-formatter-objc/nsstring/main.m
index 576e091db1bc..0787561e4da3 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-objc/nsstring/main.m
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-objc/nsstring/main.m
@@ -17,6 +17,7 @@ int main (int argc, const char * argv[])
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+ NSString *empty = @"";
NSString *str0 = [[NSNumber numberWithUnsignedLongLong:0xFF] stringValue];
NSString *str1 = [NSString stringWithCString:"A rather short ASCII NSString object is here" encoding:NSASCIIStringEncoding];
NSString *str2 = [NSString stringWithUTF8String:"A rather short UTF8 NSString object is here"];
@@ -69,6 +70,7 @@ int main (int argc, const char * argv[])
NSArray *components = @[@"usr", @"blah", @"stuff"];
NSString *path = [NSString pathWithComponents: components];
+ NSString *empty_path = [empty stringByDeletingPathExtension];
const unichar someOfTheseAreNUL[] = {'a',' ', 'v','e','r','y',' ',
'm','u','c','h',' ','b','o','r','i','n','g',' ','t','a','s','k',