summaryrefslogtreecommitdiffstats
path: root/lldb/source
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/Core/ValueObject.cpp24
-rw-r--r--lldb/source/DataFormatters/StringPrinter.cpp32
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp25
-rw-r--r--lldb/source/Target/Process.cpp2
4 files changed, 63 insertions, 20 deletions
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index cf9dd776c6b..15c34b47b3a 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -1255,13 +1255,14 @@ CopyStringDataToBufferSP(const StreamString& source,
return true;
}
-size_t
+std::pair<size_t,bool>
ValueObject::ReadPointedString (lldb::DataBufferSP& buffer_sp,
Error& error,
uint32_t max_length,
bool honor_array,
Format item_format)
{
+ bool was_capped = false;
StreamString s;
ExecutionContext exe_ctx (GetExecutionContextRef());
Target* target = exe_ctx.GetTargetPtr();
@@ -1271,7 +1272,7 @@ ValueObject::ReadPointedString (lldb::DataBufferSP& buffer_sp,
s << "<no target to read from>";
error.SetErrorString("no target to read from");
CopyStringDataToBufferSP(s, buffer_sp);
- return 0;
+ return {0,was_capped};
}
if (max_length == 0)
@@ -1317,7 +1318,7 @@ ValueObject::ReadPointedString (lldb::DataBufferSP& buffer_sp,
s << "<invalid address>";
error.SetErrorString("invalid address");
CopyStringDataToBufferSP(s, buffer_sp);
- return 0;
+ return {0,was_capped};
}
Address cstr_so_addr (cstr_address);
@@ -1334,7 +1335,7 @@ ValueObject::ReadPointedString (lldb::DataBufferSP& buffer_sp,
for (size_t offset = 0; offset < bytes_read; offset++)
s.Printf("%c", *data.PeekData(offset, 1));
if (capped_data)
- s << "...";
+ was_capped = true;
}
}
else
@@ -1386,7 +1387,7 @@ ValueObject::ReadPointedString (lldb::DataBufferSP& buffer_sp,
if (cstr_len_displayed >= 0)
{
if (capped_cstr)
- s << "...";
+ was_capped = true;
}
}
}
@@ -1396,7 +1397,7 @@ ValueObject::ReadPointedString (lldb::DataBufferSP& buffer_sp,
s << "<not a string object>";
}
CopyStringDataToBufferSP(s, buffer_sp);
- return total_bytes_read;
+ return {total_bytes_read,was_capped};
}
std::pair<TypeValidatorResult, std::string>
@@ -1644,17 +1645,18 @@ ValueObject::DumpPrintableRepresentation(Stream& s,
{
Error error;
lldb::DataBufferSP buffer_sp;
- ReadPointedString(buffer_sp,
- error,
- 0,
- (custom_format == eFormatVectorOfChar) ||
- (custom_format == eFormatCharArray));
+ std::pair<size_t, bool> read_string = ReadPointedString(buffer_sp,
+ error,
+ 0,
+ (custom_format == eFormatVectorOfChar) ||
+ (custom_format == eFormatCharArray));
lldb_private::formatters::StringPrinter::ReadBufferAndDumpToStreamOptions options(*this);
options.SetData(DataExtractor(buffer_sp, lldb::eByteOrderInvalid, 8)); // none of this matters for a string - pass some defaults
options.SetStream(&s);
options.SetPrefixToken(0);
options.SetQuote('"');
options.SetSourceSize(buffer_sp->GetByteSize());
+ options.SetIsTruncated(read_string.second);
formatters::StringPrinter::ReadBufferAndDumpToStream<lldb_private::formatters::StringPrinter::StringElementType::ASCII>(options);
return !error.Fail();
}
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);
}
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index 3eaebef152a..950bd62c5c9 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -563,14 +563,23 @@ lldb_private::formatters::LibcxxWStringSummaryProvider (ValueObject& valobj, Str
return false;
DataExtractor extractor;
+
+ StringPrinter::ReadBufferAndDumpToStreamOptions options(valobj);
+
if (summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryCapped)
- size = std::min<decltype(size)>(size, valobj.GetTargetSP()->GetMaximumSizeOfStringSummary());
+ {
+ const auto max_size = valobj.GetTargetSP()->GetMaximumSizeOfStringSummary();
+ if (size > max_size)
+ {
+ size = max_size;
+ options.SetIsTruncated(true);
+ }
+ }
location_sp->GetPointeeData(extractor, 0, size);
// std::wstring::size() is measured in 'characters', not bytes
auto wchar_t_size = valobj.GetTargetSP()->GetScratchClangASTContext()->GetBasicType(lldb::eBasicTypeWChar).GetByteSize(nullptr);
- StringPrinter::ReadBufferAndDumpToStreamOptions options(valobj);
options.SetData(extractor);
options.SetStream(&stream);
options.SetPrefixToken("L");
@@ -618,12 +627,20 @@ lldb_private::formatters::LibcxxStringSummaryProvider (ValueObject& valobj, Stre
if (!location_sp)
return false;
+ StringPrinter::ReadBufferAndDumpToStreamOptions options(valobj);
+
DataExtractor extractor;
if (summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryCapped)
- size = std::min<decltype(size)>(size, valobj.GetTargetSP()->GetMaximumSizeOfStringSummary());
+ {
+ const auto max_size = valobj.GetTargetSP()->GetMaximumSizeOfStringSummary();
+ if (size > max_size)
+ {
+ size = max_size;
+ options.SetIsTruncated(true);
+ }
+ }
location_sp->GetPointeeData(extractor, 0, size);
- StringPrinter::ReadBufferAndDumpToStreamOptions options(valobj);
options.SetData(extractor);
options.SetStream(&stream);
options.SetPrefixToken(0);
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index b0e0591d552..6ffc4a96a9b 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -1960,7 +1960,7 @@ Process::LoadImage (const FileSpec &image_spec, Error &error)
if (error_str_sp->IsCStringContainer(true))
{
DataBufferSP buffer_sp(new DataBufferHeap(10240,0));
- size_t num_chars = error_str_sp->ReadPointedString (buffer_sp, error, 10240);
+ size_t num_chars = error_str_sp->ReadPointedString (buffer_sp, error, 10240).first;
if (error.Success() && num_chars > 0)
{
error.Clear();
OpenPOWER on IntegriCloud