[Lldb-commits] [PATCH] D70393: [lldb] Fix NSURL data formatter truncation issue in Swift
Martin Svensson via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Nov 19 05:14:42 PST 2019
poya updated this revision to Diff 230045.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D70393/new/
https://reviews.llvm.org/D70393
Files:
lldb/source/Plugins/Language/ObjC/Cocoa.cpp
Index: lldb/source/Plugins/Language/ObjC/Cocoa.cpp
===================================================================
--- lldb/source/Plugins/Language/ObjC/Cocoa.cpp
+++ lldb/source/Plugins/Language/ObjC/Cocoa.cpp
@@ -659,6 +659,32 @@
return true;
}
+static void NSURL_ConcatSummary(StreamString &first, const StreamString &second,
+ std::string prefix, std::string suffix) {
+ if (second.Empty())
+ return;
+
+ // Remove suffix and quotation char from first
+ std::string first_str_copy = first.GetString();
+ llvm::StringRef first_str = first_str_copy;
+ if (!suffix.empty())
+ first_str.consume_back(suffix);
+ if (!first_str.empty())
+ first_str = first_str.drop_back();
+
+ // Remove prefix and quotation char from second
+ llvm::StringRef second_str = second.GetString();
+ if (!prefix.empty())
+ second_str.consume_front(prefix);
+ if (!second_str.empty())
+ second_str = second_str.drop_front();
+
+ if (!first_str.empty() && !second_str.empty()) {
+ first.Clear();
+ first.Printf("%s -- %s", first_str.str().c_str(), second_str.str().c_str());
+ }
+}
+
bool lldb_private::formatters::NSURLSummaryProvider(
ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
ProcessSP process_sp = valobj.GetProcessSP();
@@ -702,21 +728,20 @@
if (!NSStringSummaryProvider(*text, summary, options))
return false;
if (base && base->GetValueAsUnsigned(0)) {
- std::string summary_str = summary.GetString();
-
- if (!summary_str.empty())
- summary_str.pop_back();
- summary_str += " -- ";
StreamString base_summary;
if (NSURLSummaryProvider(*base, base_summary, options) &&
!base_summary.Empty()) {
- llvm::StringRef base_str = base_summary.GetString();
- if (base_str.size() > 2)
- base_str = base_str.drop_front(2);
- summary_str += base_str;
+ std::string prefix, suffix;
+ if (Language *language = Language::FindPlugin(options.GetLanguage())) {
+ if (!language->GetFormatterPrefixSuffix(*text, ConstString("NSString"),
+ prefix, suffix)) {
+ prefix.clear();
+ suffix.clear();
+ }
+ }
+
+ NSURL_ConcatSummary(summary, base_summary, prefix, suffix);
}
- summary.Clear();
- summary.PutCString(summary_str);
}
if (!summary.Empty()) {
stream.PutCString(summary.GetString());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70393.230045.patch
Type: text/x-patch
Size: 2423 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20191119/a5074457/attachment-0001.bin>
More information about the lldb-commits
mailing list