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 <stddef.h>
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  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;
145  ByIndexMap m_children_byindex;
146  /// Guarded by m_child_mutex;
147  NameToIndexMap m_name_toindex;
148  /// Guarded by m_child_mutex;
149  SyntheticChildrenCache m_synthetic_children_cache;
150 
151  uint32_t m_synthetic_children_count; // FIXME use the ValueObject's
152  // ChildrenManager instead of a special
153  // purpose 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
NameToIndexMap m_name_toindex
Guarded by m_child_mutex;.
A class that represents a running process on the host machine.
bool SetValueFromCString(const char *value_str, Status &error) override
const ValueObjectSynthetic & operator=(const ValueObjectSynthetic &)=delete
void SetFormat(lldb::Format format) override
std::map< const char *, uint32_t > NameToIndexMap
lldb::ValueObjectSP GetChildMemberWithName(ConstString name, bool can_create) override
Format
Display format definitions.
lldb::LanguageType GetPreferredDisplayLanguage() override
virtual lldb::DynamicValueType GetDynamicValueType()
virtual ValueObject * GetParent()
Definition: ValueObject.h:735
LanguageType
Programming language type.
ByIndexMap m_children_byindex
Guarded by m_child_mutex;.
std::vector< lldb::ValueObjectSP > SyntheticChildrenCache
static llvm::raw_ostream & error(Stream &strm)
size_t GetIndexOfChildWithName(ConstString name) override
std::unique_ptr< SyntheticChildrenFrontEnd > m_synth_filter_up
virtual bool IsDynamic()
Definition: ValueObject.h:621
SyntheticChildrenCache m_synthetic_children_cache
Guarded by m_child_mutex;.
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:40
lldb::ValueObjectSP GetNonSyntheticValue() override
const ValueObject * GetParent() const override
ValueObjectSynthetic(ValueObject &parent, lldb::SyntheticChildrenSP filter)
Represents a generic type in a programming language.
Definition: CompilerType.h:33
lldb::ValueObjectSP GetSP()
Definition: ValueObject.h:539
lldb::ValueObjectSP GetDynamicValue(lldb::DynamicValueType valueType) override
size_t CalculateNumChildren(uint32_t max) override
std::map< uint32_t, ValueObject * > ByIndexMap
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