Skip to content

Commit a341b83

Browse files
committed
[LLDB] Add formatters for MSVC STL std::(forward_)list
1 parent f98cf07 commit a341b83

File tree

9 files changed

+356
-111
lines changed

9 files changed

+356
-111
lines changed

lldb/examples/synthetic/gnu_libstdcpp.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,6 @@
66
# thing for your setup
77

88

9-
def ForwardListSummaryProvider(valobj, dict):
10-
list_capping_size = valobj.GetTarget().GetMaximumNumberOfChildrenToDisplay()
11-
text = "size=" + str(valobj.GetNumChildren())
12-
if valobj.GetNumChildren() > list_capping_size:
13-
return "(capped) " + text
14-
else:
15-
return text
16-
17-
189
def StdOptionalSummaryProvider(valobj, dict):
1910
has_value = valobj.GetNumChildren() > 0
2011
# We add wrapping spaces for consistency with the libcxx formatter

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ add_lldb_library(lldbPluginCPlusPlusLanguage PLUGIN
1414
CxxStringTypes.cpp
1515
Generic.cpp
1616
GenericBitset.cpp
17+
GenericList.cpp
1718
GenericOptional.cpp
1819
LibCxx.cpp
1920
LibCxxAtomic.cpp
2021
LibCxxInitializerList.cpp
21-
LibCxxList.cpp
2222
LibCxxMap.cpp
2323
LibCxxQueue.cpp
2424
LibCxxRangesRefView.cpp

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

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,14 +1440,12 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
14401440
stl_deref_flags,
14411441
"lldb.formatters.cpp.gnu_libstdcpp.StdUnorderedMapSynthProvider")));
14421442
cpp_category_sp->AddTypeSynthetic(
1443-
"^std::((__debug::)?|(__cxx11::)?)list<.+>(( )?&)?$",
1444-
eFormatterMatchRegex,
1443+
"^std::__(debug|cxx11)::list<.+>(( )?&)?$", eFormatterMatchRegex,
14451444
SyntheticChildrenSP(new ScriptedSyntheticChildren(
14461445
stl_deref_flags,
14471446
"lldb.formatters.cpp.gnu_libstdcpp.StdListSynthProvider")));
14481447
cpp_category_sp->AddTypeSynthetic(
1449-
"^std::((__debug::)?|(__cxx11::)?)forward_list<.+>(( )?&)?$",
1450-
eFormatterMatchRegex,
1448+
"^std::__(debug|cxx11)::forward_list<.+>(( )?&)?$", eFormatterMatchRegex,
14511449
SyntheticChildrenSP(new ScriptedSyntheticChildren(
14521450
stl_synth_flags,
14531451
"lldb.formatters.cpp.gnu_libstdcpp.StdForwardListSynthProvider")));
@@ -1501,18 +1499,15 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
15011499
"^std::(__debug::)?unordered_(multi)?(map|set)<.+> >$",
15021500
stl_summary_flags, true);
15031501

1504-
AddCXXSummary(cpp_category_sp,
1505-
lldb_private::formatters::ContainerSizeSummaryProvider,
1506-
"libstdc++ std::list summary provider",
1507-
"^std::((__debug::)?|(__cxx11::)?)list<.+>(( )?&)?$",
1508-
stl_summary_flags, true);
1502+
AddCXXSummary(
1503+
cpp_category_sp, lldb_private::formatters::ContainerSizeSummaryProvider,
1504+
"libstdc++ std::list summary provider",
1505+
"^std::__(debug|cxx11)::list<.+>(( )?&)?$", stl_summary_flags, true);
15091506

