diff options
author | Enrico Granata <egranata@apple.com> | 2015-07-07 00:20:57 +0000 |
---|---|---|
committer | Enrico Granata <egranata@apple.com> | 2015-07-07 00:20:57 +0000 |
commit | d529d04fd73c55f35d3f6425314a6780e9146f23 (patch) | |
tree | c1bc3b8509a1dde0e927d7afa53f5dccd5beaea5 /lldb/source | |
parent | 5a2acd1e1ebaef6fac73b81554284ba5e7ac1ac6 (diff) | |
download | bcm5719-llvm-d529d04fd73c55f35d3f6425314a6780e9146f23.tar.gz bcm5719-llvm-d529d04fd73c55f35d3f6425314a6780e9146f23.zip |
Add a summary for vector types
The summary is - quite simply - a one-line printout of the vector elements
We still need synthetic children:
a) as a source of the elements to print in the summary
b) for graphical IDEs that display structure regardless of the summary settings
rdar://5429347
llvm-svn: 241531
Diffstat (limited to 'lldb/source')
-rw-r--r-- | lldb/source/DataFormatters/FormatManager.cpp | 20 | ||||
-rw-r--r-- | lldb/source/DataFormatters/VectorType.cpp | 48 |
2 files changed, 67 insertions, 1 deletions
diff --git a/lldb/source/DataFormatters/FormatManager.cpp b/lldb/source/DataFormatters/FormatManager.cpp index 47456ba5c45..4e0fffbe6a1 100644 --- a/lldb/source/DataFormatters/FormatManager.cpp +++ b/lldb/source/DataFormatters/FormatManager.cpp @@ -1608,6 +1608,26 @@ FormatManager::LoadHardcodedFormatters() } return nullptr; }); + m_hardcoded_summaries.push_back( + [](lldb_private::ValueObject& valobj, + lldb::DynamicValueType, + FormatManager& fmt_mgr) -> TypeSummaryImpl::SharedPointer { + static CXXFunctionSummaryFormat::SharedPointer formatter_sp(new CXXFunctionSummaryFormat(TypeSummaryImpl::Flags() + .SetCascades(true) + .SetDontShowChildren(true) + .SetHideItemNames(true) + .SetShowMembersOneLiner(true) + .SetSkipPointers(true) + .SetSkipReferences(false), + lldb_private::formatters::VectorTypeSummaryProvider, + "vector_type pointer summary provider")); + if (valobj.GetClangType().IsVectorType(nullptr, nullptr)) + { + if (fmt_mgr.GetCategory(fmt_mgr.m_vectortypes_category_name)->IsEnabled()) + return formatter_sp; + } + return nullptr; + }); } { // insert code to load synthetics here diff --git a/lldb/source/DataFormatters/VectorType.cpp b/lldb/source/DataFormatters/VectorType.cpp index 57bf696ba4f..316d7b540bc 100644 --- a/lldb/source/DataFormatters/VectorType.cpp +++ b/lldb/source/DataFormatters/VectorType.cpp @@ -7,9 +7,10 @@ // //===----------------------------------------------------------------------===// -#include "lldb/DataFormatters/CXXFormatterFunctions.h" +#include "lldb/DataFormatters/VectorType.h" #include "lldb/Core/ValueObject.h" +#include "lldb/DataFormatters/CXXFormatterFunctions.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/ClangASTType.h" @@ -267,6 +268,51 @@ namespace lldb_private { } } +bool +lldb_private::formatters::VectorTypeSummaryProvider (ValueObject& valobj, + Stream& s, + const TypeSummaryOptions&) +{ + auto synthetic_children = VectorTypeSyntheticFrontEndCreator(nullptr, valobj.GetSP()); + if (!synthetic_children) + return false; + + synthetic_children->Update(); + + s.PutChar('('); + bool first = true; + + size_t idx = 0, len = synthetic_children->CalculateNumChildren(); + + for (; + idx < len; + idx++) + { + auto child_sp = synthetic_children->GetChildAtIndex(idx); + if (!child_sp) + continue; + child_sp = child_sp->GetQualifiedRepresentationIfAvailable(lldb::eDynamicDontRunTarget, true); + + const char* child_value = child_sp->GetValueAsCString(); + if (child_value && *child_value) + { + if (first) + { + s.Printf("%s", child_value); + first = false; + } + else + { + s.Printf(", %s", child_value); + } + } + } + + s.PutChar(')'); + + return true; +} + lldb_private::SyntheticChildrenFrontEnd* lldb_private::formatters::VectorTypeSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP valobj_sp) { |