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 liblldb_ValueObjectSyntheticFilter_h_
10 #define liblldb_ValueObjectSyntheticFilter_h_
11 
14 #include "lldb/Core/ValueObject.h"
17 #include "lldb/lldb-defines.h"
18 #include "lldb/lldb-enumerations.h"
19 #include "lldb/lldb-forward.h"
21 
22 #include <cstdint>
23 #include <memory>
24 
25 #include <stddef.h>
26 
27 namespace lldb_private {
28 class Declaration;
29 }
30 namespace lldb_private {
31 class Status;
32 }
33 namespace lldb_private {
34 class SyntheticChildrenFrontEnd;
35 }
36 namespace lldb_private {
37 
38 // A ValueObject that obtains its children from some source other than
39 // real information
40 // This is currently used to implement Python-based children and filters but
41 // you can bind it to any source of synthetic information and have it behave
42 // accordingly
44 public:
45  ~ValueObjectSynthetic() override;
46 
47  uint64_t GetByteSize() override;
48 
49  ConstString GetTypeName() override;
50 
52 
54 
55  bool MightHaveChildren() override;
56 
57  size_t CalculateNumChildren(uint32_t max) override;
58 
59  lldb::ValueType GetValueType() const override;
60 
61  lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create) override;
62 
63  lldb::ValueObjectSP GetChildMemberWithName(ConstString name,
64  bool can_create) override;
65 
66  size_t GetIndexOfChildWithName(ConstString name) override;
67 
68  lldb::ValueObjectSP
69  GetDynamicValue(lldb::DynamicValueType valueType) override;
70 
71  bool IsInScope() override;
72 
73  bool HasSyntheticValue() override { return false; }
74 
75  bool IsSynthetic() override { return true; }
76 
77  void CalculateSyntheticValue(bool use_synthetic) override {}
78 
79  bool IsDynamic() override {
80  return ((m_parent != nullptr) ? m_parent->IsDynamic() : false);
81  }
82 
83  lldb::ValueObjectSP GetStaticValue() override {
84  return ((m_parent != nullptr) ? m_parent->GetStaticValue() : GetSP());
85  }
86 
88  return ((m_parent != nullptr) ? m_parent->GetDynamicValueType()
90  }
91 
92  ValueObject *GetParent() override {
93  return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
94  }
95 
96  const ValueObject *GetParent() const override {
97  return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
98  }
99 
100  lldb::ValueObjectSP GetNonSyntheticValue() override;
101 
102  bool CanProvideValue() override;
103 
104  bool DoesProvideSyntheticValue() override {
106  }
107 
108  bool GetIsConstant() const override { return false; }
109 
110  bool SetValueFromCString(const char *value_str, Status &error) override;
111 
112  void SetFormat(lldb::Format format) override;
113 
115 
117 
118  bool IsSyntheticChildrenGenerated() override;
119 
120  void SetSyntheticChildrenGenerated(bool b) override;
121 
122  bool GetDeclaration(Declaration &decl) override;
123 
124  uint64_t GetLanguageFlags() override;
125 
126  void SetLanguageFlags(uint64_t flags) override;
127 
128 protected:
129  bool UpdateValue() override;
130 
132  return eLazyBoolYes;
133  }
134 
136 
137  virtual void CreateSynthFilter();
138 
139  // we need to hold on to the SyntheticChildren because someone might delete
140  // the type binding while we are alive
141  lldb::SyntheticChildrenSP m_synth_sp;
142  std::unique_ptr<SyntheticChildrenFrontEnd> m_synth_filter_up;
143 
147 
150 
151  ByIndexMap m_children_byindex;
152  NameToIndexMap m_name_toindex;
153  uint32_t m_synthetic_children_count; // FIXME use the ValueObject's
154  // ChildrenManager instead of a special
155  // purpose solution
156  SyntheticChildrenCache m_synthetic_children_cache;
157 
159 
161 
163 
164 private:
165  friend class ValueObject;
166  ValueObjectSynthetic(ValueObject &parent, lldb::SyntheticChildrenSP filter);
167 
168  void CopyValueData(ValueObject *source);
169 
170  DISALLOW_COPY_AND_ASSIGN(ValueObjectSynthetic);
171 };
172 
173 } // namespace lldb_private
174 
175 #endif // liblldb_ValueObjectSyntheticFilter_h_
collection::iterator iterator
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
bool SetValueFromCString(const char *value_str, Status &error) override
void SetFormat(lldb::Format format) override
ThreadSafeSTLMap< const char *, uint32_t > NameToIndexMap
lldb::ValueObjectSP GetChildMemberWithName(ConstString name, bool can_create) override
lldb::LanguageType GetPreferredDisplayLanguage() override
virtual lldb::DynamicValueType GetDynamicValueType()
virtual ValueObject * GetParent()
Definition: ValueObject.h:771
LanguageType
Programming language type.
ThreadSafeSTLVector< lldb::ValueObjectSP > SyntheticChildrenCache
size_t GetIndexOfChildWithName(ConstString name) override
std::unique_ptr< SyntheticChildrenFrontEnd > m_synth_filter_up
virtual bool IsDynamic()
Definition: ValueObject.h:647
bool GetDeclaration(Declaration &decl) override
lldb::DynamicValueType GetDynamicValueType()
virtual lldb::ValueObjectSP GetStaticValue()
bool UpdateValueIfNeeded(bool update_format=true)
lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create) override
A uniqued constant string class.
Definition: ConstString.h:38
lldb::ValueObjectSP GetNonSyntheticValue() override
const ValueObject * GetParent() const override
lldb::ValueObjectSP GetSP()
Definition: ValueObject.h:565
lldb::ValueObjectSP GetDynamicValue(lldb::DynamicValueType valueType) override
size_t CalculateNumChildren(uint32_t max) override
ThreadSafeSTLMap< uint32_t, ValueObject * > ByIndexMap
void CalculateSyntheticValue(bool use_synthetic) override
A class that describes the declaration location of a lldb object.
Definition: Declaration.h:24
bool MightHaveChildren() override
Find out if a ValueObject might have children.
void SetLanguageFlags(uint64_t flags) override
lldb::ValueObjectSP GetStaticValue() override
lldb::ValueType GetValueType() const override
An error handling class.
Definition: Status.h:44