LLDB  mainline
SBTypeFilter.cpp
Go to the documentation of this file.
1 //===-- SBTypeFilter.cpp --------------------------------------------------===//
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 
10 #include "SBReproducerPrivate.h"
11 
12 #include "lldb/API/SBStream.h"
13 
15 
16 using namespace lldb;
17 using namespace lldb_private;
18 
19 SBTypeFilter::SBTypeFilter() : m_opaque_sp() {
21 }
22 
24  : m_opaque_sp(TypeFilterImplSP(new TypeFilterImpl(options))) {
26 }
27 
29  : m_opaque_sp(rhs.m_opaque_sp) {
31 }
32 
33 SBTypeFilter::~SBTypeFilter() = default;
34 
35 bool SBTypeFilter::IsValid() const {
37  return this->operator bool();
38 }
39 SBTypeFilter::operator bool() const {
40  LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeFilter, operator bool);
41 
42  return m_opaque_sp.get() != nullptr;
43 }
44 
47 
48  if (IsValid())
49  return m_opaque_sp->GetOptions();
50  return 0;
51 }
52 
55 
56  if (CopyOnWrite_Impl())
57  m_opaque_sp->SetOptions(value);
58 }
59 
61  lldb::DescriptionLevel description_level) {
63  (lldb::SBStream &, lldb::DescriptionLevel), description,
64  description_level);
65 
66  if (!IsValid())
67  return false;
68  else {
69  description.Printf("%s\n", m_opaque_sp->GetDescription().c_str());
70  return true;
71  }
72 }
73 
76 
77  if (CopyOnWrite_Impl())
78  m_opaque_sp->Clear();
79 }
80 
84 
85  if (IsValid())
86  return m_opaque_sp->GetCount();
87  return 0;
88 }
89 
92  (uint32_t), i);
93 
94  if (IsValid()) {
95  const char *item = m_opaque_sp->GetExpressionPathAtIndex(i);
96  if (item && *item == '.')
97  item++;
98  return item;
99  }
100  return nullptr;
101 }
102 
105  (uint32_t, const char *), i, item);
106 
107  if (CopyOnWrite_Impl())
108  return m_opaque_sp->SetExpressionPathAtIndex(i, item);
109  else
110  return false;
111 }
112 
113 void SBTypeFilter::AppendExpressionPath(const char *item) {
115  item);
116 
117  if (CopyOnWrite_Impl())
118  m_opaque_sp->AddExpressionPath(item);
119 }
120 
123  SBTypeFilter, operator=,(const lldb::SBTypeFilter &), rhs);
124 
125  if (this != &rhs) {
126  m_opaque_sp = rhs.m_opaque_sp;
127  }
128  return LLDB_RECORD_RESULT(*this);
129 }
130 
132  LLDB_RECORD_METHOD(bool, SBTypeFilter, operator==,(lldb::SBTypeFilter &),
133  rhs);
134 
135  if (!IsValid())
136  return !rhs.IsValid();
137 
138  return m_opaque_sp == rhs.m_opaque_sp;
139 }
140 
143  rhs);
144 
145  if (!IsValid())
146  return !rhs.IsValid();
147 
149  return false;
150 
151  for (uint32_t j = 0; j < GetNumberOfExpressionPaths(); j++)
152  if (strcmp(GetExpressionPathAtIndex(j), rhs.GetExpressionPathAtIndex(j)) !=
153  0)
154  return false;
155 
156  return GetOptions() == rhs.GetOptions();
157 }
158 
160  LLDB_RECORD_METHOD(bool, SBTypeFilter, operator!=,(lldb::SBTypeFilter &),
161  rhs);
162 
163  if (!IsValid())
164  return !rhs.IsValid();
165 
166  return m_opaque_sp != rhs.m_opaque_sp;
167 }
168 
169 lldb::TypeFilterImplSP SBTypeFilter::GetSP() { return m_opaque_sp; }
170 
171 void SBTypeFilter::SetSP(const lldb::TypeFilterImplSP &typefilter_impl_sp) {
172  m_opaque_sp = typefilter_impl_sp;
173 }
174 
175 SBTypeFilter::SBTypeFilter(const lldb::TypeFilterImplSP &typefilter_impl_sp)
176  : m_opaque_sp(typefilter_impl_sp) {}
177 
179  if (!IsValid())
180  return false;
181  if (m_opaque_sp.unique())
182  return true;
183 
184  TypeFilterImplSP new_sp(new TypeFilterImpl(GetOptions()));
185 
186  for (uint32_t j = 0; j < GetNumberOfExpressionPaths(); j++)
187  new_sp->AddExpressionPath(GetExpressionPathAtIndex(j));
188 
189  SetSP(new_sp);
190 
191  return true;
192 }
193 
194 namespace lldb_private {
195 namespace repro {
196 
197 template <>
203  LLDB_REGISTER_METHOD_CONST(bool, SBTypeFilter, operator bool, ());
210  ());
212  (uint32_t));
214  (uint32_t, const char *));
216  (const char *));
218  SBTypeFilter, operator=,(const lldb::SBTypeFilter &));
222 }
223 
224 }
225 }
The registry contains a unique mapping between functions and their ID.
A class that represents a running process on the host machine.
#define LLDB_RECORD_CONSTRUCTOR_NO_ARGS(Class)
void SetOptions(uint32_t)
void RegisterMethods< SBTypeFilter >(Registry &R)
void SetSP(const lldb::TypeFilterImplSP &typefilter_impl_sp)
const char * GetExpressionPathAtIndex(uint32_t i)
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
#define LLDB_REGISTER_CONSTRUCTOR(Class, Signature)
#define LLDB_RECORD_METHOD_NO_ARGS(Result, Class, Method)
#define LLDB_RECORD_CONSTRUCTOR(Class, Signature,...)
void Printf(const char *format,...) __attribute__((format(printf
Definition: SBStream.cpp:69
bool ReplaceExpressionPathAtIndex(uint32_t i, const char *item)
uint32_t GetOptions()
#define LLDB_RECORD_METHOD(Result, Class, Method, Signature,...)
bool IsValid() const
bool operator!=(lldb::SBTypeFilter &rhs)
lldb::TypeFilterImplSP m_opaque_sp
Definition: SBTypeFilter.h:65
bool IsEqualTo(lldb::SBTypeFilter &rhs)
uint32_t GetNumberOfExpressionPaths()
Definition: SBAddress.h:15
void AppendExpressionPath(const char *item)
lldb::SBTypeFilter & operator=(const lldb::SBTypeFilter &rhs)
#define LLDB_REGISTER_METHOD(Result, Class, Method, Signature)
#define LLDB_RECORD_METHOD_CONST_NO_ARGS(Result, Class, Method)
bool operator==(lldb::SBTypeFilter &rhs)
bool GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level)
#define LLDB_RECORD_RESULT(Result)
lldb::TypeFilterImplSP GetSP()
#define LLDB_REGISTER_METHOD_CONST(Result, Class, Method, Signature)