LLDB  mainline
ValueObjectSyntheticFilter.h
Go to the documentation of this file.
1 //===-- ValueObjectSyntheticFilter.h ----------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_CORE_VALUEOBJECTSYNTHETICFILTER_H
10 #define LLDB_CORE_VALUEOBJECTSYNTHETICFILTER_H
11 
12 #include "lldb/Core/ValueObject.h"
15 #include "lldb/lldb-defines.h"
16 #include "lldb/lldb-enumerations.h"
17 #include "lldb/lldb-forward.h"
19 
20 #include <cstdint>
21 #include <memory>
22 
23 #include <cstddef>
24 
25 namespace lldb_private {
26 class Declaration;
27 class Status;
28 class SyntheticChildrenFrontEnd;
29 
30 /// A ValueObject that obtains its children from some source other than
31 /// real information.
32 /// This is currently used to implement Python-based children and filters but
33 /// you can bind it to any source of synthetic information and have it behave
34 /// accordingly.
36 public:
37  ~ValueObjectSynthetic() override;
38 
39  llvm::Optional<uint64_t> GetByteSize() override;
40 
41  ConstString GetTypeName() override;
42 
44 
46 
47  bool MightHaveChildren() override;
48 
49  size_t CalculateNumChildren(uint32_t max) override;
50 
51  lldb::ValueType GetValueType() const override;
52 
53  lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create) override;
54 
55  lldb::ValueObjectSP GetChildMemberWithName(ConstString name,
56  bool can_create) override;
57 
58  size_t GetIndexOfChildWithName(ConstString name) override;
59 
60  lldb::ValueObjectSP
61  GetDynamicValue(lldb::DynamicValueType valueType) override;
62 
63  bool IsInScope() override;
64 
65  bool HasSyntheticValue() override { return false; }
66 
67  bool IsSynthetic() override { return true; }
68 
69  void CalculateSyntheticValue() override {}
70 
71  bool IsDynamic() override {
72  return ((m_parent != nullptr) ? m_parent->IsDynamic() : false);
73  }
74 
75  lldb::ValueObjectSP GetStaticValue() override {
76  return ((m_parent != nullptr) ? m_parent->GetStaticValue() : GetSP());
77  }
78 
80  return ((m_parent != nullptr) ? m_parent->GetDynamicValueType()
82  }
83 
84  ValueObject *GetParent() override {
85  return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
86  }
87 
88  const ValueObject *GetParent() const override {
89  return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
90  }
91 
92  lldb::ValueObjectSP GetNonSyntheticValue() override;
93 
94  bool CanProvideValue() override;
95 
96  bool DoesProvideSyntheticValue() override {
98  }
99 
100  bool GetIsConstant() const override { return false; }
101 
102  bool SetValueFromCString(const char *value_str, Status &error) override;
103 
104  void SetFormat(lldb::Format format) override;
105 
107 
109 
110  bool IsSyntheticChildrenGenerated() override;
111 
112  void SetSyntheticChildrenGenerated(bool b) override;
113 
114  bool GetDeclaration(Declaration &decl) override;
115 
116  uint64_t GetLanguageFlags() override;
117 
118  void SetLanguageFlags(uint64_t flags) override;
119 
120 protected:
121  bool UpdateValue() override;
122 
124  return eLazyBoolYes;
125  }
126 
128 
129  virtual void CreateSynthFilter();
130 
131  // we need to hold on to the SyntheticChildren because someone might delete
132  // the type binding while we are alive
133  lldb::SyntheticChildrenSP m_synth_sp;
134  std::unique_ptr<SyntheticChildrenFrontEnd> m_synth_filter_up;
135 
136  typedef std::map<uint32_t, ValueObject *> ByIndexMap;
137  typedef std::map<const char *, uint32_t> NameToIndexMap;
138  typedef std::vector<lldb::ValueObjectSP> SyntheticChildrenCache;
139 
140  typedef ByIndexMap::iterator ByIndexIterator;
141  typedef NameToIndexMap::iterator NameToIndexIterator;
142 
143  std::mutex m_child_mutex;
144  /// Guarded by m_child_mutex;
146  /// Guarded by m_child_mutex;
148  /// Guarded by m_child_mutex;
150 
151  // FIXME: use the ValueObject's ChildrenManager instead of a special purpose
152  // solution.
154 
156 
158 
160 
161 private:
162  friend class ValueObject;
163  ValueObjectSynthetic(ValueObject &parent, lldb::SyntheticChildrenSP filter);
164 
165  void CopyValueData(ValueObject *source);
166 
167  ValueObjectSynthetic(const ValueObjectSynthetic &) = delete;
168  const ValueObjectSynthetic &operator=(const ValueObjectSynthetic &) = delete;
169 };
170 
171 } // namespace lldb_private
172 
173 #endif // LLDB_CORE_VALUEOBJECTSYNTHETICFILTER_H
lldb_private::ValueObjectSynthetic::m_provides_value
LazyBool m_provides_value
Definition: ValueObjectSyntheticFilter.h:159
lldb_private::ValueObjectSynthetic::ByIndexMap
std::map< uint32_t, ValueObject * > ByIndexMap
Definition: ValueObjectSyntheticFilter.h:136
lldb_private::ValueObjectSynthetic::m_synthetic_children_cache
SyntheticChildrenCache m_synthetic_children_cache
Guarded by m_child_mutex;.
Definition: ValueObjectSyntheticFilter.h:149
lldb_private::ValueObjectSynthetic::SetPreferredDisplayLanguage
void SetPreferredDisplayLanguage(lldb::LanguageType)
Definition: ValueObjectSyntheticFilter.cpp:380
lldb::Format
Format
Display format definitions.
Definition: lldb-enumerations.h:155
lldb_private::ValueObjectSynthetic::GetByteSize
llvm::Optional< uint64_t > GetByteSize() override
Definition: ValueObjectSyntheticFilter.cpp:124
lldb_private::ValueObjectSynthetic::NameToIndexIterator
NameToIndexMap::iterator NameToIndexIterator
Definition: ValueObjectSyntheticFilter.h:141
lldb_private::ValueObjectSynthetic::GetDynamicValueType
virtual lldb::DynamicValueType GetDynamicValueType()
Definition: ValueObjectSyntheticFilter.h:79
lldb_private::ValueObject::IsDynamic
virtual bool IsDynamic()
Definition: ValueObject.h:637
lldb_private::ValueObjectSynthetic::DoesProvideSyntheticValue
bool DoesProvideSyntheticValue() override
Definition: ValueObjectSyntheticFilter.h:96
lldb::eNoDynamicValues
@ eNoDynamicValues
Definition: lldb-enumerations.h:495
lldb_private::ValueObjectSynthetic::m_synthetic_children_count
uint32_t m_synthetic_children_count
Definition: ValueObjectSyntheticFilter.h:153
lldb_private::ValueObjectSynthetic::m_synth_filter_up
std::unique_ptr< SyntheticChildrenFrontEnd > m_synth_filter_up
Definition: ValueObjectSyntheticFilter.h:134
lldb_private::ValueObjectSynthetic::IsDynamic
bool IsDynamic() override
Definition: ValueObjectSyntheticFilter.h:71
lldb_private::ValueObjectSynthetic::GetIsConstant
bool GetIsConstant() const override
Definition: ValueObjectSyntheticFilter.h:100
lldb-defines.h
lldb_private::ValueObjectSynthetic::CreateSynthFilter
virtual void CreateSynthFilter()
Definition: ValueObjectSyntheticFilter.cpp:132
lldb_private::eLazyBoolYes
@ eLazyBoolYes
Definition: lldb-private-enumerations.h:115
lldb_private::ValueObjectSynthetic::GetParent
const ValueObject * GetParent() const override
Definition: ValueObjectSyntheticFilter.h:88
lldb_private::ValueObjectSynthetic::SetSyntheticChildrenGenerated
void SetSyntheticChildrenGenerated(bool b) override
Definition: ValueObjectSyntheticFilter.cpp:402
lldb_private::ValueObjectSynthetic::GetParent
ValueObject * GetParent() override
Definition: ValueObjectSyntheticFilter.h:84
lldb_private::ValueObjectSynthetic::SetLanguageFlags
void SetLanguageFlags(uint64_t flags) override
Definition: ValueObjectSyntheticFilter.cpp:421
lldb::LanguageType
LanguageType
Programming language type.
Definition: lldb-enumerations.h:436
lldb_private::ValueObjectSynthetic::~ValueObjectSynthetic
~ValueObjectSynthetic() override
lldb_private::ValueObject::ValueObjectSynthetic
friend class ValueObjectSynthetic
Definition: ValueObject.h:935
lldb_private::LazyBool
LazyBool
Definition: lldb-private-enumerations.h:115
lldb_private::ValueObjectSynthetic::GetDynamicValue
lldb::ValueObjectSP GetDynamicValue(lldb::DynamicValueType valueType) override
Definition: ValueObjectSyntheticFilter.cpp:109
lldb_private::ValueObjectSynthetic::UpdateValue
bool UpdateValue() override
Definition: ValueObjectSyntheticFilter.cpp:150
lldb_private::ValueObjectSynthetic::m_name_toindex
NameToIndexMap m_name_toindex
Guarded by m_child_mutex;.
Definition: ValueObjectSyntheticFilter.h:147
lldb-private-enumerations.h
lldb_private::ValueObjectSynthetic::m_child_mutex
std::mutex m_child_mutex
Definition: ValueObjectSyntheticFilter.h:143
lldb_private::ValueObjectSynthetic::IsSyntheticChildrenGenerated
bool IsSyntheticChildrenGenerated() override
Definition: ValueObjectSyntheticFilter.cpp:396
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::ValueObjectSynthetic::MightHaveChildren
bool MightHaveChildren() override
Find out if a ValueObject might have children.
Definition: ValueObjectSyntheticFilter.cpp:117
lldb_private::ValueObjectSynthetic::CalculateNumChildren
size_t CalculateNumChildren(uint32_t max) override
Should only be called by ValueObject::GetNumChildren().
Definition: ValueObjectSyntheticFilter.cpp:83
lldb_private::ValueObjectSynthetic::GetChildAtIndex
lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create) override
Definition: ValueObjectSyntheticFilter.cpp:235
lldb_private::ValueObject::GetStaticValue
virtual lldb::ValueObjectSP GetStaticValue()
Definition: ValueObject.h:590
lldb_private::ValueObject::GetSP
lldb::ValueObjectSP GetSP()
Definition: ValueObject.h:555
lldb_private::ValueObjectSynthetic::NameToIndexMap
std::map< const char *, uint32_t > NameToIndexMap
Definition: ValueObjectSyntheticFilter.h:137
lldb_private::ValueObjectSynthetic::GetDisplayTypeName
ConstString GetDisplayTypeName() override
Definition: ValueObjectSyntheticFilter.cpp:76
lldb_private::ValueObjectSynthetic::m_might_have_children
LazyBool m_might_have_children
Definition: ValueObjectSyntheticFilter.h:157
lldb_private::ConstString
Definition: ConstString.h:40
lldb-enumerations.h
lldb_private::ValueObject::UpdateValueIfNeeded
bool UpdateValueIfNeeded(bool update_format=true)
Definition: ValueObject.cpp:111
lldb_private::ValueObjectSynthetic::IsSynthetic
bool IsSynthetic() override
Definition: ValueObjectSyntheticFilter.h:67
lldb_private::ValueObjectSynthetic::m_synth_sp
lldb::SyntheticChildrenSP m_synth_sp
Definition: ValueObjectSyntheticFilter.h:133
lldb_private::ValueObjectSynthetic::ByIndexIterator
ByIndexMap::iterator ByIndexIterator
Definition: ValueObjectSyntheticFilter.h:140
lldb_private::ValueObject::GetParent
virtual ValueObject * GetParent()
Definition: ValueObject.h:753
lldb_private::ValueObjectSynthetic::GetValueType
lldb::ValueType GetValueType() const override
Definition: ValueObjectSyntheticFilter.cpp:128
lldb::DynamicValueType
DynamicValueType
Definition: lldb-enumerations.h:494
lldb_private::ValueObjectSynthetic::GetDeclaration
bool GetDeclaration(Declaration &decl) override
Definition: ValueObjectSyntheticFilter.cpp:408
CompilerType.h
lldb_private::ValueObjectSynthetic::GetPreferredDisplayLanguage
lldb::LanguageType GetPreferredDisplayLanguage() override
Definition: ValueObjectSyntheticFilter.cpp:387
ValueObject.h
lldb_private::ValueObjectSynthetic::IsInScope
bool IsInScope() override
Definition: ValueObjectSyntheticFilter.cpp:346
lldb_private::ValueObjectSynthetic::GetCompilerTypeImpl
CompilerType GetCompilerTypeImpl() override
Definition: ValueObjectSyntheticFilter.cpp:64
lldb_private::Status
Definition: Status.h:44
lldb_private::ValueObject
ValueObject:
Definition: ValueObject.h:105
lldb_private::ValueObjectSynthetic::GetLanguageFlags
uint64_t GetLanguageFlags() override
Definition: ValueObjectSyntheticFilter.cpp:415
lldb::ValueType
ValueType
Definition: lldb-enumerations.h:315
lldb_private::ValueObjectSynthetic::CanProvideValue
bool CanProvideValue() override
Definition: ValueObjectSyntheticFilter.cpp:358
uint32_t
lldb_private::ValueObjectSynthetic::CopyValueData
void CopyValueData(ValueObject *source)
Definition: ValueObjectSyntheticFilter.cpp:352
lldb_private::ValueObjectSynthetic::CalculateSyntheticValue
void CalculateSyntheticValue() override
Definition: ValueObjectSyntheticFilter.h:69
lldb_private::ValueObject::m_parent
ValueObject * m_parent
The parent value object, or nullptr if this has no parent.
Definition: ValueObject.h:840
lldb_private::ValueObjectSynthetic::GetStaticValue
lldb::ValueObjectSP GetStaticValue() override
Definition: ValueObjectSyntheticFilter.h:75
lldb_private::ValueObject::GetDynamicValueType
lldb::DynamicValueType GetDynamicValueType()
Definition: ValueObject.cpp:3059
lldb_private::ValueObjectSynthetic::SyntheticChildrenCache
std::vector< lldb::ValueObjectSP > SyntheticChildrenCache
Definition: ValueObjectSyntheticFilter.h:138
lldb_private::ValueObjectSynthetic::operator=
const ValueObjectSynthetic & operator=(const ValueObjectSynthetic &)=delete
lldb_private::ValueObjectSynthetic::CanUpdateWithInvalidExecutionContext
LazyBool CanUpdateWithInvalidExecutionContext() override
Definition: ValueObjectSyntheticFilter.h:123
lldb_private::CompilerType
Generic representation of a type in a programming language.
Definition: CompilerType.h:33
lldb-forward.h
lldb_private::ValueObjectSynthetic::GetTypeName
ConstString GetTypeName() override
Definition: ValueObjectSyntheticFilter.cpp:68
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::ValueObjectSynthetic::m_parent_type_name
ConstString m_parent_type_name
Definition: ValueObjectSyntheticFilter.h:155
lldb_private::ValueObjectSynthetic::GetChildMemberWithName
lldb::ValueObjectSP GetChildMemberWithName(ConstString name, bool can_create) override
Definition: ValueObjectSyntheticFilter.cpp:308
lldb_private::ValueObjectSynthetic
A ValueObject that obtains its children from some source other than real information.
Definition: ValueObjectSyntheticFilter.h:35
ConstString.h
lldb_private::ValueObjectSynthetic::SetValueFromCString
bool SetValueFromCString(const char *value_str, Status &error) override
Definition: ValueObjectSyntheticFilter.cpp:366
lldb_private::Declaration
Definition: Declaration.h:24
lldb_private::ValueObjectSynthetic::GetNonSyntheticValue
lldb::ValueObjectSP GetNonSyntheticValue() override
Definition: ValueObjectSyntheticFilter.cpp:348
lldb_private::ValueObjectSynthetic::GetIndexOfChildWithName
size_t GetIndexOfChildWithName(ConstString name) override
Definition: ValueObjectSyntheticFilter.cpp:320
lldb_private::ValueObjectSynthetic::GetQualifiedTypeName
ConstString GetQualifiedTypeName() override
Definition: ValueObjectSyntheticFilter.cpp:72
lldb_private::LineStatus::Status
@ Status
lldb_private::ValueObjectSynthetic::HasSyntheticValue
bool HasSyntheticValue() override
Definition: ValueObjectSyntheticFilter.h:65
lldb_private::ValueObjectSynthetic::SetFormat
void SetFormat(lldb::Format format) override
Definition: ValueObjectSyntheticFilter.cpp:371
lldb_private::ValueObjectSynthetic::m_children_byindex
ByIndexMap m_children_byindex
Guarded by m_child_mutex;.
Definition: ValueObjectSyntheticFilter.h:145