diff --git a/lldb/include/lldb/API/SBDebugger.h b/lldb/include/lldb/API/SBDebugger.h index 3c80faa61694..679ef12ed952 100644 --- a/lldb/include/lldb/API/SBDebugger.h +++ b/lldb/include/lldb/API/SBDebugger.h @@ -241,6 +241,36 @@ public: void SetCloseInputOnEOF (bool b); + SBTypeCategory + GetCategory (const char* category_name); + + SBTypeCategory + CreateCategory (const char* category_name); + + bool + DeleteCategory (const char* category_name); + + uint32_t + GetNumCategories (); + + SBTypeCategory + GetCategoryAtIndex (uint32_t); + + SBTypeCategory + GetDefaultCategory(); + + SBTypeFormat + GetFormatForType (SBTypeNameSpecifier); + + SBTypeSummary + GetSummaryForType (SBTypeNameSpecifier); + + SBTypeFilter + GetFilterForType (SBTypeNameSpecifier); + + SBTypeSynthetic + GetSyntheticForType (SBTypeNameSpecifier); + private: friend class SBInputReader; diff --git a/lldb/include/lldb/API/SBDefines.h b/lldb/include/lldb/API/SBDefines.h index e8c50e67c630..82f34e0c17ed 100644 --- a/lldb/include/lldb/API/SBDefines.h +++ b/lldb/include/lldb/API/SBDefines.h @@ -59,6 +59,12 @@ class SBSymbolContextList; class SBTarget; class SBThread; class SBType; +class SBTypeCategory; +class SBTypeFilter; +class SBTypeFormat; +class SBTypeNameSpecifier; +class SBTypeSummary; +class SBTypeSynthetic; class SBTypeList; class SBValue; class SBValueList; diff --git a/lldb/include/lldb/API/SBTypeCategory.h b/lldb/include/lldb/API/SBTypeCategory.h new file mode 100644 index 000000000000..cde5a2d02a98 --- /dev/null +++ b/lldb/include/lldb/API/SBTypeCategory.h @@ -0,0 +1,150 @@ +//===-- SBTypeCategory.h --------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBTypeCategory_h_ +#define LLDB_SBTypeCategory_h_ + +#include "lldb/API/SBDefines.h" + +namespace lldb { + + class SBTypeCategory + { + public: + + SBTypeCategory(); + + SBTypeCategory (const lldb::SBTypeCategory &rhs); + + ~SBTypeCategory (); + + bool + IsValid() const; + + bool + GetEnabled (); + + void + SetEnabled (bool); + + const char* + GetName(); + + bool + GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level); + + uint32_t + GetNumFormats (); + + uint32_t + GetNumSummaries (); + + uint32_t + GetNumFilters (); + + uint32_t + GetNumSynthetics (); + + SBTypeNameSpecifier + GetTypeNameSpecifierForFilterAtIndex (uint32_t); + + SBTypeNameSpecifier + GetTypeNameSpecifierForFormatAtIndex (uint32_t); + + SBTypeNameSpecifier + GetTypeNameSpecifierForSummaryAtIndex (uint32_t); + + SBTypeNameSpecifier + GetTypeNameSpecifierForSyntheticAtIndex (uint32_t); + + SBTypeFilter + GetFilterForType (SBTypeNameSpecifier); + + SBTypeFormat + GetFormatForType (SBTypeNameSpecifier); + + SBTypeSummary + GetSummaryForType (SBTypeNameSpecifier); + + SBTypeSynthetic + GetSyntheticForType (SBTypeNameSpecifier); + + SBTypeFilter + GetFilterAtIndex (uint32_t); + + SBTypeFormat + GetFormatAtIndex (uint32_t); + + SBTypeSummary + GetSummaryAtIndex (uint32_t); + + SBTypeSynthetic + GetSyntheticAtIndex (uint32_t); + + bool + AddTypeFormat (SBTypeNameSpecifier, + SBTypeFormat); + + bool + DeleteTypeFormat (SBTypeNameSpecifier); + + bool + AddTypeSummary (SBTypeNameSpecifier, + SBTypeSummary); + + bool + DeleteTypeSummary (SBTypeNameSpecifier); + + bool + AddTypeFilter (SBTypeNameSpecifier, + SBTypeFilter); + + bool + DeleteTypeFilter (SBTypeNameSpecifier); + + bool + AddTypeSynthetic (SBTypeNameSpecifier, + SBTypeSynthetic); + + bool + DeleteTypeSynthetic (SBTypeNameSpecifier); + + lldb::SBTypeCategory & + operator = (const lldb::SBTypeCategory &rhs); + + bool + operator == (lldb::SBTypeCategory &rhs); + + bool + operator != (lldb::SBTypeCategory &rhs); + + protected: + friend class SBDebugger; + + lldb::TypeCategoryImplSP + GetSP (); + + void + SetSP (const lldb::TypeCategoryImplSP &typecategory_impl_sp); + + TypeCategoryImplSP m_opaque_sp; + + SBTypeCategory (const lldb::TypeCategoryImplSP &); + + SBTypeCategory (const char*); + + bool + IsDefaultCategory(); + + }; + +} // namespace lldb + +#endif // LLDB_SBTypeCategory_h_ diff --git a/lldb/include/lldb/API/SBTypeFilter.h b/lldb/include/lldb/API/SBTypeFilter.h new file mode 100644 index 000000000000..57f76822e826 --- /dev/null +++ b/lldb/include/lldb/API/SBTypeFilter.h @@ -0,0 +1,91 @@ +//===-- SBTypeFilter.h --------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBTypeFilter_h_ +#define LLDB_SBTypeFilter_h_ + +#include "lldb/API/SBDefines.h" + +namespace lldb { + + class SBTypeFilter + { + public: + + SBTypeFilter(); + + SBTypeFilter (uint32_t options); // see lldb::eTypeOption values + + SBTypeFilter (const lldb::SBTypeFilter &rhs); + + ~SBTypeFilter (); + + bool + IsValid() const; + + uint32_t + GetNumberOfExpressionPaths (); + + const char* + GetExpressionPathAtIndex (uint32_t i); + + bool + ReplaceExpressionPathAtIndex (uint32_t i, const char* item); + + void + AppendExpressionPath (const char* item); + + void + Clear(); + + uint32_t + GetOptions(); + + void + SetOptions (uint32_t); + + bool + GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level); + + lldb::SBTypeFilter & + operator = (const lldb::SBTypeFilter &rhs); + + bool + IsEqualTo (lldb::SBTypeFilter &rhs); + + bool + operator == (lldb::SBTypeFilter &rhs); + + bool + operator != (lldb::SBTypeFilter &rhs); + + protected: + friend class SBDebugger; + friend class SBTypeCategory; + + lldb::TypeFilterImplSP + GetSP (); + + void + SetSP (const lldb::TypeFilterImplSP &typefilter_impl_sp); + + lldb::TypeFilterImplSP m_opaque_sp; + + SBTypeFilter (const lldb::TypeFilterImplSP &); + + bool + CopyOnWrite_Impl(); + + }; + + +} // namespace lldb + +#endif // LLDB_SBTypeFilter_h_ diff --git a/lldb/include/lldb/API/SBTypeFormat.h b/lldb/include/lldb/API/SBTypeFormat.h new file mode 100644 index 000000000000..1079dd40d0f9 --- /dev/null +++ b/lldb/include/lldb/API/SBTypeFormat.h @@ -0,0 +1,83 @@ +//===-- SBTypeFormat.h --------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBTypeFormat_h_ +#define LLDB_SBTypeFormat_h_ + +#include "lldb/API/SBDefines.h" + +namespace lldb { + +class SBTypeFormat +{ +public: + + SBTypeFormat(); + + SBTypeFormat (lldb::Format format, + uint32_t options = 0); // see lldb::eTypeOption values + + SBTypeFormat (const lldb::SBTypeFormat &rhs); + + ~SBTypeFormat (); + + bool + IsValid() const; + + lldb::Format + GetFormat (); + + uint32_t + GetOptions(); + + void + SetFormat (lldb::Format); + + void + SetOptions (uint32_t); + + bool + GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level); + + lldb::SBTypeFormat & + operator = (const lldb::SBTypeFormat &rhs); + + bool + IsEqualTo (lldb::SBTypeFormat &rhs); + + bool + operator == (lldb::SBTypeFormat &rhs); + + bool + operator != (lldb::SBTypeFormat &rhs); + +protected: + friend class SBDebugger; + friend class SBTypeCategory; + + lldb::TypeFormatImplSP + GetSP (); + + void + SetSP (const lldb::TypeFormatImplSP &typeformat_impl_sp); + + lldb::TypeFormatImplSP m_opaque_sp; + + SBTypeFormat (const lldb::TypeFormatImplSP &); + + bool + CopyOnWrite_Impl(); + +}; + + +} // namespace lldb + +#endif // LLDB_SBTypeFormat_h_ diff --git a/lldb/include/lldb/API/SBTypeNameSpecifier.h b/lldb/include/lldb/API/SBTypeNameSpecifier.h new file mode 100644 index 000000000000..af815815e5f0 --- /dev/null +++ b/lldb/include/lldb/API/SBTypeNameSpecifier.h @@ -0,0 +1,71 @@ +//===-- SBTypeNameSpecifier.h --------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBTypeNameSpecifier_h_ +#define LLDB_SBTypeNameSpecifier_h_ + +#include "lldb/API/SBDefines.h" + +namespace lldb { + + class SBTypeNameSpecifier + { + public: + + SBTypeNameSpecifier(); + + SBTypeNameSpecifier (const char* name, + bool is_regex = false); + + SBTypeNameSpecifier (const lldb::SBTypeNameSpecifier &rhs); + + ~SBTypeNameSpecifier (); + + bool + IsValid() const; + + const char* + GetName(); + + bool + IsRegex(); + + bool + GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level); + + lldb::SBTypeNameSpecifier & + operator = (const lldb::SBTypeNameSpecifier &rhs); + + bool + IsEqualTo (lldb::SBTypeNameSpecifier &rhs); + + bool + operator == (lldb::SBTypeNameSpecifier &rhs); + + bool + operator != (lldb::SBTypeNameSpecifier &rhs); + + protected: + friend class SBTypeCategory; + + lldb::TypeNameSpecifierImplSP + GetSP (); + + void + SetSP (const lldb::TypeNameSpecifierImplSP &type_namespec_sp); + + lldb::TypeNameSpecifierImplSP m_opaque_sp; + + SBTypeNameSpecifier (const lldb::TypeNameSpecifierImplSP &); + }; + +} // namespace lldb + +#endif // LLDB_SBTypeNameSpecifier_h_ diff --git a/lldb/include/lldb/API/SBTypeSummary.h b/lldb/include/lldb/API/SBTypeSummary.h new file mode 100644 index 000000000000..053623e8bb36 --- /dev/null +++ b/lldb/include/lldb/API/SBTypeSummary.h @@ -0,0 +1,110 @@ +//===-- SBTypeSummary.h -------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBTypeSummary_h_ +#define LLDB_SBTypeSummary_h_ + +#include "lldb/API/SBDefines.h" + +namespace lldb { + + class SBTypeSummary + { + public: + + SBTypeSummary(); + + static SBTypeSummary + CreateWithSummaryString (const char* data, + uint32_t options = 0); // see lldb::eTypeOption values + + static SBTypeSummary + CreateWithFunctionName (const char* data, + uint32_t options = 0); // see lldb::eTypeOption values + + static SBTypeSummary + CreateWithScriptCode (const char* data, + uint32_t options = 0); // see lldb::eTypeOption values + + SBTypeSummary (const lldb::SBTypeSummary &rhs); + + ~SBTypeSummary (); + + bool + IsValid() const; + + bool + IsFunctionCode(); + + bool + IsFunctionName(); + + bool + IsSummaryString(); + + const char* + GetData (); + + void + SetSummaryString (const char* data); + + void + SetFunctionName (const char* data); + + void + SetFunctionCode (const char* data); + + uint32_t + GetOptions (); + + void + SetOptions (uint32_t); + + bool + GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level); + + lldb::SBTypeSummary & + operator = (const lldb::SBTypeSummary &rhs); + + bool + IsEqualTo (lldb::SBTypeSummary &rhs); + + bool + operator == (lldb::SBTypeSummary &rhs); + + bool + operator != (lldb::SBTypeSummary &rhs); + + protected: + friend class SBDebugger; + friend class SBTypeCategory; + + lldb::TypeSummaryImplSP + GetSP (); + + void + SetSP (const lldb::TypeSummaryImplSP &typefilter_impl_sp); + + lldb::TypeSummaryImplSP m_opaque_sp; + + SBTypeSummary (const lldb::TypeSummaryImplSP &); + + bool + CopyOnWrite_Impl(); + + bool + ChangeSummaryType (bool want_script); + + }; + + +} // namespace lldb + +#endif // LLDB_SBTypeSummary_h_ diff --git a/lldb/include/lldb/API/SBTypeSynthetic.h b/lldb/include/lldb/API/SBTypeSynthetic.h new file mode 100644 index 000000000000..09ad4335521d --- /dev/null +++ b/lldb/include/lldb/API/SBTypeSynthetic.h @@ -0,0 +1,97 @@ +//===-- SBTypeSynthetic.h -----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBTypeSynthetic_h_ +#define LLDB_SBTypeSynthetic_h_ + +#include "lldb/API/SBDefines.h" + +namespace lldb { + + class SBTypeSynthetic + { + public: + + SBTypeSynthetic(); + + static SBTypeSynthetic + CreateWithClassName (const char* data, + uint32_t options = 0); // see lldb::eTypeOption values + + static SBTypeSynthetic + CreateWithScriptCode (const char* data, + uint32_t options = 0); // see lldb::eTypeOption values + + SBTypeSynthetic (const lldb::SBTypeSynthetic &rhs); + + ~SBTypeSynthetic (); + + bool + IsValid() const; + + bool + IsClassCode(); + + bool + IsClassName(); + + const char* + GetData (); + + void + SetClassName (const char* data); + + void + SetClassCode (const char* data); + + uint32_t + GetOptions (); + + void + SetOptions (uint32_t); + + bool + GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level); + + lldb::SBTypeSynthetic & + operator = (const lldb::SBTypeSynthetic &rhs); + + bool + IsEqualTo (lldb::SBTypeSynthetic &rhs); + + bool + operator == (lldb::SBTypeSynthetic &rhs); + + bool + operator != (lldb::SBTypeSynthetic &rhs); + + protected: + friend class SBDebugger; + friend class SBTypeCategory; + + lldb::TypeSyntheticImplSP + GetSP (); + + void + SetSP (const lldb::TypeSyntheticImplSP &typefilter_impl_sp); + + lldb::TypeSyntheticImplSP m_opaque_sp; + + SBTypeSynthetic (const lldb::TypeSyntheticImplSP &); + + bool + CopyOnWrite_Impl(); + + }; + + +} // namespace lldb + +#endif // LLDB_SBTypeSynthetic_h_ diff --git a/lldb/include/lldb/Core/DataVisualization.h b/lldb/include/lldb/Core/DataVisualization.h index 1ad6af3d426b..0169f407845d 100644 --- a/lldb/include/lldb/Core/DataVisualization.h +++ b/lldb/include/lldb/Core/DataVisualization.h @@ -47,11 +47,14 @@ public: class ValueFormats { public: - static lldb::ValueFormatSP + static lldb::TypeFormatImplSP GetFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic); + static lldb::TypeFormatImplSP + GetFormat (const ConstString &type); + static void - Add (const ConstString &type, const lldb::ValueFormatSP &entry); + Add (const ConstString &type, const lldb::TypeFormatImplSP &entry); static bool Delete (const ConstString &type); @@ -60,13 +63,19 @@ public: Clear (); static void - LoopThrough (ValueFormat::ValueCallback callback, void* callback_baton); + LoopThrough (TypeFormatImpl::ValueCallback callback, void* callback_baton); static uint32_t GetCount (); + + static lldb::TypeNameSpecifierImplSP + GetTypeNameSpecifierForFormatAtIndex (uint32_t); + + static lldb::TypeFormatImplSP + GetFormatAtIndex (uint32_t); }; - static lldb::SummaryFormatSP + static lldb::TypeSummaryImplSP GetSummaryFormat(ValueObject& valobj, lldb::DynamicValueType use_dynamic); @@ -76,19 +85,19 @@ public: static bool AnyMatches(ConstString type_name, - FormatCategory::FormatCategoryItems items = FormatCategory::ALL_ITEM_TYPES, + TypeCategoryImpl::FormatCategoryItems items = TypeCategoryImpl::ALL_ITEM_TYPES, bool only_enabled = true, const char** matching_category = NULL, - FormatCategory::FormatCategoryItems* matching_type = NULL); + TypeCategoryImpl::FormatCategoryItems* matching_type = NULL); class NamedSummaryFormats { public: static bool - GetSummaryFormat (const ConstString &type, lldb::SummaryFormatSP &entry); + GetSummaryFormat (const ConstString &type, lldb::TypeSummaryImplSP &entry); static void - Add (const ConstString &type, const lldb::SummaryFormatSP &entry); + Add (const ConstString &type, const lldb::TypeSummaryImplSP &entry); static bool Delete (const ConstString &type); @@ -97,7 +106,7 @@ public: Clear (); static void - LoopThrough (SummaryFormat::SummaryCallback callback, void* callback_baton); + LoopThrough (TypeSummaryImpl::SummaryCallback callback, void* callback_baton); static uint32_t GetCount (); @@ -108,8 +117,10 @@ public: public: static bool - GetCategory (const ConstString &category, lldb::FormatCategorySP &entry); - + GetCategory (const ConstString &category, + lldb::TypeCategoryImplSP &entry, + bool allow_create = true); + static void Add (const ConstString &category); @@ -120,19 +131,30 @@ public: Clear (); static void - Clear (ConstString &category); + Clear (const ConstString &category); static void - Enable (ConstString& category); + Enable (const ConstString& category, + CategoryMap::Position = CategoryMap::Default); static void - Disable (ConstString& category); + Disable (const ConstString& category); + + static void + Enable (const lldb::TypeCategoryImplSP& category, + CategoryMap::Position = CategoryMap::Default); + + static void + Disable (const lldb::TypeCategoryImplSP& category); static void LoopThrough (FormatManager::CategoryCallback callback, void* callback_baton); static uint32_t GetCount (); + + static lldb::TypeCategoryImplSP + GetCategoryAtIndex (uint32_t); }; }; diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index bf7379c67f36..a7dece86aea8 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -450,6 +450,12 @@ public: static lldb::DebuggerSP FindDebuggerWithInstanceName (const ConstString &instance_name); + + static uint32_t + GetNumDebuggers(); + + static lldb::DebuggerSP + GetDebuggerAtIndex (uint32_t); static bool FormatPrompt (const char *format, diff --git a/lldb/include/lldb/Core/FormatClasses.h b/lldb/include/lldb/Core/FormatClasses.h index de81c03f7c21..11b6c39d47b8 100644 --- a/lldb/include/lldb/Core/FormatClasses.h +++ b/lldb/include/lldb/Core/FormatClasses.h @@ -45,47 +45,193 @@ struct PyObject; namespace lldb_private { -struct ValueFormat +class TypeFormatImpl { - uint32_t m_my_revision; - bool m_cascades; - bool m_skip_pointers; - bool m_skip_references; - lldb::Format m_format; - ValueFormat (lldb::Format f = lldb::eFormatInvalid, - bool casc = false, - bool skipptr = false, - bool skipref = false); +public: + class Flags + { + public: + + Flags () : + m_flags (lldb::eTypeOptionCascade) + {} + + Flags (const Flags& other) : + m_flags (other.m_flags) + {} + + Flags (uint32_t value) : + m_flags (value) + {} + + Flags& + operator = (const Flags& rhs) + { + if (&rhs != this) + m_flags = rhs.m_flags; + + return *this; + } + + Flags& + operator = (const uint32_t& rhs) + { + m_flags = rhs; + return *this; + } + + Flags& + Clear() + { + m_flags = 0; + return *this; + } + + bool + GetCascades () const + { + return (m_flags & lldb::eTypeOptionCascade) == lldb::eTypeOptionCascade; + } + + Flags& + SetCascades (bool value = true) + { + if (value) + m_flags |= lldb::eTypeOptionCascade; + else + m_flags &= ~lldb::eTypeOptionCascade; + return *this; + } + + bool + GetSkipPointers () const + { + return (m_flags & lldb::eTypeOptionSkipPointers) == lldb::eTypeOptionSkipPointers; + } + + Flags& + SetSkipPointers (bool value = true) + { + if (value) + m_flags |= lldb::eTypeOptionSkipPointers; + else + m_flags &= ~lldb::eTypeOptionSkipPointers; + return *this; + } + + bool + GetSkipReferences () const + { + return (m_flags & lldb::eTypeOptionSkipReferences) == lldb::eTypeOptionSkipReferences; + } + + Flags& + SetSkipReferences (bool value = true) + { + if (value) + m_flags |= lldb::eTypeOptionSkipReferences; + else + m_flags &= ~lldb::eTypeOptionSkipReferences; + return *this; + } + + uint32_t + GetValue () + { + return m_flags; + } + + void + SetValue (uint32_t value) + { + m_flags = value; + } + + private: + uint32_t m_flags; + }; - typedef SHARED_PTR(ValueFormat) SharedPointer; - typedef bool(*ValueCallback)(void*, ConstString, const lldb::ValueFormatSP&); + TypeFormatImpl (lldb::Format f = lldb::eFormatInvalid, + const Flags& flags = Flags()); - ~ValueFormat() + typedef SHARED_PTR(TypeFormatImpl) SharedPointer; + typedef bool(*ValueCallback)(void*, ConstString, const lldb::TypeFormatImplSP&); + + ~TypeFormatImpl () { } bool - Cascades() const + Cascades () const { - return m_cascades; + return m_flags.GetCascades(); } bool - SkipsPointers() const + SkipsPointers () const { - return m_skip_pointers; + return m_flags.GetSkipPointers(); } bool - SkipsReferences() const + SkipsReferences () const { - return m_skip_references; + return m_flags.GetSkipReferences(); + } + + void + SetCascades (bool value) + { + m_flags.SetCascades(value); + } + + void + SetSkipsPointers (bool value) + { + m_flags.SetSkipPointers(value); + } + + void + SetSkipsReferences (bool value) + { + m_flags.SetSkipReferences(value); } lldb::Format - GetFormat() const + GetFormat () const { return m_format; } - + + void + SetFormat (lldb::Format fmt) + { + m_format = fmt; + } + + uint32_t + GetOptions () + { + return m_flags.GetValue(); + } + + void + SetOptions (uint32_t value) + { + m_flags.SetValue(value); + } + + uint32_t& + GetRevision () + { + return m_my_revision; + } + + std::string + GetDescription(); + +protected: + Flags m_flags; + lldb::Format m_format; + uint32_t m_my_revision; }; class SyntheticChildrenFrontEnd @@ -122,69 +268,231 @@ public: class SyntheticChildren { public: - uint32_t m_my_revision; - bool m_cascades; - bool m_skip_pointers; - bool m_skip_references; -public: - SyntheticChildren(bool casc = false, - bool skipptr = false, - bool skipref = false) : - m_cascades(casc), - m_skip_pointers(skipptr), - m_skip_references(skipref) + + class Flags + { + public: + + Flags () : + m_flags (lldb::eTypeOptionCascade) + {} + + Flags (const Flags& other) : + m_flags (other.m_flags) + {} + + Flags (uint32_t value) : + m_flags (value) + {} + + Flags& + operator = (const Flags& rhs) + { + if (&rhs != this) + m_flags = rhs.m_flags; + + return *this; + } + + Flags& + operator = (const uint32_t& rhs) + { + m_flags = rhs; + return *this; + } + + Flags& + Clear() + { + m_flags = 0; + return *this; + } + + bool + GetCascades () const + { + return (m_flags & lldb::eTypeOptionCascade) == lldb::eTypeOptionCascade; + } + + Flags& + SetCascades (bool value = true) + { + if (value) + m_flags |= lldb::eTypeOptionCascade; + else + m_flags &= ~lldb::eTypeOptionCascade; + return *this; + } + + bool + GetSkipPointers () const + { + return (m_flags & lldb::eTypeOptionSkipPointers) == lldb::eTypeOptionSkipPointers; + } + + Flags& + SetSkipPointers (bool value = true) + { + if (value) + m_flags |= lldb::eTypeOptionSkipPointers; + else + m_flags &= ~lldb::eTypeOptionSkipPointers; + return *this; + } + + bool + GetSkipReferences () const + { + return (m_flags & lldb::eTypeOptionSkipReferences) == lldb::eTypeOptionSkipReferences; + } + + Flags& + SetSkipReferences (bool value = true) + { + if (value) + m_flags |= lldb::eTypeOptionSkipReferences; + else + m_flags &= ~lldb::eTypeOptionSkipReferences; + return *this; + } + + uint32_t + GetValue () + { + return m_flags; + } + + void + SetValue (uint32_t value) + { + m_flags = value; + } + + private: + uint32_t m_flags; + }; + + SyntheticChildren (const Flags& flags) : + m_flags(flags) { } virtual - ~SyntheticChildren() + ~SyntheticChildren () { } bool - Cascades() const + Cascades () const { - return m_cascades; + return m_flags.GetCascades(); } bool - SkipsPointers() const + SkipsPointers () const { - return m_skip_pointers; + return m_flags.GetSkipPointers(); } bool - SkipsReferences() const + SkipsReferences () const { - return m_skip_references; + return m_flags.GetSkipReferences(); + } + + void + SetCascades (bool value) + { + m_flags.SetCascades(value); + } + + void + SetSkipsPointers (bool value) + { + m_flags.SetSkipPointers(value); + } + + void + SetSkipsReferences (bool value) + { + m_flags.SetSkipReferences(value); + } + + uint32_t + GetOptions () + { + return m_flags.GetValue(); + } + + void + SetOptions (uint32_t value) + { + m_flags.SetValue(value); } virtual bool - IsScripted() = 0; + IsScripted () = 0; virtual std::string - GetDescription() = 0; + GetDescription () = 0; virtual SyntheticChildrenFrontEnd::SharedPointer - GetFrontEnd(lldb::ValueObjectSP backend) = 0; + GetFrontEnd (lldb::ValueObjectSP backend) = 0; typedef SHARED_PTR(SyntheticChildren) SharedPointer; typedef bool(*SyntheticChildrenCallback)(void*, ConstString, const SyntheticChildren::SharedPointer&); + uint32_t& + GetRevision () + { + return m_my_revision; + } + +protected: + uint32_t m_my_revision; + Flags m_flags; }; -class SyntheticFilter : public SyntheticChildren +class TypeFilterImpl : public SyntheticChildren { std::vector m_expression_paths; public: - SyntheticFilter(bool casc = false, - bool skipptr = false, - bool skipref = false) : - SyntheticChildren(casc, skipptr, skipref), - m_expression_paths() + TypeFilterImpl(const SyntheticChildren::Flags& flags) : + SyntheticChildren(flags), + m_expression_paths() { } void - AddExpressionPath(std::string path) + AddExpressionPath (const char* path) + { + AddExpressionPath(std::string(path)); + } + + void + Clear() + { + m_expression_paths.clear(); + } + + int + GetCount() const + { + return m_expression_paths.size(); + } + + const char* + GetExpressionPathAtIndex(int i) const + { + return m_expression_paths[i].c_str(); + } + + bool + SetExpressionPathAtIndex (int i, const char* path) + { + return SetExpressionPathAtIndex(i, std::string(path)); + } + + void + AddExpressionPath (std::string path) { bool need_add_dot = true; if (path[0] == '.' || @@ -197,17 +505,23 @@ public: else m_expression_paths.push_back(std::string(".") + path); } - - int - GetCount() const - { - return m_expression_paths.size(); - } - const std::string& - GetExpressionPathAtIndex(int i) const + bool + SetExpressionPathAtIndex (int i, std::string path) { - return m_expression_paths[i]; + if (i >= GetCount()) + return false; + bool need_add_dot = true; + if (path[0] == '.' || + (path[0] == '-' && path[1] == '>') || + path[0] == '[') + need_add_dot = false; + // add a '.' symbol to help forgetful users + if(!need_add_dot) + m_expression_paths[i] = path; + else + m_expression_paths[i] = std::string(".") + path; + return true; } bool @@ -222,10 +536,10 @@ public: class FrontEnd : public SyntheticChildrenFrontEnd { private: - SyntheticFilter* filter; + TypeFilterImpl* filter; public: - FrontEnd(SyntheticFilter* flt, + FrontEnd(TypeFilterImpl* flt, lldb::ValueObjectSP be) : SyntheticChildrenFrontEnd(be), filter(flt) @@ -247,7 +561,7 @@ public: { if (idx >= filter->GetCount()) return lldb::ValueObjectSP(); - return m_backend->GetSyntheticExpressionPathChild(filter->GetExpressionPathAtIndex(idx).c_str(), can_create); + return m_backend->GetSyntheticExpressionPathChild(filter->GetExpressionPathAtIndex(idx), can_create); } virtual void @@ -259,7 +573,7 @@ public: const char* name_cstr = name.GetCString(); for (int i = 0; i < filter->GetCount(); i++) { - const char* expr_cstr = filter->GetExpressionPathAtIndex(i).c_str(); + const char* expr_cstr = filter->GetExpressionPathAtIndex(i); if (::strcmp(name_cstr, expr_cstr)) return i; } @@ -280,24 +594,48 @@ public: #ifndef LLDB_DISABLE_PYTHON -class SyntheticScriptProvider : public SyntheticChildren +class TypeSyntheticImpl : public SyntheticChildren { std::string m_python_class; + std::string m_python_code; public: - SyntheticScriptProvider(bool casc = false, - bool skipptr = false, - bool skipref = false, - std::string pclass = "") : - SyntheticChildren(casc, skipptr, skipref), - m_python_class(pclass) + + TypeSyntheticImpl(const SyntheticChildren::Flags& flags, + const char* pclass, + const char* pcode = NULL) : + SyntheticChildren(flags), + m_python_class(), + m_python_code() { + if (pclass) + m_python_class = pclass; + if (pcode) + m_python_code = pcode; } - - - std::string + + const char* GetPythonClassName() { - return m_python_class; + return m_python_class.c_str(); + } + + const char* + GetPythonCode() + { + return m_python_code.c_str(); + } + + void + SetPythonClassName (const char* fname) + { + m_python_class.assign(fname); + m_python_code.clear(); + } + + void + SetPythonCode (const char* script) + { + m_python_code.assign(script); } std::string @@ -477,12 +815,10 @@ public: }; - SyntheticArrayView(bool casc = false, - bool skipptr = false, - bool skipref = false) : - SyntheticChildren(casc, skipptr, skipref), - m_head(), - m_tail(&m_head) + SyntheticArrayView(const SyntheticChildren::Flags& flags) : + SyntheticChildren(flags), + m_head(), + m_tail(&m_head) { } @@ -566,7 +902,7 @@ private: }; -class SummaryFormat +class TypeSummaryImpl { public: class Flags @@ -574,13 +910,17 @@ public: public: Flags () : - m_flags (FVCascades) + m_flags (lldb::eTypeOptionCascade) {} Flags (const Flags& other) : m_flags (other.m_flags) {} + Flags (uint32_t value) : + m_flags (value) + {} + Flags& operator = (const Flags& rhs) { @@ -590,6 +930,13 @@ public: return *this; } + Flags& + operator = (const uint32_t& rhs) + { + m_flags = rhs; + return *this; + } + Flags& Clear() { @@ -600,203 +947,278 @@ public: bool GetCascades () const { - return (m_flags & FVCascades) == FVCascades; + return (m_flags & lldb::eTypeOptionCascade) == lldb::eTypeOptionCascade; } Flags& SetCascades (bool value = true) { if (value) - m_flags |= FVCascades; + m_flags |= lldb::eTypeOptionCascade; else - m_flags &= ~FVCascades; + m_flags &= ~lldb::eTypeOptionCascade; return *this; } bool GetSkipPointers () const { - return (m_flags & FVSkipPointers) == FVSkipPointers; + return (m_flags & lldb::eTypeOptionSkipPointers) == lldb::eTypeOptionSkipPointers; } Flags& SetSkipPointers (bool value = true) { if (value) - m_flags |= FVSkipPointers; + m_flags |= lldb::eTypeOptionSkipPointers; else - m_flags &= ~FVSkipPointers; + m_flags &= ~lldb::eTypeOptionSkipPointers; return *this; } bool GetSkipReferences () const { - return (m_flags & FVSkipReferences) == FVSkipReferences; + return (m_flags & lldb::eTypeOptionSkipReferences) == lldb::eTypeOptionSkipReferences; } Flags& SetSkipReferences (bool value = true) { if (value) - m_flags |= FVSkipReferences; + m_flags |= lldb::eTypeOptionSkipReferences; else - m_flags &= ~FVSkipReferences; + m_flags &= ~lldb::eTypeOptionSkipReferences; return *this; } bool GetDontShowChildren () const { - return (m_flags & FVDontShowChildren) == FVDontShowChildren; + return (m_flags & lldb::eTypeOptionHideChildren) == lldb::eTypeOptionHideChildren; } Flags& SetDontShowChildren (bool value = true) { if (value) - m_flags |= FVDontShowChildren; + m_flags |= lldb::eTypeOptionHideChildren; else - m_flags &= ~FVDontShowChildren; + m_flags &= ~lldb::eTypeOptionHideChildren; return *this; } bool GetDontShowValue () const { - return (m_flags & FVDontShowValue) == FVDontShowValue; + return (m_flags & lldb::eTypeOptionHideValue) == lldb::eTypeOptionHideValue; } Flags& SetDontShowValue (bool value = true) { if (value) - m_flags |= FVDontShowValue; + m_flags |= lldb::eTypeOptionHideValue; else - m_flags &= ~FVDontShowValue; + m_flags &= ~lldb::eTypeOptionHideValue; return *this; } bool GetShowMembersOneLiner () const { - return (m_flags & FVShowMembersOneLiner) == FVShowMembersOneLiner; + return (m_flags & lldb::eTypeOptionShowOneLiner) == lldb::eTypeOptionShowOneLiner; } Flags& SetShowMembersOneLiner (bool value = true) { if (value) - m_flags |= FVShowMembersOneLiner; + m_flags |= lldb::eTypeOptionShowOneLiner; else - m_flags &= ~FVShowMembersOneLiner; + m_flags &= ~lldb::eTypeOptionShowOneLiner; return *this; } bool GetHideItemNames () const { - return (m_flags & FVHideItemNames) == FVHideItemNames; + return (m_flags & lldb::eTypeOptionHideNames) == lldb::eTypeOptionHideNames; } Flags& SetHideItemNames (bool value = true) { if (value) - m_flags |= FVHideItemNames; + m_flags |= lldb::eTypeOptionHideNames; else - m_flags &= ~FVHideItemNames; + m_flags &= ~lldb::eTypeOptionHideNames; return *this; } + + uint32_t + GetValue () + { + return m_flags; + } + + void + SetValue (uint32_t value) + { + m_flags = value; + } private: uint32_t m_flags; - enum FlagValues - { - FVCascades = 0x0001u, - FVSkipPointers = 0x0002u, - FVSkipReferences = 0x0004u, - FVDontShowChildren = 0x0008u, - FVDontShowValue = 0x0010u, - FVShowMembersOneLiner = 0x0020u, - FVHideItemNames = 0x0040u - }; }; - uint32_t m_my_revision; - Flags m_flags; - - SummaryFormat(const SummaryFormat::Flags& flags); + TypeSummaryImpl (const TypeSummaryImpl::Flags& flags); bool - Cascades() const + Cascades () const { return m_flags.GetCascades(); } bool - SkipsPointers() const + SkipsPointers () const { return m_flags.GetSkipPointers(); } bool - SkipsReferences() const + SkipsReferences () const { return m_flags.GetSkipReferences(); } bool - DoesPrintChildren() const + DoesPrintChildren () const { return !m_flags.GetDontShowChildren(); } bool - DoesPrintValue() const + DoesPrintValue () const { return !m_flags.GetDontShowValue(); } bool - IsOneliner() const + IsOneliner () const { return m_flags.GetShowMembersOneLiner(); } bool - HideNames() const + HideNames () const { return m_flags.GetHideItemNames(); } - + + void + SetCascades (bool value) + { + m_flags.SetCascades(value); + } + + void + SetSkipsPointers (bool value) + { + m_flags.SetSkipPointers(value); + } + + void + SetSkipsReferences (bool value) + { + m_flags.SetSkipReferences(value); + } + + void + SetDoesPrintChildren (bool value) + { + m_flags.SetDontShowChildren(!value); + } + + void + SetDoesPrintValue (bool value) + { + m_flags.SetDontShowValue(!value); + } + + void + SetIsOneliner (bool value) + { + m_flags.SetShowMembersOneLiner(value); + } + + void + SetHideNames (bool value) + { + m_flags.SetHideItemNames(value); + } + + uint32_t + GetOptions () + { + return m_flags.GetValue(); + } + + void + SetOptions (uint32_t value) + { + m_flags.SetValue(value); + } + virtual - ~SummaryFormat() + ~TypeSummaryImpl () { } virtual std::string - FormatObject(lldb::ValueObjectSP object) = 0; + FormatObject (lldb::ValueObjectSP object) = 0; virtual std::string - GetDescription() = 0; + GetDescription () = 0; - typedef SHARED_PTR(SummaryFormat) SharedPointer; - typedef bool(*SummaryCallback)(void*, ConstString, const lldb::SummaryFormatSP&); - typedef bool(*RegexSummaryCallback)(void*, lldb::RegularExpressionSP, const lldb::SummaryFormatSP&); + virtual bool + IsScripted() = 0; + uint32_t& + GetRevision () + { + return m_my_revision; + } + + typedef 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; + }; // simple string-based summaries, using ${var to show data -struct StringSummaryFormat : public SummaryFormat +struct StringSummaryFormat : public TypeSummaryImpl { std::string m_format; - StringSummaryFormat(const SummaryFormat::Flags& flags, - std::string f); + StringSummaryFormat(const TypeSummaryImpl::Flags& flags, + const char* f); - std::string - GetFormat() const + const char* + GetSummaryString () const { - return m_format; + return m_format.c_str(); + } + + void + SetSummaryString (const char* data) + { + if (data) + m_format.assign(data); + else + m_format.clear(); } virtual @@ -809,31 +1231,56 @@ struct StringSummaryFormat : public SummaryFormat virtual std::string GetDescription(); + + virtual bool + IsScripted() + { + return false; + } }; #ifndef LLDB_DISABLE_PYTHON // Python-based summaries, running script code to show data -struct ScriptSummaryFormat : public SummaryFormat +struct ScriptSummaryFormat : public TypeSummaryImpl { std::string m_function_name; std::string m_python_script; - ScriptSummaryFormat(const SummaryFormat::Flags& flags, - std::string fname, - std::string pscri); + ScriptSummaryFormat(const TypeSummaryImpl::Flags& flags, + const char *function_name, + const char* python_script = NULL); - std::string - GetFunctionName() const + const char* + GetFunctionName () const { - return m_function_name; + return m_function_name.c_str(); } - std::string - GetPythonScript() const + const char* + GetPythonScript () const { - return m_python_script; + return m_python_script.c_str(); + } + + void + SetFunctionName (const char* function_name) + { + if (function_name) + m_function_name.assign(function_name); + else + m_function_name.clear(); + m_python_script.clear(); + } + + void + SetPythonScript (const char* script) + { + if (script) + m_python_script.assign(script); + else + m_python_script.clear(); } virtual @@ -847,12 +1294,56 @@ struct ScriptSummaryFormat : public SummaryFormat virtual std::string GetDescription(); + virtual bool + IsScripted() + { + return true; + } + typedef SHARED_PTR(ScriptSummaryFormat) SharedPointer; }; #endif // #ifndef LLDB_DISABLE_PYTHON +// TODO: at the moment, this class is only used as a backing store for SBTypeNameSpecifier in the public API +// In the future, this might be used as the basic unit for typename-to-formatter matching, replacing +// the current plain/regexp distinction in FormatNavigator<> +class TypeNameSpecifierImpl +{ +public: + + TypeNameSpecifierImpl() : + m_name(), + m_is_regex(false) + { + } + + TypeNameSpecifierImpl (const char* name, bool is_regex) : + m_name(), + m_is_regex(is_regex) + { + if (name) + m_name.assign(name); + } + + const char* + GetName() + { + return m_name.c_str(); + } + + bool + IsRegex() + { + return m_is_regex; + } + +private: + std::string m_name; + bool m_is_regex; +}; + } // namespace lldb_private #endif // lldb_FormatClasses_h_ diff --git a/lldb/include/lldb/Core/FormatManager.h b/lldb/include/lldb/Core/FormatManager.h index b6be9643b009..39c7db7fdac8 100644 --- a/lldb/include/lldb/Core/FormatManager.h +++ b/lldb/include/lldb/Core/FormatManager.h @@ -34,19 +34,19 @@ namespace lldb_private { class CategoryMap; -class FormatCategory +class TypeCategoryImpl { private: - typedef FormatNavigator SummaryNavigator; - typedef FormatNavigator RegexSummaryNavigator; + typedef FormatNavigator SummaryNavigator; + typedef FormatNavigator RegexSummaryNavigator; - typedef FormatNavigator FilterNavigator; - typedef FormatNavigator RegexFilterNavigator; + typedef FormatNavigator FilterNavigator; + typedef FormatNavigator RegexFilterNavigator; #ifndef LLDB_DISABLE_PYTHON - typedef FormatNavigator SynthNavigator; - typedef FormatNavigator RegexSynthNavigator; + typedef FormatNavigator SynthNavigator; + typedef FormatNavigator RegexSynthNavigator; #endif // #ifndef LLDB_DISABLE_PYTHON typedef SummaryNavigator::MapType SummaryMap; @@ -61,7 +61,7 @@ private: public: typedef uint16_t FormatCategoryItems; - static const uint16_t ALL_ITEM_TYPES = 0xFFFF; + static const uint16_t ALL_ITEM_TYPES = UINT16_MAX; typedef SummaryNavigator::SharedPointer SummaryNavigatorSP; typedef RegexSummaryNavigator::SharedPointer RegexSummaryNavigatorSP; @@ -72,8 +72,8 @@ public: typedef RegexSynthNavigator::SharedPointer RegexSynthNavigatorSP; #endif // #ifndef LLDB_DISABLE_PYTHON - FormatCategory (IFormatChangeListener* clist, - std::string name); + TypeCategoryImpl (IFormatChangeListener* clist, + ConstString name); SummaryNavigatorSP GetSummaryNavigator () @@ -98,6 +98,42 @@ public: { return RegexFilterNavigatorSP(m_regex_filter_nav); } + + lldb::TypeNameSpecifierImplSP + GetTypeNameSpecifierForSummaryAtIndex (uint32_t index) + { + if (index < m_summary_nav->GetCount()) + return m_summary_nav->GetTypeNameSpecifierAtIndex(index); + else + return m_regex_summary_nav->GetTypeNameSpecifierAtIndex(index-m_summary_nav->GetCount()); + } + + SummaryNavigator::MapValueType + GetSummaryAtIndex (uint32_t index) + { + if (index < m_summary_nav->GetCount()) + return m_summary_nav->GetAtIndex(index); + else + return m_regex_summary_nav->GetAtIndex(index-m_summary_nav->GetCount()); + } + + FilterNavigator::MapValueType + GetFilterAtIndex (uint32_t index) + { + if (index < m_filter_nav->GetCount()) + return m_filter_nav->GetAtIndex(index); + else + return m_regex_filter_nav->GetAtIndex(index-m_filter_nav->GetCount()); + } + + lldb::TypeNameSpecifierImplSP + GetTypeNameSpecifierForFilterAtIndex (uint32_t index) + { + if (index < m_filter_nav->GetCount()) + return m_filter_nav->GetTypeNameSpecifierAtIndex(index); + else + return m_regex_filter_nav->GetTypeNameSpecifierAtIndex(index-m_filter_nav->GetCount()); + } #ifndef LLDB_DISABLE_PYTHON SynthNavigatorSP @@ -111,6 +147,25 @@ public: { return RegexSynthNavigatorSP(m_regex_synth_nav); } + + SynthNavigator::MapValueType + GetSyntheticAtIndex (uint32_t index) + { + if (index < m_synth_nav->GetCount()) + return m_synth_nav->GetAtIndex(index); + else + return m_regex_synth_nav->GetAtIndex(index-m_synth_nav->GetCount()); + } + + lldb::TypeNameSpecifierImplSP + GetTypeNameSpecifierForSyntheticAtIndex (uint32_t index) + { + if (index < m_synth_nav->GetCount()) + return m_synth_nav->GetTypeNameSpecifierAtIndex(index); + else + return m_regex_synth_nav->GetTypeNameSpecifierAtIndex(index - m_synth_nav->GetCount()); + } + #endif // #ifndef LLDB_DISABLE_PYTHON bool @@ -118,10 +173,19 @@ public: { return m_enabled; } - + + uint32_t + GetEnabledPosition() + { + if (m_enabled == false) + return UINT32_MAX; + else + return m_enabled_position; + } + bool Get (ValueObject& valobj, - lldb::SummaryFormatSP& entry, + lldb::TypeSummaryImplSP& entry, lldb::DynamicValueType use_dynamic, uint32_t* reason = NULL); @@ -141,10 +205,10 @@ public: uint32_t GetCount (FormatCategoryItems items = ALL_ITEM_TYPES); - std::string + const char* GetName () { - return m_name; + return m_name.GetCString(); } bool @@ -154,7 +218,7 @@ public: const char** matching_category = NULL, FormatCategoryItems* matching_type = NULL); - typedef SHARED_PTR(FormatCategory) SharedPointer; + typedef SHARED_PTR(TypeCategoryImpl) SharedPointer; private: SummaryNavigator::SharedPointer m_summary_nav; @@ -172,13 +236,17 @@ private: Mutex m_mutex; - std::string m_name; + ConstString m_name; + + uint32_t m_enabled_position; void - Enable (bool value = true) + Enable (bool value, + uint32_t position) { Mutex::Locker(m_mutex); - m_enabled = value; + m_enabled = value; + m_enabled_position = position; if (m_change_listener) m_change_listener->Changed(); } @@ -186,20 +254,20 @@ private: void Disable () { - Enable(false); + Enable(false, UINT32_MAX); } friend class CategoryMap; - friend class FormatNavigator; - friend class FormatNavigator; + friend class FormatNavigator; + friend class FormatNavigator; - friend class FormatNavigator; - friend class FormatNavigator; + friend class FormatNavigator; + friend class FormatNavigator; #ifndef LLDB_DISABLE_PYTHON - friend class FormatNavigator; - friend class FormatNavigator; + friend class FormatNavigator; + friend class FormatNavigator; #endif // #ifndef LLDB_DISABLE_PYTHON @@ -209,15 +277,20 @@ class CategoryMap { private: typedef ConstString KeyType; - typedef FormatCategory ValueType; + typedef TypeCategoryImpl ValueType; typedef ValueType::SharedPointer ValueSP; - typedef std::list ActiveCategoriesList; + typedef std::list ActiveCategoriesList; typedef ActiveCategoriesList::iterator ActiveCategoriesIterator; public: typedef std::map MapType; typedef MapType::iterator MapIterator; typedef bool(*CallbackType)(void*, const ValueSP&); + typedef uint32_t Position; + + static const Position First = 0; + static const Position Default = 1; + static const Position Last = UINT32_MAX; CategoryMap (IFormatChangeListener* lst) : m_map_mutex(Mutex::eMutexTypeRecursive), @@ -225,6 +298,10 @@ public: m_map(), m_active_categories() { + ConstString default_cs("default"); + lldb::TypeCategoryImplSP default_sp = lldb::TypeCategoryImplSP(new TypeCategoryImpl(listener, default_cs)); + Add(default_cs,default_sp); + Enable(default_cs,First); } void @@ -251,26 +328,68 @@ public: return true; } - void - Enable (KeyType category_name) + bool + Enable (KeyType category_name, + Position pos = Default) { Mutex::Locker(m_map_mutex); ValueSP category; if (!Get(category_name,category)) - return; - category->Enable(); - m_active_categories.push_front(category); + return false; + return Enable(category, pos); } - void + bool Disable (KeyType category_name) { Mutex::Locker(m_map_mutex); ValueSP category; if (!Get(category_name,category)) - return; - category->Disable(); - m_active_categories.remove_if(delete_matching_categories(category)); + return false; + return Disable(category); + } + + bool + Enable (ValueSP category, + Position pos = Default) + { + Mutex::Locker(m_map_mutex); + if (category.get()) + { + Position pos_w = pos; + if (pos == First) + m_active_categories.push_front(category); + else if (pos == Last || pos == m_active_categories.size()) + m_active_categories.push_back(category); + else if (pos < m_active_categories.size()) + { + ActiveCategoriesList::iterator iter = m_active_categories.begin(); + while (pos_w) + { + pos_w--,iter++; + } + m_active_categories.insert(iter,category); + } + else + return false; + category->Enable(true, + pos); + return true; + } + return false; + } + + bool + Disable (ValueSP category) + { + Mutex::Locker(m_map_mutex); + if (category.get()) + { + m_active_categories.remove_if(delete_matching_categories(category)); + category->Disable(); + return true; + } + return false; } void @@ -295,15 +414,36 @@ public: return true; } + bool + Get (uint32_t pos, + ValueSP& entry) + { + Mutex::Locker(m_map_mutex); + MapIterator iter = m_map.begin(); + MapIterator end = m_map.end(); + while (pos > 0) + { + iter++; + pos--; + if (iter == end) + return false; + } + entry = iter->second; + return false; + } + void LoopThrough (CallbackType callback, void* param); + lldb::TypeCategoryImplSP + GetAtIndex (uint32_t); + bool AnyMatches (ConstString type_name, - FormatCategory::FormatCategoryItems items = FormatCategory::ALL_ITEM_TYPES, + TypeCategoryImpl::FormatCategoryItems items = TypeCategoryImpl::ALL_ITEM_TYPES, bool only_enabled = true, const char** matching_category = NULL, - FormatCategory::FormatCategoryItems* matching_type = NULL); + TypeCategoryImpl::FormatCategoryItems* matching_type = NULL); uint32_t GetCount () @@ -311,7 +451,7 @@ public: return m_map.size(); } - lldb::SummaryFormatSP + lldb::TypeSummaryImplSP GetSummaryFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic); @@ -323,12 +463,12 @@ private: class delete_matching_categories { - lldb::FormatCategorySP ptr; + lldb::TypeCategoryImplSP ptr; public: - delete_matching_categories(lldb::FormatCategorySP p) : ptr(p) + delete_matching_categories(lldb::TypeCategoryImplSP p) : ptr(p) {} - bool operator()(const lldb::FormatCategorySP& other) + bool operator()(const lldb::TypeCategoryImplSP& other) { return ptr.get() == other.get(); } @@ -361,9 +501,9 @@ private: class FormatManager : public IFormatChangeListener { - typedef FormatNavigator ValueNavigator; + typedef FormatNavigator ValueNavigator; typedef ValueNavigator::MapType ValueMap; - typedef FormatMap NamedSummariesMap; + typedef FormatMap NamedSummariesMap; typedef CategoryMap::MapType::iterator CategoryMapIterator; public: @@ -384,9 +524,11 @@ public: } void - EnableCategory (const ConstString& category_name) + EnableCategory (const ConstString& category_name, + CategoryMap::Position pos = CategoryMap::Default) { - m_categories_map.Enable(category_name); + m_categories_map.Enable(category_name, + pos); } void @@ -395,6 +537,20 @@ public: m_categories_map.Disable(category_name); } + void + EnableCategory (const lldb::TypeCategoryImplSP& category, + CategoryMap::Position pos = CategoryMap::Default) + { + m_categories_map.Enable(category, + pos); + } + + void + DisableCategory (const lldb::TypeCategoryImplSP& category) + { + m_categories_map.Disable(category); + } + bool DeleteCategory (const ConstString& category_name) { @@ -413,13 +569,19 @@ public: return m_categories_map.GetCount(); } + lldb::TypeCategoryImplSP + GetCategoryAtIndex (uint32_t index) + { + return m_categories_map.GetAtIndex(index); + } + void LoopThroughCategories (CategoryCallback callback, void* param) { m_categories_map.LoopThrough(callback, param); } - lldb::FormatCategorySP + lldb::TypeCategoryImplSP GetCategory (const char* category_name = NULL, bool can_create = true) { @@ -428,11 +590,11 @@ public: return GetCategory(ConstString(category_name)); } - lldb::FormatCategorySP + lldb::TypeCategoryImplSP GetCategory (const ConstString& category_name, bool can_create = true); - lldb::SummaryFormatSP + lldb::TypeSummaryImplSP GetSummaryFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic) { @@ -448,10 +610,10 @@ public: bool AnyMatches (ConstString type_name, - FormatCategory::FormatCategoryItems items = FormatCategory::ALL_ITEM_TYPES, + TypeCategoryImpl::FormatCategoryItems items = TypeCategoryImpl::ALL_ITEM_TYPES, bool only_enabled = true, const char** matching_category = NULL, - FormatCategory::FormatCategoryItems* matching_type = NULL) + TypeCategoryImpl::FormatCategoryItems* matching_type = NULL) { return m_categories_map.AnyMatches(type_name, items, diff --git a/lldb/include/lldb/Core/FormatNavigator.h b/lldb/include/lldb/Core/FormatNavigator.h index e83a4f94c453..54b725d47fea 100644 --- a/lldb/include/lldb/Core/FormatNavigator.h +++ b/lldb/include/lldb/Core/FormatNavigator.h @@ -128,9 +128,9 @@ public: const ValueSP& entry) { if (listener) - entry->m_my_revision = listener->GetCurrentRevision(); + entry->GetRevision() = listener->GetCurrentRevision(); else - entry->m_my_revision = 0; + entry->GetRevision() = 0; Mutex::Locker(m_map_mutex); m_map[name] = entry; @@ -194,6 +194,38 @@ public: return m_map.size(); } + ValueSP + GetValueAtIndex (uint32_t index) + { + Mutex::Locker(m_map_mutex); + MapIterator iter = m_map.begin(); + MapIterator end = m_map.end(); + while (index > 0) + { + iter++; + index--; + if (end == iter) + return ValueSP(); + } + return iter->second; + } + + KeyType + GetKeyAtIndex (uint32_t index) + { + Mutex::Locker(m_map_mutex); + MapIterator iter = m_map.begin(); + MapIterator end = m_map.end(); + while (index > 0) + { + iter++; + index--; + if (end == iter) + return KeyType(); + } + return iter->first; + } + protected: MapType m_map; Mutex m_map_mutex; @@ -234,7 +266,7 @@ public: typedef typename std::tr1::shared_ptr > SharedPointer; - friend class FormatCategory; + friend class TypeCategoryImpl; FormatNavigator(std::string name, IFormatChangeListener* lst) : @@ -274,6 +306,30 @@ public: return ret; } + bool + Get (ConstString type, MapValueType& entry) + { + return Get_Impl(type, entry, Types()); + } + + bool + GetExact (ConstString type, MapValueType& entry) + { + return GetExact_Impl(type, entry, Types()); + } + + MapValueType + GetAtIndex (uint32_t index) + { + return m_format_map.GetValueAtIndex(index); + } + + lldb::TypeNameSpecifierImplSP + GetTypeNameSpecifierAtIndex (uint32_t index) + { + return GetTypeNameSpecifierAtIndex_Impl(index, Types()); + } + void Clear () { @@ -350,12 +406,42 @@ protected: return m_format_map.Get(type, entry); } + template + bool + GetExact_Impl (ConstString type, MapValueType& entry, Types dummy) + { + return Get_Impl(type,entry,dummy); + } + + template + lldb::TypeNameSpecifierImplSP + GetTypeNameSpecifierAtIndex_Impl (uint32_t index, Types dummy) + { + ConstString key = m_format_map.GetKeyAtIndex(index); + if (key) + return lldb::TypeNameSpecifierImplSP(new TypeNameSpecifierImpl(key.AsCString(), + false)); + else + return lldb::TypeNameSpecifierImplSP(); + } + + template + lldb::TypeNameSpecifierImplSP + GetTypeNameSpecifierAtIndex_Impl (uint32_t index, Types dummy) + { + lldb::RegularExpressionSP regex = m_format_map.GetKeyAtIndex(index); + if (regex.get() == NULL) + return lldb::TypeNameSpecifierImplSP(); + return lldb::TypeNameSpecifierImplSP(new TypeNameSpecifierImpl(regex->GetText(), + true)); + } + template bool Get_Impl (ConstString key, MapValueType& value, Types) { - Mutex& x_mutex = m_format_map.mutex(); - lldb_private::Mutex::Locker locker(x_mutex); + Mutex& x_mutex = m_format_map.mutex(); + lldb_private::Mutex::Locker locker(x_mutex); MapIterator pos, end = m_format_map.map().end(); for (pos = m_format_map.map().begin(); pos != end; pos++) { @@ -368,11 +454,24 @@ protected: } return false; } - + + template bool - Get (ConstString type, MapValueType& entry) + GetExact_Impl (ConstString key, MapValueType& value, Types) { - return Get_Impl(type, entry, Types()); + Mutex& x_mutex = m_format_map.mutex(); + lldb_private::Mutex::Locker locker(x_mutex); + MapIterator pos, end = m_format_map.map().end(); + for (pos = m_format_map.map().begin(); pos != end; pos++) + { + lldb::RegularExpressionSP regex = pos->first; + if (strcmp(regex->GetText(),key.AsCString()) == 0) + { + value = pos->second; + return true; + } + } + return false; } #define LLDB_MAX_REASONABLE_OBJC_CLASS_DEPTH 100 diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h index 9307cce70d2b..90161a3e4d54 100644 --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -963,7 +963,7 @@ public: } void - SetCustomSummaryFormat(lldb::SummaryFormatSP format) + SetCustomSummaryFormat(lldb::TypeSummaryImplSP format) { m_forced_summary_format = format; m_user_id_of_forced_summary = m_update_point.GetModID(); @@ -971,7 +971,7 @@ public: m_is_getting_summary = false; } - lldb::SummaryFormatSP + lldb::TypeSummaryImplSP GetCustomSummaryFormat() { return m_forced_summary_format; @@ -990,7 +990,7 @@ public: return (m_forced_summary_format.get()); } - lldb::SummaryFormatSP + lldb::TypeSummaryImplSP GetSummaryFormat() { UpdateFormatsIfNeeded(m_last_format_mgr_dynamic); @@ -1000,7 +1000,7 @@ public: } void - SetSummaryFormat(lldb::SummaryFormatSP format) + SetSummaryFormat(lldb::TypeSummaryImplSP format) { m_last_summary_format = format; m_summary_str.clear(); @@ -1008,13 +1008,13 @@ public: } void - SetValueFormat(lldb::ValueFormatSP format) + SetValueFormat(lldb::TypeFormatImplSP format) { m_last_value_format = format; m_value_str.clear(); } - lldb::ValueFormatSP + lldb::TypeFormatImplSP GetValueFormat() { UpdateFormatsIfNeeded(m_last_format_mgr_dynamic); @@ -1110,9 +1110,9 @@ protected: lldb::Format m_format; uint32_t m_last_format_mgr_revision; lldb::DynamicValueType m_last_format_mgr_dynamic; - lldb::SummaryFormatSP m_last_summary_format; - lldb::SummaryFormatSP m_forced_summary_format; - lldb::ValueFormatSP m_last_value_format; + lldb::TypeSummaryImplSP m_last_summary_format; + lldb::TypeSummaryImplSP m_forced_summary_format; + lldb::TypeFormatImplSP m_last_value_format; lldb::SyntheticChildrenSP m_last_synthetic_filter; ProcessModID m_user_id_of_forced_summary; AddressType m_address_type_of_ptr_or_ref_children; diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreter.h b/lldb/include/lldb/Interpreter/ScriptInterpreter.h index 223c26668819..7cecbbad7009 100644 --- a/lldb/include/lldb/Interpreter/ScriptInterpreter.h +++ b/lldb/include/lldb/Interpreter/ScriptInterpreter.h @@ -109,7 +109,13 @@ public: } virtual bool - GenerateTypeScriptFunction (StringList &input, StringList &output) + GenerateTypeScriptFunction (const char* oneliner, StringList &output, void* name_token = NULL) + { + return false; + } + + virtual bool + GenerateTypeScriptFunction (StringList &input, StringList &output, void* name_token = NULL) { return false; } @@ -121,7 +127,13 @@ public: } virtual bool - GenerateTypeSynthClass (StringList &input, StringList &output) + GenerateTypeSynthClass (StringList &input, StringList &output, void* name_token = NULL) + { + return false; + } + + virtual bool + GenerateTypeSynthClass (const char* oneliner, StringList &output, void* name_token = NULL) { return false; } @@ -133,13 +145,6 @@ public: return NULL; } - // use this if the function code is just a one-liner script - virtual bool - GenerateTypeScriptFunction (const char* oneliner, StringList &output) - { - return false; - } - virtual bool GenerateFunction(std::string& signature, StringList &input, StringList &output) { diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreterPython.h b/lldb/include/lldb/Interpreter/ScriptInterpreterPython.h index 839e36db1e91..53e6b1f5f9ed 100644 --- a/lldb/include/lldb/Interpreter/ScriptInterpreterPython.h +++ b/lldb/include/lldb/Interpreter/ScriptInterpreterPython.h @@ -56,14 +56,17 @@ public: ExportFunctionDefinitionToInterpreter (StringList &function_def); bool - GenerateTypeScriptFunction (StringList &input, StringList &output); + GenerateTypeScriptFunction (StringList &input, StringList &output, void* name_token = NULL); bool - GenerateTypeSynthClass (StringList &input, StringList &output); + GenerateTypeSynthClass (StringList &input, StringList &output, void* name_token = NULL); + + bool + GenerateTypeSynthClass (const char* oneliner, StringList &output, void* name_token = NULL); // use this if the function code is just a one-liner script bool - GenerateTypeScriptFunction (const char* oneliner, StringList &output); + GenerateTypeScriptFunction (const char* oneliner, StringList &output, void* name_token = NULL); virtual bool GenerateScriptAliasFunction (StringList &input, StringList &output); diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h index 798479ee775b..f8aba437dc06 100644 --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -600,6 +600,22 @@ namespace lldb { } TemplateArgumentKind; + //---------------------------------------------------------------------- + // Options that can be set for a formatter to alter its behavior + // Not all of these are applicable to all formatter types + //---------------------------------------------------------------------- + typedef enum TypeOptions + { + eTypeOptionNone = (0u), + eTypeOptionCascade = (1u << 0), + eTypeOptionSkipPointers = (1u << 1), + eTypeOptionSkipReferences = (1u << 2), + eTypeOptionHideChildren = (1u << 3), + eTypeOptionHideValue = (1u << 4), + eTypeOptionShowOneLiner = (1u << 5), + eTypeOptionHideNames = (1u << 6) + } TypeOptions; + } // namespace lldb diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h index 5440e082829a..7dd4842d8f31 100644 --- a/lldb/include/lldb/lldb-forward.h +++ b/lldb/include/lldb/lldb-forward.h @@ -86,7 +86,7 @@ class ExecutionContextScope; class FileSpec; class FileSpecList; class Flags; -class FormatCategory; +class TypeCategoryImpl; class FormatManager; class FuncUnwinders; class Function; @@ -154,8 +154,8 @@ template class StreamBuffer; class StreamFile; class StreamString; class StringList; -struct StringSummaryFormat; -struct SummaryFormat; +class StringSummaryFormat; +class TypeSummaryImpl; class Symbol; class SymbolContext; class SymbolContextList; @@ -167,8 +167,9 @@ class SymbolVendor; class Symtab; class SyntheticChildren; class SyntheticChildrenFrontEnd; +class TypeFilterImpl; #ifndef LLDB_DISABLE_PYTHON -class SyntheticScriptProvider; +class TypeSyntheticImpl; #endif class Target; class TargetList; @@ -190,7 +191,8 @@ class TypeImpl; class TypeAndOrName; class TypeList; class TypeListImpl; -class TypeMemberImpl; +class TypeMemberImpl; +class TypeNameSpecifierImpl; class UUID; class Unwind; class UnwindAssembly; @@ -199,7 +201,7 @@ class UnwindTable; class UserSettingsController; class VMRange; class Value; -struct ValueFormat; +struct TypeFormatImpl; class ValueList; class ValueObject; class ValueObjectChild; @@ -243,7 +245,7 @@ namespace lldb { typedef std::tr1::shared_ptr DisassemblerSP; typedef std::tr1::shared_ptr DynamicLoaderSP; typedef std::tr1::shared_ptr EventSP; - typedef std::tr1::shared_ptr FormatCategorySP; + typedef std::tr1::shared_ptr TypeCategoryImplSP; typedef std::tr1::shared_ptr FunctionSP; typedef std::tr1::shared_ptr InlineFunctionInfoSP; typedef std::tr1::shared_ptr InputReaderSP; @@ -267,7 +269,7 @@ namespace lldb { typedef std::tr1::shared_ptr SectionSP; typedef std::tr1::shared_ptr SearchFilterSP; #ifndef LLDB_DISABLE_PYTHON - typedef std::tr1::shared_ptr ScriptFormatSP; + typedef std::tr1::shared_ptr ScriptSummaryFormatSP; #endif // #ifndef LLDB_DISABLE_PYTHON typedef std::tr1::shared_ptr StackFrameSP; typedef std::tr1::weak_ptr StackFrameWP; @@ -275,14 +277,17 @@ namespace lldb { typedef std::tr1::shared_ptr StopInfoSP; typedef std::tr1::shared_ptr StoppointLocationSP; typedef std::tr1::shared_ptr StreamSP; - typedef std::tr1::shared_ptr StringSummaryFormatSP; - typedef std::tr1::shared_ptr SummaryFormatSP; + typedef std::tr1::shared_ptr StringTypeSummaryImplSP; + typedef std::tr1::shared_ptr TypeSummaryImplSP; + typedef std::tr1::shared_ptr TypeNameSpecifierImplSP; typedef std::tr1::shared_ptr SymbolFileSP; typedef std::tr1::shared_ptr SymbolFileTypeSP; typedef std::tr1::weak_ptr SymbolFileTypeWP; typedef std::tr1::shared_ptr SymbolContextSpecifierSP; typedef std::tr1::shared_ptr SyntheticChildrenSP; typedef std::tr1::shared_ptr SyntheticChildrenFrontEndSP; + typedef std::tr1::shared_ptr TypeFilterImplSP; + typedef std::tr1::shared_ptr TypeSyntheticImplSP; typedef std::tr1::shared_ptr TargetSP; typedef std::tr1::weak_ptr TargetWP; typedef std::tr1::shared_ptr ThreadSP; @@ -298,7 +303,7 @@ namespace lldb { typedef std::tr1::shared_ptr UnwindPlanSP; typedef lldb_private::SharingPtr ValueObjectSP; typedef std::tr1::shared_ptr ValueSP; - typedef std::tr1::shared_ptr ValueFormatSP; + typedef std::tr1::shared_ptr TypeFormatImplSP; typedef std::tr1::shared_ptr ValueListSP; typedef std::tr1::shared_ptr VariableSP; typedef std::tr1::shared_ptr VariableListSP; diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj index fc26ed100722..b588b9654cc4 100644 --- a/lldb/lldb.xcodeproj/project.pbxproj +++ b/lldb/lldb.xcodeproj/project.pbxproj @@ -408,12 +408,24 @@ 4CF52AF8142829390051E832 /* SBFileSpecList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CF52AF7142829390051E832 /* SBFileSpecList.cpp */; }; 94031A9E13CF486700DCFF3C /* InputReaderEZ.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94031A9D13CF486600DCFF3C /* InputReaderEZ.cpp */; }; 9415F61813B2C0EF00A52B36 /* FormatManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9415F61713B2C0EF00A52B36 /* FormatManager.cpp */; }; + 941BCC7F14E48C4000BB969C /* SBTypeFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 9461568614E355F2003A195C /* SBTypeFilter.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 941BCC8014E48C4000BB969C /* SBTypeFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = 9461568714E355F2003A195C /* SBTypeFormat.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 941BCC8114E48C4000BB969C /* SBTypeSummary.h in Headers */ = {isa = PBXBuildFile; fileRef = 9461568814E355F2003A195C /* SBTypeSummary.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 941BCC8214E48C4000BB969C /* SBTypeSynthetic.h in Headers */ = {isa = PBXBuildFile; fileRef = 9461568914E355F2003A195C /* SBTypeSynthetic.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9443B122140C18C40013457C /* SBData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9443B121140C18C10013457C /* SBData.cpp */; }; 9443B123140C26AB0013457C /* SBData.h in Headers */ = {isa = PBXBuildFile; fileRef = 9443B120140C18A90013457C /* SBData.h */; settings = {ATTRIBUTES = (Public, ); }; }; 94611EB213CCA4A4003A22AF /* RefCounter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94611EB113CCA4A4003A22AF /* RefCounter.cpp */; }; + 9461569A14E358A6003A195C /* SBTypeFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9461568A14E35621003A195C /* SBTypeFilter.cpp */; }; + 9461569B14E358A6003A195C /* SBTypeFormat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9461568B14E35621003A195C /* SBTypeFormat.cpp */; }; + 9461569C14E358A6003A195C /* SBTypeSummary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9461568C14E35621003A195C /* SBTypeSummary.cpp */; }; + 9461569D14E358A6003A195C /* SBTypeSynthetic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9461568D14E35621003A195C /* SBTypeSynthetic.cpp */; }; 9463D4CD13B1798800C230D4 /* CommandObjectType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9463D4CC13B1798800C230D4 /* CommandObjectType.cpp */; }; 9467E65213C3D97600B3B6F3 /* TypeHierarchyNavigator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9467E65113C3D97600B3B6F3 /* TypeHierarchyNavigator.cpp */; }; 9470A8F01402DFFB0056FF61 /* DataVisualization.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9470A8EF1402DFFB0056FF61 /* DataVisualization.cpp */; }; + 9475C18814E5E9FA001BFC6D /* SBTypeCategory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9475C18714E5E9FA001BFC6D /* SBTypeCategory.cpp */; }; + 9475C18914E5EA08001BFC6D /* SBTypeCategory.h in Headers */ = {isa = PBXBuildFile; fileRef = 9475C18514E5E9C5001BFC6D /* SBTypeCategory.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9475C18E14E5F834001BFC6D /* SBTypeNameSpecifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9475C18D14E5F834001BFC6D /* SBTypeNameSpecifier.cpp */; }; + 9475C18F14E5F858001BFC6D /* SBTypeNameSpecifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 9475C18C14E5F826001BFC6D /* SBTypeNameSpecifier.h */; settings = {ATTRIBUTES = (Public, ); }; }; 949ADF031406F648004833E1 /* ValueObjectConstResultImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 949ADF021406F648004833E1 /* ValueObjectConstResultImpl.cpp */; }; 94B6E76213D88365005F417F /* ValueObjectSyntheticFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94B6E76113D88362005F417F /* ValueObjectSyntheticFilter.cpp */; }; 94FA3DE01405D50400833217 /* ValueObjectConstResultChild.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94FA3DDF1405D50300833217 /* ValueObjectConstResultChild.cpp */; }; @@ -1259,12 +1271,30 @@ 9443B121140C18C10013457C /* SBData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBData.cpp; path = source/API/SBData.cpp; sourceTree = ""; }; 94611EAF13CCA363003A22AF /* RefCounter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RefCounter.h; path = include/lldb/Utility/RefCounter.h; sourceTree = ""; }; 94611EB113CCA4A4003A22AF /* RefCounter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RefCounter.cpp; path = source/Utility/RefCounter.cpp; sourceTree = ""; }; + 9461568614E355F2003A195C /* SBTypeFilter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBTypeFilter.h; path = include/lldb/API/SBTypeFilter.h; sourceTree = ""; }; + 9461568714E355F2003A195C /* SBTypeFormat.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBTypeFormat.h; path = include/lldb/API/SBTypeFormat.h; sourceTree = ""; }; + 9461568814E355F2003A195C /* SBTypeSummary.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBTypeSummary.h; path = include/lldb/API/SBTypeSummary.h; sourceTree = ""; }; + 9461568914E355F2003A195C /* SBTypeSynthetic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBTypeSynthetic.h; path = include/lldb/API/SBTypeSynthetic.h; sourceTree = ""; }; + 9461568A14E35621003A195C /* SBTypeFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBTypeFilter.cpp; path = source/API/SBTypeFilter.cpp; sourceTree = ""; }; + 9461568B14E35621003A195C /* SBTypeFormat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBTypeFormat.cpp; path = source/API/SBTypeFormat.cpp; sourceTree = ""; }; + 9461568C14E35621003A195C /* SBTypeSummary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBTypeSummary.cpp; path = source/API/SBTypeSummary.cpp; sourceTree = ""; }; + 9461568D14E35621003A195C /* SBTypeSynthetic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBTypeSynthetic.cpp; path = source/API/SBTypeSynthetic.cpp; sourceTree = ""; }; + 9461569214E3567F003A195C /* SBTypeFilter.i */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBTypeFilter.i; sourceTree = ""; }; + 9461569314E3567F003A195C /* SBTypeFormat.i */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBTypeFormat.i; sourceTree = ""; }; + 9461569414E3567F003A195C /* SBTypeSummary.i */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBTypeSummary.i; sourceTree = ""; }; + 9461569514E3567F003A195C /* SBTypeSynthetic.i */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBTypeSynthetic.i; sourceTree = ""; }; 9463D4CC13B1798800C230D4 /* CommandObjectType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = CommandObjectType.cpp; path = source/Commands/CommandObjectType.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 9463D4CE13B179A500C230D4 /* CommandObjectType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CommandObjectType.h; path = source/Commands/CommandObjectType.h; sourceTree = ""; }; 9467E65113C3D97600B3B6F3 /* TypeHierarchyNavigator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TypeHierarchyNavigator.cpp; path = source/Symbol/TypeHierarchyNavigator.cpp; sourceTree = ""; }; 9467E65413C3D98900B3B6F3 /* TypeHierarchyNavigator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TypeHierarchyNavigator.h; path = include/lldb/Symbol/TypeHierarchyNavigator.h; sourceTree = ""; }; - 9470A8EE1402DF940056FF61 /* DataVisualization.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = DataVisualization.h; path = include/lldb/Core/DataVisualization.h; sourceTree = ""; }; - 9470A8EF1402DFFB0056FF61 /* DataVisualization.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DataVisualization.cpp; path = source/Core/DataVisualization.cpp; sourceTree = ""; }; + 9470A8EE1402DF940056FF61 /* DataVisualization.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = DataVisualization.h; path = include/lldb/Core/DataVisualization.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; + 9470A8EF1402DFFB0056FF61 /* DataVisualization.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = DataVisualization.cpp; path = source/Core/DataVisualization.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; + 9475C18514E5E9C5001BFC6D /* SBTypeCategory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBTypeCategory.h; path = include/lldb/API/SBTypeCategory.h; sourceTree = ""; }; + 9475C18714E5E9FA001BFC6D /* SBTypeCategory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBTypeCategory.cpp; path = source/API/SBTypeCategory.cpp; sourceTree = ""; }; + 9475C18A14E5EA1C001BFC6D /* SBTypeCategory.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBTypeCategory.i; sourceTree = ""; }; + 9475C18B14E5F818001BFC6D /* SBTypeNameSpecifier.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBTypeNameSpecifier.i; sourceTree = ""; }; + 9475C18C14E5F826001BFC6D /* SBTypeNameSpecifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBTypeNameSpecifier.h; path = include/lldb/API/SBTypeNameSpecifier.h; sourceTree = ""; }; + 9475C18D14E5F834001BFC6D /* SBTypeNameSpecifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBTypeNameSpecifier.cpp; path = source/API/SBTypeNameSpecifier.cpp; sourceTree = ""; }; 949ADF001406F62E004833E1 /* ValueObjectConstResultImpl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ValueObjectConstResultImpl.h; path = include/lldb/Core/ValueObjectConstResultImpl.h; sourceTree = ""; }; 949ADF021406F648004833E1 /* ValueObjectConstResultImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectConstResultImpl.cpp; path = source/Core/ValueObjectConstResultImpl.cpp; sourceTree = ""; }; 94A8287514031D05006C37A8 /* FormatNavigator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FormatNavigator.h; path = include/lldb/Core/FormatNavigator.h; sourceTree = ""; }; @@ -1715,6 +1745,12 @@ 2611FF0F142D83060017FEA3 /* SBTarget.i */, 2611FF10142D83060017FEA3 /* SBThread.i */, 2611FF11142D83060017FEA3 /* SBType.i */, + 9475C18A14E5EA1C001BFC6D /* SBTypeCategory.i */, + 9461569214E3567F003A195C /* SBTypeFilter.i */, + 9461569314E3567F003A195C /* SBTypeFormat.i */, + 9475C18B14E5F818001BFC6D /* SBTypeNameSpecifier.i */, + 9461569414E3567F003A195C /* SBTypeSummary.i */, + 9461569514E3567F003A195C /* SBTypeSynthetic.i */, 2611FF12142D83060017FEA3 /* SBValue.i */, 2611FF13142D83060017FEA3 /* SBValueList.i */, B2A5872514313B480092BFBA /* SBWatchpoint.i */, @@ -1822,6 +1858,18 @@ 9A9831091125FC5800A56CB0 /* SBThread.cpp */, 2617447911685869005ADD65 /* SBType.h */, 261744771168585B005ADD65 /* SBType.cpp */, + 9475C18514E5E9C5001BFC6D /* SBTypeCategory.h */, + 9475C18714E5E9FA001BFC6D /* SBTypeCategory.cpp */, + 9461568614E355F2003A195C /* SBTypeFilter.h */, + 9461568A14E35621003A195C /* SBTypeFilter.cpp */, + 9461568714E355F2003A195C /* SBTypeFormat.h */, + 9461568B14E35621003A195C /* SBTypeFormat.cpp */, + 9475C18C14E5F826001BFC6D /* SBTypeNameSpecifier.h */, + 9475C18D14E5F834001BFC6D /* SBTypeNameSpecifier.cpp */, + 9461568814E355F2003A195C /* SBTypeSummary.h */, + 9461568C14E35621003A195C /* SBTypeSummary.cpp */, + 9461568914E355F2003A195C /* SBTypeSynthetic.h */, + 9461568D14E35621003A195C /* SBTypeSynthetic.cpp */, 9A19A6A51163BB7E00E0D453 /* SBValue.h */, 9A19A6AD1163BB9800E0D453 /* SBValue.cpp */, 9A357582116CFDEE00E8ED2F /* SBValueList.h */, @@ -2876,6 +2924,12 @@ 2668022C115FD13D008E1FE4 /* SBTarget.h in Headers */, 2668022E115FD13D008E1FE4 /* SBThread.h in Headers */, 2617447A11685869005ADD65 /* SBType.h in Headers */, + 9475C18914E5EA08001BFC6D /* SBTypeCategory.h in Headers */, + 941BCC7F14E48C4000BB969C /* SBTypeFilter.h in Headers */, + 941BCC8014E48C4000BB969C /* SBTypeFormat.h in Headers */, + 9475C18F14E5F858001BFC6D /* SBTypeNameSpecifier.h in Headers */, + 941BCC8114E48C4000BB969C /* SBTypeSummary.h in Headers */, + 941BCC8214E48C4000BB969C /* SBTypeSynthetic.h in Headers */, 9A19A6AF1163BBB200E0D453 /* SBValue.h in Headers */, 9A357583116CFDEE00E8ED2F /* SBValueList.h in Headers */, 26D265A2136B40EE002EEE45 /* SharingPtr.h in Headers */, @@ -3177,6 +3231,10 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 9461569A14E358A6003A195C /* SBTypeFilter.cpp in Sources */, + 9461569B14E358A6003A195C /* SBTypeFormat.cpp in Sources */, + 9461569C14E358A6003A195C /* SBTypeSummary.cpp in Sources */, + 9461569D14E358A6003A195C /* SBTypeSynthetic.cpp in Sources */, 26680324116005D9008E1FE4 /* SBThread.cpp in Sources */, 26680326116005DB008E1FE4 /* SBTarget.cpp in Sources */, 26680327116005DC008E1FE4 /* SBSourceManager.cpp in Sources */, @@ -3217,6 +3275,8 @@ 26B82840142D020F002DBC64 /* SBSection.cpp in Sources */, B2A58724143119D50092BFBA /* SBWatchpoint.cpp in Sources */, 2660AAB914622483003A9694 /* LLDBWrapPython.cpp in Sources */, + 9475C18814E5E9FA001BFC6D /* SBTypeCategory.cpp in Sources */, + 9475C18E14E5F834001BFC6D /* SBTypeNameSpecifier.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/lldb/scripts/Python/build-swig-Python.sh b/lldb/scripts/Python/build-swig-Python.sh index 6ccea31d8b95..5fcbe7a81f2e 100755 --- a/lldb/scripts/Python/build-swig-Python.sh +++ b/lldb/scripts/Python/build-swig-Python.sh @@ -73,6 +73,12 @@ HEADER_FILES="${SRC_ROOT}/include/lldb/lldb.h"\ " ${SRC_ROOT}/include/lldb/API/SBTarget.h"\ " ${SRC_ROOT}/include/lldb/API/SBThread.h"\ " ${SRC_ROOT}/include/lldb/API/SBType.h"\ +" ${SRC_ROOT}/include/lldb/API/SBTypeCategory.h"\ +" ${SRC_ROOT}/include/lldb/API/SBTypeFilter.h"\ +" ${SRC_ROOT}/include/lldb/API/SBTypeFormat.h"\ +" ${SRC_ROOT}/include/lldb/API/SBTypeNameSpecifier.h"\ +" ${SRC_ROOT}/include/lldb/API/SBTypeSummary.h"\ +" ${SRC_ROOT}/include/lldb/API/SBTypeSynthetic.h"\ " ${SRC_ROOT}/include/lldb/API/SBValue.h"\ " ${SRC_ROOT}/include/lldb/API/SBValueList.h"\ " ${SRC_ROOT}/include/lldb/API/SBWatchpoint.h"\ @@ -109,6 +115,12 @@ INTERFACE_FILES="${SRC_ROOT}/scripts/Python/interface/SBAddress.i"\ " ${SRC_ROOT}/scripts/Python/interface/SBTarget.i"\ " ${SRC_ROOT}/scripts/Python/interface/SBThread.i"\ " ${SRC_ROOT}/scripts/Python/interface/SBType.i"\ +" ${SRC_ROOT}/scripts/Python/interface/SBTypeCategory.i"\ +" ${SRC_ROOT}/scripts/Python/interface/SBTypeFilter.i"\ +" ${SRC_ROOT}/scripts/Python/interface/SBTypeFormat.i"\ +" ${SRC_ROOT}/scripts/Python/interface/SBTypeNameSpecifier.i"\ +" ${SRC_ROOT}/scripts/Python/interface/SBTypeSummary.i"\ +" ${SRC_ROOT}/scripts/Python/interface/SBTypeSynthetic.i"\ " ${SRC_ROOT}/scripts/Python/interface/SBValue.i"\ " ${SRC_ROOT}/scripts/Python/interface/SBValueList.i"\ " ${SRC_ROOT}/scripts/Python/interface/SBWatchpoint.i" diff --git a/lldb/scripts/Python/interface/SBDebugger.i b/lldb/scripts/Python/interface/SBDebugger.i index 1882021f5e9d..5048a83d0ec8 100644 --- a/lldb/scripts/Python/interface/SBDebugger.i +++ b/lldb/scripts/Python/interface/SBDebugger.i @@ -321,6 +321,37 @@ public: void SetCloseInputOnEOF (bool b); + + lldb::SBTypeCategory + GetCategory (const char* category_name); + + lldb::SBTypeCategory + CreateCategory (const char* category_name); + + bool + DeleteCategory (const char* category_name); + + uint32_t + GetNumCategories (); + + lldb::SBTypeCategory + GetCategoryAtIndex (uint32_t); + + lldb::SBTypeCategory + GetDefaultCategory(); + + lldb::SBTypeFormat + GetFormatForType (lldb::SBTypeNameSpecifier); + + lldb::SBTypeSummary + GetSummaryForType (lldb::SBTypeNameSpecifier); + + lldb::SBTypeFilter + GetFilterForType (lldb::SBTypeNameSpecifier); + + lldb::SBTypeSynthetic + GetSyntheticForType (lldb::SBTypeNameSpecifier); + }; // class SBDebugger } // namespace lldb diff --git a/lldb/scripts/Python/interface/SBTypeCategory.i b/lldb/scripts/Python/interface/SBTypeCategory.i new file mode 100644 index 000000000000..fa1a63c7df3d --- /dev/null +++ b/lldb/scripts/Python/interface/SBTypeCategory.i @@ -0,0 +1,140 @@ +//===-- SWIG Interface for SBTypeCategory---------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + + %feature("docstring", + "Represents a category that can contain formatters for types. + ") SBTypeCategory; + + class SBTypeCategory + { + public: + + SBTypeCategory(); + + SBTypeCategory (const lldb::SBTypeCategory &rhs); + + ~SBTypeCategory (); + + bool + IsValid() const; + + bool + GetEnabled (); + + void + SetEnabled (bool); + + const char* + GetName(); + + bool + GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level); + + uint32_t + GetNumFormats (); + + uint32_t + GetNumSummaries (); + + uint32_t + GetNumFilters (); + + uint32_t + GetNumSynthetics (); + + lldb::SBTypeNameSpecifier + GetTypeNameSpecifierForFilterAtIndex (uint32_t); + + lldb::SBTypeNameSpecifier + GetTypeNameSpecifierForFormatAtIndex (uint32_t); + + lldb::SBTypeNameSpecifier + GetTypeNameSpecifierForSummaryAtIndex (uint32_t); + + lldb::SBTypeNameSpecifier + GetTypeNameSpecifierForSyntheticAtIndex (uint32_t); + + lldb::SBTypeFilter + GetFilterForType (lldb::SBTypeNameSpecifier); + + lldb::SBTypeFormat + GetFormatForType (lldb::SBTypeNameSpecifier); + + lldb::SBTypeSummary + GetSummaryForType (lldb::SBTypeNameSpecifier); + + lldb::SBTypeSynthetic + GetSyntheticForType (lldb::SBTypeNameSpecifier); + + lldb::SBTypeFilter + GetFilterAtIndex (uint32_t); + + lldb::SBTypeFormat + GetFormatAtIndex (uint32_t); + + lldb::SBTypeSummary + GetSummaryAtIndex (uint32_t); + + lldb::SBTypeSynthetic + GetSyntheticAtIndex (uint32_t); + + bool + AddTypeFormat (lldb::SBTypeNameSpecifier, + lldb::SBTypeFormat); + + bool + DeleteTypeFormat (lldb::SBTypeNameSpecifier); + + bool + AddTypeSummary (lldb::SBTypeNameSpecifier, + lldb::SBTypeSummary); + + bool + DeleteTypeSummary (lldb::SBTypeNameSpecifier); + + bool + AddTypeFilter (lldb::SBTypeNameSpecifier, + lldb::SBTypeFilter); + + bool + DeleteTypeFilter (lldb::SBTypeNameSpecifier); + + bool + AddTypeSynthetic (lldb::SBTypeNameSpecifier, + lldb::SBTypeSynthetic); + + bool + DeleteTypeSynthetic (lldb::SBTypeNameSpecifier); + + %pythoncode %{ + __swig_getmethods__["num_formats"] = GetNumFormats + if _newclass: x = property(GetNumFormats, None) + __swig_getmethods__["num_summaries"] = GetNumSummaries + if _newclass: x = property(GetNumSummaries, None) + __swig_getmethods__["num_filters"] = GetNumFilters + if _newclass: x = property(GetNumFilters, None) + __swig_getmethods__["num_synthetics"] = GetNumSynthetics + if _newclass: x = property(GetNumSynthetics, None) + + __swig_getmethods__["name"] = GetName + if _newclass: x = property(GetName, None) + + __swig_getmethods__["enabled"] = GetEnabled + __swig_setmethods__["enabled"] = SetEnabled + if _newclass: x = property(GetEnabled, SetEnabled) + %} + + }; + + +} // namespace lldb + diff --git a/lldb/scripts/Python/interface/SBTypeFilter.i b/lldb/scripts/Python/interface/SBTypeFilter.i new file mode 100644 index 000000000000..046859a68bf7 --- /dev/null +++ b/lldb/scripts/Python/interface/SBTypeFilter.i @@ -0,0 +1,69 @@ +//===-- SWIG Interface for SBTypeFilter----------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + + %feature("docstring", + "Represents a filter that can be associated to one or more types. + ") SBTypeFilter; + + class SBTypeFilter + { + public: + + SBTypeFilter(); + + SBTypeFilter (uint32_t options); + + SBTypeFilter (const lldb::SBTypeFilter &rhs); + + ~SBTypeFilter (); + + bool + IsValid() const; + + bool + IsEqualTo (lldb::SBTypeFilter &rhs); + + uint32_t + GetNumberOfExpressionPaths (); + + const char* + GetExpressionPathAtIndex (uint32_t i); + + bool + ReplaceExpressionPathAtIndex (uint32_t i, const char* item); + + void + AppendExpressionPath (const char* item); + + void + Clear(); + + uint32_t + GetOptions(); + + void + SetOptions (uint32_t); + + bool + GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level); + + %pythoncode %{ + __swig_getmethods__["options"] = GetOptions + __swig_setmethods__["options"] = SetOptions + if _newclass: x = property(GetOptions, SetOptions) + + __swig_getmethods__["count"] = GetNumberOfExpressionPaths + if _newclass: x = property(GetNumberOfExpressionPaths, None) + %} + + }; + +} // namespace lldb diff --git a/lldb/scripts/Python/interface/SBTypeFormat.i b/lldb/scripts/Python/interface/SBTypeFormat.i new file mode 100644 index 000000000000..2116a02affce --- /dev/null +++ b/lldb/scripts/Python/interface/SBTypeFormat.i @@ -0,0 +1,64 @@ +//===-- SWIG Interface for SBTypeFormat----------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + + %feature("docstring", + "Represents a format that can be associated to one or more types. + ") SBTypeFormat; + + class SBTypeFormat + { + public: + + SBTypeFormat(); + + SBTypeFormat (lldb::Format format, uint32_t options = 0); + + SBTypeFormat (const lldb::SBTypeFormat &rhs); + + ~SBTypeFormat (); + + bool + IsValid() const; + + bool + IsEqualTo (lldb::SBTypeFormat &rhs); + + lldb::Format + GetFormat (); + + uint32_t + GetOptions(); + + void + SetFormat (lldb::Format); + + void + SetOptions (uint32_t); + + bool + GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level); + + %pythoncode %{ + __swig_getmethods__["format"] = GetFormat + __swig_setmethods__["format"] = SetFormat + if _newclass: x = property(GetFormat, SetFormat) + + __swig_getmethods__["options"] = GetOptions + __swig_setmethods__["options"] = SetOptions + if _newclass: x = property(GetOptions, SetOptions) + %} + + }; + + +} // namespace lldb + diff --git a/lldb/scripts/Python/interface/SBTypeNameSpecifier.i b/lldb/scripts/Python/interface/SBTypeNameSpecifier.i new file mode 100644 index 000000000000..f50761c602e0 --- /dev/null +++ b/lldb/scripts/Python/interface/SBTypeNameSpecifier.i @@ -0,0 +1,57 @@ +//===-- SWIG Interface for SBTypeNameSpecifier---------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + + %feature("docstring", + "Represents a general way to provide a type name to LLDB APIs. + ") SBTypeNameSpecifier; + + class SBTypeNameSpecifier + { + public: + + SBTypeNameSpecifier(); + + SBTypeNameSpecifier (const char* name, + bool is_regex = false); + + SBTypeNameSpecifier (const lldb::SBTypeNameSpecifier &rhs); + + ~SBTypeNameSpecifier (); + + bool + IsValid() const; + + bool + IsEqualTo (lldb::SBTypeNameSpecifier &rhs); + + const char* + GetName(); + + bool + IsRegex(); + + bool + GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level); + + %pythoncode %{ + __swig_getmethods__["name"] = GetName + if _newclass: x = property(GetName, None) + + __swig_getmethods__["is_regex"] = IsRegex + if _newclass: x = property(IsRegex, None) + %} + + + }; + +} // namespace lldb + diff --git a/lldb/scripts/Python/interface/SBTypeSummary.i b/lldb/scripts/Python/interface/SBTypeSummary.i new file mode 100644 index 000000000000..f96897752bf5 --- /dev/null +++ b/lldb/scripts/Python/interface/SBTypeSummary.i @@ -0,0 +1,93 @@ +//===-- SWIG Interface for SBTypeSummary---------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + + %feature("docstring", + "Represents a summary that can be associated to one or more types. + ") SBTypeSummary; + + class SBTypeSummary + { + public: + + SBTypeSummary(); + + static SBTypeSummary + CreateWithSummaryString (const char* data, uint32_t options = 0); + + static SBTypeSummary + CreateWithFunctionName (const char* data, uint32_t options = 0); + + static SBTypeSummary + CreateWithScriptCode (const char* data, uint32_t options = 0); + + SBTypeSummary (const lldb::SBTypeSummary &rhs); + + ~SBTypeSummary (); + + bool + IsValid() const; + + bool + IsEqualTo (lldb::SBTypeSummary &rhs); + + bool + IsFunctionCode(); + + bool + IsFunctionName(); + + bool + IsSummaryString(); + + const char* + GetData (); + + void + SetSummaryString (const char* data); + + void + SetFunctionName (const char* data); + + void + SetFunctionCode (const char* data); + + uint32_t + GetOptions (); + + void + SetOptions (uint32_t); + + bool + GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level); + + %pythoncode %{ + __swig_getmethods__["options"] = GetOptions + __swig_setmethods__["options"] = SetOptions + if _newclass: x = property(GetOptions, SetOptions) + + __swig_getmethods__["is_summary_string"] = IsSummaryString + if _newclass: x = property(IsSummaryString, None) + + __swig_getmethods__["is_function_name"] = IsFunctionName + if _newclass: x = property(IsFunctionName, None) + + __swig_getmethods__["is_function_code"] = IsFunctionCode + if _newclass: x = property(IsFunctionCode, None) + + __swig_getmethods__["summary_data"] = GetData + if _newclass: x = property(GetData, None) + %} + + }; + +} // namespace lldb + diff --git a/lldb/scripts/Python/interface/SBTypeSynthetic.i b/lldb/scripts/Python/interface/SBTypeSynthetic.i new file mode 100644 index 000000000000..3e785ff9b5c1 --- /dev/null +++ b/lldb/scripts/Python/interface/SBTypeSynthetic.i @@ -0,0 +1,74 @@ +//===-- SWIG Interface for SBTypeSynthetic-------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + + %feature("docstring", + "Represents a summary that can be associated to one or more types. + ") SBTypeSynthetic; + + class SBTypeSynthetic + { + public: + + SBTypeSynthetic(); + + static lldb::SBTypeSynthetic + CreateWithClassName (const char* data, uint32_t options = 0); + + static lldb::SBTypeSynthetic + CreateWithScriptCode (const char* data, uint32_t options = 0); + + SBTypeSynthetic (const lldb::SBTypeSynthetic &rhs); + + ~SBTypeSynthetic (); + + bool + IsValid() const; + + bool + IsEqualTo (lldb::SBTypeSynthetic &rhs); + + bool + IsClassCode(); + + const char* + GetData (); + + void + SetClassName (const char* data); + + void + SetClassCode (const char* data); + + uint32_t + GetOptions (); + + void + SetOptions (uint32_t); + + bool + GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level); + + %pythoncode %{ + __swig_getmethods__["options"] = GetOptions + __swig_setmethods__["options"] = SetOptions + if _newclass: x = property(GetOptions, SetOptions) + + __swig_getmethods__["contains_code"] = IsClassCode + if _newclass: x = property(IsClassCode, None) + + __swig_getmethods__["synthetic_data"] = GetData + if _newclass: x = property(GetData, None) + %} + + }; + +} // namespace lldb diff --git a/lldb/scripts/Python/python-extensions.swig b/lldb/scripts/Python/python-extensions.swig index 29e39e54e57d..cd8f1cfc5f03 100644 --- a/lldb/scripts/Python/python-extensions.swig +++ b/lldb/scripts/Python/python-extensions.swig @@ -322,6 +322,48 @@ return PyString_FromString(""); } } +%extend lldb::SBTypeCategory { + PyObject *lldb::SBTypeCategory::__str__ (){ + lldb::SBStream description; + $self->GetDescription (description, lldb::eDescriptionLevelBrief); + const char *desc = description.GetData(); + size_t desc_len = description.GetSize(); + if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) + --desc_len; + if (desc_len > 0) + return PyString_FromStringAndSize (desc, desc_len); + else + return PyString_FromString(""); + } +} +%extend lldb::SBTypeFilter { + PyObject *lldb::SBTypeFilter::__str__ (){ + lldb::SBStream description; + $self->GetDescription (description, lldb::eDescriptionLevelBrief); + const char *desc = description.GetData(); + size_t desc_len = description.GetSize(); + if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) + --desc_len; + if (desc_len > 0) + return PyString_FromStringAndSize (desc, desc_len); + else + return PyString_FromString(""); + } +} +%extend lldb::SBTypeFormat { + PyObject *lldb::SBTypeFormat::__str__ (){ + lldb::SBStream description; + $self->GetDescription (description, lldb::eDescriptionLevelBrief); + const char *desc = description.GetData(); + size_t desc_len = description.GetSize(); + if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) + --desc_len; + if (desc_len > 0) + return PyString_FromStringAndSize (desc, desc_len); + else + return PyString_FromString(""); + } +} %extend lldb::SBTypeMember { PyObject *lldb::SBTypeMember::__str__ (){ lldb::SBStream description; @@ -336,6 +378,48 @@ return PyString_FromString(""); } } +%extend lldb::SBTypeNameSpecifier { + PyObject *lldb::SBTypeNameSpecifier::__str__ (){ + lldb::SBStream description; + $self->GetDescription (description, lldb::eDescriptionLevelBrief); + const char *desc = description.GetData(); + size_t desc_len = description.GetSize(); + if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) + --desc_len; + if (desc_len > 0) + return PyString_FromStringAndSize (desc, desc_len); + else + return PyString_FromString(""); + } +} +%extend lldb::SBTypeSummary { + PyObject *lldb::SBTypeSummary::__str__ (){ + lldb::SBStream description; + $self->GetDescription (description, lldb::eDescriptionLevelBrief); + const char *desc = description.GetData(); + size_t desc_len = description.GetSize(); + if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) + --desc_len; + if (desc_len > 0) + return PyString_FromStringAndSize (desc, desc_len); + else + return PyString_FromString(""); + } +} +%extend lldb::SBTypeSynthetic { + PyObject *lldb::SBTypeSynthetic::__str__ (){ + lldb::SBStream description; + $self->GetDescription (description, lldb::eDescriptionLevelBrief); + const char *desc = description.GetData(); + size_t desc_len = description.GetSize(); + if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) + --desc_len; + if (desc_len > 0) + return PyString_FromStringAndSize (desc, desc_len); + else + return PyString_FromString(""); + } +} %extend lldb::SBThread { PyObject *lldb::SBThread::__str__ (){ lldb::SBStream description; diff --git a/lldb/scripts/lldb.swig b/lldb/scripts/lldb.swig index e60c6089bcfb..98de4ffff961 100644 --- a/lldb/scripts/lldb.swig +++ b/lldb/scripts/lldb.swig @@ -82,6 +82,12 @@ import os #include "lldb/API/SBTarget.h" #include "lldb/API/SBThread.h" #include "lldb/API/SBType.h" +#include "lldb/API/SBTypeCategory.h" +#include "lldb/API/SBTypeFilter.h" +#include "lldb/API/SBTypeFormat.h" +#include "lldb/API/SBTypeNameSpecifier.h" +#include "lldb/API/SBTypeSummary.h" +#include "lldb/API/SBTypeSynthetic.h" #include "lldb/API/SBValue.h" #include "lldb/API/SBValueList.h" #include "lldb/API/SBWatchpoint.h" @@ -134,6 +140,12 @@ import os %include "./Python/interface/SBTarget.i" %include "./Python/interface/SBThread.i" %include "./Python/interface/SBType.i" +%include "./Python/interface/SBTypeCategory.i" +%include "./Python/interface/SBTypeFilter.i" +%include "./Python/interface/SBTypeFormat.i" +%include "./Python/interface/SBTypeNameSpecifier.i" +%include "./Python/interface/SBTypeSummary.i" +%include "./Python/interface/SBTypeSynthetic.i" %include "./Python/interface/SBValue.i" %include "./Python/interface/SBValueList.i" %include "./Python/interface/SBWatchpoint.i" diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index 9c2eea065ce8..f98ca35f813f 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -25,6 +25,15 @@ #include "lldb/API/SBStringList.h" #include "lldb/API/SBTarget.h" #include "lldb/API/SBThread.h" +#include "lldb/API/SBTypeCategory.h" +#include "lldb/API/SBTypeFormat.h" +#include "lldb/API/SBTypeFilter.h" +#include "lldb/API/SBTypeNameSpecifier.h" +#include "lldb/API/SBTypeSummary.h" +#include "lldb/API/SBTypeSynthetic.h" + + +#include "lldb/Core/DataVisualization.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/State.h" #include "lldb/Interpreter/Args.h" @@ -1054,3 +1063,140 @@ SBDebugger::SetCloseInputOnEOF (bool b) if (m_opaque_sp) m_opaque_sp->SetCloseInputOnEOF (b); } + +SBTypeCategory +SBDebugger::GetCategory (const char* category_name) +{ + if (!category_name || *category_name == 0) + return SBTypeCategory(); + + TypeCategoryImplSP category_sp; + + if (DataVisualization::Categories::GetCategory(ConstString(category_name), category_sp, false)) + return SBTypeCategory(category_sp); + else + return SBTypeCategory(); +} + +SBTypeCategory +SBDebugger::CreateCategory (const char* category_name) +{ + if (!category_name || *category_name == 0) + return SBTypeCategory(); + + TypeCategoryImplSP category_sp; + + if (DataVisualization::Categories::GetCategory(ConstString(category_name), category_sp, true)) + return SBTypeCategory(category_sp); + else + return SBTypeCategory(); +} + +bool +SBDebugger::DeleteCategory (const char* category_name) +{ + if (!category_name || *category_name == 0) + return false; + + return DataVisualization::Categories::Delete(ConstString(category_name)); +} + +uint32_t +SBDebugger::GetNumCategories() +{ + return DataVisualization::Categories::GetCount(); +} + +SBTypeCategory +SBDebugger::GetCategoryAtIndex (uint32_t index) +{ + return SBTypeCategory(DataVisualization::Categories::GetCategoryAtIndex(index)); +} + +SBTypeCategory +SBDebugger::GetDefaultCategory() +{ + return GetCategory("default"); +} + +SBTypeFormat +SBDebugger::GetFormatForType (SBTypeNameSpecifier type_name) +{ + SBTypeCategory default_category_sb = GetDefaultCategory(); + if (default_category_sb.GetEnabled()) + return default_category_sb.GetFormatForType(type_name); + return SBTypeFormat(); +} + +SBTypeSummary +SBDebugger::GetSummaryForType (SBTypeNameSpecifier type_name) +{ + SBTypeSummary summary_chosen; + uint32_t num_categories = GetNumCategories(); + SBTypeCategory category_sb; + uint32_t prio_category = UINT32_MAX; + for (uint32_t category_id = 0; + category_id < num_categories; + category_id++) + { + category_sb = GetCategoryAtIndex(category_id); + if (category_sb.GetEnabled() == false) + continue; + SBTypeSummary summary_current = category_sb.GetSummaryForType(type_name); + if (summary_current.IsValid() && (summary_chosen.IsValid() == false || (prio_category > category_sb.m_opaque_sp->GetEnabledPosition()))) + { + prio_category = category_sb.m_opaque_sp->GetEnabledPosition(); + summary_chosen = summary_current; + } + } + return summary_chosen; +} + +SBTypeFilter +SBDebugger::GetFilterForType (SBTypeNameSpecifier type_name) +{ + SBTypeFilter filter_chosen; + uint32_t num_categories = GetNumCategories(); + SBTypeCategory category_sb; + uint32_t prio_category = UINT32_MAX; + for (uint32_t category_id = 0; + category_id < num_categories; + category_id++) + { + category_sb = GetCategoryAtIndex(category_id); + if (category_sb.GetEnabled() == false) + continue; + SBTypeFilter filter_current = category_sb.GetFilterForType(type_name); + if (filter_current.IsValid() && (filter_chosen.IsValid() == false || (prio_category > category_sb.m_opaque_sp->GetEnabledPosition()))) + { + prio_category = category_sb.m_opaque_sp->GetEnabledPosition(); + filter_chosen = filter_current; + } + } + return filter_chosen; +} + +SBTypeSynthetic +SBDebugger::GetSyntheticForType (SBTypeNameSpecifier type_name) +{ + SBTypeSynthetic synth_chosen; + uint32_t num_categories = GetNumCategories(); + SBTypeCategory category_sb; + uint32_t prio_category = UINT32_MAX; + for (uint32_t category_id = 0; + category_id < num_categories; + category_id++) + { + category_sb = GetCategoryAtIndex(category_id); + if (category_sb.GetEnabled() == false) + continue; + SBTypeSynthetic synth_current = category_sb.GetSyntheticForType(type_name); + if (synth_current.IsValid() && (synth_chosen.IsValid() == false || (prio_category > category_sb.m_opaque_sp->GetEnabledPosition()))) + { + prio_category = category_sb.m_opaque_sp->GetEnabledPosition(); + synth_chosen = synth_current; + } + } + return synth_chosen; +} + diff --git a/lldb/source/API/SBTypeCategory.cpp b/lldb/source/API/SBTypeCategory.cpp new file mode 100644 index 000000000000..b76f84445873 --- /dev/null +++ b/lldb/source/API/SBTypeCategory.cpp @@ -0,0 +1,556 @@ +//===-- SBTypeCategory.cpp ----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/API/SBTypeCategory.h" + +#include "lldb/API/SBTypeFilter.h" +#include "lldb/API/SBTypeFormat.h" +#include "lldb/API/SBTypeSummary.h" +#include "lldb/API/SBTypeSynthetic.h" +#include "lldb/API/SBTypeNameSpecifier.h" +#include "lldb/API/SBStream.h" + +#include "lldb/Core/DataVisualization.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Interpreter/CommandInterpreter.h" +#include "lldb/Interpreter/ScriptInterpreter.h" + +using namespace lldb; +using namespace lldb_private; + +typedef std::pair ImplType; + +SBTypeCategory::SBTypeCategory() : +m_opaque_sp() +{ +} + +SBTypeCategory::SBTypeCategory (const char* name) : +m_opaque_sp() +{ + DataVisualization::Categories::GetCategory(ConstString(name), m_opaque_sp); +} + +SBTypeCategory::SBTypeCategory (const lldb::SBTypeCategory &rhs) : +m_opaque_sp(rhs.m_opaque_sp) +{ +} + +SBTypeCategory::~SBTypeCategory () +{ +} + +bool +SBTypeCategory::IsValid() const +{ + return (m_opaque_sp.get() != NULL); +} + +bool +SBTypeCategory::GetEnabled () +{ + if (!IsValid()) + return false; + return m_opaque_sp->IsEnabled(); +} + +void +SBTypeCategory::SetEnabled (bool enabled) +{ + if (!IsValid()) + return; + if (enabled) + DataVisualization::Categories::Enable(m_opaque_sp); + else + DataVisualization::Categories::Disable(m_opaque_sp); +} + +const char* +SBTypeCategory::GetName() +{ + if (!IsValid()) + return false; + return m_opaque_sp->GetName(); +} + +uint32_t +SBTypeCategory::GetNumFormats () +{ + if (!IsDefaultCategory()) + return 0; + + return DataVisualization::ValueFormats::GetCount(); +} + +uint32_t +SBTypeCategory::GetNumSummaries () +{ + if (!IsValid()) + return 0; + return m_opaque_sp->GetSummaryNavigator()->GetCount() + m_opaque_sp->GetRegexSummaryNavigator()->GetCount(); +} + +uint32_t +SBTypeCategory::GetNumFilters () +{ + if (!IsValid()) + return 0; + return m_opaque_sp->GetFilterNavigator()->GetCount() + m_opaque_sp->GetRegexFilterNavigator()->GetCount(); +} + +uint32_t +SBTypeCategory::GetNumSynthetics () +{ + if (!IsValid()) + return 0; + return m_opaque_sp->GetSyntheticNavigator()->GetCount() + m_opaque_sp->GetRegexSyntheticNavigator()->GetCount(); +} + +lldb::SBTypeNameSpecifier +SBTypeCategory::GetTypeNameSpecifierForFilterAtIndex (uint32_t index) +{ + if (!IsValid()) + return SBTypeNameSpecifier(); + return SBTypeNameSpecifier(m_opaque_sp->GetTypeNameSpecifierForFilterAtIndex(index)); +} + +lldb::SBTypeNameSpecifier +SBTypeCategory::GetTypeNameSpecifierForFormatAtIndex (uint32_t index) +{ + if (!IsDefaultCategory()) + return SBTypeNameSpecifier(); + return SBTypeNameSpecifier(DataVisualization::ValueFormats::GetTypeNameSpecifierForFormatAtIndex(index)); +} + +lldb::SBTypeNameSpecifier +SBTypeCategory::GetTypeNameSpecifierForSummaryAtIndex (uint32_t index) +{ + if (!IsValid()) + return SBTypeNameSpecifier(); + return SBTypeNameSpecifier(m_opaque_sp->GetTypeNameSpecifierForSummaryAtIndex(index)); +} + +lldb::SBTypeNameSpecifier +SBTypeCategory::GetTypeNameSpecifierForSyntheticAtIndex (uint32_t index) +{ + if (!IsValid()) + return SBTypeNameSpecifier(); + return SBTypeNameSpecifier(m_opaque_sp->GetTypeNameSpecifierForSyntheticAtIndex(index)); +} + +SBTypeFilter +SBTypeCategory::GetFilterForType (SBTypeNameSpecifier spec) +{ + if (!IsValid()) + return SBTypeFilter(); + + if (!spec.IsValid()) + return SBTypeFilter(); + + lldb::SyntheticChildrenSP children_sp; + + if (spec.IsRegex()) + m_opaque_sp->GetRegexFilterNavigator()->GetExact(ConstString(spec.GetName()), children_sp); + else + m_opaque_sp->GetFilterNavigator()->GetExact(ConstString(spec.GetName()), children_sp); + + if (!children_sp) + return lldb::SBTypeFilter(); + + TypeFilterImplSP filter_sp = std::tr1::static_pointer_cast(children_sp); + + return lldb::SBTypeFilter(filter_sp); + +} +SBTypeFormat +SBTypeCategory::GetFormatForType (SBTypeNameSpecifier spec) +{ + if (!IsDefaultCategory()) + return SBTypeFormat(); + + if (!spec.IsValid()) + return SBTypeFormat(); + + if (spec.IsRegex()) + return SBTypeFormat(); + + return SBTypeFormat(DataVisualization::ValueFormats::GetFormat(ConstString(spec.GetName()))); +} + +SBTypeSummary +SBTypeCategory::GetSummaryForType (SBTypeNameSpecifier spec) +{ + if (!IsValid()) + return SBTypeSummary(); + + if (!spec.IsValid()) + return SBTypeSummary(); + + lldb::TypeSummaryImplSP summary_sp; + + if (spec.IsRegex()) + m_opaque_sp->GetRegexSummaryNavigator()->GetExact(ConstString(spec.GetName()), summary_sp); + else + m_opaque_sp->GetSummaryNavigator()->GetExact(ConstString(spec.GetName()), summary_sp); + + if (!summary_sp) + return lldb::SBTypeSummary(); + + return lldb::SBTypeSummary(summary_sp); +} + +SBTypeSynthetic +SBTypeCategory::GetSyntheticForType (SBTypeNameSpecifier spec) +{ + if (!IsValid()) + return SBTypeSynthetic(); + + if (!spec.IsValid()) + return SBTypeSynthetic(); + + lldb::SyntheticChildrenSP children_sp; + + if (spec.IsRegex()) + m_opaque_sp->GetRegexSyntheticNavigator()->GetExact(ConstString(spec.GetName()), children_sp); + else + m_opaque_sp->GetSyntheticNavigator()->GetExact(ConstString(spec.GetName()), children_sp); + + if (!children_sp) + return lldb::SBTypeSynthetic(); + + TypeSyntheticImplSP synth_sp = std::tr1::static_pointer_cast(children_sp); + + return lldb::SBTypeSynthetic(synth_sp); +} + +SBTypeFilter +SBTypeCategory::GetFilterAtIndex (uint32_t index) +{ + if (!IsValid()) + return SBTypeFilter(); + lldb::SyntheticChildrenSP children_sp = m_opaque_sp->GetSyntheticAtIndex((index)); + + if (!children_sp.get()) + return lldb::SBTypeFilter(); + + TypeFilterImplSP filter_sp = std::tr1::static_pointer_cast(children_sp); + + return lldb::SBTypeFilter(filter_sp); +} + +SBTypeFormat +SBTypeCategory::GetFormatAtIndex (uint32_t index) +{ + if (!IsDefaultCategory()) + return SBTypeFormat(); + return SBTypeFormat(DataVisualization::ValueFormats::GetFormatAtIndex((index))); +} + +SBTypeSummary +SBTypeCategory::GetSummaryAtIndex (uint32_t index) +{ + if (!IsValid()) + return SBTypeSummary(); + return SBTypeSummary(m_opaque_sp->GetSummaryAtIndex((index))); +} + +SBTypeSynthetic +SBTypeCategory::GetSyntheticAtIndex (uint32_t index) +{ + if (!IsValid()) + return SBTypeSynthetic(); + lldb::SyntheticChildrenSP children_sp = m_opaque_sp->GetSyntheticAtIndex((index)); + + if (!children_sp.get()) + return lldb::SBTypeSynthetic(); + + TypeSyntheticImplSP synth_sp = std::tr1::static_pointer_cast(children_sp); + + return lldb::SBTypeSynthetic(synth_sp); +} + +bool +SBTypeCategory::AddTypeFormat (SBTypeNameSpecifier type_name, + SBTypeFormat format) +{ + if (!IsDefaultCategory()) + return false; + + if (!type_name.IsValid()) + return false; + + if (!format.IsValid()) + return false; + + if (type_name.IsRegex()) + return false; + + DataVisualization::ValueFormats::Add(ConstString(type_name.GetName()), format.GetSP()); + + return true; +} + +bool +SBTypeCategory::DeleteTypeFormat (SBTypeNameSpecifier type_name) +{ + if (!IsDefaultCategory()) + return false; + + if (!type_name.IsValid()) + return false; + + if (type_name.IsRegex()) + return false; + + return DataVisualization::ValueFormats::Delete(ConstString(type_name.GetName())); +} + +bool +SBTypeCategory::AddTypeSummary (SBTypeNameSpecifier type_name, + SBTypeSummary summary) +{ + if (!IsValid()) + return false; + + if (!type_name.IsValid()) + return false; + + if (!summary.IsValid()) + return false; + + // FIXME: we need to iterate over all the Debugger objects and have each of them contain a copy of the function + // since we currently have formatters live in a global space, while Python code lives in a specific Debugger-related environment + // this should eventually be fixed by deciding a final location in the LLDB object space for formatters + if (summary.IsFunctionCode()) + { + void *name_token = (void*)ConstString(type_name.GetName()).GetCString(); + const char* script = summary.GetData(); + StringList input; input.SplitIntoLines(script, strlen(script)); + uint32_t num_debuggers = lldb_private::Debugger::GetNumDebuggers(); + bool need_set = true; + for (uint32_t j = 0; + j < num_debuggers; + j++) + { + DebuggerSP debugger_sp = lldb_private::Debugger::GetDebuggerAtIndex(j); + if (debugger_sp) + { + ScriptInterpreter* interpreter_ptr = debugger_sp->GetCommandInterpreter().GetScriptInterpreter(); + if (interpreter_ptr) + { + StringList output; + if (interpreter_ptr->GenerateTypeScriptFunction(input, output, name_token) && output.GetSize() > 0) + { + if (need_set) + { + need_set = false; + summary.SetFunctionName(output.GetStringAtIndex(0)); + } + } + } + } + } + } + + if (type_name.IsRegex()) + m_opaque_sp->GetRegexSummaryNavigator()->Add(lldb::RegularExpressionSP(new RegularExpression(type_name.GetName())), summary.GetSP()); + else + m_opaque_sp->GetSummaryNavigator()->Add(ConstString(type_name.GetName()), summary.GetSP()); + + return true; +} + +bool +SBTypeCategory::DeleteTypeSummary (SBTypeNameSpecifier type_name) +{ + if (!IsValid()) + return false; + + if (!type_name.IsValid()) + return false; + + if (type_name.IsRegex()) + return m_opaque_sp->GetRegexSummaryNavigator()->Delete(ConstString(type_name.GetName())); + else + return m_opaque_sp->GetSummaryNavigator()->Delete(ConstString(type_name.GetName())); +} + +bool +SBTypeCategory::AddTypeFilter (SBTypeNameSpecifier type_name, + SBTypeFilter filter) +{ + if (!IsValid()) + return false; + + if (!type_name.IsValid()) + return false; + + if (!filter.IsValid()) + return false; + + if (type_name.IsRegex()) + m_opaque_sp->GetRegexFilterNavigator()->Add(lldb::RegularExpressionSP(new RegularExpression(type_name.GetName())), filter.GetSP()); + else + m_opaque_sp->GetFilterNavigator()->Add(ConstString(type_name.GetName()), filter.GetSP()); + + return true; +} + +bool +SBTypeCategory::DeleteTypeFilter (SBTypeNameSpecifier type_name) +{ + if (!IsValid()) + return false; + + if (!type_name.IsValid()) + return false; + + if (type_name.IsRegex()) + return m_opaque_sp->GetRegexFilterNavigator()->Delete(ConstString(type_name.GetName())); + else + return m_opaque_sp->GetFilterNavigator()->Delete(ConstString(type_name.GetName())); +} + +bool +SBTypeCategory::AddTypeSynthetic (SBTypeNameSpecifier type_name, + SBTypeSynthetic synth) +{ + if (!IsValid()) + return false; + + if (!type_name.IsValid()) + return false; + + if (!synth.IsValid()) + return false; + + // FIXME: we need to iterate over all the Debugger objects and have each of them contain a copy of the function + // since we currently have formatters live in a global space, while Python code lives in a specific Debugger-related environment + // this should eventually be fixed by deciding a final location in the LLDB object space for formatters + if (synth.IsClassCode()) + { + void *name_token = (void*)ConstString(type_name.GetName()).GetCString(); + const char* script = synth.GetData(); + StringList input; input.SplitIntoLines(script, strlen(script)); + uint32_t num_debuggers = lldb_private::Debugger::GetNumDebuggers(); + bool need_set = true; + for (uint32_t j = 0; + j < num_debuggers; + j++) + { + DebuggerSP debugger_sp = lldb_private::Debugger::GetDebuggerAtIndex(j); + if (debugger_sp) + { + ScriptInterpreter* interpreter_ptr = debugger_sp->GetCommandInterpreter().GetScriptInterpreter(); + if (interpreter_ptr) + { + StringList output; + if (interpreter_ptr->GenerateTypeSynthClass(input, output, name_token) && output.GetSize() > 0) + { + if (need_set) + { + need_set = false; + synth.SetClassName(output.GetStringAtIndex(0)); + } + } + } + } + } + } + + if (type_name.IsRegex()) + m_opaque_sp->GetRegexSyntheticNavigator()->Add(lldb::RegularExpressionSP(new RegularExpression(type_name.GetName())), synth.GetSP()); + else + m_opaque_sp->GetSyntheticNavigator()->Add(ConstString(type_name.GetName()), synth.GetSP()); + + return true; +} + +bool +SBTypeCategory::DeleteTypeSynthetic (SBTypeNameSpecifier type_name) +{ + if (!IsValid()) + return false; + + if (!type_name.IsValid()) + return false; + + if (type_name.IsRegex()) + return m_opaque_sp->GetRegexSyntheticNavigator()->Delete(ConstString(type_name.GetName())); + else + return m_opaque_sp->GetSyntheticNavigator()->Delete(ConstString(type_name.GetName())); +} + +bool +SBTypeCategory::GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level) +{ + if (!IsValid()) + return false; + description.Printf("Category name: %s\n",GetName()); + return true; +} + +lldb::SBTypeCategory & +SBTypeCategory::operator = (const lldb::SBTypeCategory &rhs) +{ + if (this != &rhs) + { + m_opaque_sp = rhs.m_opaque_sp; + } + return *this; +} + +bool +SBTypeCategory::operator == (lldb::SBTypeCategory &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + + return m_opaque_sp.get() == rhs.m_opaque_sp.get(); + +} + +bool +SBTypeCategory::operator != (lldb::SBTypeCategory &rhs) +{ + if (IsValid() == false) + return rhs.IsValid(); + + return m_opaque_sp.get() != rhs.m_opaque_sp.get(); +} + +lldb::TypeCategoryImplSP +SBTypeCategory::GetSP () +{ + if (!IsValid()) + return lldb::TypeCategoryImplSP(); + return m_opaque_sp; +} + +void +SBTypeCategory::SetSP (const lldb::TypeCategoryImplSP &typecategory_impl_sp) +{ + m_opaque_sp = typecategory_impl_sp; +} + +SBTypeCategory::SBTypeCategory (const lldb::TypeCategoryImplSP &typecategory_impl_sp) : +m_opaque_sp(typecategory_impl_sp) +{ +} + +bool +SBTypeCategory::IsDefaultCategory() +{ + if (!IsValid()) + return false; + + return (strcmp(m_opaque_sp->GetName(),"default") == 0); +} + diff --git a/lldb/source/API/SBTypeFilter.cpp b/lldb/source/API/SBTypeFilter.cpp new file mode 100644 index 000000000000..50ecc25a6d46 --- /dev/null +++ b/lldb/source/API/SBTypeFilter.cpp @@ -0,0 +1,197 @@ +//===-- SBTypeFilter.cpp ------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/API/SBTypeFilter.h" + +#include "lldb/API/SBStream.h" + +#include "lldb/Core/DataVisualization.h" + +using namespace lldb; +using namespace lldb_private; + +SBTypeFilter::SBTypeFilter() : +m_opaque_sp() +{ +} + +SBTypeFilter::SBTypeFilter (uint32_t options) +: m_opaque_sp(TypeFilterImplSP(new TypeFilterImpl(options))) +{ +} + +SBTypeFilter::SBTypeFilter (const lldb::SBTypeFilter &rhs) : +m_opaque_sp(rhs.m_opaque_sp) +{ +} + +SBTypeFilter::~SBTypeFilter () +{ +} + +bool +SBTypeFilter::IsValid() const +{ + return m_opaque_sp.get() != NULL; +} + +uint32_t +SBTypeFilter::GetOptions() +{ + if (IsValid()) + return m_opaque_sp->GetOptions(); + return 0; +} + +void +SBTypeFilter::SetOptions (uint32_t value) +{ + if (CopyOnWrite_Impl()) + m_opaque_sp->SetOptions(value); +} + +bool +SBTypeFilter::GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level) +{ + if (!IsValid()) + return false; + else { + description.Printf("%s\n", + m_opaque_sp->GetDescription().c_str()); + return true; + } +} + +void +SBTypeFilter::Clear() +{ + if (CopyOnWrite_Impl()) + m_opaque_sp->Clear(); +} + +uint32_t +SBTypeFilter::GetNumberOfExpressionPaths() +{ + if (IsValid()) + return m_opaque_sp->GetCount(); + return 0; +} + +const char* +SBTypeFilter::GetExpressionPathAtIndex (uint32_t i) +{ + if (IsValid()) + { + const char* item = m_opaque_sp->GetExpressionPathAtIndex(i); + if (item && *item == '.') + item++; + return item; + } + return NULL; +} + +bool +SBTypeFilter::ReplaceExpressionPathAtIndex (uint32_t i, const char* item) +{ + if (CopyOnWrite_Impl()) + return m_opaque_sp->SetExpressionPathAtIndex(i, item); + else + return false; +} + +void +SBTypeFilter::AppendExpressionPath (const char* item) +{ + if (CopyOnWrite_Impl()) + m_opaque_sp->AddExpressionPath(item); +} + +lldb::SBTypeFilter & +SBTypeFilter::operator = (const lldb::SBTypeFilter &rhs) +{ + if (this != &rhs) + { + m_opaque_sp = rhs.m_opaque_sp; + } + return *this; +} + +bool +SBTypeFilter::operator == (lldb::SBTypeFilter &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + + return m_opaque_sp == rhs.m_opaque_sp; +} + +bool +SBTypeFilter::IsEqualTo (lldb::SBTypeFilter &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + + if (GetNumberOfExpressionPaths() != rhs.GetNumberOfExpressionPaths()) + return false; + + for (uint32_t j = 0; + j < GetNumberOfExpressionPaths(); + j++) + if ( strcmp(GetExpressionPathAtIndex(j),rhs.GetExpressionPathAtIndex(j)) != 0) + return false; + + return GetOptions() == rhs.GetOptions(); +} + +bool +SBTypeFilter::operator != (lldb::SBTypeFilter &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + + return m_opaque_sp != rhs.m_opaque_sp; +} + +lldb::TypeFilterImplSP +SBTypeFilter::GetSP () +{ + return m_opaque_sp; +} + +void +SBTypeFilter::SetSP (const lldb::TypeFilterImplSP &typefilter_impl_sp) +{ + m_opaque_sp = typefilter_impl_sp; +} + +SBTypeFilter::SBTypeFilter (const lldb::TypeFilterImplSP &typefilter_impl_sp) : +m_opaque_sp(typefilter_impl_sp) +{ +} + +bool +SBTypeFilter::CopyOnWrite_Impl() +{ + if (!IsValid()) + return false; + if (m_opaque_sp.unique()) + return true; + + TypeFilterImplSP new_sp(new TypeFilterImpl(GetOptions())); + + for (uint32_t j = 0; + j < GetNumberOfExpressionPaths(); + j++) + new_sp->AddExpressionPath(GetExpressionPathAtIndex(j)); + + SetSP(new_sp); + + return true; +} diff --git a/lldb/source/API/SBTypeFormat.cpp b/lldb/source/API/SBTypeFormat.cpp new file mode 100644 index 000000000000..20df87bbdaf5 --- /dev/null +++ b/lldb/source/API/SBTypeFormat.cpp @@ -0,0 +1,153 @@ +//===-- SBTypeFormat.cpp ------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/API/SBTypeFormat.h" + +#include "lldb/API/SBStream.h" + +#include "lldb/Core/DataVisualization.h" + +using namespace lldb; +using namespace lldb_private; + +SBTypeFormat::SBTypeFormat() : +m_opaque_sp() +{ +} + +SBTypeFormat::SBTypeFormat (lldb::Format format, + uint32_t options) +: m_opaque_sp(TypeFormatImplSP(new TypeFormatImpl(format,options))) +{ +} + +SBTypeFormat::SBTypeFormat (const lldb::SBTypeFormat &rhs) : +m_opaque_sp(rhs.m_opaque_sp) +{ +} + +SBTypeFormat::~SBTypeFormat () +{ +} + +bool +SBTypeFormat::IsValid() const +{ + return m_opaque_sp.get() != NULL; +} + +lldb::Format +SBTypeFormat::GetFormat () +{ + if (IsValid()) + return m_opaque_sp->GetFormat(); + return lldb::eFormatInvalid; +} + +uint32_t +SBTypeFormat::GetOptions() +{ + if (IsValid()) + return m_opaque_sp->GetOptions(); + return 0; +} + +void +SBTypeFormat::SetFormat (lldb::Format fmt) +{ + if (CopyOnWrite_Impl()) + m_opaque_sp->SetFormat(fmt); +} + +void +SBTypeFormat::SetOptions (uint32_t value) +{ + if (CopyOnWrite_Impl()) + m_opaque_sp->SetOptions(value); +} + +bool +SBTypeFormat::GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level) +{ + if (!IsValid()) + return false; + else { + description.Printf("%s\n", + m_opaque_sp->GetDescription().c_str()); + return true; + } +} + +lldb::SBTypeFormat & +SBTypeFormat::operator = (const lldb::SBTypeFormat &rhs) +{ + if (this != &rhs) + { + m_opaque_sp = rhs.m_opaque_sp; + } + return *this; +} + +bool +SBTypeFormat::operator == (lldb::SBTypeFormat &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + return m_opaque_sp == rhs.m_opaque_sp; +} + +bool +SBTypeFormat::IsEqualTo (lldb::SBTypeFormat &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + + if (GetFormat() == rhs.GetFormat()) + return GetOptions() == rhs.GetOptions(); + else + return false; +} + +bool +SBTypeFormat::operator != (lldb::SBTypeFormat &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + return m_opaque_sp != rhs.m_opaque_sp; +} + +lldb::TypeFormatImplSP +SBTypeFormat::GetSP () +{ + return m_opaque_sp; +} + +void +SBTypeFormat::SetSP (const lldb::TypeFormatImplSP &typeformat_impl_sp) +{ + m_opaque_sp = typeformat_impl_sp; +} + +SBTypeFormat::SBTypeFormat (const lldb::TypeFormatImplSP &typeformat_impl_sp) : + m_opaque_sp(typeformat_impl_sp) +{ +} + +bool +SBTypeFormat::CopyOnWrite_Impl() +{ + if (!IsValid()) + return false; + if (m_opaque_sp.unique()) + return true; + + SetSP(TypeFormatImplSP(new TypeFormatImpl(GetFormat(),GetOptions()))); + return true; +} diff --git a/lldb/source/API/SBTypeNameSpecifier.cpp b/lldb/source/API/SBTypeNameSpecifier.cpp new file mode 100644 index 000000000000..ef43e805f4f2 --- /dev/null +++ b/lldb/source/API/SBTypeNameSpecifier.cpp @@ -0,0 +1,127 @@ +//===-- SBTypeNameSpecifier.cpp ------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/API/SBTypeNameSpecifier.h" + +#include "lldb/API/SBStream.h" + +#include "lldb/Core/DataVisualization.h" + +using namespace lldb; +using namespace lldb_private; + +SBTypeNameSpecifier::SBTypeNameSpecifier() : +m_opaque_sp() +{ +} + +SBTypeNameSpecifier::SBTypeNameSpecifier (const char* name, + bool is_regex) : +m_opaque_sp(new TypeNameSpecifierImpl(name, is_regex)) +{ + if (name == NULL || (*name) == 0) + m_opaque_sp.reset(); +} + +SBTypeNameSpecifier::SBTypeNameSpecifier (const lldb::SBTypeNameSpecifier &rhs) : +m_opaque_sp(rhs.m_opaque_sp) +{} + +SBTypeNameSpecifier::~SBTypeNameSpecifier () +{ +} + +bool +SBTypeNameSpecifier::IsValid() const +{ + return m_opaque_sp.get() != NULL; +} + +const char* +SBTypeNameSpecifier::GetName () +{ + if (!IsValid()) + return NULL; + + return m_opaque_sp->GetName(); +} + +bool +SBTypeNameSpecifier::IsRegex () +{ + if (!IsValid()) + return false; + + return m_opaque_sp->IsRegex(); +} + +bool +SBTypeNameSpecifier::GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level) +{ + if (!IsValid()) + return false; + description.Printf("SBTypeNameSpecifier(%s,%s)", GetName(), IsRegex() ? "regex" : "plain"); + return true; +} + +lldb::SBTypeNameSpecifier & +SBTypeNameSpecifier::operator = (const lldb::SBTypeNameSpecifier &rhs) +{ + if (this != &rhs) + { + m_opaque_sp = rhs.m_opaque_sp; + } + return *this; +} + +bool +SBTypeNameSpecifier::operator == (lldb::SBTypeNameSpecifier &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + return m_opaque_sp == rhs.m_opaque_sp; +} + +bool +SBTypeNameSpecifier::IsEqualTo (lldb::SBTypeNameSpecifier &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + + if (IsRegex() != rhs.IsRegex()) + return false; + + return (strcmp(GetName(), rhs.GetName()) == 0); +} + +bool +SBTypeNameSpecifier::operator != (lldb::SBTypeNameSpecifier &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + return m_opaque_sp != rhs.m_opaque_sp; +} + +lldb::TypeNameSpecifierImplSP +SBTypeNameSpecifier::GetSP () +{ + return m_opaque_sp; +} + +void +SBTypeNameSpecifier::SetSP (const lldb::TypeNameSpecifierImplSP &type_namespec_sp) +{ + m_opaque_sp = type_namespec_sp; +} + +SBTypeNameSpecifier::SBTypeNameSpecifier (const lldb::TypeNameSpecifierImplSP &type_namespec_sp) : +m_opaque_sp(type_namespec_sp) +{ +} diff --git a/lldb/source/API/SBTypeSummary.cpp b/lldb/source/API/SBTypeSummary.cpp new file mode 100644 index 000000000000..5edff66e660a --- /dev/null +++ b/lldb/source/API/SBTypeSummary.cpp @@ -0,0 +1,298 @@ +//===-- SBTypeSummary.cpp -----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/API/SBTypeSummary.h" + +#include "lldb/API/SBStream.h" + +#include "lldb/Core/DataVisualization.h" + +using namespace lldb; +using namespace lldb_private; + +SBTypeSummary::SBTypeSummary() : +m_opaque_sp() +{ +} + +SBTypeSummary +SBTypeSummary::CreateWithSummaryString (const char* data, uint32_t options) +{ + if (!data || data[0] == 0) + return SBTypeSummary(); + + return SBTypeSummary(TypeSummaryImplSP(new StringSummaryFormat(options, data))); +} + +SBTypeSummary +SBTypeSummary::CreateWithFunctionName (const char* data, uint32_t options) +{ + if (!data || data[0] == 0) + return SBTypeSummary(); + + return SBTypeSummary(TypeSummaryImplSP(new ScriptSummaryFormat(options, data))); +} + +SBTypeSummary +SBTypeSummary::CreateWithScriptCode (const char* data, uint32_t options) +{ + if (!data || data[0] == 0) + return SBTypeSummary(); + + return SBTypeSummary(TypeSummaryImplSP(new ScriptSummaryFormat(options, "", data))); +} + +SBTypeSummary::SBTypeSummary (const lldb::SBTypeSummary &rhs) : +m_opaque_sp(rhs.m_opaque_sp) +{ +} + +SBTypeSummary::~SBTypeSummary () +{ +} + +bool +SBTypeSummary::IsValid() const +{ + return m_opaque_sp.get() != NULL; +} + +bool +SBTypeSummary::IsFunctionCode() +{ + if (!IsValid()) + return false; + if (m_opaque_sp->IsScripted()) + { + ScriptSummaryFormat* script_summary_ptr = (ScriptSummaryFormat*)m_opaque_sp.get(); + const char* ftext = script_summary_ptr->GetPythonScript(); + return (ftext && *ftext != 0); + } + return false; +} + +bool +SBTypeSummary::IsFunctionName() +{ + if (!IsValid()) + return false; + if (m_opaque_sp->IsScripted()) + { + ScriptSummaryFormat* script_summary_ptr = (ScriptSummaryFormat*)m_opaque_sp.get(); + const char* ftext = script_summary_ptr->GetPythonScript(); + return (!ftext || *ftext == 0); + } + return false; +} + +bool +SBTypeSummary::IsSummaryString() +{ + if (!IsValid()) + return false; + + return !m_opaque_sp->IsScripted(); +} + +const char* +SBTypeSummary::GetData () +{ + if (!IsValid()) + return NULL; + if (m_opaque_sp->IsScripted()) + { + ScriptSummaryFormat* script_summary_ptr = (ScriptSummaryFormat*)m_opaque_sp.get(); + const char* fname = script_summary_ptr->GetFunctionName(); + const char* ftext = script_summary_ptr->GetPythonScript(); + if (ftext && *ftext) + return ftext; + return fname; + } + else + { + StringSummaryFormat* string_summary_ptr = (StringSummaryFormat*)m_opaque_sp.get(); + return string_summary_ptr->GetSummaryString(); + } +} + +uint32_t +SBTypeSummary::GetOptions () +{ + if (!IsValid()) + return lldb::eTypeOptionNone; + return m_opaque_sp->GetOptions(); +} + +void +SBTypeSummary::SetOptions (uint32_t value) +{ + if (!CopyOnWrite_Impl()) + return; + m_opaque_sp->SetOptions(value); +} + +void +SBTypeSummary::SetSummaryString (const char* data) +{ + if (!IsValid()) + return; + if (m_opaque_sp->IsScripted()) + ChangeSummaryType(false); + ((StringSummaryFormat*)m_opaque_sp.get())->SetSummaryString(data); +} + +void +SBTypeSummary::SetFunctionName (const char* data) +{ + if (!IsValid()) + return; + if (!m_opaque_sp->IsScripted()) + ChangeSummaryType(true); + ((ScriptSummaryFormat*)m_opaque_sp.get())->SetFunctionName(data); +} + +void +SBTypeSummary::SetFunctionCode (const char* data) +{ + if (!IsValid()) + return; + if (!m_opaque_sp->IsScripted()) + ChangeSummaryType(true); + ((ScriptSummaryFormat*)m_opaque_sp.get())->SetPythonScript(data); +} + +bool +SBTypeSummary::GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level) +{ + if (!CopyOnWrite_Impl()) + return false; + else { + description.Printf("%s\n", + m_opaque_sp->GetDescription().c_str()); + return true; + } +} + +lldb::SBTypeSummary & +SBTypeSummary::operator = (const lldb::SBTypeSummary &rhs) +{ + if (this != &rhs) + { + m_opaque_sp = rhs.m_opaque_sp; + } + return *this; +} + +bool +SBTypeSummary::operator == (lldb::SBTypeSummary &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + return m_opaque_sp == rhs.m_opaque_sp; +} + +bool +SBTypeSummary::IsEqualTo (lldb::SBTypeSummary &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + + if (m_opaque_sp->IsScripted() != rhs.m_opaque_sp->IsScripted()) + return false; + + if (IsFunctionCode() != rhs.IsFunctionCode()) + return false; + + if (IsSummaryString() != rhs.IsSummaryString()) + return false; + + if (IsFunctionName() != rhs.IsFunctionName()) + return false; + + if ( strcmp(GetData(), rhs.GetData()) ) + return false; + + return GetOptions() == rhs.GetOptions(); + +} + +bool +SBTypeSummary::operator != (lldb::SBTypeSummary &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + return m_opaque_sp != rhs.m_opaque_sp; +} + +lldb::TypeSummaryImplSP +SBTypeSummary::GetSP () +{ + return m_opaque_sp; +} + +void +SBTypeSummary::SetSP (const lldb::TypeSummaryImplSP &typesummary_impl_sp) +{ + m_opaque_sp = typesummary_impl_sp; +} + +SBTypeSummary::SBTypeSummary (const lldb::TypeSummaryImplSP &typesummary_impl_sp) : +m_opaque_sp(typesummary_impl_sp) +{ +} + +bool +SBTypeSummary::CopyOnWrite_Impl() +{ + if (!IsValid()) + return false; + if (m_opaque_sp.unique()) + return true; + + TypeSummaryImplSP new_sp; + + if (m_opaque_sp->IsScripted()) + { + ScriptSummaryFormat* current_summary_ptr = (ScriptSummaryFormat*)m_opaque_sp.get(); + new_sp = TypeSummaryImplSP(new ScriptSummaryFormat(GetOptions(), + current_summary_ptr->GetFunctionName(), + current_summary_ptr->GetPythonScript())); + } + else { + StringSummaryFormat* current_summary_ptr = (StringSummaryFormat*)m_opaque_sp.get(); + new_sp = TypeSummaryImplSP(new StringSummaryFormat(GetOptions(), + current_summary_ptr->GetSummaryString())); + } + + SetSP(new_sp); + + return true; +} + +bool +SBTypeSummary::ChangeSummaryType (bool want_script) +{ + if (!IsValid()) + return false; + + if (want_script == m_opaque_sp->IsScripted()) + return CopyOnWrite_Impl(); + + TypeSummaryImplSP new_sp; + + if (want_script) + new_sp = TypeSummaryImplSP(new ScriptSummaryFormat(GetOptions(), "", "")); + else + new_sp = TypeSummaryImplSP(new StringSummaryFormat(GetOptions(), "")); + + SetSP(new_sp); + + return true; +} diff --git a/lldb/source/API/SBTypeSynthetic.cpp b/lldb/source/API/SBTypeSynthetic.cpp new file mode 100644 index 000000000000..66e2d8b68b37 --- /dev/null +++ b/lldb/source/API/SBTypeSynthetic.cpp @@ -0,0 +1,203 @@ +//===-- SBTypeSynthetic.cpp -----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/API/SBTypeSynthetic.h" + +#include "lldb/API/SBStream.h" + +#include "lldb/Core/DataVisualization.h" + +using namespace lldb; +using namespace lldb_private; + +SBTypeSynthetic::SBTypeSynthetic() : +m_opaque_sp() +{ +} + +SBTypeSynthetic +SBTypeSynthetic::CreateWithClassName (const char* data, uint32_t options) +{ + if (!data || data[0] == 0) + return SBTypeSynthetic(); + return SBTypeSynthetic(TypeSyntheticImplSP(new TypeSyntheticImpl(options, data, ""))); +} + +SBTypeSynthetic +SBTypeSynthetic::CreateWithScriptCode (const char* data, uint32_t options) +{ + if (!data || data[0] == 0) + return SBTypeSynthetic(); + return SBTypeSynthetic(TypeSyntheticImplSP(new TypeSyntheticImpl(options, "", data))); +} + +SBTypeSynthetic::SBTypeSynthetic (const lldb::SBTypeSynthetic &rhs) : +m_opaque_sp(rhs.m_opaque_sp) +{ +} + +SBTypeSynthetic::~SBTypeSynthetic () +{ +} + +bool +SBTypeSynthetic::IsValid() const +{ + return m_opaque_sp.get() != NULL; +} + +bool +SBTypeSynthetic::IsClassCode() +{ + if (!IsValid()) + return false; + const char* code = m_opaque_sp->GetPythonCode(); + return (code && *code); +} + +bool +SBTypeSynthetic::IsClassName() +{ + if (!IsValid()) + return false; + return !IsClassCode(); +} + +const char* +SBTypeSynthetic::GetData () +{ + if (!IsValid()) + return NULL; + if (IsClassCode()) + return m_opaque_sp->GetPythonCode(); + else + return m_opaque_sp->GetPythonClassName(); +} + +void +SBTypeSynthetic::SetClassName (const char* data) +{ + if (IsValid() && data && *data) + m_opaque_sp->SetPythonClassName(data); +} + +void +SBTypeSynthetic::SetClassCode (const char* data) +{ + if (IsValid() && data && *data) + m_opaque_sp->SetPythonCode(data); +} + +uint32_t +SBTypeSynthetic::GetOptions () +{ + if (!IsValid()) + return lldb::eTypeOptionNone; + return m_opaque_sp->GetOptions(); +} + +void +SBTypeSynthetic::SetOptions (uint32_t value) +{ + if (!CopyOnWrite_Impl()) + return; + m_opaque_sp->SetOptions(value); +} + +bool +SBTypeSynthetic::GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level) +{ + if (!CopyOnWrite_Impl()) + return false; + else { + description.Printf("%s\n", + m_opaque_sp->GetDescription().c_str()); + return true; + } +} + +lldb::SBTypeSynthetic & +SBTypeSynthetic::operator = (const lldb::SBTypeSynthetic &rhs) +{ + if (this != &rhs) + { + m_opaque_sp = rhs.m_opaque_sp; + } + return *this; +} + +bool +SBTypeSynthetic::operator == (lldb::SBTypeSynthetic &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + return m_opaque_sp == rhs.m_opaque_sp; +} + +bool +SBTypeSynthetic::IsEqualTo (lldb::SBTypeSynthetic &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + + if (m_opaque_sp->IsScripted() != rhs.m_opaque_sp->IsScripted()) + return false; + + if (IsClassCode() != rhs.IsClassCode()) + return false; + + if ( strcmp(GetData(), rhs.GetData()) ) + return false; + + return GetOptions() == rhs.GetOptions(); + +} + +bool +SBTypeSynthetic::operator != (lldb::SBTypeSynthetic &rhs) +{ + if (IsValid() == false) + return !rhs.IsValid(); + return m_opaque_sp != rhs.m_opaque_sp; +} + +lldb::TypeSyntheticImplSP +SBTypeSynthetic::GetSP () +{ + return m_opaque_sp; +} + +void +SBTypeSynthetic::SetSP (const lldb::TypeSyntheticImplSP &TypeSynthetic_impl_sp) +{ + m_opaque_sp = TypeSynthetic_impl_sp; +} + +SBTypeSynthetic::SBTypeSynthetic (const lldb::TypeSyntheticImplSP &TypeSynthetic_impl_sp) : +m_opaque_sp(TypeSynthetic_impl_sp) +{ +} + +bool +SBTypeSynthetic::CopyOnWrite_Impl() +{ + if (!IsValid()) + return false; + if (m_opaque_sp.unique()) + return true; + + TypeSyntheticImplSP new_sp(new TypeSyntheticImpl(m_opaque_sp->GetOptions(), + m_opaque_sp->GetPythonClassName(), + m_opaque_sp->GetPythonCode())); + + SetSP(new_sp); + + return true; +} diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp index 78a0d140d1e5..c8a9bcc217f6 100644 --- a/lldb/source/Commands/CommandObjectFrame.cpp +++ b/lldb/source/Commands/CommandObjectFrame.cpp @@ -399,7 +399,7 @@ public: const char *name_cstr = NULL; size_t idx; - SummaryFormatSP summary_format_sp; + TypeSummaryImplSP summary_format_sp; if (!m_option_variable.summary.empty()) DataVisualization::NamedSummaryFormats::GetSummaryFormat(ConstString(m_option_variable.summary.c_str()), summary_format_sp); diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp index 5739bbe5e2bc..90fdafca17fa 100644 --- a/lldb/source/Commands/CommandObjectType.cpp +++ b/lldb/source/Commands/CommandObjectType.cpp @@ -37,7 +37,7 @@ class ScriptAddOptions public: - SummaryFormat::Flags m_flags; + TypeSummaryImpl::Flags m_flags; StringList m_target_types; StringList m_user_source; @@ -48,7 +48,7 @@ public: std::string m_category; - ScriptAddOptions(const SummaryFormat::Flags& flags, + ScriptAddOptions(const TypeSummaryImpl::Flags& flags, bool regx, const ConstString& name, std::string catg) : @@ -133,7 +133,7 @@ private: // Instance variables to hold the values for command options. - SummaryFormat::Flags m_flags; + TypeSummaryImpl::Flags m_flags; bool m_regex; std::string m_format_string; ConstString m_name; @@ -181,7 +181,7 @@ public: static bool AddSummary(const ConstString& type_name, - lldb::SummaryFormatSP entry, + lldb::TypeSummaryImplSP entry, SummaryFormatType type, std::string category, Error* error = NULL); @@ -496,12 +496,12 @@ public: return false; } - ValueFormatSP entry; + TypeFormatImplSP entry; - entry.reset(new ValueFormat(format, - m_command_options.m_cascade, - m_command_options.m_skip_pointers, - m_command_options.m_skip_references)); + entry.reset(new TypeFormatImpl(format, + TypeFormatImpl::Flags().SetCascades(m_command_options.m_cascade). + SetSkipPointers(m_command_options.m_skip_pointers). + SetSkipReferences(m_command_options.m_skip_references))); // now I have a valid format, let's add it to every type @@ -641,7 +641,7 @@ public: // CommandObjectTypeFormatList //------------------------------------------------------------------------- -bool CommandObjectTypeFormatList_LoopCallback(void* pt2self, ConstString type, const lldb::ValueFormatSP& entry); +bool CommandObjectTypeFormatList_LoopCallback(void* pt2self, ConstString type, const lldb::TypeFormatImplSP& entry); class CommandObjectTypeFormatList; @@ -702,22 +702,19 @@ private: bool LoopCallback (ConstString type, - const lldb::ValueFormatSP& entry, + const lldb::TypeFormatImplSP& entry, RegularExpression* regex, CommandReturnObject *result) { if (regex == NULL || regex->Execute(type.AsCString())) { - result->GetOutputStream().Printf ("%s: %s%s%s%s\n", type.AsCString(), - FormatManager::GetFormatAsCString (entry->m_format), - entry->m_cascades ? "" : " (not cascading)", - entry->m_skip_pointers ? " (skip pointers)" : "", - entry->m_skip_references ? " (skip references)" : ""); + result->GetOutputStream().Printf ("%s: %s\n", type.AsCString(), + entry->GetDescription().c_str()); } return true; } - friend bool CommandObjectTypeFormatList_LoopCallback(void* pt2self, ConstString type, const lldb::ValueFormatSP& entry); + friend bool CommandObjectTypeFormatList_LoopCallback(void* pt2self, ConstString type, const lldb::TypeFormatImplSP& entry); }; @@ -725,7 +722,7 @@ bool CommandObjectTypeFormatList_LoopCallback ( void* pt2self, ConstString type, - const lldb::ValueFormatSP& entry) + const lldb::TypeFormatImplSP& entry) { CommandObjectTypeFormatList_LoopCallbackParam* param = (CommandObjectTypeFormatList_LoopCallbackParam*)pt2self; return param->self->LoopCallback(type, entry, param->regex, param->result); @@ -850,10 +847,10 @@ public: } // now I have a valid function name, let's add this as script for every type in the list - SummaryFormatSP script_format; + TypeSummaryImplSP script_format; script_format.reset(new ScriptSummaryFormat(options->m_flags, - std::string(funct_name), - options->m_user_source.CopyList(" "))); + funct_name, + options->m_user_source.CopyList(" ").c_str())); Error error; @@ -1035,7 +1032,7 @@ CommandObjectTypeSummaryAdd::Execute_ScriptSummary (Args& command, CommandReturn return false; } - SummaryFormatSP script_format; + TypeSummaryImplSP script_format; if (!m_options.m_python_function.empty()) // we have a Python function ready to use { @@ -1054,9 +1051,11 @@ CommandObjectTypeSummaryAdd::Execute_ScriptSummary (Args& command, CommandReturn return false; } + std::string code = (" " + m_options.m_python_function + "(valobj,dict)"); + script_format.reset(new ScriptSummaryFormat(m_options.m_flags, - std::string(funct_name), - " " + m_options.m_python_function + "(valobj,dict)")); + funct_name, + code.c_str())); } else if (!m_options.m_python_script.empty()) // we have a quick 1-line script, just use it { @@ -1091,9 +1090,11 @@ CommandObjectTypeSummaryAdd::Execute_ScriptSummary (Args& command, CommandReturn return false; } + std::string code = " " + m_options.m_python_script; + script_format.reset(new ScriptSummaryFormat(m_options.m_flags, - std::string(funct_name), - " " + m_options.m_python_script)); + funct_name, + code.c_str())); } else // use an InputReader to grab Python code from the user { @@ -1189,7 +1190,7 @@ CommandObjectTypeSummaryAdd::Execute_StringSummary (Args& command, CommandReturn Error error; - lldb::SummaryFormatSP entry(new StringSummaryFormat(m_options.m_flags, + lldb::TypeSummaryImplSP entry(new StringSummaryFormat(m_options.m_flags, format_cstr)); if (error.Fail()) @@ -1343,12 +1344,12 @@ CommandObjectTypeSummaryAdd::Execute (Args& command, CommandReturnObject &result bool CommandObjectTypeSummaryAdd::AddSummary(const ConstString& type_name, - SummaryFormatSP entry, + TypeSummaryImplSP entry, SummaryFormatType type, std::string category_name, Error* error) { - lldb::FormatCategorySP category; + lldb::TypeCategoryImplSP category; DataVisualization::Categories::GetCategory(ConstString(category_name.c_str()), category); if (type == eRegexSummary) @@ -1475,11 +1476,11 @@ private: static bool PerCategoryCallback(void* param, - const lldb::FormatCategorySP& cate) + const lldb::TypeCategoryImplSP& category_sp) { - ConstString *name = (ConstString*)param; - cate->Delete(*name, eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary); - return true; + ConstString *name = (ConstString*)param; + category_sp->Delete(*name, eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary); + return true; } public: @@ -1534,7 +1535,7 @@ public: return result.Succeeded(); } - lldb::FormatCategorySP category; + lldb::TypeCategoryImplSP category; DataVisualization::Categories::GetCategory(ConstString(m_options.m_category.c_str()), category); bool delete_category = category->Delete(typeCS, @@ -1631,7 +1632,7 @@ private: static bool PerCategoryCallback(void* param, - const lldb::FormatCategorySP& cate) + const lldb::TypeCategoryImplSP& cate) { cate->GetSummaryNavigator()->Clear(); cate->GetRegexSummaryNavigator()->Clear(); @@ -1661,7 +1662,7 @@ public: else { - lldb::FormatCategorySP category; + lldb::TypeCategoryImplSP category; if (command.GetArgumentCount() > 0) { const char* cat_name = command.GetArgumentAtIndex(0); @@ -1840,14 +1841,14 @@ private: static bool PerCategoryCallback(void* param_vp, - const lldb::FormatCategorySP& cate) + const lldb::TypeCategoryImplSP& cate) { CommandObjectTypeSummaryList_LoopCallbackParam* param = (CommandObjectTypeSummaryList_LoopCallbackParam*)param_vp; CommandReturnObject* result = param->result; - const char* cate_name = cate->GetName().c_str(); + const char* cate_name = cate->GetName(); // if the category is disabled or empty and there is no regex, just skip it if ((cate->IsEnabled() == false || cate->GetCount(eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary) == 0) && param->cate_regex == NULL) @@ -1874,7 +1875,7 @@ private: bool LoopCallback (const char* type, - const lldb::SummaryFormatSP& entry, + const lldb::TypeSummaryImplSP& entry, RegularExpression* regex, CommandReturnObject *result) { @@ -1883,15 +1884,15 @@ private: return true; } - friend bool CommandObjectTypeSummaryList_LoopCallback(void* pt2self, ConstString type, const lldb::SummaryFormatSP& entry); - friend bool CommandObjectTypeRXSummaryList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const lldb::SummaryFormatSP& entry); + friend bool CommandObjectTypeSummaryList_LoopCallback(void* pt2self, ConstString type, const lldb::TypeSummaryImplSP& entry); + friend bool CommandObjectTypeRXSummaryList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const lldb::TypeSummaryImplSP& entry); }; bool CommandObjectTypeSummaryList_LoopCallback ( void* pt2self, ConstString type, - const lldb::SummaryFormatSP& entry) + const lldb::TypeSummaryImplSP& entry) { CommandObjectTypeSummaryList_LoopCallbackParam* param = (CommandObjectTypeSummaryList_LoopCallbackParam*)pt2self; return param->self->LoopCallback(type.AsCString(), entry, param->regex, param->result); @@ -1901,7 +1902,7 @@ bool CommandObjectTypeRXSummaryList_LoopCallback ( void* pt2self, lldb::RegularExpressionSP regex, - const lldb::SummaryFormatSP& entry) + const lldb::TypeSummaryImplSP& entry) { CommandObjectTypeSummaryList_LoopCallbackParam* param = (CommandObjectTypeSummaryList_LoopCallbackParam*)pt2self; return param->self->LoopCallback(regex->GetText(), entry, param->regex, param->result); @@ -1967,7 +1968,7 @@ public: return false; } DataVisualization::Categories::Enable(typeCS); - lldb::FormatCategorySP cate; + lldb::TypeCategoryImplSP cate; if (DataVisualization::Categories::GetCategory(typeCS, cate) && cate.get()) { if (cate->GetCount() == 0) @@ -2141,14 +2142,14 @@ private: static bool PerCategoryCallback(void* param_vp, - const lldb::FormatCategorySP& cate) + const lldb::TypeCategoryImplSP& cate) { CommandObjectTypeCategoryList_CallbackParam* param = (CommandObjectTypeCategoryList_CallbackParam*)param_vp; CommandReturnObject* result = param->result; RegularExpression* regex = param->regex; - const char* cate_name = cate->GetName().c_str(); + const char* cate_name = cate->GetName(); if (regex == NULL || regex->Execute(cate_name)) result->GetOutputStream().Printf("Category %s is%s enabled\n", @@ -2346,10 +2347,10 @@ private: static bool PerCategoryCallback(void* param_vp, - const lldb::FormatCategorySP& cate) + const lldb::TypeCategoryImplSP& cate) { - const char* cate_name = cate->GetName().c_str(); + const char* cate_name = cate->GetName(); CommandObjectTypeFilterList_LoopCallbackParam* param = (CommandObjectTypeFilterList_LoopCallbackParam*)param_vp; @@ -2558,14 +2559,14 @@ private: static bool PerCategoryCallback(void* param_vp, - const lldb::FormatCategorySP& cate) + const lldb::TypeCategoryImplSP& cate) { CommandObjectTypeSynthList_LoopCallbackParam* param = (CommandObjectTypeSynthList_LoopCallbackParam*)param_vp; CommandReturnObject* result = param->result; - const char* cate_name = cate->GetName().c_str(); + const char* cate_name = cate->GetName(); // if the category is disabled or empty and there is no regex, just skip it if ((cate->IsEnabled() == false || cate->GetCount(eFormatCategoryItemSynth | eFormatCategoryItemRegexSynth) == 0) && param->cate_regex == NULL) @@ -2707,7 +2708,7 @@ private: static bool PerCategoryCallback(void* param, - const lldb::FormatCategorySP& cate) + const lldb::TypeCategoryImplSP& cate) { ConstString *name = (ConstString*)param; return cate->Delete(*name, eFormatCategoryItemFilter | eFormatCategoryItemRegexFilter); @@ -2765,7 +2766,7 @@ public: return result.Succeeded(); } - lldb::FormatCategorySP category; + lldb::TypeCategoryImplSP category; DataVisualization::Categories::GetCategory(ConstString(m_options.m_category.c_str()), category); bool delete_category = category->GetFilterNavigator()->Delete(typeCS); @@ -2871,7 +2872,7 @@ private: static bool PerCategoryCallback(void* param, - const lldb::FormatCategorySP& cate) + const lldb::TypeCategoryImplSP& cate) { ConstString* name = (ConstString*)param; return cate->Delete(*name, eFormatCategoryItemSynth | eFormatCategoryItemRegexSynth); @@ -2929,7 +2930,7 @@ public: return result.Succeeded(); } - lldb::FormatCategorySP category; + lldb::TypeCategoryImplSP category; DataVisualization::Categories::GetCategory(ConstString(m_options.m_category.c_str()), category); bool delete_category = category->GetSyntheticNavigator()->Delete(typeCS); @@ -3031,7 +3032,7 @@ private: static bool PerCategoryCallback(void* param, - const lldb::FormatCategorySP& cate) + const lldb::TypeCategoryImplSP& cate) { cate->Clear(eFormatCategoryItemFilter | eFormatCategoryItemRegexFilter); return true; @@ -3060,7 +3061,7 @@ public: else { - lldb::FormatCategorySP category; + lldb::TypeCategoryImplSP category; if (command.GetArgumentCount() > 0) { const char* cat_name = command.GetArgumentAtIndex(0); @@ -3158,7 +3159,7 @@ private: static bool PerCategoryCallback(void* param, - const lldb::FormatCategorySP& cate) + const lldb::TypeCategoryImplSP& cate) { cate->Clear(eFormatCategoryItemSynth | eFormatCategoryItemRegexSynth); return true; @@ -3187,7 +3188,7 @@ public: else { - lldb::FormatCategorySP category; + lldb::TypeCategoryImplSP category; if (command.GetArgumentCount() > 0) { const char* cat_name = command.GetArgumentAtIndex(0); @@ -3338,13 +3339,13 @@ public: // everything should be fine now, let's add the synth provider class SyntheticChildrenSP synth_provider; - synth_provider.reset(new SyntheticScriptProvider(options->m_cascade, - options->m_skip_pointers, - options->m_skip_references, - std::string(class_name))); + synth_provider.reset(new TypeSyntheticImpl(SyntheticChildren::Flags().SetCascades(options->m_cascade). + SetSkipPointers(options->m_skip_pointers). + SetSkipReferences(options->m_skip_references), + class_name)); - lldb::FormatCategorySP category; + lldb::TypeCategoryImplSP category; DataVisualization::Categories::GetCategory(ConstString(options->m_category.c_str()), category); Error error; @@ -3457,16 +3458,17 @@ CommandObjectTypeSynthAdd::Execute_PythonClass (Args& command, CommandReturnObje SyntheticChildrenSP entry; - SyntheticScriptProvider* impl = new SyntheticScriptProvider(m_options.m_cascade, - m_options.m_skip_pointers, - m_options.m_skip_references, - m_options.m_class_name); + TypeSyntheticImpl* impl = new TypeSyntheticImpl(SyntheticChildren::Flags(). + SetCascades(m_options.m_cascade). + SetSkipPointers(m_options.m_skip_pointers). + SetSkipReferences(m_options.m_skip_references), + m_options.m_class_name.c_str()); entry.reset(impl); // now I have a valid provider, let's add it to every type - lldb::FormatCategorySP category; + lldb::TypeCategoryImplSP category; DataVisualization::Categories::GetCategory(ConstString(m_options.m_category.c_str()), category); Error error; @@ -3525,7 +3527,7 @@ CommandObjectTypeSynthAdd::AddSynth(const ConstString& type_name, std::string category_name, Error* error) { - lldb::FormatCategorySP category; + lldb::TypeCategoryImplSP category; DataVisualization::Categories::GetCategory(ConstString(category_name.c_str()), category); if (category->AnyMatches(type_name, @@ -3704,7 +3706,7 @@ private: std::string category_name, Error* error) { - lldb::FormatCategorySP category; + lldb::TypeCategoryImplSP category; DataVisualization::Categories::GetCategory(ConstString(category_name.c_str()), category); if (category->AnyMatches(type_name, @@ -3811,9 +3813,9 @@ public: SyntheticChildrenSP entry; - SyntheticFilter* impl = new SyntheticFilter(m_options.m_cascade, - m_options.m_skip_pointers, - m_options.m_skip_references); + TypeFilterImpl* impl = new TypeFilterImpl(SyntheticChildren::Flags().SetCascades(m_options.m_cascade). + SetSkipPointers(m_options.m_skip_pointers). + SetSkipReferences(m_options.m_skip_references)); entry.reset(impl); @@ -3826,7 +3828,7 @@ public: // now I have a valid provider, let's add it to every type - lldb::FormatCategorySP category; + lldb::TypeCategoryImplSP category; DataVisualization::Categories::GetCategory(ConstString(m_options.m_category.c_str()), category); Error error; diff --git a/lldb/source/Core/DataVisualization.cpp b/lldb/source/Core/DataVisualization.cpp index ce587dc944f6..c5f0088c7dca 100644 --- a/lldb/source/Core/DataVisualization.cpp +++ b/lldb/source/Core/DataVisualization.cpp @@ -38,16 +38,24 @@ DataVisualization::GetCurrentRevision () return GetFormatManager().GetCurrentRevision(); } -lldb::ValueFormatSP +lldb::TypeFormatImplSP DataVisualization::ValueFormats::GetFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic) { - lldb::ValueFormatSP entry; + lldb::TypeFormatImplSP entry; GetFormatManager().GetValueNavigator().Get(valobj, entry, use_dynamic); return entry; } +lldb::TypeFormatImplSP +DataVisualization::ValueFormats::GetFormat (const ConstString &type) +{ + lldb::TypeFormatImplSP entry; + GetFormatManager().GetValueNavigator().Get(type, entry); + return entry; +} + void -DataVisualization::ValueFormats::Add (const ConstString &type, const lldb::ValueFormatSP &entry) +DataVisualization::ValueFormats::Add (const ConstString &type, const lldb::TypeFormatImplSP &entry) { GetFormatManager().GetValueNavigator().Add(FormatManager::GetValidTypeName(type),entry); } @@ -65,7 +73,7 @@ DataVisualization::ValueFormats::Clear () } void -DataVisualization::ValueFormats::LoopThrough (ValueFormat::ValueCallback callback, void* callback_baton) +DataVisualization::ValueFormats::LoopThrough (TypeFormatImpl::ValueCallback callback, void* callback_baton) { GetFormatManager().GetValueNavigator().LoopThrough(callback, callback_baton); } @@ -76,7 +84,19 @@ DataVisualization::ValueFormats::GetCount () return GetFormatManager().GetValueNavigator().GetCount(); } -lldb::SummaryFormatSP +lldb::TypeNameSpecifierImplSP +DataVisualization::ValueFormats::GetTypeNameSpecifierForFormatAtIndex (uint32_t index) +{ + return GetFormatManager().GetValueNavigator().GetTypeNameSpecifierAtIndex(index); +} + +lldb::TypeFormatImplSP +DataVisualization::ValueFormats::GetFormatAtIndex (uint32_t index) +{ + return GetFormatManager().GetValueNavigator().GetAtIndex(index); +} + +lldb::TypeSummaryImplSP DataVisualization::GetSummaryFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic) { @@ -92,10 +112,10 @@ DataVisualization::GetSyntheticChildren (ValueObject& valobj, bool DataVisualization::AnyMatches (ConstString type_name, - FormatCategory::FormatCategoryItems items, + TypeCategoryImpl::FormatCategoryItems items, bool only_enabled, const char** matching_category, - FormatCategory::FormatCategoryItems* matching_type) + TypeCategoryImpl::FormatCategoryItems* matching_type) { return GetFormatManager().AnyMatches(type_name, items, @@ -105,10 +125,11 @@ DataVisualization::AnyMatches (ConstString type_name, } bool -DataVisualization::Categories::GetCategory (const ConstString &category, lldb::FormatCategorySP &entry) +DataVisualization::Categories::GetCategory (const ConstString &category, lldb::TypeCategoryImplSP &entry, + bool allow_create) { - entry = GetFormatManager().GetCategory(category); - return true; + entry = GetFormatManager().GetCategory(category, allow_create); + return (entry.get() != NULL); } void @@ -131,27 +152,43 @@ DataVisualization::Categories::Clear () } void -DataVisualization::Categories::Clear (ConstString &category) +DataVisualization::Categories::Clear (const ConstString &category) { GetFormatManager().GetCategory(category)->Clear(eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary); } void -DataVisualization::Categories::Enable (ConstString& category) +DataVisualization::Categories::Enable (const ConstString& category, + CategoryMap::Position pos) { - if (GetFormatManager().GetCategory(category)->IsEnabled() == false) - GetFormatManager().EnableCategory(category); - else - { + if (GetFormatManager().GetCategory(category)->IsEnabled()) GetFormatManager().DisableCategory(category); - GetFormatManager().EnableCategory(category); + GetFormatManager().EnableCategory(category, pos); +} + +void +DataVisualization::Categories::Disable (const ConstString& category) +{ + if (GetFormatManager().GetCategory(category)->IsEnabled() == true) + GetFormatManager().DisableCategory(category); +} + +void +DataVisualization::Categories::Enable (const lldb::TypeCategoryImplSP& category, + CategoryMap::Position pos) +{ + if (category.get()) + { + if (category->IsEnabled()) + GetFormatManager().DisableCategory(category); + GetFormatManager().EnableCategory(category, pos); } } void -DataVisualization::Categories::Disable (ConstString& category) +DataVisualization::Categories::Disable (const lldb::TypeCategoryImplSP& category) { - if (GetFormatManager().GetCategory(category)->IsEnabled() == true) + if (category.get() && category->IsEnabled() == true) GetFormatManager().DisableCategory(category); } @@ -167,14 +204,20 @@ DataVisualization::Categories::GetCount () return GetFormatManager().GetCategoriesCount(); } +lldb::TypeCategoryImplSP +DataVisualization::Categories::GetCategoryAtIndex (uint32_t index) +{ + return GetFormatManager().GetCategoryAtIndex(index); +} + bool -DataVisualization::NamedSummaryFormats::GetSummaryFormat (const ConstString &type, lldb::SummaryFormatSP &entry) +DataVisualization::NamedSummaryFormats::GetSummaryFormat (const ConstString &type, lldb::TypeSummaryImplSP &entry) { return GetFormatManager().GetNamedSummaryNavigator().Get(type,entry); } void -DataVisualization::NamedSummaryFormats::Add (const ConstString &type, const lldb::SummaryFormatSP &entry) +DataVisualization::NamedSummaryFormats::Add (const ConstString &type, const lldb::TypeSummaryImplSP &entry) { GetFormatManager().GetNamedSummaryNavigator().Add(FormatManager::GetValidTypeName(type),entry); } @@ -192,7 +235,7 @@ DataVisualization::NamedSummaryFormats::Clear () } void -DataVisualization::NamedSummaryFormats::LoopThrough (SummaryFormat::SummaryCallback callback, void* callback_baton) +DataVisualization::NamedSummaryFormats::LoopThrough (TypeSummaryImpl::SummaryCallback callback, void* callback_baton) { GetFormatManager().GetNamedSummaryNavigator().LoopThrough(callback, callback_baton); } diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 060e579eadc1..ad6b86f044b0 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -729,6 +729,27 @@ Debugger::GetAsyncErrorStream () CommandInterpreter::eBroadcastBitAsynchronousErrorData)); } +uint32_t +Debugger::GetNumDebuggers() +{ + Mutex::Locker locker (GetDebuggerListMutex ()); + return GetDebuggerList().size(); +} + +lldb::DebuggerSP +Debugger::GetDebuggerAtIndex (uint32_t index) +{ + DebuggerSP debugger_sp; + + Mutex::Locker locker (GetDebuggerListMutex ()); + DebuggerList &debugger_list = GetDebuggerList(); + + if (index < debugger_list.size()) + debugger_sp = debugger_list[index]; + + return debugger_sp; +} + DebuggerSP Debugger::FindDebuggerWithID (lldb::user_id_t id) { diff --git a/lldb/source/Core/FormatClasses.cpp b/lldb/source/Core/FormatClasses.cpp index 07fcb4140c5f..ded4938568be 100644 --- a/lldb/source/Core/FormatClasses.cpp +++ b/lldb/source/Core/FormatClasses.cpp @@ -44,29 +44,39 @@ struct PyObject; using namespace lldb; using namespace lldb_private; -ValueFormat::ValueFormat (lldb::Format f, - bool casc, - bool skipptr, - bool skipref) : - m_cascades(casc), - m_skip_pointers(skipptr), - m_skip_references(skipref), +TypeFormatImpl::TypeFormatImpl (lldb::Format f, + const Flags& flags) : + m_flags(flags), m_format (f) { } -SummaryFormat::SummaryFormat(const SummaryFormat::Flags& flags) : +std::string +TypeFormatImpl::GetDescription() +{ + StreamString sstr; + sstr.Printf ("%s%s%s%s\n", + FormatManager::GetFormatAsCString (GetFormat()), + Cascades() ? "" : " (not cascading)", + SkipsPointers() ? " (skip pointers)" : "", + SkipsReferences() ? " (skip references)" : ""); + return sstr.GetString(); +} + +TypeSummaryImpl::TypeSummaryImpl(const TypeSummaryImpl::Flags& flags) : m_flags(flags) { } -StringSummaryFormat::StringSummaryFormat(const SummaryFormat::Flags& flags, - std::string f) : - SummaryFormat(flags), - m_format(f) -{ -} +StringSummaryFormat::StringSummaryFormat(const TypeSummaryImpl::Flags& flags, + const char *format_cstr) : + TypeSummaryImpl(flags), + m_format() +{ + if (format_cstr) + m_format.assign(format_cstr); +} std::string StringSummaryFormat::FormatObject(lldb::ValueObjectSP object) @@ -141,15 +151,19 @@ StringSummaryFormat::GetDescription() #ifndef LLDB_DISABLE_PYTHON -ScriptSummaryFormat::ScriptSummaryFormat(const SummaryFormat::Flags& flags, - std::string fname, - std::string pscri) : - SummaryFormat(flags), - m_function_name(fname), - m_python_script(pscri) -{ -} +ScriptSummaryFormat::ScriptSummaryFormat(const TypeSummaryImpl::Flags& flags, + const char * function_name, + const char * python_script) : + TypeSummaryImpl(flags), + m_function_name(), + m_python_script() +{ + if (function_name) + m_function_name.assign(function_name); + if (python_script) + m_python_script.assign(python_script); +} std::string ScriptSummaryFormat::FormatObject(lldb::ValueObjectSP object) @@ -177,18 +191,18 @@ ScriptSummaryFormat::GetDescription() #endif // #ifndef LLDB_DISABLE_PYTHON std::string -SyntheticFilter::GetDescription() +TypeFilterImpl::GetDescription() { StreamString sstr; sstr.Printf("%s%s%s {\n", - m_cascades ? "" : " (not cascading)", - m_skip_pointers ? " (skip pointers)" : "", - m_skip_references ? " (skip references)" : ""); + Cascades() ? "" : " (not cascading)", + SkipsPointers() ? " (skip pointers)" : "", + SkipsReferences() ? " (skip references)" : ""); for (int i = 0; i < GetCount(); i++) { sstr.Printf(" %s\n", - GetExpressionPathAtIndex(i).c_str()); + GetExpressionPathAtIndex(i)); } sstr.Printf("}"); @@ -200,9 +214,10 @@ SyntheticArrayView::GetDescription() { StreamString sstr; sstr.Printf("%s%s%s {\n", - m_cascades ? "" : " (not cascading)", - m_skip_pointers ? " (skip pointers)" : "", - m_skip_references ? " (skip references)" : ""); + Cascades() ? "" : " (not cascading)", + SkipsPointers() ? " (skip pointers)" : "", + SkipsReferences() ? " (skip references)" : ""); + SyntheticArrayRange* ptr = &m_head; while (ptr && ptr != m_tail) { @@ -222,7 +237,7 @@ SyntheticArrayView::GetDescription() #ifndef LLDB_DISABLE_PYTHON -SyntheticScriptProvider::FrontEnd::FrontEnd(std::string pclass, +TypeSyntheticImpl::FrontEnd::FrontEnd(std::string pclass, lldb::ValueObjectSP be) : SyntheticChildrenFrontEnd(be), m_python_class(pclass) @@ -242,13 +257,13 @@ SyntheticScriptProvider::FrontEnd::FrontEnd(std::string pclass, m_wrapper = m_interpreter->CreateSyntheticScriptedProvider(m_python_class, m_backend); } -SyntheticScriptProvider::FrontEnd::~FrontEnd() +TypeSyntheticImpl::FrontEnd::~FrontEnd() { Py_XDECREF((PyObject*)m_wrapper); } lldb::ValueObjectSP -SyntheticScriptProvider::FrontEnd::GetChildAtIndex (uint32_t idx, bool can_create) +TypeSyntheticImpl::FrontEnd::GetChildAtIndex (uint32_t idx, bool can_create) { if (m_wrapper == NULL || m_interpreter == NULL) return lldb::ValueObjectSP(); @@ -257,13 +272,13 @@ SyntheticScriptProvider::FrontEnd::GetChildAtIndex (uint32_t idx, bool can_creat } std::string -SyntheticScriptProvider::GetDescription() +TypeSyntheticImpl::GetDescription() { StreamString sstr; sstr.Printf("%s%s%s Python class %s", - m_cascades ? "" : " (not cascading)", - m_skip_pointers ? " (skip pointers)" : "", - m_skip_references ? " (skip references)" : "", + Cascades() ? "" : " (not cascading)", + SkipsPointers() ? " (skip pointers)" : "", + SkipsReferences() ? " (skip references)" : "", m_python_class.c_str()); return sstr.GetString(); diff --git a/lldb/source/Core/FormatManager.cpp b/lldb/source/Core/FormatManager.cpp index fb24f17d3ee0..278bc69df95d 100644 --- a/lldb/source/Core/FormatManager.cpp +++ b/lldb/source/Core/FormatManager.cpp @@ -157,8 +157,8 @@ FormatManager::GetFormatAsCString (Format format) return NULL; } -FormatCategory::FormatCategory(IFormatChangeListener* clist, - std::string name) : +TypeCategoryImpl::TypeCategoryImpl(IFormatChangeListener* clist, + ConstString name) : m_summary_nav(new SummaryNavigator("summary",clist)), m_regex_summary_nav(new RegexSummaryNavigator("regex-summary",clist)), m_filter_nav(new FilterNavigator("filter",clist)), @@ -174,8 +174,8 @@ FormatCategory::FormatCategory(IFormatChangeListener* clist, {} bool -FormatCategory::Get (ValueObject& valobj, - lldb::SummaryFormatSP& entry, +TypeCategoryImpl::Get (ValueObject& valobj, + lldb::TypeSummaryImplSP& entry, lldb::DynamicValueType use_dynamic, uint32_t* reason) { @@ -190,14 +190,14 @@ FormatCategory::Get (ValueObject& valobj, } bool -FormatCategory::Get(ValueObject& valobj, +TypeCategoryImpl::Get(ValueObject& valobj, lldb::SyntheticChildrenSP& entry_sp, lldb::DynamicValueType use_dynamic, uint32_t* reason) { if (!IsEnabled()) return false; - SyntheticFilter::SharedPointer filter_sp; + TypeFilterImpl::SharedPointer filter_sp; uint32_t reason_filter = 0; bool regex_filter = false; // first find both Filter and Synth, and then check which is most recent @@ -209,7 +209,7 @@ FormatCategory::Get(ValueObject& valobj, bool regex_synth = false; uint32_t reason_synth = 0; bool pick_synth = false; - SyntheticScriptProvider::SharedPointer synth; + TypeSyntheticImpl::SharedPointer synth; if (!GetSyntheticNavigator()->Get(valobj, synth, use_dynamic, &reason_synth)) regex_synth = GetRegexSyntheticNavigator()->Get (valobj, synth, use_dynamic, &reason_synth); if (!filter_sp.get() && !synth.get()) @@ -222,7 +222,7 @@ FormatCategory::Get(ValueObject& valobj, else /*if (filter_sp.get() && synth.get())*/ { - if (filter_sp->m_my_revision > synth->m_my_revision) + if (filter_sp->GetRevision() > synth->GetRevision()) pick_synth = false; else pick_synth = true; @@ -255,7 +255,7 @@ FormatCategory::Get(ValueObject& valobj, } void -FormatCategory::Clear (FormatCategoryItems items) +TypeCategoryImpl::Clear (FormatCategoryItems items) { if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary ) m_summary_nav->Clear(); @@ -274,7 +274,7 @@ FormatCategory::Clear (FormatCategoryItems items) } bool -FormatCategory::Delete (ConstString name, +TypeCategoryImpl::Delete (ConstString name, FormatCategoryItems items) { bool success = false; @@ -296,7 +296,7 @@ FormatCategory::Delete (ConstString name, } uint32_t -FormatCategory::GetCount (FormatCategoryItems items) +TypeCategoryImpl::GetCount (FormatCategoryItems items) { uint32_t count = 0; if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary ) @@ -317,7 +317,7 @@ FormatCategory::GetCount (FormatCategoryItems items) } bool -FormatCategory::AnyMatches(ConstString type_name, +TypeCategoryImpl::AnyMatches(ConstString type_name, FormatCategoryItems items, bool only_enabled, const char** matching_category, @@ -326,10 +326,10 @@ FormatCategory::AnyMatches(ConstString type_name, if (!IsEnabled() && only_enabled) return false; - lldb::SummaryFormatSP summary; - SyntheticFilter::SharedPointer filter; + lldb::TypeSummaryImplSP summary; + TypeFilterImpl::SharedPointer filter; #ifndef LLDB_DISABLE_PYTHON - SyntheticScriptProvider::SharedPointer synth; + TypeSyntheticImpl::SharedPointer synth; #endif if ( (items & eFormatCategoryItemSummary) == eFormatCategoryItemSummary ) @@ -337,7 +337,7 @@ FormatCategory::AnyMatches(ConstString type_name, if (m_summary_nav->Get(type_name, summary)) { if (matching_category) - *matching_category = m_name.c_str(); + *matching_category = m_name.GetCString(); if (matching_type) *matching_type = eFormatCategoryItemSummary; return true; @@ -348,7 +348,7 @@ FormatCategory::AnyMatches(ConstString type_name, if (m_regex_summary_nav->Get(type_name, summary)) { if (matching_category) - *matching_category = m_name.c_str(); + *matching_category = m_name.GetCString(); if (matching_type) *matching_type = eFormatCategoryItemRegexSummary; return true; @@ -359,7 +359,7 @@ FormatCategory::AnyMatches(ConstString type_name, if (m_filter_nav->Get(type_name, filter)) { if (matching_category) - *matching_category = m_name.c_str(); + *matching_category = m_name.GetCString(); if (matching_type) *matching_type = eFormatCategoryItemFilter; return true; @@ -370,7 +370,7 @@ FormatCategory::AnyMatches(ConstString type_name, if (m_regex_filter_nav->Get(type_name, filter)) { if (matching_category) - *matching_category = m_name.c_str(); + *matching_category = m_name.GetCString(); if (matching_type) *matching_type = eFormatCategoryItemRegexFilter; return true; @@ -382,7 +382,7 @@ FormatCategory::AnyMatches(ConstString type_name, if (m_synth_nav->Get(type_name, synth)) { if (matching_category) - *matching_category = m_name.c_str(); + *matching_category = m_name.GetCString(); if (matching_type) *matching_type = eFormatCategoryItemSynth; return true; @@ -393,7 +393,7 @@ FormatCategory::AnyMatches(ConstString type_name, if (m_regex_synth_nav->Get(type_name, synth)) { if (matching_category) - *matching_category = m_name.c_str(); + *matching_category = m_name.GetCString(); if (matching_type) *matching_type = eFormatCategoryItemRegexSynth; return true; @@ -405,10 +405,10 @@ FormatCategory::AnyMatches(ConstString type_name, bool CategoryMap::AnyMatches (ConstString type_name, - FormatCategory::FormatCategoryItems items, - bool only_enabled, - const char** matching_category, - FormatCategory::FormatCategoryItems* matching_type) + TypeCategoryImpl::FormatCategoryItems items, + bool only_enabled, + const char** matching_category, + TypeCategoryImpl::FormatCategoryItems* matching_type) { Mutex::Locker(m_map_mutex); @@ -425,7 +425,7 @@ CategoryMap::AnyMatches (ConstString type_name, return false; } -lldb::SummaryFormatSP +lldb::TypeSummaryImplSP CategoryMap::GetSummaryFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic) { @@ -436,13 +436,13 @@ CategoryMap::GetSummaryFormat (ValueObject& valobj, for (begin = m_active_categories.begin(); begin != end; begin++) { - lldb::FormatCategorySP category = *begin; - lldb::SummaryFormatSP current_format; + lldb::TypeCategoryImplSP category = *begin; + lldb::TypeSummaryImplSP current_format; if (!category->Get(valobj, current_format, use_dynamic, &reason_why)) continue; return current_format; } - return lldb::SummaryFormatSP(); + return lldb::TypeSummaryImplSP(); } lldb::SyntheticChildrenSP @@ -457,7 +457,7 @@ CategoryMap::GetSyntheticChildren (ValueObject& valobj, for (begin = m_active_categories.begin(); begin != end; begin++) { - lldb::FormatCategorySP category = *begin; + lldb::TypeCategoryImplSP category = *begin; lldb::SyntheticChildrenSP current_format; if (!category->Get(valobj, current_format, use_dynamic, &reason_why)) continue; @@ -478,8 +478,8 @@ CategoryMap::LoopThrough(CallbackType callback, void* param) ActiveCategoriesIterator begin, end = m_active_categories.end(); for (begin = m_active_categories.begin(); begin != end; begin++) { - lldb::FormatCategorySP category = *begin; - ConstString type = ConstString(category->GetName().c_str()); + lldb::TypeCategoryImplSP category = *begin; + ConstString type = ConstString(category->GetName()); if (!callback(param, category)) break; } @@ -500,20 +500,39 @@ CategoryMap::LoopThrough(CallbackType callback, void* param) } } -lldb::FormatCategorySP +TypeCategoryImplSP +CategoryMap::GetAtIndex (uint32_t index) +{ + Mutex::Locker(m_map_mutex); + + if (index < m_map.size()) + { + MapIterator pos, end = m_map.end(); + for (pos = m_map.begin(); pos != end; pos++) + { + if (index == 0) + return pos->second; + index--; + } + } + + return TypeCategoryImplSP(); +} + +lldb::TypeCategoryImplSP FormatManager::GetCategory (const ConstString& category_name, bool can_create) { if (!category_name) return GetCategory(m_default_category_name); - lldb::FormatCategorySP category; + lldb::TypeCategoryImplSP category; if (m_categories_map.Get(category_name, category)) return category; if (!can_create) - return lldb::FormatCategorySP(); + return lldb::TypeCategoryImplSP(); - m_categories_map.Add(category_name,lldb::FormatCategorySP(new FormatCategory(this, category_name.AsCString()))); + m_categories_map.Add(category_name,lldb::TypeCategoryImplSP(new TypeCategoryImpl(this, category_name))); return GetCategory(category_name); } @@ -566,35 +585,33 @@ FormatManager::FormatManager() : // add some default stuff // most formats, summaries, ... actually belong to the users' lldbinit file rather than here - lldb::SummaryFormatSP string_format(new StringSummaryFormat(SummaryFormat::Flags().SetCascades(false) - .SetSkipPointers(true) - .SetSkipReferences(false) - .SetDontShowChildren(true) - .SetDontShowValue(false) - .SetShowMembersOneLiner(false) - .SetHideItemNames(false), - "${var%s}")); + lldb::TypeSummaryImplSP string_format(new StringSummaryFormat(TypeSummaryImpl::Flags().SetCascades(false) + .SetSkipPointers(true) + .SetSkipReferences(false) + .SetDontShowChildren(true) + .SetDontShowValue(false) + .SetShowMembersOneLiner(false) + .SetHideItemNames(false), + "${var%s}")); - lldb::SummaryFormatSP string_array_format(new StringSummaryFormat(SummaryFormat::Flags().SetCascades(false) - .SetSkipPointers(true) - .SetSkipReferences(false) - .SetDontShowChildren(false) - .SetDontShowValue(true) - .SetShowMembersOneLiner(false) - .SetHideItemNames(false), - "${var%s}")); + lldb::TypeSummaryImplSP string_array_format(new StringSummaryFormat(TypeSummaryImpl::Flags().SetCascades(false) + .SetSkipPointers(true) + .SetSkipReferences(false) + .SetDontShowChildren(false) + .SetDontShowValue(true) + .SetShowMembersOneLiner(false) + .SetHideItemNames(false), + "${var%s}")); lldb::RegularExpressionSP any_size_char_arr(new RegularExpression("char \\[[0-9]+\\]")); - FormatCategory::SharedPointer sys_category_sp = GetCategory(m_system_category_name); + TypeCategoryImpl::SharedPointer sys_category_sp = GetCategory(m_system_category_name); sys_category_sp->GetSummaryNavigator()->Add(ConstString("char *"), string_format); sys_category_sp->GetSummaryNavigator()->Add(ConstString("const char *"), string_format); sys_category_sp->GetRegexSummaryNavigator()->Add(any_size_char_arr, string_array_format); - GetCategory(m_default_category_name); // this call is there to force LLDB into creating an empty "default" category - // WARNING: temporary code!! // The platform should be responsible for initializing its own formatters // (e.g. to handle versioning, different runtime libraries, ...) @@ -602,16 +619,16 @@ FormatManager::FormatManager() : // the GNU libstdc++ are defined regardless, and enabled by default // This is going to be moved to some platform-dependent location // (in the meanwhile, these formatters should work for Mac OS X & Linux) - lldb::SummaryFormatSP std_string_summary_sp(new StringSummaryFormat(SummaryFormat::Flags().SetCascades(true) - .SetSkipPointers(false) - .SetSkipReferences(false) - .SetDontShowChildren(true) - .SetDontShowValue(true) - .SetShowMembersOneLiner(false) - .SetHideItemNames(false), - "${var._M_dataplus._M_p}")); + lldb::TypeSummaryImplSP std_string_summary_sp(new StringSummaryFormat(TypeSummaryImpl::Flags().SetCascades(true) + .SetSkipPointers(false) + .SetSkipReferences(false) + .SetDontShowChildren(true) + .SetDontShowValue(true) + .SetShowMembersOneLiner(false) + .SetHideItemNames(false), + "${var._M_dataplus._M_p}")); - FormatCategory::SharedPointer gnu_category_sp = GetCategory(m_gnu_cpp_category_name); + TypeCategoryImpl::SharedPointer gnu_category_sp = GetCategory(m_gnu_cpp_category_name); gnu_category_sp->GetSummaryNavigator()->Add(ConstString("std::string"), std_string_summary_sp); @@ -624,40 +641,34 @@ FormatManager::FormatManager() : #ifndef LLDB_DISABLE_PYTHON + + SyntheticChildren::Flags stl_synth_flags; + stl_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences(false); + gnu_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^(std::)?vector<.+>$")), - SyntheticChildrenSP(new SyntheticScriptProvider(true, - false, - false, - "gnu_libstdcpp.StdVectorSynthProvider"))); + SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags, + "gnu_libstdcpp.StdVectorSynthProvider"))); gnu_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^(std::)?map<.+> >$")), - SyntheticChildrenSP(new SyntheticScriptProvider(true, - false, - false, - "gnu_libstdcpp.StdMapSynthProvider"))); + SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags, + "gnu_libstdcpp.StdMapSynthProvider"))); gnu_category_sp->GetRegexSyntheticNavigator()->Add(RegularExpressionSP(new RegularExpression("^(std::)?list<.+>$")), - SyntheticChildrenSP(new SyntheticScriptProvider(true, - false, - false, - "gnu_libstdcpp.StdListSynthProvider"))); + SyntheticChildrenSP(new TypeSyntheticImpl(stl_synth_flags, + "gnu_libstdcpp.StdListSynthProvider"))); - lldb::SummaryFormatSP ObjC_BOOL_summary(new ScriptSummaryFormat(SummaryFormat::Flags().SetCascades(false) - .SetSkipPointers(false) - .SetSkipReferences(false) - .SetDontShowChildren(true) - .SetDontShowValue(true) - .SetShowMembersOneLiner(false) - .SetHideItemNames(false), - "objc.BOOL_SummaryProvider", - "")); - FormatCategory::SharedPointer objc_category_sp = GetCategory(m_objc_category_name); + lldb::TypeSummaryImplSP ObjC_BOOL_summary(new ScriptSummaryFormat(TypeSummaryImpl::Flags().SetCascades(false) + .SetSkipPointers(false) + .SetSkipReferences(false) + .SetDontShowChildren(true) + .SetDontShowValue(true) + .SetShowMembersOneLiner(false) + .SetHideItemNames(false), + "objc.BOOL_SummaryProvider", + "")); + TypeCategoryImpl::SharedPointer objc_category_sp = GetCategory(m_objc_category_name); objc_category_sp->GetSummaryNavigator()->Add(ConstString("BOOL"), ObjC_BOOL_summary); #endif - - // DO NOT change the order of these calls, unless you WANT a change in the priority of these categories - EnableCategory(m_system_category_name); - EnableCategory(m_objc_category_name); - EnableCategory(m_gnu_cpp_category_name); - EnableCategory(m_default_category_name); - + EnableCategory(m_objc_category_name,CategoryMap::Last); + EnableCategory(m_gnu_cpp_category_name,CategoryMap::Last); + EnableCategory(m_system_category_name,CategoryMap::Last); } diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index 8767b82c87d0..9182979fd40b 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -575,7 +575,7 @@ ValueObject::GetSummaryAsCString () { if (m_summary_str.empty()) { - SummaryFormat *summary_format = GetSummaryFormat().get(); + TypeSummaryImpl *summary_format = GetSummaryFormat().get(); if (summary_format) { @@ -1771,7 +1771,7 @@ ValueObject::GetSyntheticArrayRangeChild (uint32_t from, uint32_t to, bool can_c // We haven't made a synthetic array member for INDEX yet, so // lets make one and cache it for any future reference. - SyntheticArrayView *view = new SyntheticArrayView(); + SyntheticArrayView *view = new SyntheticArrayView(SyntheticChildren::Flags()); view->AddRange(from,to); SyntheticChildrenSP view_sp(view); synthetic_child = new ValueObjectSynthetic(*this, view_sp); @@ -3075,7 +3075,7 @@ ValueObject::DumpValueObject std::string value_str; const char *val_cstr = NULL; const char *sum_cstr = NULL; - SummaryFormat* entry = valobj->GetSummaryFormat().get(); + TypeSummaryImpl* entry = valobj->GetSummaryFormat().get(); if (omit_summary_depth > 0) entry = NULL; diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp index d2d355cac414..71b7162102aa 100644 --- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp +++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp @@ -1140,7 +1140,7 @@ ScriptInterpreterPython::GenerateFunction(std::string& signature, StringList &in // this implementation is identical to GenerateBreakpointCommandCallbackData (apart from the name // given to generated functions, of course) bool -ScriptInterpreterPython::GenerateTypeScriptFunction (StringList &user_input, StringList &output) +ScriptInterpreterPython::GenerateTypeScriptFunction (StringList &user_input, StringList &output, void* name_token) { static int num_created_functions = 0; user_input.RemoveBlankLines (); @@ -1154,7 +1154,10 @@ ScriptInterpreterPython::GenerateTypeScriptFunction (StringList &user_input, Str // Take what the user wrote, wrap it all up inside one big auto-generated Python function, passing in the // ValueObject as parameter to the function. - sstr.Printf ("lldb_autogen_python_type_print_func_%d", num_created_functions); + if (!name_token) + sstr.Printf ("lldb_autogen_python_type_print_func_%d", num_created_functions); + else + sstr.Printf ("lldb_gen_python_type_print_func_%p", name_token); ++num_created_functions; std::string auto_generated_function_name = sstr.GetData(); @@ -1267,7 +1270,7 @@ ScriptInterpreterPython::GenerateScriptAliasFunction (StringList &user_input, St bool -ScriptInterpreterPython::GenerateTypeSynthClass (StringList &user_input, StringList &output) +ScriptInterpreterPython::GenerateTypeSynthClass (StringList &user_input, StringList &output, void* name_token) { static int num_created_classes = 0; user_input.RemoveBlankLines (); @@ -1280,7 +1283,10 @@ ScriptInterpreterPython::GenerateTypeSynthClass (StringList &user_input, StringL // Wrap all user input into a Python class - sstr.Printf ("lldb_autogen_python_type_synth_class_%d", num_created_classes); + if (!name_token) + sstr.Printf ("lldb_autogen_python_type_synth_class_%d", num_created_classes); + else + sstr.Printf ("lldb_gen_python_type_synth_class_%p", name_token); ++num_created_classes; std::string auto_generated_class_name = sstr.GetData(); @@ -1349,12 +1355,22 @@ ScriptInterpreterPython::CreateSyntheticScriptedProvider (std::string class_name } bool -ScriptInterpreterPython::GenerateTypeScriptFunction (const char* oneliner, StringList &output) +ScriptInterpreterPython::GenerateTypeScriptFunction (const char* oneliner, StringList &output, void* name_token) { - StringList input(oneliner); - return GenerateTypeScriptFunction(input, output); + StringList input; + input.SplitIntoLines(oneliner, strlen(oneliner)); + return GenerateTypeScriptFunction(input, output, name_token); } +bool +ScriptInterpreterPython::GenerateTypeSynthClass (const char* oneliner, StringList &output, void* name_token) +{ + StringList input; + input.SplitIntoLines(oneliner, strlen(oneliner)); + return GenerateTypeSynthClass(input, output, name_token); +} + + bool ScriptInterpreterPython::GenerateBreakpointCommandCallbackData (StringList &user_input, StringList &callback_data) { @@ -1775,12 +1791,12 @@ ScriptInterpreterPython::LoadScriptingModule (const char* pathname, return false; } - // call __lldb_module_init(debugger,dict) + // call __lldb_init_module(debugger,dict) if (!g_swig_call_module_init (basename, m_dictionary_name.c_str(), debugger_sp)) { - error.SetErrorString("calling __lldb_module_init failed"); + error.SetErrorString("calling __lldb_init_module failed"); return false; } return true;