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 size_t CalculateNumChildren(uint32_t max) override;
51
52 lldb::ValueType GetValueType() const override;
53
54 lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create) override;
55
56 lldb::ValueObjectSP GetChildMemberWithName(ConstString name,
57 bool can_create) override;
58
59 size_t GetIndexOfChildWithName(ConstString name) override;
60
61 lldb::ValueObjectSP
62 GetDynamicValue(lldb::DynamicValueType valueType) override;
63
64 bool IsInScope() override;
65
66 bool HasSyntheticValue() override { return false; }
67
68 bool IsSynthetic() override { return true; }
69
70 void CalculateSyntheticValue() override {}
71
72 bool IsDynamic() override {
73 return ((m_parent != nullptr) ? m_parent->IsDynamic() : false);
74 }
75
76 lldb::ValueObjectSP GetStaticValue() override {
77 return ((m_parent != nullptr) ? m_parent->GetStaticValue() : GetSP());
78 }
79
81 return ((m_parent != nullptr) ? m_parent->GetDynamicValueType()
83 }
84
85 ValueObject *GetParent() override {
86 return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
87 }
88
89 const ValueObject *GetParent() const override {
90 return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
91 }
92
93 lldb::ValueObjectSP GetNonSyntheticValue() override;
94
95 bool CanProvideValue() override;
96
97 bool DoesProvideSyntheticValue() override {
99 }
100
101 bool GetIsConstant() const override { return false; }
102
103 bool SetValueFromCString(const char *value_str, Status &error) override;
104
105 void SetFormat(lldb::Format format) override;
106
108
110
111 bool IsSyntheticChildrenGenerated() override;
112
113 void SetSyntheticChildrenGenerated(bool b) override;
114
115 bool GetDeclaration(Declaration &decl) override;
116
117 uint64_t GetLanguageFlags() override;
118
119 void SetLanguageFlags(uint64_t flags) override;
120
121protected:
122 bool UpdateValue() override;
123
125 return eLazyBoolYes;
126 }
127
129
130 virtual void CreateSynthFilter();
131
132 // we need to hold on to the SyntheticChildren because someone might delete
133 // the type binding while we are alive
134 lldb::SyntheticChildrenSP m_synth_sp;
135 std::unique_ptr<SyntheticChildrenFrontEnd> m_synth_filter_up;
136
137 typedef std::map<uint32_t, ValueObject *> ByIndexMap;
138 typedef std::map<const char *, uint32_t> NameToIndexMap;
139 typedef std::vector<lldb::ValueObjectSP> SyntheticChildrenCache;
140
141 typedef ByIndexMap::iterator ByIndexIterator;
142 typedef NameToIndexMap::iterator NameToIndexIterator;
143
144 std::mutex m_child_mutex;
145 /// Guarded by m_child_mutex;
147 /// Guarded by m_child_mutex;
149 /// Guarded by m_child_mutex;
151
152 // FIXME: use the ValueObject's ChildrenManager instead of a special purpose
153 // solution.
155
157
159
161
162private:
163 friend class ValueObject;
164 ValueObjectSynthetic(ValueObject &parent, lldb::SyntheticChildrenSP filter);
165
166 void CopyValueData(ValueObject *source);
167
170};
171
172} // namespace lldb_private
173
174#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:39
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 GetChildMemberWithName(ConstString name, bool can_create) override
bool SetValueFromCString(const char *value_str, Status &error) override
size_t CalculateNumChildren(uint32_t max) override
Should only be called by ValueObject::GetNumChildren().
lldb::ValueType GetValueType() const override
lldb::LanguageType GetPreferredDisplayLanguage() override
void SetFormat(lldb::Format format) override
NameToIndexMap m_name_toindex
Guarded by m_child_mutex;.
lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create) override
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.
size_t GetIndexOfChildWithName(ConstString name) override
const ValueObjectSynthetic & operator=(const ValueObjectSynthetic &)=delete
std::vector< lldb::ValueObjectSP > SyntheticChildrenCache
void SetLanguageFlags(uint64_t flags) override
const ValueObject * GetParent() const override
friend class ValueObjectSynthetic
Definition: ValueObject.h:935
lldb::ValueObjectSP GetSP()
Definition: ValueObject.h:555
virtual bool IsDynamic()
Definition: ValueObject.h:637
lldb::DynamicValueType GetDynamicValueType()
ValueObject * m_parent
The parent value object, or nullptr if this has no parent.
Definition: ValueObject.h:840
bool UpdateValueIfNeeded(bool update_format=true)
virtual lldb::ValueObjectSP GetStaticValue()
Definition: ValueObject.h:590
virtual ValueObject * GetParent()
Definition: ValueObject.h:753
A class that represents a running process on the host machine.
Format
Display format definitions.
LanguageType
Programming language type.
@ eNoDynamicValues