xref: /freebsd/contrib/llvm-project/lldb/source/Breakpoint/BreakpointName.cpp (revision 700637cbb5e582861067a11aaca4d053546871d2)
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 
20 using namespace lldb;
21 using namespace lldb_private;
22 
23 const Flags::ValueType BreakpointName::Permissions::permissions_mask
24     [BreakpointName::Permissions::PermissionKinds::allPerms + 1] = {
25         (1u << 0), (1u << 1), (1u << 2), (0x5u)};
26 
GetDescription(Stream * s,lldb::DescriptionLevel level)27 bool BreakpointName::Permissions::GetDescription(Stream *s,
28                                                  lldb::DescriptionLevel level) {
29     if (!AnySet())
30       return false;
31     s->IndentMore();
32     s->Indent();
33     if (IsSet(listPerm))
34       s->Printf("list: %s", GetAllowList() ? "allowed" : "disallowed");
35 
36     if (IsSet(disablePerm))
37       s->Printf("disable: %s", GetAllowDisable() ? "allowed" : "disallowed");
38 
39     if (IsSet(deletePerm))
40       s->Printf("delete: %s", GetAllowDelete() ? "allowed" : "disallowed");
41     s->IndentLess();
42     return true;
43 }
44 
GetDescription(Stream * s,lldb::DescriptionLevel level)45 bool BreakpointName::GetDescription(Stream *s, lldb::DescriptionLevel level) {
46   bool printed_any = false;
47   if (!m_help.empty())
48     s->Printf("Help: %s\n", m_help.c_str());
49 
50   if (GetOptions().AnySet())
51   {
52     s->PutCString("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("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 
ConfigureBreakpoint(lldb::BreakpointSP bp_sp)71 void BreakpointName::ConfigureBreakpoint(lldb::BreakpointSP bp_sp)
72 {
73   bp_sp->GetOptions().CopyOverSetOptions(GetOptions());
74   bp_sp->GetPermissions().MergeInto(GetPermissions());
75 }
76