diff options
Diffstat (limited to 'include/lldb/DataFormatters/TypeSummary.h')
-rw-r--r-- | include/lldb/DataFormatters/TypeSummary.h | 190 |
1 files changed, 88 insertions, 102 deletions
diff --git a/include/lldb/DataFormatters/TypeSummary.h b/include/lldb/DataFormatters/TypeSummary.h index c2838eac27f1..e5bf4ecadfdf 100644 --- a/include/lldb/DataFormatters/TypeSummary.h +++ b/include/lldb/DataFormatters/TypeSummary.h @@ -1,4 +1,4 @@ -//===-- TypeSummary.h --------------------------------------------*- C++ -*-===// +//===-- TypeSummary.h -------------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -14,11 +14,11 @@ #include <stdint.h> // C++ Includes +#include <functional> +#include <memory> #include <string> -#include <vector> // Other libraries and framework includes - // Project includes #include "lldb/lldb-public.h" #include "lldb/lldb-enumerations.h" @@ -26,8 +26,6 @@ #include "lldb/Core/Error.h" #include "lldb/Core/FormatEntity.h" #include "lldb/Core/StructuredData.h" -#include "lldb/Core/ValueObject.h" -#include "lldb/Symbol/Type.h" namespace lldb_private { class TypeSummaryOptions @@ -36,6 +34,8 @@ namespace lldb_private { TypeSummaryOptions (); TypeSummaryOptions (const TypeSummaryOptions& rhs); + ~TypeSummaryOptions() = default; + TypeSummaryOptions& operator = (const TypeSummaryOptions& rhs); @@ -50,8 +50,7 @@ namespace lldb_private { TypeSummaryOptions& SetCapping (lldb::TypeSummaryCapping); - - ~TypeSummaryOptions() = default; + private: lldb::LanguageType m_lang; lldb::TypeSummaryCapping m_capping; @@ -60,10 +59,26 @@ namespace lldb_private { class TypeSummaryImpl { public: + enum class Kind + { + eSummaryString, + eScript, + eCallback, + eInternal + }; + + virtual + ~TypeSummaryImpl() = default; + + Kind + GetKind () const + { + return m_kind; + } + class Flags { public: - Flags () : m_flags (lldb::eTypeOptionCascade) {} @@ -162,6 +177,22 @@ namespace lldb_private { m_flags &= ~lldb::eTypeOptionHideChildren; return *this; } + + bool + GetHideEmptyAggregates () const + { + return (m_flags & lldb::eTypeOptionHideEmptyAggregates) == lldb::eTypeOptionHideEmptyAggregates; + } + + Flags& + SetHideEmptyAggregates (bool value = true) + { + if (value) + m_flags |= lldb::eTypeOptionHideEmptyAggregates; + else + m_flags &= ~lldb::eTypeOptionHideEmptyAggregates; + return *this; + } bool GetDontShowValue () const @@ -243,31 +274,24 @@ namespace lldb_private { uint32_t m_flags; }; - typedef enum Type - { - eTypeUnknown, - eTypeString, - eTypeScript, - eTypeCallback - } Type; - - TypeSummaryImpl (const TypeSummaryImpl::Flags& flags); - bool Cascades () const { return m_flags.GetCascades(); } + bool SkipsPointers () const { return m_flags.GetSkipPointers(); } + bool SkipsReferences () const { return m_flags.GetSkipReferences(); } + bool NonCacheable () const { @@ -279,6 +303,12 @@ namespace lldb_private { { return !m_flags.GetDontShowChildren(); } + + virtual bool + DoesPrintEmptyAggregates () const + { + return !m_flags.GetHideEmptyAggregates(); + } virtual bool DoesPrintValue (ValueObject* valobj) const @@ -358,11 +388,6 @@ namespace lldb_private { m_flags.SetValue(value); } - virtual - ~TypeSummaryImpl () - { - } - // we are using a ValueObject* instead of a ValueObjectSP because we do not need to hold on to this for // extended periods of time and we trust the ValueObject to stay around for as long as it is required // for us to generate its summary @@ -374,12 +399,6 @@ namespace lldb_private { virtual std::string GetDescription () = 0; - virtual bool - IsScripted () = 0; - - virtual Type - GetType () = 0; - uint32_t& GetRevision () { @@ -387,14 +406,16 @@ namespace lldb_private { } typedef std::shared_ptr<TypeSummaryImpl> SharedPointer; - typedef bool(*SummaryCallback)(void*, ConstString, const lldb::TypeSummaryImplSP&); - typedef bool(*RegexSummaryCallback)(void*, lldb::RegularExpressionSP, const lldb::TypeSummaryImplSP&); protected: uint32_t m_my_revision; Flags m_flags; + TypeSummaryImpl (Kind kind, + const TypeSummaryImpl::Flags& flags); + private: + Kind m_kind; DISALLOW_COPY_AND_ASSIGN(TypeSummaryImpl); }; @@ -407,11 +428,8 @@ namespace lldb_private { StringSummaryFormat(const TypeSummaryImpl::Flags& flags, const char* f); - - virtual - ~StringSummaryFormat() - { - } + + ~StringSummaryFormat() override = default; const char* GetSummaryString () const @@ -422,25 +440,17 @@ namespace lldb_private { void SetSummaryString (const char* f); - virtual bool + bool FormatObject(ValueObject *valobj, std::string& dest, - const TypeSummaryOptions& options); - - virtual std::string - GetDescription(); - - virtual bool - IsScripted () - { - return false; - } + const TypeSummaryOptions& options) override; + std::string + GetDescription() override; - virtual Type - GetType () + static bool classof(const TypeSummaryImpl* S) { - return TypeSummaryImpl::eTypeString; + return S->GetKind() == Kind::eSummaryString; } private: @@ -452,9 +462,9 @@ namespace lldb_private { { // we should convert these to SBValue and SBStream if we ever cross // the boundary towards the external world - typedef bool (*Callback)(ValueObject&, - Stream&, - const TypeSummaryOptions&); + typedef std::function<bool(ValueObject&, + Stream&, + const TypeSummaryOptions&)> Callback; Callback m_impl; std::string m_description; @@ -462,7 +472,9 @@ namespace lldb_private { CXXFunctionSummaryFormat (const TypeSummaryImpl::Flags& flags, Callback impl, const char* description); - + + ~CXXFunctionSummaryFormat() override = default; + Callback GetBackendFunction () const { @@ -489,30 +501,18 @@ namespace lldb_private { else m_description.clear(); } + + bool + FormatObject(ValueObject *valobj, + std::string& dest, + const TypeSummaryOptions& options) override; - virtual - ~CXXFunctionSummaryFormat () - { - } - - virtual bool - FormatObject (ValueObject *valobj, - std::string& dest, - const TypeSummaryOptions& options); - - virtual std::string - GetDescription (); - - virtual bool - IsScripted () - { - return false; - } + std::string + GetDescription() override; - virtual Type - GetType () + static bool classof(const TypeSummaryImpl* S) { - return TypeSummaryImpl::eTypeCallback; + return S->GetKind() == Kind::eCallback; } typedef std::shared_ptr<CXXFunctionSummaryFormat> SharedPointer; @@ -521,8 +521,6 @@ namespace lldb_private { DISALLOW_COPY_AND_ASSIGN(CXXFunctionSummaryFormat); }; -#ifndef LLDB_DISABLE_PYTHON - // Python-based summaries, running script code to show data struct ScriptSummaryFormat : public TypeSummaryImpl { @@ -532,8 +530,10 @@ namespace lldb_private { ScriptSummaryFormat(const TypeSummaryImpl::Flags& flags, const char *function_name, - const char* python_script = NULL); - + const char* python_script = nullptr); + + ~ScriptSummaryFormat() override = default; + const char* GetFunctionName () const { @@ -565,38 +565,24 @@ namespace lldb_private { m_python_script.clear(); } - virtual - ~ScriptSummaryFormat () - { - } - - virtual bool - FormatObject (ValueObject *valobj, - std::string& dest, - const TypeSummaryOptions& options); - - virtual std::string - GetDescription (); + bool + FormatObject(ValueObject *valobj, + std::string& dest, + const TypeSummaryOptions& options) override; - virtual bool - IsScripted () - { - return true; - } + std::string + GetDescription() override; - virtual Type - GetType () + static bool classof(const TypeSummaryImpl* S) { - return TypeSummaryImpl::eTypeScript; + return S->GetKind() == Kind::eScript; } typedef std::shared_ptr<ScriptSummaryFormat> SharedPointer; - private: DISALLOW_COPY_AND_ASSIGN(ScriptSummaryFormat); }; -#endif } // namespace lldb_private -#endif // lldb_TypeSummary_h_ +#endif // lldb_TypeSummary_h_ |