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());