diff options
author | Raphael Isemann <teemperor@gmail.com> | 2020-03-19 12:20:18 +0100 |
---|---|---|
committer | Raphael Isemann <teemperor@gmail.com> | 2020-03-19 18:50:26 +0100 |
commit | 7b2442584e40f97693c38c0d79b83f770d557039 (patch) | |
tree | e9959b3c23180a35491013b3e6a67f160adb8ab4 /lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp | |
parent | 74494d9992bdf266259f8add410f346971471c46 (diff) | |
download | llvm-7b2442584e40f97693c38c0d79b83f770d557039.zip llvm-7b2442584e40f97693c38c0d79b83f770d557039.tar.gz llvm-7b2442584e40f97693c38c0d79b83f770d557039.tar.bz2 |
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/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp')
-rw-r--r-- | lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp index 78f5875..b4af67e 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp @@ -259,6 +259,7 @@ bool lldb_private::formatters::LibStdcppStringSummaryProvider( if (error.Fail()) return false; options.SetSourceSize(size_of_data); + options.SetHasSourceSize(true); if (!StringPrinter::ReadStringAndDumpToStream< StringPrinter::StringElementType::UTF8>(options)) { @@ -319,6 +320,7 @@ bool lldb_private::formatters::LibStdcppWStringSummaryProvider( if (error.Fail()) return false; options.SetSourceSize(size_of_data); + options.SetHasSourceSize(true); options.SetPrefixToken("L"); switch (wchar_size) { |