Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:59

0001 //===-- ValueObjectSyntheticFilter.h ----------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_VALUEOBJECT_VALUEOBJECTSYNTHETICFILTER_H
0010 #define LLDB_VALUEOBJECT_VALUEOBJECTSYNTHETICFILTER_H
0011 
0012 #include "lldb/Symbol/CompilerType.h"
0013 #include "lldb/Utility/ConstString.h"
0014 #include "lldb/ValueObject/ValueObject.h"
0015 #include "lldb/lldb-defines.h"
0016 #include "lldb/lldb-enumerations.h"
0017 #include "lldb/lldb-forward.h"
0018 #include "lldb/lldb-private-enumerations.h"
0019 
0020 #include <cstdint>
0021 #include <memory>
0022 #include <optional>
0023 
0024 #include <cstddef>
0025 
0026 namespace lldb_private {
0027 class Declaration;
0028 class Status;
0029 class SyntheticChildrenFrontEnd;
0030 
0031 /// A ValueObject that obtains its children from some source other than
0032 /// real information.
0033 /// This is currently used to implement Python-based children and filters but
0034 /// you can bind it to any source of synthetic information and have it behave
0035 /// accordingly.
0036 class ValueObjectSynthetic : public ValueObject {
0037 public:
0038   ~ValueObjectSynthetic() override;
0039 
0040   std::optional<uint64_t> GetByteSize() override;
0041 
0042   ConstString GetTypeName() override;
0043 
0044   ConstString GetQualifiedTypeName() override;
0045 
0046   ConstString GetDisplayTypeName() override;
0047 
0048   bool MightHaveChildren() override;
0049 
0050   llvm::Expected<uint32_t> CalculateNumChildren(uint32_t max) override;
0051 
0052   lldb::ValueType GetValueType() const override;
0053 
0054   lldb::ValueObjectSP GetChildAtIndex(uint32_t idx,
0055                                       bool can_create = true) override;
0056 
0057   lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name,
0058                                              bool can_create = true) override;
0059 
0060   size_t GetIndexOfChildWithName(llvm::StringRef name) override;
0061 
0062   lldb::ValueObjectSP
0063   GetDynamicValue(lldb::DynamicValueType valueType) override;
0064 
0065   bool IsInScope() override;
0066 
0067   bool HasSyntheticValue() override { return false; }
0068 
0069   bool IsSynthetic() override { return true; }
0070 
0071   void CalculateSyntheticValue() override {}
0072 
0073   bool IsDynamic() override {
0074     return ((m_parent != nullptr) ? m_parent->IsDynamic() : false);
0075   }
0076 
0077   lldb::ValueObjectSP GetStaticValue() override {
0078     return ((m_parent != nullptr) ? m_parent->GetStaticValue() : GetSP());
0079   }
0080 
0081   virtual lldb::DynamicValueType GetDynamicValueType() {
0082     return ((m_parent != nullptr) ? m_parent->GetDynamicValueType()
0083                                   : lldb::eNoDynamicValues);
0084   }
0085 
0086   lldb::VariableSP GetVariable() override {
0087     return m_parent != nullptr ? m_parent->GetVariable() : nullptr;
0088   }
0089 
0090   ValueObject *GetParent() override {
0091     return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
0092   }
0093 
0094   const ValueObject *GetParent() const override {
0095     return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
0096   }
0097 
0098   lldb::ValueObjectSP GetNonSyntheticValue() override;
0099 
0100   bool CanProvideValue() override;
0101 
0102   bool DoesProvideSyntheticValue() override {
0103     return (UpdateValueIfNeeded(), m_provides_value == eLazyBoolYes);
0104   }
0105 
0106   bool GetIsConstant() const override { return false; }
0107 
0108   bool SetValueFromCString(const char *value_str, Status &error) override;
0109 
0110   void SetFormat(lldb::Format format) override;
0111 
0112   lldb::LanguageType GetPreferredDisplayLanguage() override;
0113 
0114   void SetPreferredDisplayLanguage(lldb::LanguageType);
0115 
0116   bool IsSyntheticChildrenGenerated() override;
0117 
0118   void SetSyntheticChildrenGenerated(bool b) override;
0119 
0120   bool GetDeclaration(Declaration &decl) override;
0121 
0122   uint64_t GetLanguageFlags() override;
0123 
0124   void SetLanguageFlags(uint64_t flags) override;
0125 
0126 protected:
0127   bool UpdateValue() override;
0128 
0129   LazyBool CanUpdateWithInvalidExecutionContext() override {
0130     return eLazyBoolYes;
0131   }
0132 
0133   CompilerType GetCompilerTypeImpl() override;
0134 
0135   virtual void CreateSynthFilter();
0136 
0137   // we need to hold on to the SyntheticChildren because someone might delete
0138   // the type binding while we are alive
0139   lldb::SyntheticChildrenSP m_synth_sp;
0140   std::unique_ptr<SyntheticChildrenFrontEnd> m_synth_filter_up;
0141 
0142   typedef std::map<uint32_t, ValueObject *> ByIndexMap;
0143   typedef std::map<const char *, uint32_t> NameToIndexMap;
0144   typedef std::vector<lldb::ValueObjectSP> SyntheticChildrenCache;
0145 
0146   typedef ByIndexMap::iterator ByIndexIterator;
0147   typedef NameToIndexMap::iterator NameToIndexIterator;
0148 
0149   std::mutex m_child_mutex;
0150   /// Guarded by m_child_mutex;
0151   ByIndexMap m_children_byindex;
0152   /// Guarded by m_child_mutex;
0153   NameToIndexMap m_name_toindex;
0154   /// Guarded by m_child_mutex;
0155   SyntheticChildrenCache m_synthetic_children_cache;
0156 
0157   // FIXME: use the ValueObject's  ChildrenManager instead of a special purpose
0158   // solution.
0159   uint32_t m_synthetic_children_count;
0160 
0161   ConstString m_parent_type_name;
0162 
0163   LazyBool m_might_have_children;
0164 
0165   LazyBool m_provides_value;
0166 
0167 private:
0168   friend class ValueObject;
0169   ValueObjectSynthetic(ValueObject &parent, lldb::SyntheticChildrenSP filter);
0170 
0171   void CopyValueData(ValueObject *source);
0172 
0173   ValueObjectSynthetic(const ValueObjectSynthetic &) = delete;
0174   const ValueObjectSynthetic &operator=(const ValueObjectSynthetic &) = delete;
0175 };
0176 
0177 } // namespace lldb_private
0178 
0179 #endif // LLDB_VALUEOBJECT_VALUEOBJECTSYNTHETICFILTER_H