diff options
author | Enrico Granata <egranata@apple.com> | 2015-11-04 00:02:08 +0000 |
---|---|---|
committer | Enrico Granata <egranata@apple.com> | 2015-11-04 00:02:08 +0000 |
commit | b766292951e660eb59caab38524406afecee04de (patch) | |
tree | 2e45e88848e59ccc150339407a4d9fc9a04ad5ce /lldb/source/DataFormatters/StringPrinter.cpp | |
parent | e54a4fa95d308578e30818d3fc6c2575ce6611fb (diff) | |
download | bcm5719-llvm-b766292951e660eb59caab38524406afecee04de.tar.gz bcm5719-llvm-b766292951e660eb59caab38524406afecee04de.zip |
Fix an issue where LLDB would truncate summaries for string types without producing any evidence thereof
llvm-svn: 252018
Diffstat (limited to 'lldb/source/DataFormatters/StringPrinter.cpp')
-rw-r--r-- | lldb/source/DataFormatters/StringPrinter.cpp | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/lldb/source/DataFormatters/StringPrinter.cpp b/lldb/source/DataFormatters/StringPrinter.cpp index 041933ae7e9..b114add5064 100644 --- a/lldb/source/DataFormatters/StringPrinter.cpp +++ b/lldb/source/DataFormatters/StringPrinter.cpp @@ -374,6 +374,8 @@ DumpUTFBufferToStream (ConversionResult (*ConvertFunction) (const SourceDataType stream.Printf("%c",dump_options.GetQuote()); if (dump_options.GetSuffixToken() != 0) stream.Printf("%s",dump_options.GetSuffixToken()); + if (dump_options.GetIsTruncated()) + stream.Printf("..."); return true; } @@ -421,11 +423,20 @@ StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::ASCII return false; size_t size; + const auto max_size = process_sp->GetTarget().GetMaximumSizeOfStringSummary(); + bool is_truncated = false; if (options.GetSourceSize() == 0) - size = process_sp->GetTarget().GetMaximumSizeOfStringSummary(); + size = max_size; else if (!options.GetIgnoreMaxLength()) - size = std::min(options.GetSourceSize(),process_sp->GetTarget().GetMaximumSizeOfStringSummary()); + { + size = options.GetSourceSize(); + if (size > max_size) + { + size = max_size; + is_truncated = true; + } + } else size = options.GetSourceSize(); @@ -492,6 +503,9 @@ StringPrinter::ReadStringAndDumpToStream<StringPrinter::StringElementType::ASCII else if (quote != 0) options.GetStream()->Printf("%c",quote); + if (is_truncated) + options.GetStream()->Printf("..."); + return true; } @@ -527,14 +541,23 @@ ReadUTFBufferAndDumpToStream (const StringPrinter::ReadStringAndDumpToStreamOpti uint32_t sourceSize = options.GetSourceSize(); bool needs_zero_terminator = options.GetNeedsZeroTermination(); + + bool is_truncated = false; + const auto max_size = process_sp->GetTarget().GetMaximumSizeOfStringSummary(); if (!sourceSize) { - sourceSize = process_sp->GetTarget().GetMaximumSizeOfStringSummary(); + sourceSize = max_size; needs_zero_terminator = true; } else if (!options.GetIgnoreMaxLength()) - sourceSize = std::min(sourceSize,process_sp->GetTarget().GetMaximumSizeOfStringSummary()); + { + if (sourceSize > max_size) + { + sourceSize = max_size; + is_truncated = true; + } + } const int bufferSPSize = sourceSize * type_width; @@ -562,6 +585,7 @@ ReadUTFBufferAndDumpToStream (const StringPrinter::ReadStringAndDumpToStreamOpti StringPrinter::ReadBufferAndDumpToStreamOptions dump_options(options); dump_options.SetData(data); dump_options.SetSourceSize(sourceSize); + dump_options.SetIsTruncated(is_truncated); return DumpUTFBufferToStream(ConvertFunction, dump_options); } |