Skip to content

Commit 91443ed

Browse files
author
Enrico Granata
committed
Remove a static helper function and use the StringPrinter API exclusively to format NSStrings
llvm-svn: 242583
1 parent fdcaafa commit 91443ed

File tree

1 file changed

+10
-43
lines changed

1 file changed

+10
-43
lines changed

lldb/source/DataFormatters/CXXFormatterFunctions.cpp

Lines changed: 10 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -716,48 +716,6 @@ lldb_private::formatters::NSDataSummaryProvider (ValueObject& valobj, Stream& st
716716
return true;
717717
}
718718

719-
static bool
720-
ReadAsciiBufferAndDumpToStream (lldb::addr_t location,
721-
lldb::ProcessSP& process_sp,
722-
Stream& dest,
723-
uint32_t size = 0,
724-
Error* error = NULL,
725-
size_t *data_read = NULL,
726-
char prefix_token = '@',
727-
char quote = '"')
728-
{
729-
Error my_error;
730-
size_t my_data_read;
731-
if (!process_sp || location == 0)
732-
return false;
733-
734-
if (!size)
735-
size = process_sp->GetTarget().GetMaximumSizeOfStringSummary();
736-
else
737-
size = std::min(size,process_sp->GetTarget().GetMaximumSizeOfStringSummary());
738-
739-
lldb::DataBufferSP buffer_sp(new DataBufferHeap(size,0));
740-
741-
my_data_read = process_sp->ReadCStringFromMemory(location, (char*)buffer_sp->GetBytes(), size, my_error);
742-
743-
if (error)
744-
*error = my_error;
745-
if (data_read)
746-
*data_read = my_data_read;
747-
748-
if (my_error.Fail())
749-
return false;
750-
751-
dest.Printf("%c%c",prefix_token,quote);
752-
753-
if (my_data_read)
754-
dest.Printf("%s",(char*)buffer_sp->GetBytes());
755-
756-
dest.Printf("%c",quote);
757-
758-
return true;
759-
}
760-
761719
bool
762720
lldb_private::formatters::NSTaggedString_SummaryProvider (ObjCLanguageRuntime::ClassDescriptorSP descriptor, Stream& stream)
763721
{
@@ -956,7 +914,16 @@ lldb_private::formatters::NSStringSummaryProvider (ValueObject& valobj, Stream&
956914
else if (is_inline && has_explicit_length && !is_unicode && !is_path_store && !is_mutable)
957915
{
958916
uint64_t location = 3 * ptr_size + valobj_addr;
959-
return ReadAsciiBufferAndDumpToStream(location,process_sp,stream,explicit_length);
917+
918+
ReadStringAndDumpToStreamOptions options(valobj);
919+
options.SetLocation(location);
920+
options.SetProcessSP(process_sp);
921+
options.SetStream(&stream);
922+
options.SetPrefixToken('@');
923+
options.SetQuote('"');
924+
options.SetSourceSize(explicit_length);
925+
options.SetIgnoreMaxLength(summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryUncapped);
926+
return ReadStringAndDumpToStream<StringElementType::ASCII> (options);
960927
}
961928
else if (is_unicode)
962929
{

0 commit comments

Comments
 (0)