1//===-- BreakpointName.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
9#include "llvm/Support/Casting.h"
10
11#include "lldb/Breakpoint/Breakpoint.h"
12#include "lldb/Breakpoint/BreakpointOptions.h"
13#include "lldb/Breakpoint/BreakpointLocationCollection.h"
14#include "lldb/Breakpoint/BreakpointResolver.h"
15#include "lldb/Breakpoint/BreakpointResolverFileLine.h"
16#include "lldb/Utility/Log.h"
17#include "lldb/Utility/Stream.h"
18#include "lldb/Utility/StreamString.h"
19
20using namespace lldb;
21using namespace lldb_private;
22
23const Flags::ValueType BreakpointName::Permissions::permissions_mask
24 [BreakpointName::Permissions::PermissionKinds::allPerms + 1] = {
25 (1u << 0), (1u << 1), (1u << 2), (0x5u)};
26
27bool BreakpointName::Permissions::GetDescription(Stream *s,
28 lldb::DescriptionLevel level) {
29 if (!AnySet())
30 return false;
31 s->IndentMore();
32 s->Indent();
33 if (IsSet(permission: listPerm))
34 s->Printf(format: "list: %s", GetAllowList() ? "allowed" : "disallowed");
35
36 if (IsSet(permission: disablePerm))
37 s->Printf(format: "disable: %s", GetAllowDisable() ? "allowed" : "disallowed");
38
39 if (IsSet(permission: deletePerm))
40 s->Printf(format: "delete: %s", GetAllowDelete() ? "allowed" : "disallowed");
41 s->IndentLess();
42 return true;
43}
44
45bool BreakpointName::GetDescription(Stream *s, lldb::DescriptionLevel level) {
46 bool printed_any = false;
47 if (!m_help.empty())
48 s->Printf(format: "Help: %s\n", m_help.c_str());
49
50 if (GetOptions().AnySet())
51 {
52 s->PutCString(cstr: "Options: \n");
53 s->IndentMore();
54 s->Indent();
55 GetOptions().GetDescription(s, level);
56 printed_any = true;
57 s->IndentLess();
58 }
59 if (GetPermissions().AnySet())
60 {
61 s->PutCString(cstr: "Permissions: \n");
62 s->IndentMore();
63 s->Indent();
64 GetPermissions().GetDescription(s, level);
65 printed_any = true;
66 s->IndentLess();
67 }
68 return printed_any;
69}
70
71void BreakpointName::ConfigureBreakpoint(lldb::BreakpointSP bp_sp)
72{
73 bp_sp->GetOptions().CopyOverSetOptions(rhs: GetOptions());
74 bp_sp->GetPermissions().MergeInto(incoming: GetPermissions());
75}
76

source code of lldb/source/Breakpoint/BreakpointName.cpp