New and improved data formatter for std::shared_ptr<> and std::weak_ptr<>
llvm-svn: 198724
This commit is contained in:
parent
8bcc086e58
commit
0dba9b33f0
|
@ -619,7 +619,8 @@ public:
|
||||||
DumpPrintableRepresentation (Stream& s,
|
DumpPrintableRepresentation (Stream& s,
|
||||||
ValueObjectRepresentationStyle val_obj_display = eValueObjectRepresentationStyleSummary,
|
ValueObjectRepresentationStyle val_obj_display = eValueObjectRepresentationStyleSummary,
|
||||||
lldb::Format custom_format = lldb::eFormatInvalid,
|
lldb::Format custom_format = lldb::eFormatInvalid,
|
||||||
PrintableRepresentationSpecialCases special = ePrintableRepresentationSpecialCasesAllow);
|
PrintableRepresentationSpecialCases special = ePrintableRepresentationSpecialCasesAllow,
|
||||||
|
bool do_dump_error = true);
|
||||||
bool
|
bool
|
||||||
GetValueIsValid () const;
|
GetValueIsValid () const;
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,9 @@ namespace lldb_private {
|
||||||
bool
|
bool
|
||||||
LibcxxWStringSummaryProvider (ValueObject& valobj, Stream& stream); // libc++ std::wstring
|
LibcxxWStringSummaryProvider (ValueObject& valobj, Stream& stream); // libc++ std::wstring
|
||||||
|
|
||||||
|
bool
|
||||||
|
LibcxxSmartPointerSummaryProvider (ValueObject& valobj, Stream& stream); // libc++ std::shared_ptr<> and std::weak_ptr<>
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ObjCClassSummaryProvider (ValueObject& valobj, Stream& stream);
|
ObjCClassSummaryProvider (ValueObject& valobj, Stream& stream);
|
||||||
|
|
||||||
|
|
|
@ -1546,7 +1546,8 @@ bool
|
||||||
ValueObject::DumpPrintableRepresentation(Stream& s,
|
ValueObject::DumpPrintableRepresentation(Stream& s,
|
||||||
ValueObjectRepresentationStyle val_obj_display,
|
ValueObjectRepresentationStyle val_obj_display,
|
||||||
Format custom_format,
|
Format custom_format,
|
||||||
PrintableRepresentationSpecialCases special)
|
PrintableRepresentationSpecialCases special,
|
||||||
|
bool do_dump_error)
|
||||||
{
|
{
|
||||||
|
|
||||||
Flags flags(GetTypeInfo());
|
Flags flags(GetTypeInfo());
|
||||||
|
@ -1745,7 +1746,12 @@ ValueObject::DumpPrintableRepresentation(Stream& s,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (m_error.Fail())
|
if (m_error.Fail())
|
||||||
|
{
|
||||||
|
if (do_dump_error)
|
||||||
s.Printf("<%s>", m_error.AsCString());
|
s.Printf("<%s>", m_error.AsCString());
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
else if (val_obj_display == eValueObjectRepresentationStyleSummary)
|
else if (val_obj_display == eValueObjectRepresentationStyleSummary)
|
||||||
s.PutCString("<no summary available>");
|
s.PutCString("<no summary available>");
|
||||||
else if (val_obj_display == eValueObjectRepresentationStyleValue)
|
else if (val_obj_display == eValueObjectRepresentationStyleValue)
|
||||||
|
|
|
@ -963,8 +963,9 @@ FormatManager::LoadLibcxxFormatters()
|
||||||
AddCXXSummary(libcxx_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::unordered containers summary provider", ConstString("^(std::__1::)unordered_(multi)?(map|set)<.+> >$"), stl_summary_flags, true);
|
AddCXXSummary(libcxx_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, "libc++ std::unordered containers summary provider", ConstString("^(std::__1::)unordered_(multi)?(map|set)<.+> >$"), stl_summary_flags, true);
|
||||||
|
|
||||||
stl_summary_flags.SetSkipPointers(true);
|
stl_summary_flags.SetSkipPointers(true);
|
||||||
AddStringSummary(libcxx_category_sp, "{${var.__ptr_%S}} (strong=${var.count} weak=${var.weak_count})}", ConstString("^std::__1::shared_ptr<.+>(( )?&)?$"), stl_summary_flags, true);
|
|
||||||
AddStringSummary(libcxx_category_sp, "{${var.__ptr_%S}} (strong=${var.count} weak=${var.weak_count})}", ConstString("^std::__1::weak_ptr<.+>(( )?&)?$"), stl_summary_flags, true);
|
AddCXXSummary(libcxx_category_sp, lldb_private::formatters::LibcxxSmartPointerSummaryProvider, "libc++ std::shared_ptr summary provider", ConstString("^std::__1::shared_ptr<.+>(( )?&)?$"), stl_summary_flags, true);
|
||||||
|
AddCXXSummary(libcxx_category_sp, lldb_private::formatters::LibcxxSmartPointerSummaryProvider, "libc++ std::weak_ptr summary provider", ConstString("^std::__1::weak_ptr<.+>(( )?&)?$"), stl_summary_flags, true);
|
||||||
|
|
||||||
AddCXXSynthetic(libcxx_category_sp, lldb_private::formatters::LibCxxVectorIteratorSyntheticFrontEndCreator, "std::vector iterator synthetic children", ConstString("^std::__1::__wrap_iter<.+>$"), stl_synth_flags, true);
|
AddCXXSynthetic(libcxx_category_sp, lldb_private::formatters::LibCxxVectorIteratorSyntheticFrontEndCreator, "std::vector iterator synthetic children", ConstString("^std::__1::__wrap_iter<.+>$"), stl_synth_flags, true);
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,51 @@ using namespace lldb;
|
||||||
using namespace lldb_private;
|
using namespace lldb_private;
|
||||||
using namespace lldb_private::formatters;
|
using namespace lldb_private::formatters;
|
||||||
|
|
||||||
|
bool
|
||||||
|
lldb_private::formatters::LibcxxSmartPointerSummaryProvider (ValueObject& valobj, Stream& stream)
|
||||||
|
{
|
||||||
|
ValueObjectSP valobj_sp(valobj.GetNonSyntheticValue());
|
||||||
|
if (!valobj_sp)
|
||||||
|
return false;
|
||||||
|
ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName(ConstString("__ptr_"), true));
|
||||||
|
ValueObjectSP count_sp(valobj_sp->GetChildAtNamePath( {ConstString("__cntrl_"),ConstString("__shared_owners_")} ));
|
||||||
|
ValueObjectSP weakcount_sp(valobj_sp->GetChildAtNamePath( {ConstString("__cntrl_"),ConstString("__shared_weak_owners_")} ));
|
||||||
|
|
||||||
|
if (!ptr_sp)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (ptr_sp->GetValueAsUnsigned(0) == 0)
|
||||||
|
{
|
||||||
|
stream.Printf("nullptr");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bool print_pointee = false;
|
||||||
|
Error error;
|
||||||
|
ValueObjectSP pointee_sp = ptr_sp->Dereference(error);
|
||||||
|
if (pointee_sp && error.Success())
|
||||||
|
{
|
||||||
|
if (pointee_sp->DumpPrintableRepresentation(stream,
|
||||||
|
ValueObject::eValueObjectRepresentationStyleSummary,
|
||||||
|
lldb::eFormatInvalid,
|
||||||
|
ValueObject::ePrintableRepresentationSpecialCasesDisable,
|
||||||
|
false))
|
||||||
|
print_pointee = true;
|
||||||
|
}
|
||||||
|
if (!print_pointee)
|
||||||
|
stream.Printf("ptr = 0x%" PRIx64, ptr_sp->GetValueAsUnsigned(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count_sp)
|
||||||
|
stream.Printf(" strong=%" PRIu64, 1+count_sp->GetValueAsUnsigned(0));
|
||||||
|
|
||||||
|
if (weakcount_sp)
|
||||||
|
stream.Printf(" weak=%" PRIu64, 1+weakcount_sp->GetValueAsUnsigned(0));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::LibcxxVectorBoolSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
|
lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::LibcxxVectorBoolSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) :
|
||||||
SyntheticChildrenFrontEnd(*valobj_sp.get()),
|
SyntheticChildrenFrontEnd(*valobj_sp.get()),
|
||||||
m_bool_type(),
|
m_bool_type(),
|
||||||
|
|
Loading…
Reference in New Issue