[Lldb-commits] [lldb] r221482 - Introduce the notion of "type summary options" as flags that can be passed down to individual summary formatters to alter their behavior in a formatter-dependent way
Enrico Granata
egranata at apple.com
Thu Nov 6 13:23:21 PST 2014
Author: enrico
Date: Thu Nov 6 15:23:20 2014
New Revision: 221482
URL: http://llvm.org/viewvc/llvm-project?rev=221482&view=rev
Log:
Introduce the notion of "type summary options" as flags that can be passed down to individual summary formatters to alter their behavior in a formatter-dependent way
Two flags are introduced:
- preferred display language (as in, ObjC vs. C++)
- summary capping (as in, should a limit be put to the amount of data retrieved)
The meaning - if any - of these options is for individual formatters to establish
The topic of a subsequent commit will be to actually wire these through to individual data formatters
Modified:
lldb/trunk/include/lldb/API/SBDefines.h
lldb/trunk/include/lldb/API/SBTypeSummary.h
lldb/trunk/include/lldb/API/SBValue.h
lldb/trunk/include/lldb/Core/ValueObject.h
lldb/trunk/include/lldb/Core/ValueObjectConstResult.h
lldb/trunk/include/lldb/DataFormatters/TypeSummary.h
lldb/trunk/include/lldb/lldb-enumerations.h
lldb/trunk/include/lldb/lldb-forward.h
lldb/trunk/scripts/Python/interface/SBTypeSummary.i
lldb/trunk/scripts/Python/interface/SBValue.i
lldb/trunk/source/API/SBTypeSummary.cpp
lldb/trunk/source/API/SBValue.cpp
lldb/trunk/source/Core/ValueObject.cpp
lldb/trunk/source/Core/ValueObjectConstResult.cpp
lldb/trunk/source/DataFormatters/TypeSummary.cpp
Modified: lldb/trunk/include/lldb/API/SBDefines.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDefines.h?rev=221482&r1=221481&r2=221482&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBDefines.h (original)
+++ lldb/trunk/include/lldb/API/SBDefines.h Thu Nov 6 15:23:20 2014
@@ -83,6 +83,7 @@ class LLDB_API SBTypeFormat;
class LLDB_API SBTypeMemberFunction;
class LLDB_API SBTypeNameSpecifier;
class LLDB_API SBTypeSummary;
+class LLDB_API SBTypeSummaryOptions;
#ifndef LLDB_DISABLE_PYTHON
class LLDB_API SBTypeSynthetic;
#endif
Modified: lldb/trunk/include/lldb/API/SBTypeSummary.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTypeSummary.h?rev=221482&r1=221481&r2=221482&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBTypeSummary.h (original)
+++ lldb/trunk/include/lldb/API/SBTypeSummary.h Thu Nov 6 15:23:20 2014
@@ -15,6 +15,56 @@
#ifndef LLDB_DISABLE_PYTHON
namespace lldb {
+ class SBTypeSummaryOptions
+ {
+ public:
+ SBTypeSummaryOptions();
+
+ SBTypeSummaryOptions (const lldb::SBTypeSummaryOptions &rhs);
+
+ ~SBTypeSummaryOptions ();
+
+ bool
+ IsValid ();
+
+ lldb::LanguageType
+ GetLanguage ();
+
+ lldb::TypeSummaryCapping
+ GetCapping ();
+
+ void
+ SetLanguage (lldb::LanguageType);
+
+ void
+ SetCapping (lldb::TypeSummaryCapping);
+
+ protected:
+ friend class SBValue;
+
+ lldb_private::TypeSummaryOptions *
+ operator->();
+
+ const lldb_private::TypeSummaryOptions *
+ operator->() const;
+
+ lldb_private::TypeSummaryOptions *
+ get ();
+
+ lldb_private::TypeSummaryOptions &
+ ref();
+
+ const lldb_private::TypeSummaryOptions &
+ ref() const;
+
+ SBTypeSummaryOptions (const lldb_private::TypeSummaryOptions *lldb_object_ptr);
+
+ void
+ SetOptions (const lldb_private::TypeSummaryOptions *lldb_object_ptr);
+
+ private:
+ std::unique_ptr<lldb_private::TypeSummaryOptions> m_opaque_ap;
+ };
class SBTypeSummary
{
Modified: lldb/trunk/include/lldb/API/SBValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBValue.h?rev=221482&r1=221481&r2=221482&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBValue.h (original)
+++ lldb/trunk/include/lldb/API/SBValue.h Thu Nov 6 15:23:20 2014
@@ -91,6 +91,9 @@ public:
GetSummary ();
const char *
+ GetSummary (lldb::SBTypeSummaryOptions& options);
+
+ const char *
GetObjectDescription ();
const char *
Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=221482&r1=221481&r2=221482&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Thu Nov 6 15:23:20 2014
@@ -612,6 +612,14 @@ public:
GetSummaryAsCString (TypeSummaryImpl* summary_ptr,
std::string& destination);
+ const char *
+ GetSummaryAsCString (const TypeSummaryOptions& options);
+
+ bool
+ GetSummaryAsCString (TypeSummaryImpl* summary_ptr,
+ std::string& destination,
+ const TypeSummaryOptions& options);
+
std::pair<TypeValidatorResult, std::string>
GetValidationStatus ();
@@ -852,6 +860,10 @@ public:
m_format = format;
}
+
+ virtual lldb::LanguageType
+ GetPreferredDisplayLanguage ();
+
lldb::TypeSummaryImplSP
GetSummaryFormat()
{
Modified: lldb/trunk/include/lldb/Core/ValueObjectConstResult.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectConstResult.h?rev=221482&r1=221481&r2=221482&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectConstResult.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectConstResult.h Thu Nov 6 15:23:20 2014
@@ -126,6 +126,9 @@ public:
virtual lldb::ValueObjectSP
GetDynamicValue (lldb::DynamicValueType valueType);
+
+ virtual lldb::LanguageType
+ GetPreferredDisplayLanguage ();
protected:
virtual bool
Modified: lldb/trunk/include/lldb/DataFormatters/TypeSummary.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeSummary.h?rev=221482&r1=221481&r2=221482&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/TypeSummary.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/TypeSummary.h Thu Nov 6 15:23:20 2014
@@ -28,6 +28,32 @@
#include "lldb/Symbol/Type.h"
namespace lldb_private {
+ class TypeSummaryOptions
+ {
+ public:
+ TypeSummaryOptions ();
+ TypeSummaryOptions (const TypeSummaryOptions& rhs);
+
+ TypeSummaryOptions&
+ operator = (const TypeSummaryOptions& rhs);
+
+ lldb::LanguageType
+ GetLanguage () const;
+
+ lldb::TypeSummaryCapping
+ GetCapping () const;
+
+ TypeSummaryOptions&
+ SetLanguage (lldb::LanguageType);
+
+ TypeSummaryOptions&
+ SetCapping (lldb::TypeSummaryCapping);
+
+ ~TypeSummaryOptions() = default;
+ private:
+ lldb::LanguageType m_lang;
+ lldb::TypeSummaryCapping m_capping;
+ };
class TypeSummaryImpl
{
Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=221482&r1=221481&r2=221482&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Thu Nov 6 15:23:20 2014
@@ -907,6 +907,14 @@ namespace lldb {
eTypeIsComplex = (1u << 20),
eTypeIsSigned = (1u << 21)
} TypeFlags;
+
+ //----------------------------------------------------------------------
+ // Whether a summary should cap how much data it returns to users or not
+ //----------------------------------------------------------------------
+ typedef enum TypeSummaryCapping {
+ eTypeSummaryCapped = true,
+ eTypeSummaryUncapped = false
+ } TypeSummaryCapping;
} // namespace lldb
Modified: lldb/trunk/include/lldb/lldb-forward.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=221482&r1=221481&r2=221482&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-forward.h (original)
+++ lldb/trunk/include/lldb/lldb-forward.h Thu Nov 6 15:23:20 2014
@@ -207,6 +207,7 @@ class StreamString;
class StringList;
struct StringSummaryFormat;
class TypeSummaryImpl;
+class TypeSummaryOptions;
class Symbol;
class SymbolContext;
class SymbolContextList;
Modified: lldb/trunk/scripts/Python/interface/SBTypeSummary.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBTypeSummary.i?rev=221482&r1=221481&r2=221482&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBTypeSummary.i (original)
+++ lldb/trunk/scripts/Python/interface/SBTypeSummary.i Thu Nov 6 15:23:20 2014
@@ -8,7 +8,31 @@
//===----------------------------------------------------------------------===//
namespace lldb {
-
+ class SBTypeSummaryOptions
+ {
+ public:
+ SBTypeSummaryOptions();
+
+ SBTypeSummaryOptions (const lldb::SBTypeSummaryOptions &rhs);
+
+ ~SBTypeSummaryOptions ();
+
+ bool
+ IsValid ();
+
+ lldb::LanguageType
+ GetLanguage ();
+
+ lldb::TypeSummaryCapping
+ GetCapping ();
+
+ void
+ SetLanguage (lldb::LanguageType);
+
+ void
+ SetCapping (lldb::TypeSummaryCapping);
+ };
+
%feature("docstring",
"Represents a summary that can be associated to one or more types.
") SBTypeSummary;
Modified: lldb/trunk/scripts/Python/interface/SBValue.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBValue.i?rev=221482&r1=221481&r2=221482&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBValue.i (original)
+++ lldb/trunk/scripts/Python/interface/SBValue.i Thu Nov 6 15:23:20 2014
@@ -122,6 +122,9 @@ public:
GetSummary ();
const char *
+ GetSummary (lldb::SBTypeSummaryOptions& options);
+
+ const char *
GetObjectDescription ();
const char *
Modified: lldb/trunk/source/API/SBTypeSummary.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTypeSummary.cpp?rev=221482&r1=221481&r2=221482&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTypeSummary.cpp (original)
+++ lldb/trunk/source/API/SBTypeSummary.cpp Thu Nov 6 15:23:20 2014
@@ -20,6 +20,103 @@ using namespace lldb_private;
#ifndef LLDB_DISABLE_PYTHON
+SBTypeSummaryOptions::SBTypeSummaryOptions()
+{
+ m_opaque_ap.reset(new TypeSummaryOptions());
+}
+
+SBTypeSummaryOptions::SBTypeSummaryOptions (const lldb::SBTypeSummaryOptions &rhs)
+{
+ if (rhs.m_opaque_ap)
+ m_opaque_ap.reset(new TypeSummaryOptions(*rhs.m_opaque_ap.get()));
+ else
+ m_opaque_ap.reset(new TypeSummaryOptions());
+}
+
+SBTypeSummaryOptions::~SBTypeSummaryOptions ()
+{
+}
+
+bool
+SBTypeSummaryOptions::IsValid()
+{
+ return m_opaque_ap.get();
+}
+
+lldb::LanguageType
+SBTypeSummaryOptions::GetLanguage ()
+{
+ if (IsValid())
+ return m_opaque_ap->GetLanguage();
+ return lldb::eLanguageTypeUnknown;
+}
+
+lldb::TypeSummaryCapping
+SBTypeSummaryOptions::GetCapping ()
+{
+ if (IsValid())
+ return m_opaque_ap->GetCapping();
+ return eTypeSummaryCapped;
+}
+
+void
+SBTypeSummaryOptions::SetLanguage (lldb::LanguageType l)
+{
+ if (IsValid())
+ m_opaque_ap->SetLanguage(l);
+}
+
+void
+SBTypeSummaryOptions::SetCapping (lldb::TypeSummaryCapping c)
+{
+ if (IsValid())
+ m_opaque_ap->SetCapping(c);
+}
+
+lldb_private::TypeSummaryOptions *
+SBTypeSummaryOptions::operator->()
+{
+ return m_opaque_ap.get();
+}
+
+const lldb_private::TypeSummaryOptions *
+SBTypeSummaryOptions::operator->() const
+{
+ return m_opaque_ap.get();
+}
+
+lldb_private::TypeSummaryOptions *
+SBTypeSummaryOptions::get ()
+{
+ return m_opaque_ap.get();
+}
+
+lldb_private::TypeSummaryOptions &
+SBTypeSummaryOptions::ref()
+{
+ return *m_opaque_ap.get();
+}
+
+const lldb_private::TypeSummaryOptions &
+SBTypeSummaryOptions::ref() const
+{
+ return *m_opaque_ap.get();
+}
+
+SBTypeSummaryOptions::SBTypeSummaryOptions (const lldb_private::TypeSummaryOptions *lldb_object_ptr)
+{
+ SetOptions(lldb_object_ptr);
+}
+
+void
+SBTypeSummaryOptions::SetOptions (const lldb_private::TypeSummaryOptions *lldb_object_ptr)
+{
+ if (lldb_object_ptr)
+ m_opaque_ap.reset(new TypeSummaryOptions(*lldb_object_ptr));
+ else
+ m_opaque_ap.reset(new TypeSummaryOptions());
+}
+
SBTypeSummary::SBTypeSummary() :
m_opaque_sp()
{
Modified: lldb/trunk/source/API/SBValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=221482&r1=221481&r2=221482&view=diff
==============================================================================
--- lldb/trunk/source/API/SBValue.cpp (original)
+++ lldb/trunk/source/API/SBValue.cpp Thu Nov 6 15:23:20 2014
@@ -640,6 +640,29 @@ SBValue::GetSummary ()
}
return cstr;
}
+
+const char *
+SBValue::GetSummary (lldb::SBTypeSummaryOptions& options)
+{
+ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+ const char *cstr = NULL;
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (value_sp)
+ {
+ cstr = value_sp->GetSummaryAsCString(options.ref());
+ }
+ if (log)
+ {
+ if (cstr)
+ log->Printf ("SBValue(%p)::GetSummary() => \"%s\"",
+ static_cast<void*>(value_sp.get()), cstr);
+ else
+ log->Printf ("SBValue(%p)::GetSummary() => NULL",
+ static_cast<void*>(value_sp.get()));
+ }
+ return cstr;
+}
#endif // LLDB_DISABLE_PYTHON
const char *
Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=221482&r1=221481&r2=221482&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Thu Nov 6 15:23:20 2014
@@ -44,6 +44,7 @@
#include "lldb/Symbol/ClangASTType.h"
#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Target/ExecutionContext.h"
@@ -841,6 +842,14 @@ bool
ValueObject::GetSummaryAsCString (TypeSummaryImpl* summary_ptr,
std::string& destination)
{
+ return GetSummaryAsCString(summary_ptr, destination, TypeSummaryOptions());
+}
+
+bool
+ValueObject::GetSummaryAsCString (TypeSummaryImpl* summary_ptr,
+ std::string& destination,
+ const TypeSummaryOptions& options)
+{
destination.clear();
// ideally we would like to bail out if passing NULL, but if we do so
@@ -925,10 +934,17 @@ ValueObject::GetSummaryAsCString (TypeSu
const char *
ValueObject::GetSummaryAsCString ()
{
+ return GetSummaryAsCString(TypeSummaryOptions());
+}
+
+const char *
+ValueObject::GetSummaryAsCString (const TypeSummaryOptions& options)
+{
if (UpdateValueIfNeeded(true) && m_summary_str.empty())
{
GetSummaryAsCString(GetSummaryFormat().get(),
- m_summary_str);
+ m_summary_str,
+ options);
}
if (m_summary_str.empty())
return NULL;
@@ -4133,6 +4149,29 @@ ValueObject::GetFormat () const
return m_format;
}
+lldb::LanguageType
+ValueObject::GetPreferredDisplayLanguage ()
+{
+ lldb::LanguageType type = lldb::eLanguageTypeUnknown;
+ if (GetRoot())
+ {
+ if (GetRoot() == this)
+ {
+ if (StackFrameSP frame_sp = GetFrameSP())
+ {
+ const SymbolContext& sc(frame_sp->GetSymbolContext(eSymbolContextCompUnit));
+ if (CompileUnit* cu = sc.comp_unit)
+ type = cu->GetLanguage();
+ }
+ }
+ else
+ {
+ type = GetRoot()->GetPreferredDisplayLanguage();
+ }
+ }
+ return type;
+}
+
bool
ValueObject::CanProvideValue ()
{
Modified: lldb/trunk/source/Core/ValueObjectConstResult.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectConstResult.cpp?rev=221482&r1=221481&r2=221482&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectConstResult.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectConstResult.cpp Thu Nov 6 15:23:20 2014
@@ -359,3 +359,8 @@ ValueObjectConstResult::GetDynamicValue
return ValueObjectSP();
}
+lldb::LanguageType
+ValueObjectConstResult::GetPreferredDisplayLanguage ()
+{
+ return lldb::eLanguageTypeUnknown;
+}
Modified: lldb/trunk/source/DataFormatters/TypeSummary.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/TypeSummary.cpp?rev=221482&r1=221481&r2=221482&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/TypeSummary.cpp (original)
+++ lldb/trunk/source/DataFormatters/TypeSummary.cpp Thu Nov 6 15:23:20 2014
@@ -34,6 +34,50 @@
using namespace lldb;
using namespace lldb_private;
+TypeSummaryOptions::TypeSummaryOptions () :
+ m_lang(eLanguageTypeUnknown),
+ m_capping(eTypeSummaryCapped)
+{}
+
+TypeSummaryOptions::TypeSummaryOptions (const TypeSummaryOptions& rhs) :
+ m_lang(rhs.m_lang),
+ m_capping(rhs.m_capping)
+{}
+
+TypeSummaryOptions&
+TypeSummaryOptions::operator = (const TypeSummaryOptions& rhs)
+{
+ m_lang = rhs.m_lang;
+ m_capping = rhs.m_capping;
+ return *this;
+}
+
+lldb::LanguageType
+TypeSummaryOptions::GetLanguage () const
+{
+ return m_lang;
+}
+
+lldb::TypeSummaryCapping
+TypeSummaryOptions::GetCapping () const
+{
+ return m_capping;
+}
+
+TypeSummaryOptions&
+TypeSummaryOptions::SetLanguage (lldb::LanguageType lang)
+{
+ m_lang = lang;
+ return *this;
+}
+
+TypeSummaryOptions&
+TypeSummaryOptions::SetCapping (lldb::TypeSummaryCapping cap)
+{
+ m_capping = cap;
+ return *this;
+}
+
TypeSummaryImpl::TypeSummaryImpl (const TypeSummaryImpl::Flags& flags) :
m_flags(flags)
{
More information about the lldb-commits
mailing list