forked from OSchip/llvm-project
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 llvm-svn: 221482
This commit is contained in:
parent
442293e83f
commit
c1247f5596
|
@ -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
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -90,6 +90,9 @@ public:
|
|||
const char *
|
||||
GetSummary ();
|
||||
|
||||
const char *
|
||||
GetSummary (lldb::SBTypeSummaryOptions& options);
|
||||
|
||||
const char *
|
||||
GetObjectDescription ();
|
||||
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -126,6 +126,9 @@ public:
|
|||
|
||||
virtual lldb::ValueObjectSP
|
||||
GetDynamicValue (lldb::DynamicValueType valueType);
|
||||
|
||||
virtual lldb::LanguageType
|
||||
GetPreferredDisplayLanguage ();
|
||||
|
||||
protected:
|
||||
virtual bool
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -207,6 +207,7 @@ class StreamString;
|
|||
class StringList;
|
||||
struct StringSummaryFormat;
|
||||
class TypeSummaryImpl;
|
||||
class TypeSummaryOptions;
|
||||
class Symbol;
|
||||
class SymbolContext;
|
||||
class SymbolContextList;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -121,6 +121,9 @@ public:
|
|||
const char *
|
||||
GetSummary ();
|
||||
|
||||
const char *
|
||||
GetSummary (lldb::SBTypeSummaryOptions& options);
|
||||
|
||||
const char *
|
||||
GetObjectDescription ();
|
||||
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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 *
|
||||
|
|
|
@ -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"
|
||||
|
@ -840,6 +841,14 @@ ValueObject::CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_
|
|||
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();
|
||||
|
||||
|
@ -924,11 +933,18 @@ ValueObject::GetSummaryAsCString (TypeSummaryImpl* summary_ptr,
|
|||
|
||||
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 ()
|
||||
{
|
||||
|
|
|
@ -359,3 +359,8 @@ ValueObjectConstResult::GetDynamicValue (lldb::DynamicValueType use_dynamic)
|
|||
return ValueObjectSP();
|
||||
}
|
||||
|
||||
lldb::LanguageType
|
||||
ValueObjectConstResult::GetPreferredDisplayLanguage ()
|
||||
{
|
||||
return lldb::eLanguageTypeUnknown;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue