LLDB  mainline
BreakpointName.h
Go to the documentation of this file.
1 //===-- BreakpointName.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_BREAKPOINT_BREAKPOINTNAME_H
10 #define LLDB_BREAKPOINT_BREAKPOINTNAME_H
11 
12 #include <memory>
13 #include <string>
14 #include <unordered_set>
15 #include <vector>
16 
22 #include "lldb/Core/SearchFilter.h"
23 #include "lldb/Utility/Event.h"
24 #include "lldb/Utility/Flags.h"
27 
28 namespace lldb_private {
29 
31 public:
33  {
34  public:
35 
37  deletePerm = 2, allPerms = 3 };
38 
39  Permissions(bool in_list, bool in_disable, bool in_delete)
40  {
41  m_permissions[listPerm] = in_list;
42  m_permissions[disablePerm] = in_disable;
43  m_permissions[deletePerm] = in_delete;
45  }
46 
48  {
52  m_set_mask = rhs.m_set_mask;
53  }
54 
56  {
57  m_permissions[listPerm] = true;
58  m_permissions[disablePerm] = true;
59  m_permissions[deletePerm] = true;
60  m_set_mask.Clear();
61  }
62 
63  const Permissions &operator= (const Permissions &rhs)
64  {
65  if (this != &rhs) {
69  m_set_mask = rhs.m_set_mask;
70  }
71  return *this;
72  }
73 
74  void Clear() {
75  *this = Permissions();
76  }
77 
78  // Merge the permissions from incoming into this set of permissions. Only
79  // merge set permissions, and most restrictive permission wins.
80  void MergeInto(const Permissions &incoming)
81  {
82  MergePermission(incoming, listPerm);
83  MergePermission(incoming, disablePerm);
84  MergePermission(incoming, deletePerm);
85  }
86 
87  bool GetAllowList() const { return GetPermission(listPerm); }
88  bool SetAllowList(bool value) { return SetPermission(listPerm, value); }
89 
90  bool GetAllowDelete() const { return GetPermission(deletePerm); }
91  bool SetAllowDelete(bool value) { return SetPermission(deletePerm, value); }
92 
93  bool GetAllowDisable() const { return GetPermission(disablePerm); }
94  bool SetAllowDisable(bool value) { return SetPermission(disablePerm,
95  value); }
96 
97  bool GetPermission(enum PermissionKinds permission) const
98  {
99  return m_permissions[permission];
100  }
101 
103 
104  bool IsSet(enum PermissionKinds permission) const
105  {
106  return m_set_mask.Test(permissions_mask[permission]);
107  }
108 
109  bool AnySet() {
111  }
112 
113  private:
115 
118 
119  bool SetPermission(enum PermissionKinds permission, bool value)
120  {
121  bool old_value = m_permissions[permission];
122  m_permissions[permission] = value;
123  m_set_mask.Set(permissions_mask[permission]);
124  return old_value;
125  }
126 
127  // If either side disallows the permission, the resultant disallows it.
128  void MergePermission(const Permissions &incoming,
129  enum PermissionKinds permission)
130  {
131  if (incoming.IsSet(permission))
132  {
133  SetPermission(permission, !(m_permissions[permission] |
134  incoming.m_permissions[permission]));
135  }
136  }
137  };
138 
139  BreakpointName(ConstString name, const char *help = nullptr) :
140  m_name(name), m_options(false)
141  {
142  SetHelp(help);
143  }
144 
146  BreakpointOptions &options,
147  const Permissions &permissions = Permissions(),
148  const char *help = nullptr) :
149  m_name(name), m_options(options),
150  m_permissions(permissions) {
151  SetHelp(help);
152  };
153 
155  m_name(rhs.m_name), m_options(rhs.m_options),
157  {}
158 
159  BreakpointName(ConstString name, const Breakpoint &bkpt,
160  const char *help);
161 
162  ConstString GetName() const { return m_name; }
164  const BreakpointOptions &GetOptions() const { return m_options; }
165 
166  void SetOptions(const BreakpointOptions &options) {
167  m_options = options;
168  }
169 
171  const Permissions &GetPermissions() const { return m_permissions; }
172  void SetPermissions(const Permissions &permissions) {
173  m_permissions = permissions;
174  }
175 
177  {
178  return m_permissions.GetPermission(permission);
179  }
180 
181  void SetHelp(const char *description)
182  {
183  if (description)
184  m_help.assign(description);
185  else
186  m_help.clear();
187  }
188 
189  const char *GetHelp()
190  {
191  return m_help.c_str();
192  }
193 
194  // Returns true if any options were set in the name
196 
197  void ConfigureBreakpoint(lldb::BreakpointSP bp_sp);
198 
199 private:
204 };
205 
206 } // namespace lldb_private
207 
208 #endif // LLDB_BREAKPOINT_BREAKPOINTNAME_H
lldb_private::Flags::AnySet
bool AnySet(ValueType mask) const
Test one or more flags.
Definition: Flags.h:90
lldb_private::BreakpointName::Permissions::Permissions
Permissions(bool in_list, bool in_disable, bool in_delete)
Definition: BreakpointName.h:39
StructuredData.h
lldb_private::BreakpointName::Permissions::GetDescription
bool GetDescription(Stream *s, lldb::DescriptionLevel level)
Definition: BreakpointName.cpp:38
lldb_private::BreakpointName::GetPermissions
const Permissions & GetPermissions() const
Definition: BreakpointName.h:171
lldb_private::BreakpointName::Permissions::GetAllowDelete
bool GetAllowDelete() const
Definition: BreakpointName.h:90
lldb_private::BreakpointName::GetOptions
const BreakpointOptions & GetOptions() const
Definition: BreakpointName.h:164
lldb_private::Flags::Clear
ValueType Clear(ValueType mask=~static_cast< ValueType >(0))
Clear one or more flags.
Definition: Flags.h:61
lldb_private::Flags
Definition: Flags.h:22
lldb_private::BreakpointName::GetDescription
bool GetDescription(Stream *s, lldb::DescriptionLevel level)
Definition: BreakpointName.cpp:56
lldb_private::Flags::Test
bool Test(ValueType bit) const
Test a single flag bit.
Definition: Flags.h:96
lldb_private::BreakpointName
Definition: BreakpointName.h:30
lldb_private::Stream
Definition: Stream.h:28
lldb_private::BreakpointName::Permissions::GetPermission
bool GetPermission(enum PermissionKinds permission) const
Definition: BreakpointName.h:97
lldb_private::BreakpointName::m_help
std::string m_help
Definition: BreakpointName.h:203
lldb_private::BreakpointName::Permissions::operator=
const Permissions & operator=(const Permissions &rhs)
Definition: BreakpointName.h:63
lldb_private::BreakpointName::Permissions::Permissions
Permissions()
Definition: BreakpointName.h:55
lldb_private::BreakpointName::Permissions::m_permissions
bool m_permissions[allPerms]
Definition: BreakpointName.h:116
lldb_private::BreakpointName::m_permissions
Permissions m_permissions
Definition: BreakpointName.h:202
lldb_private::BreakpointName::m_options
BreakpointOptions m_options
Definition: BreakpointName.h:201
lldb_private::BreakpointName::SetOptions
void SetOptions(const BreakpointOptions &options)
Definition: BreakpointName.h:166
lldb_private::BreakpointName::Permissions::m_set_mask
Flags m_set_mask
Definition: BreakpointName.h:117
lldb_private::BreakpointName::Permissions::disablePerm
@ disablePerm
Definition: BreakpointName.h:36
SearchFilter.h
lldb_private::BreakpointName::Permissions::PermissionKinds
PermissionKinds
Definition: BreakpointName.h:36
lldb_private::BreakpointName::SetHelp
void SetHelp(const char *description)
Definition: BreakpointName.h:181
lldb_private::BreakpointName::Permissions::AnySet
bool AnySet()
Definition: BreakpointName.h:109
lldb_private::BreakpointName::Permissions::Permissions
Permissions(const Permissions &rhs)
Definition: BreakpointName.h:47
lldb_private::BreakpointName::Permissions
Definition: BreakpointName.h:32
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::BreakpointName::BreakpointName
BreakpointName(ConstString name, const char *help=nullptr)
Definition: BreakpointName.h:139
lldb_private::BreakpointName::Permissions::allPerms
@ allPerms
Definition: BreakpointName.h:37
lldb_private::BreakpointName::SetPermissions
void SetPermissions(const Permissions &permissions)
Definition: BreakpointName.h:172
lldb_private::BreakpointName::Permissions::MergePermission
void MergePermission(const Permissions &incoming, enum PermissionKinds permission)
Definition: BreakpointName.h:128
lldb_private::BreakpointOptions
Definition: BreakpointOptions.h:27
lldb_private::BreakpointName::Permissions::GetAllowList
bool GetAllowList() const
Definition: BreakpointName.h:87
lldb_private::BreakpointName::Permissions::MergeInto
void MergeInto(const Permissions &incoming)
Definition: BreakpointName.h:80
lldb_private::BreakpointName::BreakpointName
BreakpointName(ConstString name, BreakpointOptions &options, const Permissions &permissions=Permissions(), const char *help=nullptr)
Definition: BreakpointName.h:145
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
StringList.h
lldb_private::BreakpointName::GetName
ConstString GetName() const
Definition: BreakpointName.h:162
Event.h
BreakpointOptions.h
lldb_private::BreakpointName::Permissions::SetAllowList
bool SetAllowList(bool value)
Definition: BreakpointName.h:88
lldb_private::BreakpointName::GetPermission
bool GetPermission(Permissions::PermissionKinds permission) const
Definition: BreakpointName.h:176
lldb_private::BreakpointName::Permissions::SetPermission
bool SetPermission(enum PermissionKinds permission, bool value)
Definition: BreakpointName.h:119
uint32_t
lldb_private::BreakpointName::Permissions::Clear
void Clear()
Definition: BreakpointName.h:74
BreakpointLocationList.h
lldb_private::BreakpointName::Permissions::SetAllowDisable
bool SetAllowDisable(bool value)
Definition: BreakpointName.h:94
BreakpointID.h
BreakpointLocationCollection.h
lldb_private::BreakpointName::Permissions::permissions_mask
static const Flags::ValueType permissions_mask[allPerms+1]
Definition: BreakpointName.h:114
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::BreakpointName::GetPermissions
Permissions & GetPermissions()
Definition: BreakpointName.h:170
lldb_private::BreakpointName::GetHelp
const char * GetHelp()
Definition: BreakpointName.h:189
lldb_private::Flags::Set
ValueType Set(ValueType mask)
Set one or more flags by logical OR'ing mask with the current flags.
Definition: Flags.h:73
Flags.h
lldb_private::BreakpointName::Permissions::deletePerm
@ deletePerm
Definition: BreakpointName.h:37
lldb_private::BreakpointName::Permissions::listPerm
@ listPerm
Definition: BreakpointName.h:36
lldb_private::BreakpointName::Permissions::GetAllowDisable
bool GetAllowDisable() const
Definition: BreakpointName.h:93
Stoppoint.h
lldb_private::BreakpointName::m_name
ConstString m_name
Definition: BreakpointName.h:200
lldb_private::BreakpointName::ConfigureBreakpoint
void ConfigureBreakpoint(lldb::BreakpointSP bp_sp)
Definition: BreakpointName.cpp:82
lldb_private::BreakpointName::BreakpointName
BreakpointName(const BreakpointName &rhs)
Definition: BreakpointName.h:154
lldb_private::BreakpointName::Permissions::IsSet
bool IsSet(enum PermissionKinds permission) const
Definition: BreakpointName.h:104
lldb_private::BreakpointName::GetOptions
BreakpointOptions & GetOptions()
Definition: BreakpointName.h:163
lldb::DescriptionLevel
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
Definition: lldb-enumerations.h:207
lldb_private::Breakpoint
General Outline: A breakpoint has four main parts, a filter, a resolver, the list of breakpoint locat...
Definition: Breakpoint.h:80
lldb_private::BreakpointName::Permissions::SetAllowDelete
bool SetAllowDelete(bool value)
Definition: BreakpointName.h:91