LLDB  mainline
SBTypeFilter.cpp
Go to the documentation of this file.
1 //===-- SBTypeFilter.cpp ------------------------------------------*- C++
2 //-*-===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "lldb/API/SBTypeFilter.h"
11 #include "SBReproducerPrivate.h"
12 
13 #include "lldb/API/SBStream.h"
14 
16 
17 using namespace lldb;
18 using namespace lldb_private;
19 
20 SBTypeFilter::SBTypeFilter() : m_opaque_sp() {
22 }
23 
25  : m_opaque_sp(TypeFilterImplSP(new TypeFilterImpl(options))) {
27 }
28 
30  : m_opaque_sp(rhs.m_opaque_sp) {
32 }
33 
35 
36 bool SBTypeFilter::IsValid() const {
38  return this->operator bool();
39 }
40 SBTypeFilter::operator bool() const {
41  LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeFilter, operator bool);
42 
43  return m_opaque_sp.get() != NULL;
44 }
45 
48 
49  if (IsValid())
50  return m_opaque_sp->GetOptions();
51  return 0;
52 }
53 
56 
57  if (CopyOnWrite_Impl())
58  m_opaque_sp->SetOptions(value);
59 }
60 
62  lldb::DescriptionLevel description_level) {
64  (lldb::SBStream &, lldb::DescriptionLevel), description,
65  description_level);
66 
67  if (!IsValid())
68  return false;
69  else {
70  description.Printf("%s\n", m_opaque_sp->GetDescription().c_str());
71  return true;
72  }
73 }
74 
77 
78  if (CopyOnWrite_Impl())
79  m_opaque_sp->Clear();
80 }
81 
85 
86  if (IsValid())
87  return m_opaque_sp->GetCount();
88  return 0;
89 }
90 
93  (uint32_t), i);
94 
95  if (IsValid()) {
96  const char *item = m_opaque_sp->GetExpressionPathAtIndex(i);
97  if (item && *item == '.')
98  item++;
99  return item;
100  }
101  return NULL;
102 }
103 
106  (uint32_t, const char *), i, item);
107 
108  if (CopyOnWrite_Impl())
109  return m_opaque_sp->SetExpressionPathAtIndex(i, item);
110  else
111  return false;
112 }
113 
114 void SBTypeFilter::AppendExpressionPath(const char *item) {
116  item);
117 
118  if (CopyOnWrite_Impl())
119  m_opaque_sp->AddExpressionPath(item);
120 }
121 
124  SBTypeFilter, operator=,(const lldb::SBTypeFilter &), rhs);
125 
126  if (this != &rhs) {
127  m_opaque_sp = rhs.m_opaque_sp;
128  }
129  return LLDB_RECORD_RESULT(*this);
130 }
131 
133  LLDB_RECORD_METHOD(bool, SBTypeFilter, operator==,(lldb::SBTypeFilter &),
134  rhs);
135 
136  if (!IsValid())
137  return !rhs.IsValid();
138 
139  return m_opaque_sp == rhs.m_opaque_sp;
140 }
141 
144  rhs);
145 
146  if (!IsValid())
147  return !rhs.IsValid();
148 
150  return false;
151 
152  for (uint32_t j = 0; j < GetNumberOfExpressionPaths(); j++)
153  if (strcmp(GetExpressionPathAtIndex(j), rhs.GetExpressionPathAtIndex(j)) !=
154  0)
155  return false;
156 
157  return GetOptions() == rhs.GetOptions();
158 }
159 
161  LLDB_RECORD_METHOD(bool, SBTypeFilter, operator!=,(lldb::SBTypeFilter &),
162  rhs);
163 
164  if (!IsValid())
165  return !rhs.IsValid();
166 
167  return m_opaque_sp != rhs.m_opaque_sp;
168 }
169 
170 lldb::TypeFilterImplSP SBTypeFilter::GetSP() { return m_opaque_sp; }
171 
172 void SBTypeFilter::SetSP(const lldb::TypeFilterImplSP &typefilter_impl_sp) {
173  m_opaque_sp = typefilter_impl_sp;
174 }
175 
176 SBTypeFilter::SBTypeFilter(const lldb::TypeFilterImplSP &typefilter_impl_sp)
177  : m_opaque_sp(typefilter_impl_sp) {}
178 
180  if (!IsValid())
181  return false;
182  if (m_opaque_sp.unique())
183  return true;
184 
185  TypeFilterImplSP new_sp(new TypeFilterImpl(GetOptions()));
186 
187  for (uint32_t j = 0; j < GetNumberOfExpressionPaths(); j++)
188  new_sp->AddExpressionPath(GetExpressionPathAtIndex(j));
189 
190  SetSP(new_sp);
191 
192  return true;
193 }
194 
195 namespace lldb_private {
196 namespace repro {
197 
198 template <>
204  LLDB_REGISTER_METHOD_CONST(bool, SBTypeFilter, operator bool, ());
211  ());
213  (uint32_t));
215  (uint32_t, const char *));
217  (const char *));
219  SBTypeFilter, operator=,(const lldb::SBTypeFilter &));
223 }
224 
225 }
226 }
The registry contains a unique mapping between functions and their ID.
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
#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)
#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:62
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)