1296417Sdim//===-- ValueObjectSyntheticFilter.h ----------------------------*- C++ -*-===// 2254721Semaste// 3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4353358Sdim// See https://llvm.org/LICENSE.txt for license information. 5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6254721Semaste// 7254721Semaste//===----------------------------------------------------------------------===// 8254721Semaste 9254721Semaste#ifndef liblldb_ValueObjectSyntheticFilter_h_ 10254721Semaste#define liblldb_ValueObjectSyntheticFilter_h_ 11254721Semaste 12254721Semaste#include "lldb/Core/ValueObject.h" 13344779Sdim#include "lldb/Symbol/CompilerType.h" 14344779Sdim#include "lldb/Utility/ConstString.h" 15344779Sdim#include "lldb/lldb-defines.h" 16344779Sdim#include "lldb/lldb-enumerations.h" 17344779Sdim#include "lldb/lldb-forward.h" 18344779Sdim#include "lldb/lldb-private-enumerations.h" 19254721Semaste 20344779Sdim#include <cstdint> 21321369Sdim#include <memory> 22321369Sdim 23344779Sdim#include <stddef.h> 24321369Sdim 25254721Semastenamespace lldb_private { 26321369Sdimclass Declaration; 27321369Sdimclass Status; 28321369Sdimclass SyntheticChildrenFrontEnd; 29254721Semaste 30254721Semaste// A ValueObject that obtains its children from some source other than 31254721Semaste// real information 32341825Sdim// This is currently used to implement Python-based children and filters but 33341825Sdim// you can bind it to any source of synthetic information and have it behave 34341825Sdim// accordingly 35314564Sdimclass ValueObjectSynthetic : public ValueObject { 36254721Semastepublic: 37314564Sdim ~ValueObjectSynthetic() override; 38254721Semaste 39314564Sdim uint64_t GetByteSize() override; 40254721Semaste 41314564Sdim ConstString GetTypeName() override; 42254721Semaste 43314564Sdim ConstString GetQualifiedTypeName() override; 44254721Semaste 45314564Sdim ConstString GetDisplayTypeName() override; 46254721Semaste 47314564Sdim bool MightHaveChildren() override; 48254721Semaste 49314564Sdim size_t CalculateNumChildren(uint32_t max) override; 50254721Semaste 51314564Sdim lldb::ValueType GetValueType() const override; 52288943Sdim 53314564Sdim lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create) override; 54296417Sdim 55353358Sdim lldb::ValueObjectSP GetChildMemberWithName(ConstString name, 56314564Sdim bool can_create) override; 57314564Sdim 58353358Sdim size_t GetIndexOfChildWithName(ConstString name) override; 59314564Sdim 60314564Sdim lldb::ValueObjectSP 61314564Sdim GetDynamicValue(lldb::DynamicValueType valueType) override; 62314564Sdim 63314564Sdim bool IsInScope() override; 64314564Sdim 65314564Sdim bool HasSyntheticValue() override { return false; } 66314564Sdim 67314564Sdim bool IsSynthetic() override { return true; } 68314564Sdim 69314564Sdim void CalculateSyntheticValue(bool use_synthetic) override {} 70314564Sdim 71314564Sdim bool IsDynamic() override { 72314564Sdim return ((m_parent != nullptr) ? m_parent->IsDynamic() : false); 73314564Sdim } 74314564Sdim 75314564Sdim lldb::ValueObjectSP GetStaticValue() override { 76314564Sdim return ((m_parent != nullptr) ? m_parent->GetStaticValue() : GetSP()); 77314564Sdim } 78314564Sdim 79314564Sdim virtual lldb::DynamicValueType GetDynamicValueType() { 80314564Sdim return ((m_parent != nullptr) ? m_parent->GetDynamicValueType() 81314564Sdim : lldb::eNoDynamicValues); 82314564Sdim } 83314564Sdim 84314564Sdim ValueObject *GetParent() override { 85314564Sdim return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr); 86314564Sdim } 87314564Sdim 88314564Sdim const ValueObject *GetParent() const override { 89314564Sdim return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr); 90314564Sdim } 91314564Sdim 92314564Sdim lldb::ValueObjectSP GetNonSyntheticValue() override; 93314564Sdim 94314564Sdim bool CanProvideValue() override; 95314564Sdim 96314564Sdim bool DoesProvideSyntheticValue() override { 97314564Sdim return (UpdateValueIfNeeded(), m_provides_value == eLazyBoolYes); 98314564Sdim } 99314564Sdim 100314564Sdim bool GetIsConstant() const override { return false; } 101314564Sdim 102321369Sdim bool SetValueFromCString(const char *value_str, Status &error) override; 103314564Sdim 104314564Sdim void SetFormat(lldb::Format format) override; 105314564Sdim 106314564Sdim lldb::LanguageType GetPreferredDisplayLanguage() override; 107314564Sdim 108314564Sdim void SetPreferredDisplayLanguage(lldb::LanguageType); 109314564Sdim 110314564Sdim bool IsSyntheticChildrenGenerated() override; 111314564Sdim 112314564Sdim void SetSyntheticChildrenGenerated(bool b) override; 113314564Sdim 114314564Sdim bool GetDeclaration(Declaration &decl) override; 115314564Sdim 116314564Sdim uint64_t GetLanguageFlags() override; 117314564Sdim 118314564Sdim void SetLanguageFlags(uint64_t flags) override; 119314564Sdim 120254721Semasteprotected: 121314564Sdim bool UpdateValue() override; 122254721Semaste 123314564Sdim LazyBool CanUpdateWithInvalidExecutionContext() override { 124314564Sdim return eLazyBoolYes; 125314564Sdim } 126254721Semaste 127314564Sdim CompilerType GetCompilerTypeImpl() override; 128254721Semaste 129314564Sdim virtual void CreateSynthFilter(); 130314564Sdim 131314564Sdim // we need to hold on to the SyntheticChildren because someone might delete 132314564Sdim // the type binding while we are alive 133314564Sdim lldb::SyntheticChildrenSP m_synth_sp; 134353358Sdim std::unique_ptr<SyntheticChildrenFrontEnd> m_synth_filter_up; 135314564Sdim 136360784Sdim typedef std::map<uint32_t, ValueObject *> ByIndexMap; 137360784Sdim typedef std::map<const char *, uint32_t> NameToIndexMap; 138360784Sdim typedef std::vector<lldb::ValueObjectSP> SyntheticChildrenCache; 139314564Sdim 140314564Sdim typedef ByIndexMap::iterator ByIndexIterator; 141314564Sdim typedef NameToIndexMap::iterator NameToIndexIterator; 142314564Sdim 143360784Sdim std::mutex m_child_mutex; 144360784Sdim /// Guarded by m_child_mutex; 145314564Sdim ByIndexMap m_children_byindex; 146360784Sdim /// Guarded by m_child_mutex; 147314564Sdim NameToIndexMap m_name_toindex; 148360784Sdim /// Guarded by m_child_mutex; 149360784Sdim SyntheticChildrenCache m_synthetic_children_cache; 150360784Sdim 151314564Sdim uint32_t m_synthetic_children_count; // FIXME use the ValueObject's 152314564Sdim // ChildrenManager instead of a special 153314564Sdim // purpose solution 154314564Sdim 155314564Sdim ConstString m_parent_type_name; 156314564Sdim 157314564Sdim LazyBool m_might_have_children; 158314564Sdim 159314564Sdim LazyBool m_provides_value; 160314564Sdim 161254721Semasteprivate: 162314564Sdim friend class ValueObject; 163314564Sdim ValueObjectSynthetic(ValueObject &parent, lldb::SyntheticChildrenSP filter); 164314564Sdim 165314564Sdim void CopyValueData(ValueObject *source); 166314564Sdim 167314564Sdim DISALLOW_COPY_AND_ASSIGN(ValueObjectSynthetic); 168254721Semaste}; 169254721Semaste 170254721Semaste} // namespace lldb_private 171254721Semaste 172296417Sdim#endif // liblldb_ValueObjectSyntheticFilter_h_ 173