1510-
cpp_category_sp->AddTypeSummary(
1511-
"^std::((__debug::)?|(__cxx11::)?)forward_list<.+>(( )?&)?$",
1512-
eFormatterMatchRegex,
1513-
TypeSummaryImplSP(new ScriptSummaryFormat(
1514-
stl_summary_flags,
1515-
"lldb.formatters.cpp.gnu_libstdcpp.ForwardListSummaryProvider")));
1507+
AddCXXSummary(cpp_category_sp, ContainerSizeSummaryProvider,
1508+
"libstdc++ std::forward_list summary provider",
1509+
"^std::__(debug|cxx11)::forward_list<.+>(( )?&)?$",
1510+
stl_summary_flags, true);
15161511
AddCXXSummary(cpp_category_sp, LibStdcppVariantSummaryProvider,
15171512
"libstdc++ std::variant summary provider", "^std::variant<.+>$",
15181513
stl_summary_flags, true);
@@ -1627,6 +1622,31 @@ GenericVectorSyntheticFrontEndCreator(CXXSyntheticChildren *children,
16271622
"lldb.formatters.cpp.gnu_libstdcpp.StdVectorSynthProvider", *valobj_sp);
16281623
}
16291624

1625+
static SyntheticChildrenFrontEnd *
1626+
GenericListSyntheticFrontEndCreator(CXXSyntheticChildren *children,
1627+
lldb::ValueObjectSP valobj_sp) {
1628+
if (!valobj_sp)
1629+
return nullptr;
1630+
1631+
if (IsMsvcStlList(*valobj_sp))
1632+
return MsvcStlListSyntheticFrontEndCreator(children, valobj_sp);
1633+
return new ScriptedSyntheticChildren::FrontEnd(
1634+
"lldb.formatters.cpp.gnu_libstdcpp.StdListSynthProvider", *valobj_sp);
1635+
}
1636+
1637+
static SyntheticChildrenFrontEnd *
1638+
GenericForwardListSyntheticFrontEndCreator(CXXSyntheticChildren *children,
1639+
lldb::ValueObjectSP valobj_sp) {
1640+
if (!valobj_sp)
1641+
return nullptr;
1642+
1643+
if (IsMsvcStlList(*valobj_sp))
1644+
return MsvcStlForwardListSyntheticFrontEndCreator(children, valobj_sp);
1645+
return new ScriptedSyntheticChildren::FrontEnd(
1646+
"lldb.formatters.cpp.gnu_libstdcpp.StdForwardListSynthProvider",
1647+
*valobj_sp);
1648+
}
1649+
16301650
/// Load formatters that are formatting types from more than one STL
16311651
static void LoadCommonStlFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
16321652
if (!cpp_category_sp)
@@ -1685,6 +1705,12 @@ static void LoadCommonStlFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
16851705
AddCXXSynthetic(cpp_category_sp, GenericTupleSyntheticFrontEndCreator,
16861706
"std::tuple synthetic children", "^std::tuple<.*>(( )?&)?$",
16871707
stl_synth_flags, true);
1708+
AddCXXSynthetic(cpp_category_sp, GenericListSyntheticFrontEndCreator,
1709+
"std::list synthetic children", "^std::list<.+>(( )?&)?$",
1710+
stl_synth_flags, true);
1711+
AddCXXSynthetic(cpp_category_sp, GenericForwardListSyntheticFrontEndCreator,
1712+
"std::forward_list synthetic children",
1713+
"^std::forward_list<.+>(( )?&)?$", stl_synth_flags, true);
16881714

16891715
AddCXXSummary(cpp_category_sp, GenericSmartPointerSummaryProvider,
16901716
"MSVC STL/libstdc++ std::shared_ptr summary provider",
@@ -1704,6 +1730,12 @@ static void LoadCommonStlFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
17041730
AddCXXSynthetic(cpp_category_sp, GenericVectorSyntheticFrontEndCreator,
17051731
"MSVC/libstdc++ std::vector synthetic provider",
17061732
"^std::vector<.+>(( )?&)?$", stl_synth_flags, true);
1733+
AddCXXSummary(cpp_category_sp, ContainerSizeSummaryProvider,
1734+
"MSVC STL/libstdc++ std::list summary provider",
1735+
"^std::list<.+>(( )?&)?$", stl_summary_flags, true);
1736+
AddCXXSummary(cpp_category_sp, ContainerSizeSummaryProvider,
1737+
"MSVC STL/libstdc++ std::forward_list summary provider",
1738+
"^std::forward_list<.+>(( )?&)?$", stl_summary_flags, true);
17071739
}
17081740

17091741
static void LoadMsvcStlFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {

0 commit comments

Comments
 (0)