Skip to content

Commit 87e2769

Browse files
committed
[LLDB] Add formatters for MSVC STL map-like types
1 parent c0a1825 commit 87e2769

File tree

10 files changed

+549
-44
lines changed

10 files changed

+549
-44
lines changed

lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ add_lldb_library(lldbPluginCPlusPlusLanguage PLUGIN
3434
LibStdcppTuple.cpp
3535
LibStdcppUniquePointer.cpp
3636
MsvcStl.cpp
37+
MsvcStlTree.cpp
3738
MsvcStlSmartPointer.cpp
3839
MSVCUndecoratedNameParser.cpp
3940

lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp

Lines changed: 52 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,7 +1409,7 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
14091409
stl_synth_flags,
14101410
"lldb.formatters.cpp.gnu_libstdcpp.StdVectorSynthProvider")));
14111411
cpp_category_sp->AddTypeSynthetic(
1412-
"^std::(__debug::)?map<.+> >(( )?&)?$", eFormatterMatchRegex,
1412+
"^std::__debug::map<.+> >(( )?&)?$", eFormatterMatchRegex,
14131413
SyntheticChildrenSP(new ScriptedSyntheticChildren(
14141414
stl_synth_flags,
14151415
"lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider")));
@@ -1419,17 +1419,17 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
14191419
stl_deref_flags,
14201420
"lldb.formatters.cpp.gnu_libstdcpp.StdDequeSynthProvider")));
14211421
cpp_category_sp->AddTypeSynthetic(
1422-
"^std::(__debug::)?set<.+> >(( )?&)?$", eFormatterMatchRegex,
1422+
"^std::__debug::set<.+> >(( )?&)?$", eFormatterMatchRegex,
14231423
SyntheticChildrenSP(new ScriptedSyntheticChildren(
14241424
stl_deref_flags,
14251425
"lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider")));
14261426
cpp_category_sp->AddTypeSynthetic(
1427-
"^std::(__debug::)?multimap<.+> >(( )?&)?$", eFormatterMatchRegex,
1427+
"^std::__debug::multimap<.+> >(( )?&)?$", eFormatterMatchRegex,
14281428
SyntheticChildrenSP(new ScriptedSyntheticChildren(
14291429
stl_deref_flags,
14301430
"lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider")));
14311431
cpp_category_sp->AddTypeSynthetic(
1432-
"^std::(__debug::)?multiset<.+> >(( )?&)?$", eFormatterMatchRegex,
1432+
"^std::__debug::multiset<.+> >(( )?&)?$", eFormatterMatchRegex,
14331433
SyntheticChildrenSP(new ScriptedSyntheticChildren(
14341434
stl_deref_flags,
14351435
"lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider")));
@@ -1470,15 +1470,15 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
14701470
"libstdc++ std::vector summary provider",
14711471
"^std::(__debug::)?vector<.+>(( )?&)?$", stl_summary_flags, true);
14721472

1473-
AddCXXSummary(
1474-
cpp_category_sp, lldb_private::formatters::ContainerSizeSummaryProvider,
1475-
"libstdc++ std::map summary provider",
1476-
"^std::(__debug::)?map<.+> >(( )?&)?$", stl_summary_flags, true);
1473+
AddCXXSummary(cpp_category_sp,
1474+
lldb_private::formatters::ContainerSizeSummaryProvider,
1475+
"libstdc++ std::map summary provider",
1476+
"^std::__debug::map<.+> >(( )?&)?$", stl_summary_flags, true);
14771477

1478-
AddCXXSummary(
1479-
cpp_category_sp, lldb_private::formatters::ContainerSizeSummaryProvider,
1480-
"libstdc++ std::set summary provider",
1481-
"^std::(__debug::)?set<.+> >(( )?&)?$", stl_summary_flags, true);
1478+
AddCXXSummary(cpp_category_sp,
1479+
lldb_private::formatters::ContainerSizeSummaryProvider,
1480+
"libstdc++ std::set summary provider",
1481+
"^std::__debug::set<.+> >(( )?&)?$", stl_summary_flags, true);
14821482

14831483
AddCXXSummary(
14841484
cpp_category_sp, lldb_private::formatters::ContainerSizeSummaryProvider,
@@ -1488,12 +1488,12 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
14881488
AddCXXSummary(
14891489
cpp_category_sp, lldb_private::formatters::ContainerSizeSummaryProvider,
14901490
"libstdc++ std::multimap summary provider",
1491-
"^std::(__debug::)?multimap<.+> >(( )?&)?$", stl_summary_flags, true);
1491+
"^std::__debug::multimap<.+> >(( )?&)?$", stl_summary_flags, true);
14921492

14931493
AddCXXSummary(
14941494
cpp_category_sp, lldb_private::formatters::ContainerSizeSummaryProvider,
14951495
"libstdc++ std::multiset summary provider",
1496-
"^std::(__debug::)?multiset<.+> >(( )?&)?$", stl_summary_flags, true);
1496+
"^std::__debug::multiset<.+> >(( )?&)?$", stl_summary_flags, true);
14971497

