251 lines · c
1//===-- LibCxx.h ---------------------------------------------------*- C++2//-*-===//3//4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.5// See https://llvm.org/LICENSE.txt for license information.6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXX_H11#define LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXX_H12 13#include "lldb/DataFormatters/TypeSummary.h"14#include "lldb/DataFormatters/TypeSynthetic.h"15#include "lldb/Utility/Stream.h"16#include "lldb/ValueObject/ValueObject.h"17 18namespace lldb_private {19namespace formatters {20 21/// Find a child member of \c obj_sp, trying all alternative names in order.22lldb::ValueObjectSP23GetChildMemberWithName(ValueObject &obj,24 llvm::ArrayRef<ConstString> alternative_names);25 26lldb::ValueObjectSP GetFirstValueOfLibCXXCompressedPair(ValueObject &pair);27lldb::ValueObjectSP GetSecondValueOfLibCXXCompressedPair(ValueObject &pair);28 29/// Returns the ValueObjectSP of the child of \c obj. If \c obj has no30/// child named \c child_name, returns the __compressed_pair child instead31/// with \c compressed_pair_name, if one exists.32///33/// Latest libc++ wrap the compressed children in an anonymous structure.34/// The \c anon_struct_idx indicates the location of this struct.35///36/// The returned boolean is \c true if the returned child was has an old-style37/// libc++ __compressed_pair layout.38///39/// If no child was found returns a nullptr.40std::pair<lldb::ValueObjectSP, bool>41GetValueOrOldCompressedPair(ValueObject &obj, size_t anon_struct_idx,42 llvm::StringRef child_name,43 llvm::StringRef compressed_pair_name);44bool isStdTemplate(ConstString type_name, llvm::StringRef type);45 46bool LibcxxStringSummaryProviderASCII(47 ValueObject &valobj, Stream &stream,48 const TypeSummaryOptions &summary_options); // libc++ std::string49 50bool LibcxxStringSummaryProviderUTF16(51 ValueObject &valobj, Stream &stream,52 const TypeSummaryOptions &summary_options); // libc++ std::u16string53 54bool LibcxxStringSummaryProviderUTF32(55 ValueObject &valobj, Stream &stream,56 const TypeSummaryOptions &summary_options); // libc++ std::u32string57 58bool LibcxxWStringSummaryProvider(59 ValueObject &valobj, Stream &stream,60 const TypeSummaryOptions &options); // libc++ std::wstring61 62bool LibcxxStringViewSummaryProviderASCII(63 ValueObject &valueObj, Stream &stream,64 const TypeSummaryOptions &summary_options); // libc++ std::string_view65 66bool LibcxxStringViewSummaryProviderUTF16(67 ValueObject &valobj, Stream &stream,68 const TypeSummaryOptions &summary_options); // libc++ std::u16string_view69 70bool LibcxxStringViewSummaryProviderUTF32(71 ValueObject &valobj, Stream &stream,72 const TypeSummaryOptions &summary_options); // libc++ std::u32string_view73 74bool LibcxxWStringViewSummaryProvider(75 ValueObject &valobj, Stream &stream,76 const TypeSummaryOptions &options); // libc++ std::wstring_view77 78bool LibcxxStdSliceArraySummaryProvider(79 ValueObject &valobj, Stream &stream,80 const TypeSummaryOptions &options); // libc++ std::slice_array81 82bool LibcxxSmartPointerSummaryProvider(83 ValueObject &valobj, Stream &stream,84 const TypeSummaryOptions85 &options); // libc++ std::shared_ptr<> and std::weak_ptr<>86 87// libc++ std::unique_ptr<>88bool LibcxxUniquePointerSummaryProvider(ValueObject &valobj, Stream &stream,89 const TypeSummaryOptions &options);90 91bool LibcxxFunctionSummaryProvider(92 ValueObject &valobj, Stream &stream,93 const TypeSummaryOptions &options); // libc++ std::function<>94 95SyntheticChildrenFrontEnd *96LibcxxVectorBoolSyntheticFrontEndCreator(CXXSyntheticChildren *,97 lldb::ValueObjectSP);98 99/// Formatter for libc++ std::span<>.100bool LibcxxSpanSummaryProvider(ValueObject &valobj, Stream &stream,101 const TypeSummaryOptions &options);102 103SyntheticChildrenFrontEnd *104LibCxxVectorIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *,105 lldb::ValueObjectSP);106 107class LibcxxSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {108public:109 LibcxxSharedPtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);110 111 llvm::Expected<uint32_t> CalculateNumChildren() override;112 113 lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;114 115 lldb::ChildCacheState Update() override;116 117 llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override;118 119 ~LibcxxSharedPtrSyntheticFrontEnd() override;120 121private:122 ValueObject *m_cntrl;123 ValueObject *m_ptr_obj;124};125 126class LibcxxUniquePtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {127public:128 LibcxxUniquePtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);129 130 llvm::Expected<uint32_t> CalculateNumChildren() override;131 132 lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;133 134 lldb::ChildCacheState Update() override;135 136 llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override;137 138 ~LibcxxUniquePtrSyntheticFrontEnd() override;139 140private:141 lldb::ValueObjectSP m_value_ptr_sp;142 lldb::ValueObjectSP m_deleter_sp;143};144 145SyntheticChildrenFrontEnd *146LibcxxBitsetSyntheticFrontEndCreator(CXXSyntheticChildren *,147 lldb::ValueObjectSP);148 149SyntheticChildrenFrontEnd *150LibcxxSharedPtrSyntheticFrontEndCreator(CXXSyntheticChildren *,151 lldb::ValueObjectSP);152 153SyntheticChildrenFrontEnd *154LibcxxUniquePtrSyntheticFrontEndCreator(CXXSyntheticChildren *,155 lldb::ValueObjectSP);156 157SyntheticChildrenFrontEnd *158LibcxxStdVectorSyntheticFrontEndCreator(CXXSyntheticChildren *,159 lldb::ValueObjectSP);160 161SyntheticChildrenFrontEnd *162LibcxxStdValarraySyntheticFrontEndCreator(CXXSyntheticChildren *,163 lldb::ValueObjectSP);164 165SyntheticChildrenFrontEnd *166LibcxxStdSliceArraySyntheticFrontEndCreator(CXXSyntheticChildren *,167 lldb::ValueObjectSP);168 169SyntheticChildrenFrontEnd *170LibcxxStdProxyArraySyntheticFrontEndCreator(CXXSyntheticChildren *,171 lldb::ValueObjectSP);172 173SyntheticChildrenFrontEnd *174LibcxxStdListSyntheticFrontEndCreator(CXXSyntheticChildren *,175 lldb::ValueObjectSP);176 177SyntheticChildrenFrontEnd *178LibcxxStdForwardListSyntheticFrontEndCreator(CXXSyntheticChildren *,179 lldb::ValueObjectSP);180 181SyntheticChildrenFrontEnd *182LibcxxStdMapSyntheticFrontEndCreator(CXXSyntheticChildren *,183 lldb::ValueObjectSP);184 185SyntheticChildrenFrontEnd *186LibCxxMapIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *,187 lldb::ValueObjectSP);188 189SyntheticChildrenFrontEnd *190LibcxxStdUnorderedMapSyntheticFrontEndCreator(CXXSyntheticChildren *,191 lldb::ValueObjectSP);192 193SyntheticChildrenFrontEnd *194LibCxxUnorderedMapIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *,195 lldb::ValueObjectSP);196 197SyntheticChildrenFrontEnd *LibcxxQueueFrontEndCreator(CXXSyntheticChildren *,198 lldb::ValueObjectSP);199 200SyntheticChildrenFrontEnd *LibcxxTupleFrontEndCreator(CXXSyntheticChildren *,201 lldb::ValueObjectSP);202 203SyntheticChildrenFrontEnd *204LibcxxOptionalSyntheticFrontEndCreator(CXXSyntheticChildren *,205 lldb::ValueObjectSP valobj_sp);206 207SyntheticChildrenFrontEnd *208LibcxxVariantFrontEndCreator(CXXSyntheticChildren *,209 lldb::ValueObjectSP valobj_sp);210 211SyntheticChildrenFrontEnd *212LibcxxStdSpanSyntheticFrontEndCreator(CXXSyntheticChildren *,213 lldb::ValueObjectSP);214 215SyntheticChildrenFrontEnd *216LibcxxStdRangesRefViewSyntheticFrontEndCreator(CXXSyntheticChildren *,217 lldb::ValueObjectSP);218 219bool LibcxxChronoSysSecondsSummaryProvider(220 ValueObject &valobj, Stream &stream,221 const TypeSummaryOptions &options); // libc++ std::chrono::sys_seconds222 223bool LibcxxChronoSysDaysSummaryProvider(224 ValueObject &valobj, Stream &stream,225 const TypeSummaryOptions &options); // libc++ std::chrono::sys_days226 227bool LibcxxChronoLocalSecondsSummaryProvider(228 ValueObject &valobj, Stream &stream,229 const TypeSummaryOptions &options); // libc++ std::chrono::local_seconds230 231bool LibcxxChronoLocalDaysSummaryProvider(232 ValueObject &valobj, Stream &stream,233 const TypeSummaryOptions &options); // libc++ std::chrono::local_days234 235bool LibcxxChronoMonthSummaryProvider(236 ValueObject &valobj, Stream &stream,237 const TypeSummaryOptions &options); // libc++ std::chrono::month238 239bool LibcxxChronoWeekdaySummaryProvider(240 ValueObject &valobj, Stream &stream,241 const TypeSummaryOptions &options); // libc++ std::chrono::weekday242 243bool LibcxxChronoYearMonthDaySummaryProvider(244 ValueObject &valobj, Stream &stream,245 const TypeSummaryOptions &options); // libc++ std::chrono::year_month_day246 247} // namespace formatters248} // namespace lldb_private249 250#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXX_H251