Revert "[lldb] Fix string summary of an empty NSPathStore2"

This reverts commit 939ca455e7.

This failed on the debian bot for some reason:
  File "/home/worker/lldb-x86_64-debian/lldb-x86_64-debian/llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py", line 67, in test_with_run_command
    "s summary wrong")
AssertionError: 'L"hello world! מזל טוב!\\0!\\0!!!!\\0\\0A\\0\\U0000fffd\\U0000fffd\\U0000fffd\\ [truncated]... != 'L"hello world! מזל טוב!"'
Diff is 2156 characters long. Set self.maxDiff to None to see it. : s summary wrong
This commit is contained in:
Raphael Isemann 2020-03-19 13:07:10 +01:00
parent d4ad386ee1
commit 718d94187d
5 changed files with 10 additions and 33 deletions

View File

@ -115,15 +115,9 @@ public:
lldb::ProcessSP GetProcessSP() const { return m_process_sp; }
void SetHasSourceSize(bool e) { m_has_source_size = e; }
bool HasSourceSize() const { return m_has_source_size; }
private:
uint64_t m_location = 0;
lldb::ProcessSP m_process_sp;
/// True iff we know the source size of the string.
bool m_has_source_size = false;
};
class ReadBufferAndDumpToStreamOptions : public DumpToStreamOptions {

View File

@ -525,33 +525,27 @@ static bool ReadUTFBufferAndDumpToStream(
if (!options.GetStream())
return false;
uint32_t sourceSize;
uint32_t sourceSize = options.GetSourceSize();
bool needs_zero_terminator = options.GetNeedsZeroTermination();
bool is_truncated = false;
const auto max_size = process_sp->GetTarget().GetMaximumSizeOfStringSummary();
if (options.HasSourceSize()) {
sourceSize = options.GetSourceSize();
if (!options.GetIgnoreMaxLength()) {
if (sourceSize > max_size) {
sourceSize = max_size;
is_truncated = true;
}
}
} else {
if (!sourceSize) {
sourceSize = max_size;
needs_zero_terminator = true;
} else if (!options.GetIgnoreMaxLength()) {
if (sourceSize > max_size) {
sourceSize = max_size;
is_truncated = true;
}
}
const int bufferSPSize = sourceSize * type_width;
lldb::DataBufferSP buffer_sp(new DataBufferHeap(bufferSPSize, 0));
// Check if we got bytes. We never get any bytes if we have an empty
// string, but we still continue so that we end up actually printing
// an empty string ("").
if (sourceSize != 0 && !buffer_sp->GetBytes())
if (!buffer_sp->GetBytes())
return false;
Status error;

View File

@ -170,7 +170,6 @@ bool lldb_private::formatters::NSStringSummaryProvider(
options.SetStream(&stream);
options.SetQuote('"');
options.SetSourceSize(explicit_length);
options.SetHasSourceSize(has_explicit_length);
options.SetNeedsZeroTermination(false);
options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
@ -183,7 +182,6 @@ bool lldb_private::formatters::NSStringSummaryProvider(
options.SetProcessSP(process_sp);
options.SetStream(&stream);
options.SetSourceSize(explicit_length);
options.SetHasSourceSize(has_explicit_length);
options.SetNeedsZeroTermination(false);
options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
@ -201,7 +199,6 @@ bool lldb_private::formatters::NSStringSummaryProvider(
options.SetStream(&stream);
options.SetQuote('"');
options.SetSourceSize(explicit_length);
options.SetHasSourceSize(has_explicit_length);
options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
options.SetLanguage(summary_options.GetLanguage());
@ -224,7 +221,6 @@ bool lldb_private::formatters::NSStringSummaryProvider(
options.SetStream(&stream);
options.SetQuote('"');
options.SetSourceSize(explicit_length);
options.SetHasSourceSize(has_explicit_length);
options.SetNeedsZeroTermination(!has_explicit_length);
options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
@ -245,7 +241,6 @@ bool lldb_private::formatters::NSStringSummaryProvider(
options.SetStream(&stream);
options.SetQuote('"');
options.SetSourceSize(explicit_length);
options.SetHasSourceSize(has_explicit_length);
options.SetNeedsZeroTermination(!has_explicit_length);
options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
@ -268,7 +263,6 @@ bool lldb_private::formatters::NSStringSummaryProvider(
options.SetProcessSP(process_sp);
options.SetStream(&stream);
options.SetSourceSize(explicit_length);
options.SetHasSourceSize(has_explicit_length);
options.SetNeedsZeroTermination(!has_explicit_length);
options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
@ -292,7 +286,6 @@ bool lldb_private::formatters::NSStringSummaryProvider(
options.SetProcessSP(process_sp);
options.SetStream(&stream);
options.SetSourceSize(explicit_length);
options.SetHasSourceSize(has_explicit_length);
options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
options.SetLanguage(summary_options.GetLanguage());

View File

@ -76,8 +76,8 @@ class NSStringDataFormatterTestCase(TestBase):
self.expect('frame variable hebrew', substrs=['לילה טוב'])
def nsstring_data_formatter_commands(self):
self.expect('frame variable empty str0 str1 str2 str3 str4 str5 str6 str8 str9 str10 str11 label1 label2 processName str12',
substrs=['(NSString *) empty = ', ' @""',
self.expect('frame variable str0 str1 str2 str3 str4 str5 str6 str8 str9 str10 str11 label1 label2 processName str12',
substrs=[
# '(NSString *) str0 = ',' @"255"',
'(NSString *) str1 = ', ' @"A rather short ASCII NSString object is here"',
'(NSString *) str2 = ', ' @"A rather short UTF8 NSString object is here"',
@ -104,8 +104,6 @@ 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"""

View File

@ -17,7 +17,6 @@ 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"];
@ -70,7 +69,6 @@ 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',