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
15#include "lldb/lldb-defines.h"
17#include "lldb/lldb-forward.h"
19
20#include <cstdint>
21#include <memory>
22#include <optional>
23
24#include <cstddef>
25
26namespace lldb_private {
27class Declaration;
28class Status;
29class SyntheticChildrenFrontEnd;
30
31/// A ValueObject that obtains its children from some source other than
32/// real information.
33/// This is currently used to implement Python-based children and filters but
34/// you can bind it to any source of synthetic information and have it behave
35/// accordingly.
37public:
39
40 std::optional<uint64_t> GetByteSize() override;
41
42 ConstString GetTypeName() override;
43
45
47
48 bool MightHaveChildren() override;
49
50 llvm::Expected<uint32_t> CalculateNumChildren(uint32_t max) override;
51
52 lldb::ValueType GetValueType() const override;
53
55 bool can_create = true) override;
56
58 bool can_create = true) override;
59
60 size_t GetIndexOfChildWithName(llvm::StringRef name) override;
61
63 GetDynamicValue(lldb::DynamicValueType valueType) override;
64
65 bool IsInScope() override;
66
67 bool HasSyntheticValue() override { return false; }
68
69 bool IsSynthetic() override { return true; }
70
71 void CalculateSyntheticValue() override {}
72
73 bool IsDynamic() override {
74 return ((m_parent != nullptr) ? m_parent->IsDynamic() : false);
75 }
76
78 return ((m_parent != nullptr) ? m_parent->GetStaticValue() : GetSP());
79 }
80
82 return ((m_parent != nullptr) ? m_parent->GetDynamicValueType()
84 }
85
87 return m_parent != nullptr ? m_parent->GetVariable() : nullptr;
88 }
89
90 ValueObject *GetParent() override {
91 return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
92 }
93
94 const ValueObject *GetParent() const override {
95 return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
96 }
97
99
100 bool CanProvideValue() override;
101
104 }
105
106 bool GetIsConstant() const override { return false; }
107
108 bool SetValueFromCString(const char *value_str, Status &error) override;
109
110 void SetFormat(lldb::Format format) override;
111
113
115
116 bool IsSyntheticChildrenGenerated() override;
117
118 void SetSyntheticChildrenGenerated(bool b) override;
119
120 bool GetDeclaration(Declaration &decl) override;
121
122 uint64_t GetLanguageFlags() override;
123
124 void SetLanguageFlags(uint64_t flags) override;
125
126protected:
127 bool UpdateValue() override;
128
130 return eLazyBoolYes;
131 }
132
134
135 virtual void CreateSynthFilter();
136
137 // we need to hold on to the SyntheticChildren because someone might delete
138 // the type binding while we are alive
140 std::unique_ptr<SyntheticChildrenFrontEnd> m_synth_filter_up;
141
142 typedef std::map<uint32_t, ValueObject *> ByIndexMap;
143 typedef std::map<const char *, uint32_t> NameToIndexMap;
144 typedef std::vector<lldb::ValueObjectSP> SyntheticChildrenCache;
145
146 typedef ByIndexMap::iterator ByIndexIterator;
147 typedef NameToIndexMap::iterator NameToIndexIterator;
148
149 std::mutex m_child_mutex;
150 /// Guarded by m_child_mutex;
152 /// Guarded by m_child_mutex;
154 /// Guarded by m_child_mutex;
156
157 // FIXME: use the ValueObject's ChildrenManager instead of a special purpose
158 // solution.
160
162
164
166
167private:
168 friend class ValueObject;
170
171 void CopyValueData(ValueObject *source);
172
175};
176
177} // namespace lldb_private
178
179#endif // LLDB_CORE_VALUEOBJECTSYNTHETICFILTER_H
static llvm::raw_ostream & error(Stream &strm)
Generic representation of a type in a programming language.
Definition: CompilerType.h:36
A uniqued constant string class.
Definition: ConstString.h:40
A class that describes the declaration location of a lldb object.
Definition: Declaration.h:24
An error handling class.
Definition: Status.h:44
A ValueObject that obtains its children from some source other than real information.
virtual lldb::DynamicValueType GetDynamicValueType()
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx, bool can_create=true) override
size_t GetIndexOfChildWithName(llvm::StringRef name) override
bool SetValueFromCString(const char *value_str, Status &error) override
lldb::ValueType GetValueType() const override
lldb::LanguageType GetPreferredDisplayLanguage() override
void SetFormat(lldb::Format format) override
NameToIndexMap m_name_toindex
Guarded by m_child_mutex;.
ByIndexMap m_children_byindex
Guarded by m_child_mutex;.
std::unique_ptr< SyntheticChildrenFrontEnd > m_synth_filter_up
lldb::ValueObjectSP GetDynamicValue(lldb::DynamicValueType valueType) override
std::map< uint32_t, ValueObject * > ByIndexMap
ValueObjectSynthetic(const ValueObjectSynthetic &)=delete
lldb::ValueObjectSP GetNonSyntheticValue() override
SyntheticChildrenCache m_synthetic_children_cache
Guarded by m_child_mutex;.
std::optional< uint64_t > GetByteSize() override
bool GetDeclaration(Declaration &decl) override
std::map< const char *, uint32_t > NameToIndexMap
lldb::ValueObjectSP GetStaticValue() override
bool MightHaveChildren() override
Find out if a ValueObject might have children.
lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name, bool can_create=true) override
const ValueObjectSynthetic & operator=(const ValueObjectSynthetic &)=delete
std::vector< lldb::ValueObjectSP > SyntheticChildrenCache
void SetLanguageFlags(uint64_t flags) override
llvm::Expected< uint32_t > CalculateNumChildren(uint32_t max) override
Should only be called by ValueObject::GetNumChildren().
const ValueObject * GetParent() const override
friend class ValueObjectSynthetic
Definition: ValueObject.h:1010
lldb::ValueObjectSP GetSP()
Definition: ValueObject.h:569
virtual lldb::VariableSP GetVariable()
Definition: ValueObject.h:860
virtual bool IsDynamic()
Definition: ValueObject.h:683
lldb::DynamicValueType GetDynamicValueType()
ValueObject * m_parent
The parent value object, or nullptr if this has no parent.
Definition: ValueObject.h:915
bool UpdateValueIfNeeded(bool update_format=true)
virtual lldb::ValueObjectSP GetStaticValue()
Definition: ValueObject.h:604
virtual ValueObject * GetParent()
Definition: ValueObject.h:828
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
Definition: lldb-forward.h:480
Format
Display format definitions.
LanguageType
Programming language type.
std::shared_ptr< lldb_private::Variable > VariableSP
Definition: lldb-forward.h:482
std::shared_ptr< lldb_private::SyntheticChildren > SyntheticChildrenSP
Definition: lldb-forward.h:441
@ eNoDynamicValues