blob: 37903a00236390397b94e09759e530bc1748852a [file] [log] [blame]
Raphael Isemann80814282020-01-24 08:23:27 +01001//===-- BreakpointName.cpp ------------------------------------------------===//
Jim Inghamb842f2e2017-09-14 20:22:49 +00002//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Jim Inghamb842f2e2017-09-14 20:22:49 +00006//
7//===----------------------------------------------------------------------===//
8
Jim Inghamb842f2e2017-09-14 20:22:49 +00009#include "llvm/Support/Casting.h"
10
Jim Inghamb842f2e2017-09-14 20:22:49 +000011#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),
26 (1u << 1),
27 (1u << 2),
28 (0x5u)
29};
30
Adrian Prantl0e4c4822019-03-06 21:22:25 +000031BreakpointName::BreakpointName(ConstString name, const Breakpoint &bkpt,
Jim Inghamb842f2e2017-09-14 20:22:49 +000032 const char *help) :
33 m_name(name), m_options(bkpt.GetOptions())
34{
35 SetHelp(help);
36}
37
38bool BreakpointName::Permissions::GetDescription(Stream *s,
39 lldb::DescriptionLevel level) {
40 if (!AnySet())
41 return false;
42 s->IndentMore();
43 s->Indent();
44 if (IsSet(listPerm))
45 s->Printf("list: %s", GetAllowList() ? "allowed" : "disallowed");
46
47 if (IsSet(disablePerm))
48 s->Printf("disable: %s", GetAllowDisable() ? "allowed" : "disallowed");
49
50 if (IsSet(deletePerm))
51 s->Printf("delete: %s", GetAllowDelete() ? "allowed" : "disallowed");
52 s->IndentLess();
53 return true;
54}
55
56bool BreakpointName::GetDescription(Stream *s, lldb::DescriptionLevel level) {
57 bool printed_any = false;
Jim Inghame9632eb2017-09-15 00:52:35 +000058 if (!m_help.empty())
59 s->Printf("Help: %s\n", m_help.c_str());
60
Jim Inghamb842f2e2017-09-14 20:22:49 +000061 if (GetOptions().AnySet())
62 {
63 s->PutCString("Options: \n");
64 s->IndentMore();
65 s->Indent();
66 GetOptions().GetDescription(s, level);
67 printed_any = true;
68 s->IndentLess();
69 }
70 if (GetPermissions().AnySet())
71 {
72 s->PutCString("Permissions: \n");
73 s->IndentMore();
74 s->Indent();
75 GetPermissions().GetDescription(s, level);
76 printed_any = true;
77 s->IndentLess();
78 }
79 return printed_any;
80}
81
82void BreakpointName::ConfigureBreakpoint(lldb::BreakpointSP bp_sp)
83{
84 bp_sp->GetOptions()->CopyOverSetOptions(GetOptions());
85 bp_sp->GetPermissions().MergeInto(GetPermissions());
86}