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
23#include "lldb/Utility/Event.h"
24#include "lldb/Utility/Flags.h"
27
28namespace lldb_private {
29
31public:
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 {
53 }
54
56 {
57 m_permissions[listPerm] = true;
61 }
62
64 {
65 if (this != &rhs) {
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);
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 m_name(rhs.m_name), m_options(rhs.m_options),
148 {}
149
150 ConstString GetName() const { return m_name; }
152 const BreakpointOptions &GetOptions() const { return m_options; }
153
154 void SetOptions(const BreakpointOptions &options) {
155 m_options = options;
156 }
157
159 const Permissions &GetPermissions() const { return m_permissions; }
160 void SetPermissions(const Permissions &permissions) {
161 m_permissions = permissions;
162 }
163
165 {
166 return m_permissions.GetPermission(permission);
167 }
168
169 void SetHelp(const char *description)
170 {
171 if (description)
172 m_help.assign(description);
173 else
174 m_help.clear();
175 }
176
177 const char *GetHelp()
178 {
179 return m_help.c_str();
180 }
181
182 // Returns true if any options were set in the name
184
186
187private:
191 std::string m_help;
192};
193
194} // namespace lldb_private
195
196#endif // LLDB_BREAKPOINT_BREAKPOINTNAME_H
bool IsSet(enum PermissionKinds permission) const
Permissions(bool in_list, bool in_disable, bool in_delete)
const Permissions & operator=(const Permissions &rhs)
void MergeInto(const Permissions &incoming)
void MergePermission(const Permissions &incoming, enum PermissionKinds permission)
bool GetDescription(Stream *s, lldb::DescriptionLevel level)
static const Flags::ValueType permissions_mask[allPerms+1]
bool GetPermission(enum PermissionKinds permission) const
bool SetPermission(enum PermissionKinds permission, bool value)
bool GetDescription(Stream *s, lldb::DescriptionLevel level)
void SetPermissions(const Permissions &permissions)
BreakpointName(const BreakpointName &rhs)
ConstString GetName() const
void SetHelp(const char *description)
bool GetPermission(Permissions::PermissionKinds permission) const
void SetOptions(const BreakpointOptions &options)
const BreakpointOptions & GetOptions() const
BreakpointOptions & GetOptions()
const Permissions & GetPermissions() const
BreakpointName(ConstString name, const char *help=nullptr)
void ConfigureBreakpoint(lldb::BreakpointSP bp_sp)
"lldb/Breakpoint/BreakpointOptions.h" Class that manages the options on a breakpoint or breakpoint lo...
A uniqued constant string class.
Definition: ConstString.h:40
A class to manage flags.
Definition: Flags.h:22
ValueType Clear(ValueType mask=~static_cast< ValueType >(0))
Clear one or more flags.
Definition: Flags.h:61
uint32_t ValueType
The value type for flags is a 32 bit unsigned integer type.
Definition: Flags.h:25
bool Test(ValueType bit) const
Test a single flag bit.
Definition: Flags.h:96
bool AnySet(ValueType mask) const
Test one or more flags.
Definition: Flags.h:90
ValueType Set(ValueType mask)
Set one or more flags by logical OR'ing mask with the current flags.
Definition: Flags.h:73
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
std::shared_ptr< lldb_private::Breakpoint > BreakpointSP
Definition: lldb-forward.h:313