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 
11 
12 #include "lldb/API/SBStream.h"
13 
15 
16 using namespace lldb;
17 using namespace lldb_private;
18 
20 
22  : m_opaque_sp(TypeFilterImplSP(new TypeFilterImpl(options))) {
23  LLDB_INSTRUMENT_VA(this, options);
24 }
25 
27  : m_opaque_sp(rhs.m_opaque_sp) {
28  LLDB_INSTRUMENT_VA(this, rhs);
29 }
30 
31 SBTypeFilter::~SBTypeFilter() = default;
32 
33 bool SBTypeFilter::IsValid() const {
34  LLDB_INSTRUMENT_VA(this);
35  return this->operator bool();
36 }
37 SBTypeFilter::operator bool() const {
38  LLDB_INSTRUMENT_VA(this);
39 
40  return m_opaque_sp.get() != nullptr;
41 }
42 
44  LLDB_INSTRUMENT_VA(this);
45 
46  if (IsValid())
47  return m_opaque_sp->GetOptions();
48  return 0;
49 }
50 
52  LLDB_INSTRUMENT_VA(this, value);
53 
54  if (CopyOnWrite_Impl())
55  m_opaque_sp->SetOptions(value);
56 }
57 
59  lldb::DescriptionLevel description_level) {
60  LLDB_INSTRUMENT_VA(this, description, description_level);
61 
62  if (!IsValid())
63  return false;
64  else {
65  description.Printf("%s\n", m_opaque_sp->GetDescription().c_str());
66  return true;
67  }
68 }
69 
71  LLDB_INSTRUMENT_VA(this);
72 
73  if (CopyOnWrite_Impl())
74  m_opaque_sp->Clear();
75 }
76 
78  LLDB_INSTRUMENT_VA(this);
79 
80  if (IsValid())
81  return m_opaque_sp->GetCount();
82  return 0;
83 }
84 
86  LLDB_INSTRUMENT_VA(this, i);
87 
88  if (IsValid()) {
89  const char *item = m_opaque_sp->GetExpressionPathAtIndex(i);
90  if (item && *item == '.')
91  item++;
92  return item;
93  }
94  return nullptr;
95 }
96 
98  LLDB_INSTRUMENT_VA(this, i, item);
99 
100  if (CopyOnWrite_Impl())
101  return m_opaque_sp->SetExpressionPathAtIndex(i, item);
102  else
103  return false;
104 }
105 
106 void SBTypeFilter::AppendExpressionPath(const char *item) {
107  LLDB_INSTRUMENT_VA(this, item);
108 
109  if (CopyOnWrite_Impl())
110  m_opaque_sp->AddExpressionPath(item);
111 }
112 
114  LLDB_INSTRUMENT_VA(this, rhs);
115 
116  if (this != &rhs) {
117  m_opaque_sp = rhs.m_opaque_sp;
118  }
119  return *this;
120 }
121 
123  LLDB_INSTRUMENT_VA(this, rhs);
124 
125  if (!IsValid())
126  return !rhs.IsValid();
127 
128  return m_opaque_sp == rhs.m_opaque_sp;
129 }
130 
132  LLDB_INSTRUMENT_VA(this, rhs);
133 
134  if (!IsValid())
135  return !rhs.IsValid();
136 
138  return false;
139 
140  for (uint32_t j = 0; j < GetNumberOfExpressionPaths(); j++)
141  if (strcmp(GetExpressionPathAtIndex(j), rhs.GetExpressionPathAtIndex(j)) !=
142  0)
143  return false;
144 
145  return GetOptions() == rhs.GetOptions();
146 }
147 
149  LLDB_INSTRUMENT_VA(this, rhs);
150 
151  if (!IsValid())
152  return !rhs.IsValid();
153 
154  return m_opaque_sp != rhs.m_opaque_sp;
155 }
156 
157 lldb::TypeFilterImplSP SBTypeFilter::GetSP() { return m_opaque_sp; }
158 
159 void SBTypeFilter::SetSP(const lldb::TypeFilterImplSP &typefilter_impl_sp) {
160  m_opaque_sp = typefilter_impl_sp;
161 }
162 
163 SBTypeFilter::SBTypeFilter(const lldb::TypeFilterImplSP &typefilter_impl_sp)
164  : m_opaque_sp(typefilter_impl_sp) {}
165 
167  if (!IsValid())
168  return false;
169  if (m_opaque_sp.unique())
170  return true;
171 
172  TypeFilterImplSP new_sp(new TypeFilterImpl(GetOptions()));
173 
174  for (uint32_t j = 0; j < GetNumberOfExpressionPaths(); j++)
175  new_sp->AddExpressionPath(GetExpressionPathAtIndex(j));
176 
177  SetSP(new_sp);
178 
179  return true;
180 }
lldb::SBTypeFilter::CopyOnWrite_Impl
bool CopyOnWrite_Impl()
Definition: SBTypeFilter.cpp:166
lldb::SBTypeFilter::operator==
bool operator==(lldb::SBTypeFilter &rhs)
Definition: SBTypeFilter.cpp:122
Instrumentation.h
lldb::SBTypeFilter
Definition: SBTypeFilter.h:17
lldb::SBStream::Printf
void Printf(const char *format,...) __attribute__((format(printf
Definition: SBStream.cpp:70
lldb::SBTypeFilter::GetSP
lldb::TypeFilterImplSP GetSP()
Definition: SBTypeFilter.cpp:157
lldb::SBTypeFilter::GetDescription
bool GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level)
Definition: SBTypeFilter.cpp:58
lldb::SBTypeFilter::AppendExpressionPath
void AppendExpressionPath(const char *item)
Definition: SBTypeFilter.cpp:106
lldb::SBTypeFilter::Clear
void Clear()
Definition: SBTypeFilter.cpp:70
lldb::SBTypeFilter::ReplaceExpressionPathAtIndex
bool ReplaceExpressionPathAtIndex(uint32_t i, const char *item)
Definition: SBTypeFilter.cpp:97
lldb_private::TypeFilterImpl
Definition: TypeSynthetic.h:277
lldb::SBTypeFilter::m_opaque_sp
lldb::TypeFilterImplSP m_opaque_sp
Definition: SBTypeFilter.h:65
SBStream.h
lldb::SBTypeFilter::SetOptions
void SetOptions(uint32_t)
Definition: SBTypeFilter.cpp:51
lldb::SBTypeFilter::GetExpressionPathAtIndex
const char * GetExpressionPathAtIndex(uint32_t i)
Definition: SBTypeFilter.cpp:85
lldb::SBTypeFilter::GetOptions
uint32_t GetOptions()
Definition: SBTypeFilter.cpp:43
lldb::SBTypeFilter::IsValid
bool IsValid() const
Definition: SBTypeFilter.cpp:33
lldb::SBTypeFilter::operator=
lldb::SBTypeFilter & operator=(const lldb::SBTypeFilter &rhs)
Definition: SBTypeFilter.cpp:113
lldb::SBTypeFilter::~SBTypeFilter
~SBTypeFilter()
lldb::SBTypeFilter::IsEqualTo
bool IsEqualTo(lldb::SBTypeFilter &rhs)
Definition: SBTypeFilter.cpp:131
DataVisualization.h
uint32_t
SBTypeFilter.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb::SBTypeFilter::SBTypeFilter
SBTypeFilter()
Definition: SBTypeFilter.cpp:19
lldb::SBTypeFilter::GetNumberOfExpressionPaths
uint32_t GetNumberOfExpressionPaths()
Definition: SBTypeFilter.cpp:77
LLDB_INSTRUMENT_VA
#define LLDB_INSTRUMENT_VA(...)
Definition: Instrumentation.h:98
lldb::SBStream
Definition: SBStream.h:18
lldb::SBTypeFilter::operator!=
bool operator!=(lldb::SBTypeFilter &rhs)
Definition: SBTypeFilter.cpp:148
lldb
Definition: SBAddress.h:15
lldb::DescriptionLevel
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
Definition: lldb-enumerations.h:207
lldb::SBTypeFilter::SetSP
void SetSP(const lldb::TypeFilterImplSP &typefilter_impl_sp)
Definition: SBTypeFilter.cpp:159