14981498
AddCXXSummary(cpp_category_sp,
14991499
lldb_private::formatters::ContainerSizeSummaryProvider,
@@ -1599,6 +1599,18 @@ GenericSmartPointerSummaryProvider(ValueObject &valobj, Stream &stream,
15991599
return LibStdcppSmartPointerSummaryProvider(valobj, stream, options);
16001600
}
16011601

1602+
static lldb_private::SyntheticChildrenFrontEnd *
1603+
GenericMapLikeSyntheticFrontEndCreator(CXXSyntheticChildren *children,
1604+
lldb::ValueObjectSP valobj_sp) {
1605+
if (!valobj_sp)
1606+
return nullptr;
1607+
1608+
if (IsMsvcStlMapLike(*valobj_sp))
1609+
return MsvcStlMapLikeSyntheticFrontEndCreator(valobj_sp);
1610+
return new ScriptedSyntheticChildren::FrontEnd(
1611+
"lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider", *valobj_sp);
1612+
}
1613+
16021614
/// Load formatters that are formatting types from more than one STL
16031615
static void LoadCommonStlFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
16041616
if (!cpp_category_sp)
@@ -1642,19 +1654,30 @@ static void LoadCommonStlFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
16421654
},
16431655
"MSVC STL/libstdc++ std::wstring summary provider"));
16441656

1657+
stl_summary_flags.SetDontShowChildren(false);
1658+
stl_summary_flags.SetSkipPointers(false);
1659+
16451660
AddCXXSynthetic(cpp_category_sp, GenericSmartPointerSyntheticFrontEndCreator,
16461661
"std::shared_ptr synthetic children",
16471662
"^std::shared_ptr<.+>(( )?&)?$", stl_synth_flags, true);
16481663
AddCXXSynthetic(cpp_category_sp, GenericSmartPointerSyntheticFrontEndCreator,
16491664
"std::weak_ptr synthetic children",
16501665
"^std::weak_ptr<.+>(( )?&)?$", stl_synth_flags, true);
1666+
AddCXXSynthetic(cpp_category_sp, GenericMapLikeSyntheticFrontEndCreator,
1667+
"std::(multi)?map/set synthetic children",
1668+
"^std::(multi)?(map|set)<.+>(( )?&)?$", stl_synth_flags,
1669+
true);
16511670

16521671
AddCXXSummary(cpp_category_sp, GenericSmartPointerSummaryProvider,
16531672
"MSVC STL/libstdc++ std::shared_ptr summary provider",
16541673
"^std::shared_ptr<.+>(( )?&)?$", stl_summary_flags, true);
16551674
AddCXXSummary(cpp_category_sp, GenericSmartPointerSummaryProvider,
16561675
"MSVC STL/libstdc++ std::weak_ptr summary provider",
16571676
"^std::weak_ptr<.+>(( )?&)?$", stl_summary_flags, true);
1677+
AddCXXSummary(cpp_category_sp, ContainerSizeSummaryProvider,
1678+
"MSVC STL/libstdc++ std::(multi)?map/set summary provider",
1679+
"^std::(multi)?(map|set)<.+>(( )?&)?$", stl_summary_flags,
1680+
true);
16581681
}
16591682

16601683
static void LoadMsvcStlFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
@@ -1669,6 +1692,9 @@ static void LoadMsvcStlFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
16691692
.SetDontShowValue(false)
16701693
.SetShowMembersOneLiner(false)
16711694
.SetHideItemNames(false);
1695+
SyntheticChildren::Flags stl_synth_flags;
1696+
stl_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences(
1697+
false);
16721698

16731699
using StringElementType = StringPrinter::StringElementType;
16741700

@@ -1690,6 +1716,18 @@ static void LoadMsvcStlFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
16901716
stl_summary_flags,
16911717
MsvcStlStringSummaryProvider<StringElementType::UTF32>,
16921718
"MSVC STL std::u32string summary provider"));
1719+
1720+
stl_summary_flags.SetDontShowChildren(false);
1721+
stl_summary_flags.SetSkipPointers(false);
1722+
1723+
AddCXXSynthetic(cpp_category_sp, MsvcStlTreeIterSyntheticFrontEndCreator,
1724+
"MSVC STL tree iterator synthetic children",
1725+
"^std::_Tree(_const)?_iterator<.+>(( )?&)?$", stl_synth_flags,
1726+
true);
1727+
AddCXXSummary(cpp_category_sp, MsvcStlTreeIterSummaryProvider,
1728+
"MSVC STL tree iterator summary",
1729+
"^std::_Tree(_const)?_iterator<.+>(( )?&)?$", stl_summary_flags,
1730+
true);
16931731
}
16941732

16951733
static void LoadSystemFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {

lldb/source/Plugins/Language/CPlusPlus/MsvcStl.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ bool MsvcStlSmartPointerSummaryProvider(ValueObject &valobj, Stream &stream,
3737
lldb_private::SyntheticChildrenFrontEnd *
3838
MsvcStlSmartPointerSyntheticFrontEndCreator(lldb::ValueObjectSP valobj_sp);
3939

40+
bool IsMsvcStlTreeIter(ValueObject &valobj);
41+
bool MsvcStlTreeIterSummaryProvider(ValueObject &valobj, Stream &stream,
42+
const TypeSummaryOptions &options);
43+
lldb_private::SyntheticChildrenFrontEnd *
44+
MsvcStlTreeIterSyntheticFrontEndCreator(CXXSyntheticChildren *,
45+
lldb::ValueObjectSP valobj_sp);
46+
47+
// std::map,set,multimap,multiset
48+
bool IsMsvcStlMapLike(ValueObject &valobj);
49+
lldb_private::SyntheticChildrenFrontEnd *
50+
MsvcStlMapLikeSyntheticFrontEndCreator(lldb::ValueObjectSP valobj_sp);
51+
4052
} // namespace formatters
4153
} // namespace lldb_private
4254

0 commit comments

Comments
 (0)