diff options
| author | Enrico Granata <egranata@apple.com> | 2014-10-30 18:27:31 +0000 |
|---|---|---|
| committer | Enrico Granata <egranata@apple.com> | 2014-10-30 18:27:31 +0000 |
| commit | 2206b48d6ddabad61979fa69ba09e6b6fb19b0b2 (patch) | |
| tree | 615c6a82c84cb7a44d26173afa5fb32440ced6d7 /lldb/source/DataFormatters | |
| parent | 516e983dd4e145176eb17b2de2cb1457880457da (diff) | |
| download | bcm5719-llvm-2206b48d6ddabad61979fa69ba09e6b6fb19b0b2.tar.gz bcm5719-llvm-2206b48d6ddabad61979fa69ba09e6b6fb19b0b2.zip | |
Also port the C string reading code in ValueObject over to using StringPrinter API
llvm-svn: 220917
Diffstat (limited to 'lldb/source/DataFormatters')
| -rw-r--r-- | lldb/source/DataFormatters/CXXFormatterFunctions.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/lldb/source/DataFormatters/CXXFormatterFunctions.cpp b/lldb/source/DataFormatters/CXXFormatterFunctions.cpp index 4d02ca461c4..2a0ea445271 100644 --- a/lldb/source/DataFormatters/CXXFormatterFunctions.cpp +++ b/lldb/source/DataFormatters/CXXFormatterFunctions.cpp @@ -464,22 +464,33 @@ lldb_private::formatters::LibcxxStringSummaryProvider (ValueObject& valobj, Stre { uint64_t size = 0; ValueObjectSP location_sp((ValueObject*)nullptr); + if (!ExtractLibcxxStringInfo(valobj, location_sp, size)) return false; + if (size == 0) { stream.Printf("\"\""); return true; } + if (!location_sp) return false; - Error error; - if (location_sp->ReadPointedString(stream, - error, - 0, // max length is decided by the settings - false) == 0) // do not honor array (terminates on first 0 byte even for a char[]) - stream.Printf("\"\""); // if nothing was read, print an empty string - return error.Success(); + + DataExtractor extractor; + size = std::min<decltype(size)>(size, valobj.GetTargetSP()->GetMaximumSizeOfStringSummary()); + location_sp->GetPointeeData(extractor, 0, size); + + lldb_private::formatters::ReadBufferAndDumpToStreamOptions options; + options.SetData(extractor); // none of this matters for a string - pass some defaults + options.SetStream(&stream); + options.SetPrefixToken(0); + options.SetQuote('"'); + options.SetSourceSize(size); + options.SetEscapeNonPrintables(true); + lldb_private::formatters::ReadBufferAndDumpToStream<lldb_private::formatters::StringElementType::ASCII>(options); + + return true; } bool |

