diff options
Diffstat (limited to 'include/lldb/DataFormatters')
-rw-r--r-- | include/lldb/DataFormatters/CXXFormatterFunctions.h | 504 | ||||
-rw-r--r-- | include/lldb/DataFormatters/DataVisualization.h | 13 | ||||
-rw-r--r-- | include/lldb/DataFormatters/FormatCache.h | 20 | ||||
-rw-r--r-- | include/lldb/DataFormatters/FormatManager.h | 23 | ||||
-rw-r--r-- | include/lldb/DataFormatters/FormattersContainer.h | 51 | ||||
-rw-r--r-- | include/lldb/DataFormatters/StringPrinter.h | 290 | ||||
-rw-r--r-- | include/lldb/DataFormatters/TypeCategory.h | 51 | ||||
-rw-r--r-- | include/lldb/DataFormatters/TypeCategoryMap.h | 10 | ||||
-rw-r--r-- | include/lldb/DataFormatters/TypeSummary.h | 43 | ||||
-rw-r--r-- | include/lldb/DataFormatters/TypeSynthetic.h | 147 | ||||
-rw-r--r-- | include/lldb/DataFormatters/TypeValidator.h | 280 | ||||
-rw-r--r-- | include/lldb/DataFormatters/ValueObjectPrinter.h | 143 |
12 files changed, 919 insertions, 656 deletions
diff --git a/include/lldb/DataFormatters/CXXFormatterFunctions.h b/include/lldb/DataFormatters/CXXFormatterFunctions.h index 753ffa1bae1b..53b7468bb13c 100644 --- a/include/lldb/DataFormatters/CXXFormatterFunctions.h +++ b/include/lldb/DataFormatters/CXXFormatterFunctions.h @@ -61,419 +61,139 @@ namespace lldb_private { GetOSXEpoch (); bool - Char16StringSummaryProvider (ValueObject& valobj, Stream& stream); // char16_t* and unichar* + FunctionPointerSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // C++ function pointer bool - Char32StringSummaryProvider (ValueObject& valobj, Stream& stream); // char32_t* + Char16StringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // char16_t* and unichar* bool - WCharStringSummaryProvider (ValueObject& valobj, Stream& stream); // wchar_t* + Char32StringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // char32_t* bool - Char16SummaryProvider (ValueObject& valobj, Stream& stream); // char16_t and unichar + WCharStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // wchar_t* bool - Char32SummaryProvider (ValueObject& valobj, Stream& stream); // char32_t + Char16SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // char16_t and unichar bool - WCharSummaryProvider (ValueObject& valobj, Stream& stream); // wchar_t + Char32SummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // char32_t bool - LibcxxStringSummaryProvider (ValueObject& valobj, Stream& stream); // libc++ std::string + WCharSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // wchar_t + + bool + LibcxxStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // libc++ std::string bool - LibcxxWStringSummaryProvider (ValueObject& valobj, Stream& stream); // libc++ std::wstring + LibcxxWStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // libc++ std::wstring bool - LibcxxSmartPointerSummaryProvider (ValueObject& valobj, Stream& stream); // libc++ std::shared_ptr<> and std::weak_ptr<> + LibcxxSmartPointerSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); // libc++ std::shared_ptr<> and std::weak_ptr<> bool - ObjCClassSummaryProvider (ValueObject& valobj, Stream& stream); + ObjCClassSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); SyntheticChildrenFrontEnd* ObjCClassSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); template<bool name_entries> bool - NSDictionarySummaryProvider (ValueObject& valobj, Stream& stream); + NSDictionarySummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); bool - NSIndexSetSummaryProvider (ValueObject& valobj, Stream& stream); + NSIndexSetSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); bool - NSArraySummaryProvider (ValueObject& valobj, Stream& stream); + NSArraySummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); template<bool cf_style> bool - NSSetSummaryProvider (ValueObject& valobj, Stream& stream); + NSSetSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); template<bool needs_at> bool - NSDataSummaryProvider (ValueObject& valobj, Stream& stream); + NSDataSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); bool - NSNumberSummaryProvider (ValueObject& valobj, Stream& stream); + NSNumberSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); bool - NSNotificationSummaryProvider (ValueObject& valobj, Stream& stream); + NSNotificationSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); bool - NSTimeZoneSummaryProvider (ValueObject& valobj, Stream& stream); + NSTimeZoneSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); bool - NSMachPortSummaryProvider (ValueObject& valobj, Stream& stream); + NSMachPortSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); bool - CFBagSummaryProvider (ValueObject& valobj, Stream& stream); + CFBagSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); bool - CFBinaryHeapSummaryProvider (ValueObject& valobj, Stream& stream); + CFBinaryHeapSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); bool - CFBitVectorSummaryProvider (ValueObject& valobj, Stream& stream); + CFBitVectorSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); bool - NSDateSummaryProvider (ValueObject& valobj, Stream& stream); + NSDateSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); bool - CFAbsoluteTimeSummaryProvider (ValueObject& valobj, Stream& stream); + CFAbsoluteTimeSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); bool - NSBundleSummaryProvider (ValueObject& valobj, Stream& stream); + NSBundleSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); bool - NSStringSummaryProvider (ValueObject& valobj, Stream& stream); + NSStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); bool NSTaggedString_SummaryProvider (ObjCLanguageRuntime::ClassDescriptorSP descriptor, Stream& stream); bool - NSAttributedStringSummaryProvider (ValueObject& valobj, Stream& stream); + NSAttributedStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); bool - NSMutableAttributedStringSummaryProvider (ValueObject& valobj, Stream& stream); + NSMutableAttributedStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); bool - NSURLSummaryProvider (ValueObject& valobj, Stream& stream); + NSURLSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); bool - ObjCBOOLSummaryProvider (ValueObject& valobj, Stream& stream); + ObjCBOOLSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); template <bool is_sel_ptr> bool - ObjCSELSummaryProvider (ValueObject& valobj, Stream& stream); + ObjCSELSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); bool - RuntimeSpecificDescriptionSummaryProvider (ValueObject& valobj, Stream& stream); + RuntimeSpecificDescriptionSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); extern template bool - NSDictionarySummaryProvider<true> (ValueObject&, Stream&) ; + NSDictionarySummaryProvider<true> (ValueObject&, Stream&, const TypeSummaryOptions&) ; extern template bool - NSDictionarySummaryProvider<false> (ValueObject&, Stream&) ; + NSDictionarySummaryProvider<false> (ValueObject&, Stream&, const TypeSummaryOptions&) ; extern template bool - NSDataSummaryProvider<true> (ValueObject&, Stream&) ; + NSDataSummaryProvider<true> (ValueObject&, Stream&, const TypeSummaryOptions&) ; extern template bool - NSDataSummaryProvider<false> (ValueObject&, Stream&) ; + NSDataSummaryProvider<false> (ValueObject&, Stream&, const TypeSummaryOptions&) ; extern template bool - ObjCSELSummaryProvider<true> (ValueObject&, Stream&); + ObjCSELSummaryProvider<true> (ValueObject&, Stream&, const TypeSummaryOptions&); extern template bool - ObjCSELSummaryProvider<false> (ValueObject&, Stream&); + ObjCSELSummaryProvider<false> (ValueObject&, Stream&, const TypeSummaryOptions&); SyntheticChildrenFrontEnd* NSArraySyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); - class NSDictionaryISyntheticFrontEnd : public SyntheticChildrenFrontEnd - { - private: - struct DataDescriptor_32 - { - uint32_t _used : 26; - uint32_t _szidx : 6; - }; - struct DataDescriptor_64 - { - uint64_t _used : 58; - uint32_t _szidx : 6; - }; - - struct DictionaryItemDescriptor - { - lldb::addr_t key_ptr; - lldb::addr_t val_ptr; - lldb::ValueObjectSP valobj_sp; - }; - - public: - NSDictionaryISyntheticFrontEnd (lldb::ValueObjectSP valobj_sp); - - virtual size_t - CalculateNumChildren (); - - virtual lldb::ValueObjectSP - GetChildAtIndex (size_t idx); - - virtual bool - Update(); - - virtual bool - MightHaveChildren (); - - virtual size_t - GetIndexOfChildWithName (const ConstString &name); - - virtual - ~NSDictionaryISyntheticFrontEnd (); - private: - ExecutionContextRef m_exe_ctx_ref; - uint8_t m_ptr_size; - lldb::ByteOrder m_order; - DataDescriptor_32 *m_data_32; - DataDescriptor_64 *m_data_64; - lldb::addr_t m_data_ptr; - ClangASTType m_pair_type; - std::vector<DictionaryItemDescriptor> m_children; - }; - - class NSDictionaryMSyntheticFrontEnd : public SyntheticChildrenFrontEnd - { - private: - struct DataDescriptor_32 - { - uint32_t _used : 26; - uint32_t _kvo : 1; - uint32_t _size; - uint32_t _mutations; - uint32_t _objs_addr; - uint32_t _keys_addr; - }; - struct DataDescriptor_64 - { - uint64_t _used : 58; - uint32_t _kvo : 1; - uint64_t _size; - uint64_t _mutations; - uint64_t _objs_addr; - uint64_t _keys_addr; - }; - struct DictionaryItemDescriptor - { - lldb::addr_t key_ptr; - lldb::addr_t val_ptr; - lldb::ValueObjectSP valobj_sp; - }; - public: - NSDictionaryMSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp); - - virtual size_t - CalculateNumChildren (); - - virtual lldb::ValueObjectSP - GetChildAtIndex (size_t idx); - - virtual bool - Update(); - - virtual bool - MightHaveChildren (); - - virtual size_t - GetIndexOfChildWithName (const ConstString &name); - - virtual - ~NSDictionaryMSyntheticFrontEnd (); - private: - ExecutionContextRef m_exe_ctx_ref; - uint8_t m_ptr_size; - lldb::ByteOrder m_order; - DataDescriptor_32 *m_data_32; - DataDescriptor_64 *m_data_64; - ClangASTType m_pair_type; - std::vector<DictionaryItemDescriptor> m_children; - }; - - class NSDictionaryCodeRunningSyntheticFrontEnd : public SyntheticChildrenFrontEnd - { - public: - NSDictionaryCodeRunningSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp); - - virtual size_t - CalculateNumChildren (); - - virtual lldb::ValueObjectSP - GetChildAtIndex (size_t idx); - - virtual bool - Update(); - - virtual bool - MightHaveChildren (); - - virtual size_t - GetIndexOfChildWithName (const ConstString &name); - - virtual - ~NSDictionaryCodeRunningSyntheticFrontEnd (); - }; - SyntheticChildrenFrontEnd* NSDictionarySyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); - class NSSetISyntheticFrontEnd : public SyntheticChildrenFrontEnd - { - private: - struct DataDescriptor_32 - { - uint32_t _used : 26; - uint32_t _szidx : 6; - }; - struct DataDescriptor_64 - { - uint64_t _used : 58; - uint32_t _szidx : 6; - }; - - struct SetItemDescriptor - { - lldb::addr_t item_ptr; - lldb::ValueObjectSP valobj_sp; - }; - - public: - NSSetISyntheticFrontEnd (lldb::ValueObjectSP valobj_sp); - - virtual size_t - CalculateNumChildren (); - - virtual lldb::ValueObjectSP - GetChildAtIndex (size_t idx); - - virtual bool - Update(); - - virtual bool - MightHaveChildren (); - - virtual size_t - GetIndexOfChildWithName (const ConstString &name); - - virtual - ~NSSetISyntheticFrontEnd (); - private: - ExecutionContextRef m_exe_ctx_ref; - uint8_t m_ptr_size; - DataDescriptor_32 *m_data_32; - DataDescriptor_64 *m_data_64; - lldb::addr_t m_data_ptr; - std::vector<SetItemDescriptor> m_children; - }; - - class NSOrderedSetSyntheticFrontEnd : public SyntheticChildrenFrontEnd - { - private: - - public: - NSOrderedSetSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp); - - virtual size_t - CalculateNumChildren (); - - virtual lldb::ValueObjectSP - GetChildAtIndex (size_t idx); - - virtual bool - Update(); - - virtual bool - MightHaveChildren (); - - virtual size_t - GetIndexOfChildWithName (const ConstString &name); - - virtual - ~NSOrderedSetSyntheticFrontEnd (); - private: - uint32_t m_count; - std::map<uint32_t,lldb::ValueObjectSP> m_children; - }; - - class NSSetMSyntheticFrontEnd : public SyntheticChildrenFrontEnd - { - private: - struct DataDescriptor_32 - { - uint32_t _used : 26; - uint32_t _size; - uint32_t _mutations; - uint32_t _objs_addr; - }; - struct DataDescriptor_64 - { - uint64_t _used : 58; - uint64_t _size; - uint64_t _mutations; - uint64_t _objs_addr; - }; - struct SetItemDescriptor - { - lldb::addr_t item_ptr; - lldb::ValueObjectSP valobj_sp; - }; - public: - NSSetMSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp); - - virtual size_t - CalculateNumChildren (); - - virtual lldb::ValueObjectSP - GetChildAtIndex (size_t idx); - - virtual bool - Update(); - - virtual bool - MightHaveChildren (); - - virtual size_t - GetIndexOfChildWithName (const ConstString &name); - - virtual - ~NSSetMSyntheticFrontEnd (); - private: - ExecutionContextRef m_exe_ctx_ref; - uint8_t m_ptr_size; - DataDescriptor_32 *m_data_32; - DataDescriptor_64 *m_data_64; - std::vector<SetItemDescriptor> m_children; - }; - - class NSSetCodeRunningSyntheticFrontEnd : public SyntheticChildrenFrontEnd - { - public: - NSSetCodeRunningSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp); - - virtual size_t - CalculateNumChildren (); - - virtual lldb::ValueObjectSP - GetChildAtIndex (size_t idx); - - virtual bool - Update(); - - virtual bool - MightHaveChildren (); - - virtual size_t - GetIndexOfChildWithName (const ConstString &name); - - virtual - ~NSSetCodeRunningSyntheticFrontEnd (); - }; - SyntheticChildrenFrontEnd* NSSetSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); + SyntheticChildrenFrontEnd* NSIndexPathSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); + class LibcxxVectorBoolSyntheticFrontEnd : public SyntheticChildrenFrontEnd { public: @@ -507,7 +227,7 @@ namespace lldb_private { SyntheticChildrenFrontEnd* LibcxxVectorBoolSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); bool - LibcxxContainerSummaryProvider (ValueObject& valobj, Stream& stream); + LibcxxContainerSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options); class LibstdcppVectorBoolSyntheticFrontEnd : public SyntheticChildrenFrontEnd { @@ -665,148 +385,16 @@ namespace lldb_private { SyntheticChildrenFrontEnd* LibcxxSharedPtrSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); - class LibcxxStdVectorSyntheticFrontEnd : public SyntheticChildrenFrontEnd - { - public: - LibcxxStdVectorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp); - - virtual size_t - CalculateNumChildren (); - - virtual lldb::ValueObjectSP - GetChildAtIndex (size_t idx); - - virtual bool - Update(); - - virtual bool - MightHaveChildren (); - - virtual size_t - GetIndexOfChildWithName (const ConstString &name); - - virtual - ~LibcxxStdVectorSyntheticFrontEnd (); - private: - ValueObject* m_start; - ValueObject* m_finish; - ClangASTType m_element_type; - uint32_t m_element_size; - std::map<size_t,lldb::ValueObjectSP> m_children; - }; - SyntheticChildrenFrontEnd* LibcxxStdVectorSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); - class LibcxxStdListSyntheticFrontEnd : public SyntheticChildrenFrontEnd - { - public: - LibcxxStdListSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp); - - virtual size_t - CalculateNumChildren (); - - virtual lldb::ValueObjectSP - GetChildAtIndex (size_t idx); - - virtual bool - Update(); - - virtual bool - MightHaveChildren (); - - virtual size_t - GetIndexOfChildWithName (const ConstString &name); - - virtual - ~LibcxxStdListSyntheticFrontEnd (); - private: - bool - HasLoop(); - - size_t m_list_capping_size; - static const bool g_use_loop_detect = true; - lldb::addr_t m_node_address; - ValueObject* m_head; - ValueObject* m_tail; - ClangASTType m_element_type; - size_t m_count; - std::map<size_t,lldb::ValueObjectSP> m_children; - }; - SyntheticChildrenFrontEnd* LibcxxStdListSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); - class LibcxxStdMapSyntheticFrontEnd : public SyntheticChildrenFrontEnd - { - public: - LibcxxStdMapSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp); - - virtual size_t - CalculateNumChildren (); - - virtual lldb::ValueObjectSP - GetChildAtIndex (size_t idx); - - virtual bool - Update(); - - virtual bool - MightHaveChildren (); - - virtual size_t - GetIndexOfChildWithName (const ConstString &name); - - virtual - ~LibcxxStdMapSyntheticFrontEnd (); - private: - bool - GetDataType(); - - void - GetValueOffset (const lldb::ValueObjectSP& node); - - ValueObject* m_tree; - ValueObject* m_root_node; - ClangASTType m_element_type; - uint32_t m_skip_size; - size_t m_count; - std::map<size_t,lldb::ValueObjectSP> m_children; - }; - SyntheticChildrenFrontEnd* LibcxxStdMapSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); - class LibcxxStdUnorderedMapSyntheticFrontEnd : public SyntheticChildrenFrontEnd - { - public: - LibcxxStdUnorderedMapSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp); - - virtual size_t - CalculateNumChildren (); - - virtual lldb::ValueObjectSP - GetChildAtIndex (size_t idx); - - virtual bool - Update(); - - virtual bool - MightHaveChildren (); - - virtual size_t - GetIndexOfChildWithName (const ConstString &name); - - virtual - ~LibcxxStdUnorderedMapSyntheticFrontEnd (); - private: - - ValueObject* m_tree; - size_t m_num_elements; - ValueObject* m_next_element; - std::map<size_t,lldb::ValueObjectSP> m_children; - std::vector<std::pair<ValueObject*, uint64_t> > m_elements_cache; - }; - SyntheticChildrenFrontEnd* LibcxxStdUnorderedMapSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); + SyntheticChildrenFrontEnd* LibcxxInitializerListSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); + } // namespace formatters } // namespace lldb_private diff --git a/include/lldb/DataFormatters/DataVisualization.h b/include/lldb/DataFormatters/DataVisualization.h index ca0714c29f84..a0b2e58bba28 100644 --- a/include/lldb/DataFormatters/DataVisualization.h +++ b/include/lldb/DataFormatters/DataVisualization.h @@ -72,6 +72,13 @@ public: lldb::DynamicValueType use_dynamic); #endif + static lldb::TypeValidatorImplSP + GetValidator (ValueObject& valobj, + lldb::DynamicValueType use_dynamic); + + static lldb::TypeValidatorImplSP + GetValidatorForType (lldb::TypeNameSpecifierImplSP type_sp); + static bool AnyMatches(ConstString type_name, TypeCategoryImpl::FormatCategoryItems items = TypeCategoryImpl::ALL_ITEM_TYPES, @@ -137,6 +144,12 @@ public: Disable (const lldb::TypeCategoryImplSP& category); static void + EnableStar (); + + static void + DisableStar (); + + static void LoopThrough (FormatManager::CategoryCallback callback, void* callback_baton); static uint32_t diff --git a/include/lldb/DataFormatters/FormatCache.h b/include/lldb/DataFormatters/FormatCache.h index 1505d7c46189..fa46306e5404 100644 --- a/include/lldb/DataFormatters/FormatCache.h +++ b/include/lldb/DataFormatters/FormatCache.h @@ -31,16 +31,19 @@ private: bool m_format_cached : 1; bool m_summary_cached : 1; bool m_synthetic_cached : 1; + bool m_validator_cached : 1; lldb::TypeFormatImplSP m_format_sp; lldb::TypeSummaryImplSP m_summary_sp; lldb::SyntheticChildrenSP m_synthetic_sp; + lldb::TypeValidatorImplSP m_validator_sp; public: Entry (); Entry (lldb::TypeFormatImplSP); Entry (lldb::TypeSummaryImplSP); Entry (lldb::SyntheticChildrenSP); - Entry (lldb::TypeFormatImplSP,lldb::TypeSummaryImplSP,lldb::SyntheticChildrenSP); + Entry (lldb::TypeValidatorImplSP); + Entry (lldb::TypeFormatImplSP,lldb::TypeSummaryImplSP,lldb::SyntheticChildrenSP,lldb::TypeValidatorImplSP); bool IsFormatCached (); @@ -51,6 +54,9 @@ private: bool IsSyntheticCached (); + bool + IsValidatorCached (); + lldb::TypeFormatImplSP GetFormat (); @@ -60,6 +66,9 @@ private: lldb::SyntheticChildrenSP GetSynthetic (); + lldb::TypeValidatorImplSP + GetValidator (); + void SetFormat (lldb::TypeFormatImplSP); @@ -68,6 +77,9 @@ private: void SetSynthetic (lldb::SyntheticChildrenSP); + + void + SetValidator (lldb::TypeValidatorImplSP); }; typedef std::map<ConstString,Entry> CacheMap; CacheMap m_map; @@ -91,6 +103,9 @@ public: bool GetSynthetic (const ConstString& type,lldb::SyntheticChildrenSP& synthetic_sp); + bool + GetValidator (const ConstString& type,lldb::TypeValidatorImplSP& summary_sp); + void SetFormat (const ConstString& type,lldb::TypeFormatImplSP& format_sp); @@ -101,6 +116,9 @@ public: SetSynthetic (const ConstString& type,lldb::SyntheticChildrenSP& synthetic_sp); void + SetValidator (const ConstString& type,lldb::TypeValidatorImplSP& synthetic_sp); + + void Clear (); uint64_t diff --git a/include/lldb/DataFormatters/FormatManager.h b/include/lldb/DataFormatters/FormatManager.h index 0b9144dffa17..37dae6536761 100644 --- a/include/lldb/DataFormatters/FormatManager.h +++ b/include/lldb/DataFormatters/FormatManager.h @@ -86,6 +86,18 @@ public: m_categories_map.Disable(category); } + void + EnableAllCategories () + { + m_categories_map.EnableAllCategories (); + } + + void + DisableAllCategories () + { + m_categories_map.DisableAllCategories (); + } + bool DeleteCategory (const ConstString& category_name) { @@ -148,6 +160,9 @@ public: GetSyntheticChildrenForType (lldb::TypeNameSpecifierImplSP type_sp); #endif + lldb::TypeValidatorImplSP + GetValidatorForType (lldb::TypeNameSpecifierImplSP type_sp); + lldb::TypeFormatImplSP GetFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic); @@ -162,6 +177,10 @@ public: lldb::DynamicValueType use_dynamic); #endif + lldb::TypeValidatorImplSP + GetValidator (ValueObject& valobj, + lldb::DynamicValueType use_dynamic); + bool AnyMatches (ConstString type_name, TypeCategoryImpl::FormatCategoryItems items = TypeCategoryImpl::ALL_ITEM_TYPES, @@ -272,6 +291,7 @@ private: HardcodedFormatterFinders<TypeFormatImpl> m_hardcoded_formats; HardcodedFormatterFinders<TypeSummaryImpl> m_hardcoded_summaries; HardcodedFormatterFinders<SyntheticChildren> m_hardcoded_synthetics; + HardcodedFormatterFinders<TypeValidatorImpl> m_hardcoded_validators; lldb::TypeFormatImplSP GetHardcodedFormat (ValueObject&,lldb::DynamicValueType); @@ -282,6 +302,9 @@ private: lldb::SyntheticChildrenSP GetHardcodedSyntheticChildren (ValueObject&,lldb::DynamicValueType); + lldb::TypeValidatorImplSP + GetHardcodedValidator (ValueObject&,lldb::DynamicValueType); + TypeCategoryMap& GetCategories () { diff --git a/include/lldb/DataFormatters/FormattersContainer.h b/include/lldb/DataFormatters/FormattersContainer.h index de838d1ab9c1..daf2f24ae3e5 100644 --- a/include/lldb/DataFormatters/FormattersContainer.h +++ b/include/lldb/DataFormatters/FormattersContainer.h @@ -29,6 +29,7 @@ #include "lldb/DataFormatters/TypeFormat.h" #include "lldb/DataFormatters/TypeSummary.h" #include "lldb/DataFormatters/TypeSynthetic.h" +#include "lldb/DataFormatters/TypeValidator.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/ClangASTType.h" @@ -38,6 +39,8 @@ #include "lldb/Target/StackFrame.h" #include "lldb/Target/TargetList.h" +#include "lldb/Utility/StringLexer.h" + namespace lldb_private { // this file (and its. cpp) contain the low-level implementation of LLDB Data Visualization @@ -58,18 +61,6 @@ public: }; -static inline bool -IsWhitespace (char c) -{ - return ( (c == ' ') || (c == '\t') || (c == '\v') || (c == '\f') ); -} - -static inline bool -HasPrefix (const char* str1, const char* str2) -{ - return ( ::strstr(str1, str2) == str1 ); -} - // if the user tries to add formatters for, say, "struct Foo" // those will not match any type because of the way we strip qualifiers from typenames // this method looks for the case where the user is adding a "class","struct","enum" or "union" Foo @@ -77,32 +68,23 @@ HasPrefix (const char* str1, const char* str2) static inline ConstString GetValidTypeName_Impl (const ConstString& type) { - int strip_len = 0; - - if ((bool)type == false) + if (type.IsEmpty()) return type; - const char* type_cstr = type.AsCString(); - - if ( HasPrefix(type_cstr, "class ") ) - strip_len = 6; - else if ( HasPrefix(type_cstr, "enum ") ) - strip_len = 5; - else if ( HasPrefix(type_cstr, "struct ") ) - strip_len = 7; - else if ( HasPrefix(type_cstr, "union ") ) - strip_len = 6; + std::string type_cstr(type.AsCString()); + lldb_utility::StringLexer type_lexer(type_cstr); - if (strip_len == 0) - return type; + type_lexer.AdvanceIf("class "); + type_lexer.AdvanceIf("enum "); + type_lexer.AdvanceIf("struct "); + type_lexer.AdvanceIf("union "); - type_cstr += strip_len; - while (IsWhitespace(*type_cstr) && ++type_cstr) + while (type_lexer.NextIf({' ','\t','\v','\f'}).first) ; - return ConstString(type_cstr); + return ConstString(type_lexer.GetUnlexed()); } - + template<typename KeyType, typename ValueType> class FormattersContainer; @@ -267,8 +249,7 @@ public: FormattersContainer(std::string name, IFormatChangeListener* lst) : m_format_map(lst), - m_name(name), - m_id_cs(ConstString("id")) + m_name(name) { } @@ -345,15 +326,11 @@ public: } protected: - BackEndType m_format_map; - std::string m_name; DISALLOW_COPY_AND_ASSIGN(FormattersContainer); - ConstString m_id_cs; - void Add_Impl (const MapKeyType &type, const MapValueType& entry, lldb::RegularExpressionSP *dummy) { diff --git a/include/lldb/DataFormatters/StringPrinter.h b/include/lldb/DataFormatters/StringPrinter.h new file mode 100644 index 000000000000..48e27ace5d92 --- /dev/null +++ b/include/lldb/DataFormatters/StringPrinter.h @@ -0,0 +1,290 @@ +//===-- StringPrinter.h -----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_StringPrinter_h_ +#define liblldb_StringPrinter_h_ + +#include "lldb/lldb-forward.h" + +#include "lldb/Core/DataExtractor.h" + +namespace lldb_private { + namespace formatters + { + + enum class StringElementType { + ASCII, + UTF8, + UTF16, + UTF32 + }; + + class ReadStringAndDumpToStreamOptions + { + public: + + ReadStringAndDumpToStreamOptions () : + m_location(0), + m_process_sp(), + m_stream(NULL), + m_prefix_token(0), + m_quote('"'), + m_source_size(0), + m_needs_zero_termination(true), + m_escape_non_printables(true), + m_ignore_max_length(false) + { + } + + ReadStringAndDumpToStreamOptions (ValueObject& valobj); + + ReadStringAndDumpToStreamOptions& + SetLocation (uint64_t l) + { + m_location = l; + return *this; + } + + uint64_t + GetLocation () const + { + return m_location; + } + + ReadStringAndDumpToStreamOptions& + SetProcessSP (lldb::ProcessSP p) + { + m_process_sp = p; + return *this; + } + + lldb::ProcessSP + GetProcessSP () const + { + return m_process_sp; + } + + ReadStringAndDumpToStreamOptions& + SetStream (Stream* s) + { + m_stream = s; + return *this; + } + + Stream* + GetStream () const + { + return m_stream; + } + + ReadStringAndDumpToStreamOptions& + SetPrefixToken (char p) + { + m_prefix_token = p; + return *this; + } + + char + GetPrefixToken () const + { + return m_prefix_token; + } + + ReadStringAndDumpToStreamOptions& + SetQuote (char q) + { + m_quote = q; + return *this; + } + + char + GetQuote () const + { + return m_quote; + } + + ReadStringAndDumpToStreamOptions& + SetSourceSize (uint32_t s) + { + m_source_size = s; + return *this; + } + + uint32_t + GetSourceSize () const + { + return m_source_size; + } + + ReadStringAndDumpToStreamOptions& + SetNeedsZeroTermination (bool z) + { + m_needs_zero_termination = z; + return *this; + } + + bool + GetNeedsZeroTermination () const + { + return m_needs_zero_termination; + } + + ReadStringAndDumpToStreamOptions& + SetEscapeNonPrintables (bool e) + { + m_escape_non_printables = e; + return *this; + } + + bool + GetEscapeNonPrintables () const + { + return m_escape_non_printables; + } + + ReadStringAndDumpToStreamOptions& + SetIgnoreMaxLength (bool e) + { + m_ignore_max_length = e; + return *this; + } + + bool + GetIgnoreMaxLength () const + { + return m_ignore_max_length; + } + + private: + uint64_t m_location; + lldb::ProcessSP m_process_sp; + Stream* m_stream; + char m_prefix_token; + char m_quote; + uint32_t m_source_size; + bool m_needs_zero_termination; + bool m_escape_non_printables; + bool m_ignore_max_length; + }; + + class ReadBufferAndDumpToStreamOptions + { + public: + + ReadBufferAndDumpToStreamOptions () : + m_data(), + m_stream(NULL), + m_prefix_token(0), + m_quote('"'), + m_source_size(0), + m_escape_non_printables(true) + { + } + + ReadBufferAndDumpToStreamOptions (ValueObject& valobj); + + ReadBufferAndDumpToStreamOptions& + SetData (DataExtractor d) + { + m_data = d; + return *this; + } + + lldb_private::DataExtractor + GetData () const + { + return m_data; + } + + ReadBufferAndDumpToStreamOptions& + SetStream (Stream* s) + { + m_stream = s; + return *this; + } + + Stream* + GetStream () const + { + return m_stream; + } + + ReadBufferAndDumpToStreamOptions& + SetPrefixToken (char p) + { + m_prefix_token = p; + return *this; + } + + char + GetPrefixToken () const + { + return m_prefix_token; + } + + ReadBufferAndDumpToStreamOptions& + SetQuote (char q) + { + m_quote = q; + return *this; + } + + char + GetQuote () const + { + return m_quote; + } + + ReadBufferAndDumpToStreamOptions& + SetSourceSize (uint32_t s) + { + m_source_size = s; + return *this; + } + + uint32_t + GetSourceSize () const + { + return m_source_size; + } + + ReadBufferAndDumpToStreamOptions& + SetEscapeNonPrintables (bool e) + { + m_escape_non_printables = e; + return *this; + } + + bool + GetEscapeNonPrintables () const + { + return m_escape_non_printables; + } + + private: + DataExtractor m_data; + Stream* m_stream; + char m_prefix_token; + char m_quote; + uint32_t m_source_size; + bool m_escape_non_printables; + }; + + template <StringElementType element_type> + bool + ReadStringAndDumpToStream (ReadStringAndDumpToStreamOptions options); + + template <StringElementType element_type> + bool + ReadBufferAndDumpToStream (ReadBufferAndDumpToStreamOptions options); + + } // namespace formatters +} // namespace lldb_private + +#endif // liblldb_StringPrinter_h_ diff --git a/include/lldb/DataFormatters/TypeCategory.h b/include/lldb/DataFormatters/TypeCategory.h index 491fef29b5c5..e32efa420a55 100644 --- a/include/lldb/DataFormatters/TypeCategory.h +++ b/include/lldb/DataFormatters/TypeCategory.h @@ -71,6 +71,7 @@ namespace lldb_private { typedef FormatterContainerPair<TypeFormatImpl> FormatContainer; typedef FormatterContainerPair<TypeSummaryImpl> SummaryContainer; typedef FormatterContainerPair<TypeFilterImpl> FilterContainer; + typedef FormatterContainerPair<TypeValidatorImpl> ValidatorContainer; #ifndef LLDB_DISABLE_PYTHON typedef FormatterContainerPair<ScriptedSyntheticChildren> SynthContainer; @@ -94,6 +95,9 @@ namespace lldb_private { typedef SynthContainer::RegexMatchContainerSP RegexSynthContainerSP; #endif // #ifndef LLDB_DISABLE_PYTHON + typedef ValidatorContainer::ExactMatchContainerSP ValidatorContainerSP; + typedef ValidatorContainer::RegexMatchContainerSP RegexValidatorContainerSP; + TypeCategoryImpl (IFormatChangeListener* clist, ConstString name); @@ -147,6 +151,9 @@ namespace lldb_private { GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp); #endif + ValidatorContainer::MapValueType + GetValidatorForType (lldb::TypeNameSpecifierImplSP type_sp); + lldb::TypeNameSpecifierImplSP GetTypeNameSpecifierForFormatAtIndex (size_t index); @@ -183,9 +190,26 @@ namespace lldb_private { lldb::TypeNameSpecifierImplSP GetTypeNameSpecifierForSyntheticAtIndex (size_t index); - #endif // #ifndef LLDB_DISABLE_PYTHON + ValidatorContainerSP + GetTypeValidatorsContainer () + { + return m_validator_cont.GetExactMatch(); + } + + RegexValidatorContainerSP + GetRegexTypeValidatorsContainer () + { + return m_validator_cont.GetRegexMatch(); + } + + ValidatorContainer::MapValueType + GetValidatorAtIndex (size_t index); + + lldb::TypeNameSpecifierImplSP + GetTypeNameSpecifierForValidatorAtIndex (size_t index); + bool IsEnabled () const { @@ -219,6 +243,12 @@ namespace lldb_private { lldb::SyntheticChildrenSP& entry, uint32_t* reason = NULL); + bool + Get (ValueObject& valobj, + const FormattersMatchVector& candidates, + lldb::TypeValidatorImplSP& entry, + uint32_t* reason = NULL); + void Clear (FormatCategoryItems items = ALL_ITEM_TYPES); @@ -246,14 +276,12 @@ namespace lldb_private { private: FormatContainer m_format_cont; - SummaryContainer m_summary_cont; - FilterContainer m_filter_cont; - #ifndef LLDB_DISABLE_PYTHON SynthContainer m_synth_cont; #endif // #ifndef LLDB_DISABLE_PYTHON + ValidatorContainer m_validator_cont; bool m_enabled; @@ -274,6 +302,18 @@ namespace lldb_private { Enable(false, UINT32_MAX); } + uint32_t + GetLastEnabledPosition () + { + return m_enabled_position; + } + + void + SetEnabledPosition (uint32_t p) + { + m_enabled_position = p; + } + friend class TypeCategoryMap; friend class FormattersContainer<ConstString, TypeFormatImpl>; @@ -289,6 +329,9 @@ namespace lldb_private { friend class FormattersContainer<ConstString, ScriptedSyntheticChildren>; friend class FormattersContainer<lldb::RegularExpressionSP, ScriptedSyntheticChildren>; #endif // #ifndef LLDB_DISABLE_PYTHON + + friend class FormattersContainer<ConstString, TypeValidatorImpl>; + friend class FormattersContainer<lldb::RegularExpressionSP, TypeValidatorImpl>; }; } // namespace lldb_private diff --git a/include/lldb/DataFormatters/TypeCategoryMap.h b/include/lldb/DataFormatters/TypeCategoryMap.h index 88aaeb23bfd8..41b170d5335e 100644 --- a/include/lldb/DataFormatters/TypeCategoryMap.h +++ b/include/lldb/DataFormatters/TypeCategoryMap.h @@ -63,6 +63,12 @@ namespace lldb_private { bool Disable (ValueSP category); + + void + EnableAllCategories (); + + void + DisableAllCategories (); void Clear (); @@ -108,6 +114,10 @@ namespace lldb_private { lldb::DynamicValueType use_dynamic); #endif + lldb::TypeValidatorImplSP + GetValidator (ValueObject& valobj, + lldb::DynamicValueType use_dynamic); + private: class delete_matching_categories diff --git a/include/lldb/DataFormatters/TypeSummary.h b/include/lldb/DataFormatters/TypeSummary.h index 699494336cc6..2d4e03ad9b5d 100644 --- a/include/lldb/DataFormatters/TypeSummary.h +++ b/include/lldb/DataFormatters/TypeSummary.h @@ -28,6 +28,32 @@ #include "lldb/Symbol/Type.h" namespace lldb_private { + class TypeSummaryOptions + { + public: + TypeSummaryOptions (); + TypeSummaryOptions (const TypeSummaryOptions& rhs); + + TypeSummaryOptions& + operator = (const TypeSummaryOptions& rhs); + + lldb::LanguageType + GetLanguage () const; + + lldb::TypeSummaryCapping + GetCapping () const; + + TypeSummaryOptions& + SetLanguage (lldb::LanguageType); + + TypeSummaryOptions& + SetCapping (lldb::TypeSummaryCapping); + + ~TypeSummaryOptions() = default; + private: + lldb::LanguageType m_lang; + lldb::TypeSummaryCapping m_capping; + }; class TypeSummaryImpl { @@ -313,7 +339,8 @@ namespace lldb_private { // for us to generate its summary virtual bool FormatObject (ValueObject *valobj, - std::string& dest) = 0; + std::string& dest, + const TypeSummaryOptions& options) = 0; virtual std::string GetDescription () = 0; @@ -372,7 +399,8 @@ namespace lldb_private { virtual bool FormatObject(ValueObject *valobj, - std::string& dest); + std::string& dest, + const TypeSummaryOptions& options); virtual std::string GetDescription(); @@ -397,10 +425,11 @@ namespace lldb_private { // summaries implemented via a C++ function struct CXXFunctionSummaryFormat : public TypeSummaryImpl { - // we should convert these to SBValue and SBStream if we ever cross // the boundary towards the external world - typedef bool (*Callback)(ValueObject& valobj, Stream& dest); + typedef bool (*Callback)(ValueObject&, + Stream&, + const TypeSummaryOptions&); Callback m_impl; std::string m_description; @@ -443,7 +472,8 @@ namespace lldb_private { virtual bool FormatObject (ValueObject *valobj, - std::string& dest); + std::string& dest, + const TypeSummaryOptions& options); virtual std::string GetDescription (); @@ -517,7 +547,8 @@ namespace lldb_private { virtual bool FormatObject (ValueObject *valobj, - std::string& dest); + std::string& dest, + const TypeSummaryOptions& options); virtual std::string GetDescription (); diff --git a/include/lldb/DataFormatters/TypeSynthetic.h b/include/lldb/DataFormatters/TypeSynthetic.h index a25f11d64392..675c43b1f311 100644 --- a/include/lldb/DataFormatters/TypeSynthetic.h +++ b/include/lldb/DataFormatters/TypeSynthetic.h @@ -24,8 +24,6 @@ #include "lldb/lldb-enumerations.h" #include "lldb/Core/ValueObject.h" -#include "lldb/Interpreter/ScriptInterpreterPython.h" -#include "lldb/Symbol/Type.h" namespace lldb_private { class SyntheticChildrenFrontEnd @@ -81,14 +79,71 @@ namespace lldb_private { virtual bool MightHaveChildren () = 0; + // if this function returns a non-null ValueObject, then the returned ValueObject will stand + // for this ValueObject whenever a "value" request is made to this ValueObject + virtual lldb::ValueObjectSP + GetSyntheticValue () { return nullptr; } + typedef std::shared_ptr<SyntheticChildrenFrontEnd> SharedPointer; typedef std::unique_ptr<SyntheticChildrenFrontEnd> AutoPointer; + protected: + lldb::ValueObjectSP + CreateValueObjectFromExpression (const char* name, + const char* expression, + const ExecutionContext& exe_ctx); + + lldb::ValueObjectSP + CreateValueObjectFromAddress (const char* name, + uint64_t address, + const ExecutionContext& exe_ctx, + ClangASTType type); + + lldb::ValueObjectSP + CreateValueObjectFromData (const char* name, + const DataExtractor& data, + const ExecutionContext& exe_ctx, + ClangASTType type); + private: bool m_valid; DISALLOW_COPY_AND_ASSIGN(SyntheticChildrenFrontEnd); }; + class SyntheticValueProviderFrontEnd : public SyntheticChildrenFrontEnd + { + public: + SyntheticValueProviderFrontEnd (ValueObject &backend) : + SyntheticChildrenFrontEnd(backend) + {} + + virtual + ~SyntheticValueProviderFrontEnd () + { + } + + virtual size_t + CalculateNumChildren () { return 0; } + + virtual lldb::ValueObjectSP + GetChildAtIndex (size_t idx) { return nullptr; } + + virtual size_t + GetIndexOfChildWithName (const ConstString &name) { return UINT32_MAX; } + + virtual bool + Update () { return false; } + + virtual bool + MightHaveChildren () { return false; } + + virtual lldb::ValueObjectSP + GetSyntheticValue () = 0; + + private: + DISALLOW_COPY_AND_ASSIGN(SyntheticValueProviderFrontEnd); + }; + class SyntheticChildren { public: @@ -328,37 +383,10 @@ namespace lldb_private { } void - AddExpressionPath (const std::string& path) - { - 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.push_back(path); - else - m_expression_paths.push_back(std::string(".") + path); - } + AddExpressionPath (const std::string& path); bool - SetExpressionPathAtIndex (size_t i, const std::string& path) - { - 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; - } + SetExpressionPathAtIndex (size_t i, const std::string& path); bool IsScripted () @@ -410,24 +438,7 @@ namespace lldb_private { } virtual size_t - GetIndexOfChildWithName (const ConstString &name) - { - const char* name_cstr = name.GetCString(); - for (size_t i = 0; i < filter->GetCount(); i++) - { - const char* expr_cstr = filter->GetExpressionPathAtIndex(i); - if (expr_cstr) - { - if (*expr_cstr == '.') - expr_cstr++; - else if (*expr_cstr == '-' && *(expr_cstr+1) == '>') - expr_cstr += 2; - } - if (!::strcmp(name_cstr, expr_cstr)) - return i; - } - return UINT32_MAX; - } + GetIndexOfChildWithName (const ConstString &name); typedef std::shared_ptr<SyntheticChildrenFrontEnd> SharedPointer; @@ -548,50 +559,28 @@ namespace lldb_private { ValueObject &backend); bool - IsValid () - { - return m_wrapper_sp.get() != nullptr && m_wrapper_sp->operator bool() && m_interpreter != nullptr; - } + IsValid (); virtual ~FrontEnd (); virtual size_t - CalculateNumChildren () - { - if (!m_wrapper_sp || m_interpreter == NULL) - return 0; - return m_interpreter->CalculateNumChildren(m_wrapper_sp); - } + CalculateNumChildren (); virtual lldb::ValueObjectSP GetChildAtIndex (size_t idx); virtual bool - Update () - { - if (!m_wrapper_sp || m_interpreter == NULL) - return false; - - return m_interpreter->UpdateSynthProviderInstance(m_wrapper_sp); - } + Update (); virtual bool - MightHaveChildren () - { - if (!m_wrapper_sp || m_interpreter == NULL) - return false; - - return m_interpreter->MightHaveChildrenSynthProviderInstance(m_wrapper_sp); - } + MightHaveChildren (); virtual size_t - GetIndexOfChildWithName (const ConstString &name) - { - if (!m_wrapper_sp || m_interpreter == NULL) - return UINT32_MAX; - return m_interpreter->GetIndexOfChildWithName(m_wrapper_sp, name.GetCString()); - } + GetIndexOfChildWithName (const ConstString &name); + + virtual lldb::ValueObjectSP + GetSyntheticValue (); typedef std::shared_ptr<SyntheticChildrenFrontEnd> SharedPointer; diff --git a/include/lldb/DataFormatters/TypeValidator.h b/include/lldb/DataFormatters/TypeValidator.h new file mode 100644 index 000000000000..b501e47943fa --- /dev/null +++ b/include/lldb/DataFormatters/TypeValidator.h @@ -0,0 +1,280 @@ +//===-- TypeValidator.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_TypeValidator_h_ +#define lldb_TypeValidator_h_ + +// C Includes + +// C++ Includes +#include <string> +#include <functional> + +// Other libraries and framework includes + +// Project includes +#include "lldb/lldb-public.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-private-enumerations.h" + +namespace lldb_private { + +class TypeValidatorImpl +{ +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; + }; + + TypeValidatorImpl (const Flags& flags = Flags()); + + typedef std::shared_ptr<TypeValidatorImpl> SharedPointer; + typedef bool(*ValueCallback)(void*, ConstString, const lldb::TypeValidatorImplSP&); + + virtual ~TypeValidatorImpl (); + + bool + Cascades () const + { + return m_flags.GetCascades(); + } + bool + SkipsPointers () const + { + return m_flags.GetSkipPointers(); + } + bool + SkipsReferences () const + { + 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); + } + + uint32_t& + GetRevision () + { + return m_my_revision; + } + + enum class Type + { + eTypeUnknown, + eTypeCXX + }; + + struct ValidationResult { + TypeValidatorResult m_result; + std::string m_message; + }; + + virtual Type + GetType () + { + return Type::eTypeUnknown; + } + + // we are using a ValueObject* instead of a ValueObjectSP because we do not need to hold on to this for + // extended periods of time and we trust the ValueObject to stay around for as long as it is required + // for us to generate its value + virtual ValidationResult + FormatObject (ValueObject *valobj) const = 0; + + virtual std::string + GetDescription() = 0; + + static ValidationResult + Success (); + + static ValidationResult + Failure (std::string message); + +protected: + Flags m_flags; + uint32_t m_my_revision; + +private: + DISALLOW_COPY_AND_ASSIGN(TypeValidatorImpl); +}; + +class TypeValidatorImpl_CXX : public TypeValidatorImpl +{ +public: + typedef std::function<TypeValidatorImpl::ValidationResult(ValueObject* valobj)> ValidatorFunction; + + TypeValidatorImpl_CXX (ValidatorFunction f, std::string d, const TypeValidatorImpl::Flags& flags = Flags()); + + typedef std::shared_ptr<TypeValidatorImpl_CXX> SharedPointer; + typedef bool(*ValueCallback)(void*, ConstString, const TypeValidatorImpl_CXX::SharedPointer&); + + virtual ~TypeValidatorImpl_CXX (); + + ValidatorFunction + GetValidatorFunction () const + { + return m_validator_function; + } + + void + SetValidatorFunction (ValidatorFunction f) + { + m_validator_function = f; + } + + virtual TypeValidatorImpl::Type + GetType () + { + return TypeValidatorImpl::Type::eTypeCXX; + } + + virtual ValidationResult + FormatObject (ValueObject *valobj) const; + + virtual std::string + GetDescription(); + +protected: + std::string m_description; + ValidatorFunction m_validator_function; + +private: + DISALLOW_COPY_AND_ASSIGN(TypeValidatorImpl_CXX); +}; + + +} // namespace lldb_private + +#endif // lldb_TypeValidator_h_ diff --git a/include/lldb/DataFormatters/ValueObjectPrinter.h b/include/lldb/DataFormatters/ValueObjectPrinter.h index bfe2d9c402d3..235d5389ee75 100644 --- a/include/lldb/DataFormatters/ValueObjectPrinter.h +++ b/include/lldb/DataFormatters/ValueObjectPrinter.h @@ -26,44 +26,43 @@ namespace lldb_private { struct DumpValueObjectOptions { - uint32_t m_max_ptr_depth; - uint32_t m_max_depth; - bool m_show_types; - bool m_show_location; - bool m_use_objc; - lldb::DynamicValueType m_use_dynamic; - bool m_use_synthetic; - bool m_scope_already_checked; - bool m_flat_output; - uint32_t m_omit_summary_depth; - bool m_ignore_cap; - lldb::Format m_format; + uint32_t m_max_ptr_depth = 0; + uint32_t m_max_depth = UINT32_MAX; + lldb::DynamicValueType m_use_dynamic = lldb::eNoDynamicValues; + uint32_t m_omit_summary_depth = 0; + lldb::Format m_format = lldb::eFormatDefault; lldb::TypeSummaryImplSP m_summary_sp; std::string m_root_valobj_name; - bool m_hide_root_type; - bool m_hide_name; - bool m_hide_value; - bool m_be_raw; + bool m_use_synthetic : 1; + bool m_scope_already_checked : 1; + bool m_flat_output : 1; + bool m_ignore_cap : 1; + bool m_show_types : 1; + bool m_show_location : 1; + bool m_use_objc : 1; + bool m_hide_root_type : 1; + bool m_hide_name : 1; + bool m_hide_value : 1; + bool m_run_validator : 1; + bool m_use_type_display_name : 1; + bool m_allow_oneliner_mode : 1; DumpValueObjectOptions() : - m_max_ptr_depth(0), - m_max_depth(UINT32_MAX), - m_show_types(false), - m_show_location(false), - m_use_objc(false), - m_use_dynamic(lldb::eNoDynamicValues), + m_summary_sp(), + m_root_valobj_name(), m_use_synthetic(true), m_scope_already_checked(false), m_flat_output(false), - m_omit_summary_depth(0), m_ignore_cap(false), - m_format (lldb::eFormatDefault), - m_summary_sp(), - m_root_valobj_name(), - m_hide_root_type(false), // provide a special compact display for "po" - m_hide_name(false), // provide a special compact display for "po" - m_hide_value(false), // provide a special compact display for "po" - m_be_raw(false) + m_show_types(false), + m_show_location(false), + m_use_objc(false), + m_hide_root_type(false), + m_hide_name(false), + m_hide_value(false), + m_run_validator(false), + m_use_type_display_name(true), + m_allow_oneliner_mode(true) {} static const DumpValueObjectOptions @@ -74,26 +73,7 @@ struct DumpValueObjectOptions return g_default_options; } - DumpValueObjectOptions (const DumpValueObjectOptions& rhs) : - m_max_ptr_depth(rhs.m_max_ptr_depth), - m_max_depth(rhs.m_max_depth), - m_show_types(rhs.m_show_types), - m_show_location(rhs.m_show_location), - m_use_objc(rhs.m_use_objc), - m_use_dynamic(rhs.m_use_dynamic), - m_use_synthetic(rhs.m_use_synthetic), - m_scope_already_checked(rhs.m_scope_already_checked), - m_flat_output(rhs.m_flat_output), - m_omit_summary_depth(rhs.m_omit_summary_depth), - m_ignore_cap(rhs.m_ignore_cap), - m_format(rhs.m_format), - m_summary_sp(rhs.m_summary_sp), - m_root_valobj_name(rhs.m_root_valobj_name), - m_hide_root_type(rhs.m_hide_root_type), - m_hide_name(rhs.m_hide_name), - m_hide_value(rhs.m_hide_value), - m_be_raw(rhs.m_be_raw) - {} + DumpValueObjectOptions (const DumpValueObjectOptions& rhs) = default; DumpValueObjectOptions& SetMaximumPointerDepth(uint32_t depth = 0) @@ -183,26 +163,15 @@ struct DumpValueObjectOptions } DumpValueObjectOptions& - SetRawDisplay(bool raw = false) + SetRawDisplay() { - if (raw) - { - SetUseSyntheticValue(false); - SetOmitSummaryDepth(UINT32_MAX); - SetIgnoreCap(true); - SetHideName(false); - SetHideValue(false); - m_be_raw = true; - } - else - { - SetUseSyntheticValue(true); - SetOmitSummaryDepth(0); - SetIgnoreCap(false); - SetHideName(false); - SetHideValue(false); - m_be_raw = false; - } + SetUseSyntheticValue(false); + SetOmitSummaryDepth(UINT32_MAX); + SetIgnoreCap(true); + SetHideName(false); + SetHideValue(false); + SetUseTypeDisplayName(false); + SetAllowOnelinerMode(false); return *this; } @@ -250,8 +219,30 @@ struct DumpValueObjectOptions m_hide_value = hide_value; return *this; } -}; + DumpValueObjectOptions& + SetRunValidator (bool run = true) + { + m_run_validator = run; + return *this; + } + + DumpValueObjectOptions& + SetUseTypeDisplayName (bool dis = false) + { + m_use_type_display_name = dis; + return *this; + } + + DumpValueObjectOptions& + SetAllowOnelinerMode (bool oneliner = false) + { + m_allow_oneliner_mode = oneliner; + return *this; + } + +}; + class ValueObjectPrinter { public: @@ -285,7 +276,7 @@ protected: uint32_t curr_depth); bool - GetDynamicValueIfNeeded (); + GetMostSpecializedValue (); const char* GetDescriptionForDisplay (); @@ -297,6 +288,9 @@ protected: ShouldPrintValueObject (); bool + ShouldPrintValidation (); + + bool IsNil (); bool @@ -309,6 +303,12 @@ protected: IsAggregate (); bool + PrintValidationMarkerIfNeeded (); + + bool + PrintValidationErrorIfNeeded (); + + bool PrintLocationIfNeeded (); bool @@ -385,6 +385,7 @@ private: std::string m_value; std::string m_summary; std::string m_error; + std::pair<TypeValidatorResult,std::string> m_validation; friend struct StringSummaryFormat; |