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:
41
42 Permissions(bool in_list, bool in_disable, bool in_delete) {
43 m_permissions[listPerm] = in_list;
44 m_permissions[disablePerm] = in_disable;
45 m_permissions[deletePerm] = in_delete;
47 }
48
56
58 m_permissions[listPerm] = true;
61 m_set_mask.Clear();
62 }
63
65 {
66 if (this != &rhs) {
71 }
72 return *this;
73 }
74
75 void Clear() {
76 *this = Permissions();
77 }
78
79 // Merge the permissions from incoming into this set of permissions. Only
80 // merge set permissions, and most restrictive permission wins.
81 void MergeInto(const Permissions &incoming)
82 {
83 MergePermission(incoming, listPerm);
85 MergePermission(incoming, deletePerm);
86 }
87
88 bool GetAllowList() const { return GetPermission(listPerm); }
89 bool SetAllowList(bool value) { return SetPermission(listPerm, value); }
90
91 bool GetAllowDelete() const { return GetPermission(deletePerm); }
92 bool SetAllowDelete(bool value) { return SetPermission(deletePerm, value); }
93
94 bool GetAllowDisable() const { return GetPermission(disablePerm); }
95 bool SetAllowDisable(bool value) {
96 return SetPermission(disablePerm, value);
97 }
98
99 bool GetPermission(enum PermissionKinds permission) const
100 {
101 return m_permissions[permission];
102 }
103
105
106 bool IsSet(enum PermissionKinds permission) const
107 {
108 return m_set_mask.Test(permissions_mask[permission]);
109 }
110
111 bool AnySet() {
112 return m_set_mask.AnySet(permissions_mask[allPerms]);
113 }
114
115 private:
117
120
121 bool SetPermission(enum PermissionKinds permission, bool value)
122 {
123 bool old_value = m_permissions[permission];
124 m_permissions[permission] = value;
125 m_set_mask.Set(permissions_mask[permission]);
126 return old_value;
127 }
128
129 // If either side disallows the permission, the resultant disallows it.
130 void MergePermission(const Permissions &incoming,
131 enum PermissionKinds permission) {
132 if (incoming.IsSet(permission))
133 {
134 SetPermission(permission, !(m_permissions[permission] |
135 incoming.m_permissions[permission]));
136 }
137 }
138 };
139
140 BreakpointName(ConstString name, const char *help = nullptr) :
141 m_name(name), m_options(false)
142 {
143 SetHelp(help);
144 }
145
150
151 ConstString GetName() const { return m_name; }
153 const BreakpointOptions &GetOptions() const { return m_options; }
154
155 void SetOptions(const BreakpointOptions &options) {
156 m_options = options;
157 }
158
160 const Permissions &GetPermissions() const { return m_permissions; }
161 void SetPermissions(const Permissions &permissions) {
162 m_permissions = permissions;
163 }
164
166 {
167 return m_permissions.GetPermission(permission);
168 }
169
170 void SetHelp(const char *description)
171 {
172 if (description)
173 m_help.assign(description);
174 else
175 m_help.clear();
176 }
177
178 const char *GetHelp()
179 {
180 return m_help.c_str();
181 }
182
183 // Returns true if any options were set in the name
185
187
188private:
192 std::string m_help;
193};
194
195} // namespace lldb_private
196
197#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
uint32_t ValueType
The value type for flags is a 32 bit unsigned integer type.
Definition Flags.h:25
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.
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
std::shared_ptr< lldb_private::Breakpoint > BreakpointSP