46
46
#include " LibCxxVariant.h"
47
47
#include " LibStdcpp.h"
48
48
#include " MSVCUndecoratedNameParser.h"
49
+ #include " MsvcStl.h"
49
50
#include " lldb/lldb-enumerations.h"
50
51
51
52
using namespace lldb ;
@@ -1372,6 +1373,56 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
1372
1373
" ${var.__y_} ${var.__m_} ${var.__wdl_}" )));
1373
1374
}
1374
1375
1376
+ template <StringPrinter::StringElementType element_type>
1377
+ static bool
1378
+ LibstdcppOrMsvcStringSummaryProvider (ValueObject &valobj, Stream &stream,
1379
+ const TypeSummaryOptions &options) {
1380
+ ValueObjectSP libstdcpp = valobj.GetChildMemberWithName (" _M_dataplus" );
1381
+ if (libstdcpp) {
1382
+ ValueObjectSP ptr = libstdcpp->GetChildMemberWithName (" _M_p" );
1383
+ if (!ptr)
1384
+ return false ;
1385
+ return CharTStringSummaryProvider<element_type>(*ptr, stream);
1386
+ }
1387
+ return MsvcStlStringSummaryProvider<element_type>(valobj, stream, options);
1388
+ }
1389
+
1390
+ static bool
1391
+ LibstdcppOrMsvcWStringSummaryProvider (ValueObject &valobj, Stream &stream,
1392
+ const TypeSummaryOptions &options) {
1393
+ ValueObjectSP libstdcpp = valobj.GetChildMemberWithName (" _M_dataplus" );
1394
+ if (libstdcpp) {
1395
+ ValueObjectSP ptr = libstdcpp->GetChildMemberWithName (" _M_p" );
1396
+ if (!ptr)
1397
+ return false ;
1398
+ return WCharStringSummaryProvider (*ptr, stream, options);
1399
+ }
1400
+ return MsvcStlWStringSummaryProvider (valobj, stream, options);
1401
+ }
1402
+
1403
+ static void RegisterLibstdcppOrMsvcStringSummaryProvider (
1404
+ const lldb::TypeCategoryImplSP &category_sp, llvm::StringRef string_ty,
1405
+ llvm::StringRef char_ty, const lldb::TypeSummaryImplSP &summary_sp) {
1406
+ category_sp->AddTypeSummary (string_ty, eFormatterMatchExact, summary_sp);
1407
+
1408
+ // std::basic_string<char>
1409
+ category_sp->AddTypeSummary (
1410
+ (llvm::Twine (" std::basic_string<" ) + char_ty + " >" ).str (),
1411
+ eFormatterMatchExact, summary_sp);
1412
+ // std::basic_string<char,std::char_traits<char>,std::allocator<char> >
1413
+ category_sp->AddTypeSummary ((llvm::Twine (" std::basic_string<" ) + char_ty +
1414
+ " ,std::char_traits<" + char_ty +
1415
+ " >,std::allocator<" + char_ty + " > >" )
1416
+ .str (),
1417
+ eFormatterMatchExact, summary_sp);
1418
+ // std::basic_string<char, std::char_traits<char>, std::allocator<char> >
1419
+ category_sp->AddTypeSummary ((llvm::Twine (" std::basic_string<" ) + char_ty +
1420
+ " , std::char_traits<" + char_ty +
1421
+ " >, std::allocator<" + char_ty + " > >" )
1422
+ .str (),
1423
+ eFormatterMatchExact, summary_sp);
1424
+ }
1425
+
1375
1426
static void LoadLibStdcppFormatters (lldb::TypeCategoryImplSP cpp_category_sp) {
1376
1427
if (!cpp_category_sp)
1377
1428
return ;
@@ -1385,26 +1436,20 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
1385
1436
.SetShowMembersOneLiner (false )
1386
1437
.SetHideItemNames (false );
1387
1438
1388
- lldb::TypeSummaryImplSP std_string_summary_sp (
1389
- new StringSummaryFormat (stl_summary_flags, " ${var._M_dataplus._M_p}" ));
1390
-
1391
1439
lldb::TypeSummaryImplSP cxx11_string_summary_sp (new CXXFunctionSummaryFormat (
1392
1440
stl_summary_flags, LibStdcppStringSummaryProvider,
1393
1441
" libstdc++ c++11 std::string summary provider" ));
1394
1442
lldb::TypeSummaryImplSP cxx11_wstring_summary_sp (new CXXFunctionSummaryFormat (
1395
1443
stl_summary_flags, LibStdcppWStringSummaryProvider,
1396
1444
" libstdc++ c++11 std::wstring summary provider" ));
1397
1445
1398
- cpp_category_sp->AddTypeSummary (" std::string" , eFormatterMatchExact,
1399
- std_string_summary_sp);
1400
- cpp_category_sp->AddTypeSummary (" std::basic_string<char>" ,
1401
- eFormatterMatchExact, std_string_summary_sp);
1402
- cpp_category_sp->AddTypeSummary (
1403
- " std::basic_string<char,std::char_traits<char>,std::allocator<char> >" ,
1404
- eFormatterMatchExact, std_string_summary_sp);
1405
- cpp_category_sp->AddTypeSummary (
1406
- " std::basic_string<char, std::char_traits<char>, std::allocator<char> >" ,
1407
- eFormatterMatchExact, std_string_summary_sp);
1446
+ RegisterLibstdcppOrMsvcStringSummaryProvider (
1447
+ cpp_category_sp, " std::string" , " char" ,
1448
+ lldb::TypeSummaryImplSP (new CXXFunctionSummaryFormat (
1449
+ stl_summary_flags,
1450
+ LibstdcppOrMsvcStringSummaryProvider<
1451
+ StringPrinter::StringElementType::ASCII>,
1452
+ " libstdc++/MSVC STL std::string summary provider" )));
1408
1453
1409
1454
cpp_category_sp->AddTypeSummary (" std::__cxx11::string" , eFormatterMatchExact,
1410
1455
cxx11_string_summary_sp);
@@ -1418,22 +1463,11 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
1418
1463
eFormatterMatchExact,
1419
1464
cxx11_string_summary_sp);
1420
1465
1421
- // making sure we force-pick the summary for printing wstring (_M_p is a
1422
- // wchar_t*)
1423
- lldb::TypeSummaryImplSP std_wstring_summary_sp (
1424
- new StringSummaryFormat (stl_summary_flags, " ${var._M_dataplus._M_p%S}" ));
1425
-
1426
- cpp_category_sp->AddTypeSummary (" std::wstring" , eFormatterMatchExact,
1427
- std_wstring_summary_sp);
1428
- cpp_category_sp->AddTypeSummary (" std::basic_string<wchar_t>" ,
1429
- eFormatterMatchExact, std_wstring_summary_sp);
1430
- cpp_category_sp->AddTypeSummary (" std::basic_string<wchar_t,std::char_traits<"
1431
- " wchar_t>,std::allocator<wchar_t> >" ,
1432
- eFormatterMatchExact, std_wstring_summary_sp);
1433
- cpp_category_sp->AddTypeSummary (
1434
- " std::basic_string<wchar_t, std::char_traits<wchar_t>, "
1435
- " std::allocator<wchar_t> >" ,
1436
- eFormatterMatchExact, std_wstring_summary_sp);
1466
+ RegisterLibstdcppOrMsvcStringSummaryProvider (
1467
+ cpp_category_sp, " std::wstring" , " wchar_t" ,
1468
+ lldb::TypeSummaryImplSP (new CXXFunctionSummaryFormat (
1469
+ stl_summary_flags, LibstdcppOrMsvcWStringSummaryProvider,
1470
+ " libstdc++/MSVC STL std::wstring summary provider" )));
1437
1471
1438
1472
cpp_category_sp->AddTypeSummary (" std::__cxx11::wstring" , eFormatterMatchExact,
1439
1473
cxx11_wstring_summary_sp);
@@ -1442,6 +1476,28 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
1442
1476
" std::allocator<wchar_t> >" ,
1443
1477
eFormatterMatchExact, cxx11_wstring_summary_sp);
1444
1478
1479
+ RegisterLibstdcppOrMsvcStringSummaryProvider (
1480
+ cpp_category_sp, " std::u8string" , " char8_t" ,
1481
+ lldb::TypeSummaryImplSP (new CXXFunctionSummaryFormat (
1482
+ stl_summary_flags,
1483
+ LibstdcppOrMsvcStringSummaryProvider<
1484
+ StringPrinter::StringElementType::UTF8>,
1485
+ " libstdc++/MSVC STL std::u8string summary provider" )));
1486
+ RegisterLibstdcppOrMsvcStringSummaryProvider (
1487
+ cpp_category_sp, " std::u16string" , " char16_t" ,
1488
+ lldb::TypeSummaryImplSP (new CXXFunctionSummaryFormat (
1489
+ stl_summary_flags,
1490
+ LibstdcppOrMsvcStringSummaryProvider<
1491
+ StringPrinter::StringElementType::UTF16>,
1492
+ " libstdc++/MSVC STL std::u16string summary provider" )));
1493
+ RegisterLibstdcppOrMsvcStringSummaryProvider (
1494
+ cpp_category_sp, " std::u32string" , " char32_t" ,
1495
+ lldb::TypeSummaryImplSP (new CXXFunctionSummaryFormat (
1496
+ stl_summary_flags,
1497
+ LibstdcppOrMsvcStringSummaryProvider<
1498
+ StringPrinter::StringElementType::UTF32>,
1499
+ " libstdc++/MSVC STL std::u32string summary provider" )));
1500
+
1445
1501
SyntheticChildren::Flags stl_synth_flags;
1446
1502
stl_synth_flags.SetCascades (true ).SetSkipPointers (false ).SetSkipReferences (
1447
1503
false );
0 commit comments