Skip to content
This repository has been archived by the owner on Apr 2, 2020. It is now read-only.

[DNM] Add LLDB formatters for types that live primarily in FoundationBase. #1187

Open
wants to merge 1 commit into
base: stable
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions source/Plugins/Language/Swift/SwiftLanguage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,8 @@ static void LoadSwiftFormatters(lldb::TypeCategoryImplSP swift_category_sp) {
ConstString("CoreGraphics.CGFloat"), summary_flags);
AddStringSummary(swift_category_sp, "${var.native}",
ConstString("Foundation.CGFloat"), summary_flags);
AddStringSummary(swift_category_sp, "${var.native}",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, is CGFloat living exclusively in FoundationBase? If so, the other formatter can be removed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only in swift-corelibs-foundation. Does this cover Darwin too?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I'd like to be able to debug things built with swift-corelibs-foundation and Swift 4.x :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This covers everything (Darwin and Linux). If you really want to match both, use a regex instead of duplicating the code (see other examples, or ping me if you have issues).

Also, compiler and debugger are revlocked until swift grows a stable module format so the backcompatibility argument doesn't hold.

Thanks!

ConstString("FoundationBase.CGFloat"), summary_flags);
#endif // LLDB_DISABLE_PYTHON
}

Expand All @@ -585,6 +587,11 @@ LoadFoundationValueTypesFormatters(lldb::TypeCategoryImplSP swift_category_sp) {
"Foundation.Date summary provider", ConstString("Foundation.Date"),
TypeSummaryImpl::Flags(summary_flags).SetDontShowChildren(true));

lldb_private::formatters::AddCXXSummary(
swift_category_sp, lldb_private::formatters::swift::Date_SummaryProvider,
"FoundationBase.Date summary provider", ConstString("FoundationBase.Date"),
TypeSummaryImpl::Flags(summary_flags).SetDontShowChildren(true));

lldb_private::formatters::AddCXXSummary(
swift_category_sp,
lldb_private::formatters::swift::NotificationName_SummaryProvider,
Expand All @@ -597,40 +604,80 @@ LoadFoundationValueTypesFormatters(lldb::TypeCategoryImplSP swift_category_sp) {
"Notification.Name summary provider",
ConstString("Foundation.Notification.Name"),
TypeSummaryImpl::Flags(summary_flags).SetDontShowChildren(true));
lldb_private::formatters::AddCXXSummary(
swift_category_sp,
lldb_private::formatters::swift::NotificationName_SummaryProvider,
"Notification.Name summary provider",
ConstString("FoundationBase.Notification.Type.Name"),
TypeSummaryImpl::Flags(summary_flags).SetDontShowChildren(true));
lldb_private::formatters::AddCXXSummary(
swift_category_sp,
lldb_private::formatters::swift::NotificationName_SummaryProvider,
"Notification.Name summary provider",
ConstString("FoundationBase.Notification.Name"),
TypeSummaryImpl::Flags(summary_flags).SetDontShowChildren(true));

lldb_private::formatters::AddCXXSummary(
swift_category_sp, lldb_private::formatters::swift::URL_SummaryProvider,
"URL summary provider", ConstString("Foundation.URL"),
TypeSummaryImpl::Flags(summary_flags).SetDontShowChildren(true));
lldb_private::formatters::AddCXXSummary(
swift_category_sp, lldb_private::formatters::swift::URL_SummaryProvider,
"URL summary provider", ConstString("FoundationBase.URL"),
TypeSummaryImpl::Flags(summary_flags).SetDontShowChildren(true));

lldb_private::formatters::AddCXXSummary(
swift_category_sp,
lldb_private::formatters::swift::IndexPath_SummaryProvider,
"IndexPath summary provider", ConstString("Foundation.IndexPath"),
summary_flags);
lldb_private::formatters::AddCXXSummary(
swift_category_sp,
lldb_private::formatters::swift::IndexPath_SummaryProvider,
"IndexPath summary provider", ConstString("FoundationBase.IndexPath"),
summary_flags);

lldb_private::formatters::AddCXXSummary(
swift_category_sp,
lldb_private::formatters::swift::Measurement_SummaryProvider,
"Measurement summary provider",
ConstString("Foundation.Measurement<Foundation.Unit>"),
TypeSummaryImpl::Flags(summary_flags).SetDontShowChildren(true));
lldb_private::formatters::AddCXXSummary(
swift_category_sp,
lldb_private::formatters::swift::Measurement_SummaryProvider,
"Measurement summary provider",
ConstString("FoundationBase.Measurement<FoundationBase.Unit>"),
TypeSummaryImpl::Flags(summary_flags).SetDontShowChildren(true));

lldb_private::formatters::AddCXXSummary(
swift_category_sp, lldb_private::formatters::swift::UUID_SummaryProvider,
"UUID summary provider", ConstString("Foundation.UUID"),
TypeSummaryImpl::Flags(summary_flags).SetDontShowChildren(true));
lldb_private::formatters::AddCXXSummary(
swift_category_sp, lldb_private::formatters::swift::UUID_SummaryProvider,
"UUID summary provider", ConstString("FoundationBase.UUID"),
TypeSummaryImpl::Flags(summary_flags).SetDontShowChildren(true));

lldb_private::formatters::AddCXXSummary(
swift_category_sp, lldb_private::formatters::swift::Data_SummaryProvider,
"Data summary provider", ConstString("Foundation.Data"),
TypeSummaryImpl::Flags(summary_flags).SetDontShowChildren(true));
lldb_private::formatters::AddCXXSummary(
swift_category_sp, lldb_private::formatters::swift::Data_SummaryProvider,
"Data summary provider", ConstString("FoundationBase.Data"),
TypeSummaryImpl::Flags(summary_flags).SetDontShowChildren(true));

lldb_private::formatters::AddCXXSummary(
swift_category_sp,
lldb_private::formatters::swift::Decimal_SummaryProvider,
"Decimal summary provider", ConstString("Foundation.Decimal"),
TypeSummaryImpl::Flags(summary_flags).SetDontShowChildren(true));
lldb_private::formatters::AddCXXSummary(
swift_category_sp,
lldb_private::formatters::swift::Decimal_SummaryProvider,
"Decimal summary provider", ConstString("FoundationBase.Decimal"),
TypeSummaryImpl::Flags(summary_flags).SetDontShowChildren(true));

lldb_private::formatters::AddCXXSynthetic(
swift_category_sp,
Expand All @@ -641,6 +688,15 @@ LoadFoundationValueTypesFormatters(lldb::TypeCategoryImplSP swift_category_sp) {
.SetCascades(true)
.SetSkipReferences(false)
.SetNonCacheable(false));
lldb_private::formatters::AddCXXSynthetic(
swift_category_sp,
lldb_private::formatters::swift::URLComponentsSyntheticFrontEndCreator,
"URLComponents synthetic children",
ConstString("FoundationBase.URLComponents"), SyntheticChildren::Flags()
.SetSkipPointers(true)
.SetCascades(true)
.SetSkipReferences(false)
.SetNonCacheable(false));
#endif
}

Expand Down