LLDB  mainline
BreakpointName.cpp
Go to the documentation of this file.
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 
16 #include "lldb/Utility/Log.h"
17 #include "lldb/Utility/Stream.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),
26  (1u << 1),
27  (1u << 2),
28  (0x5u)
29 };
30 
31 BreakpointName::BreakpointName(ConstString name, const Breakpoint &bkpt,
32  const char *help) :
33  m_name(name), m_options(bkpt.GetOptions())
34 {
35  SetHelp(help);
36 }
37 
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 
57  bool printed_any = false;
58  if (!m_help.empty())
59  s->Printf("Help: %s\n", m_help.c_str());
60 
61  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 
82 void BreakpointName::ConfigureBreakpoint(lldb::BreakpointSP bp_sp)
83 {
84  bp_sp->GetOptions().CopyOverSetOptions(GetOptions());
85  bp_sp->GetPermissions().MergeInto(GetPermissions());
86 }
lldb_private::Stream::IndentLess
void IndentLess(unsigned amount=2)
Decrement the current indentation level.
Definition: Stream.cpp:171
lldb_private::BreakpointOptions::GetDescription
void GetDescription(Stream *s, lldb::DescriptionLevel level) const
Definition: BreakpointOptions.cpp:528
lldb_private::BreakpointName::Permissions::GetDescription
bool GetDescription(Stream *s, lldb::DescriptionLevel level)
Definition: BreakpointName.cpp:38
lldb_private::BreakpointName::Permissions::GetAllowDelete
bool GetAllowDelete() const
Definition: BreakpointName.h:90
BreakpointResolver.h
lldb_private::BreakpointName::GetDescription
bool GetDescription(Stream *s, lldb::DescriptionLevel level)
Definition: BreakpointName.cpp:56
lldb_private::Stream
Definition: Stream.h:28
lldb_private::BreakpointName::m_help
std::string m_help
Definition: BreakpointName.h:203
lldb_private::BreakpointName::Permissions::disablePerm
@ disablePerm
Definition: BreakpointName.h:36
lldb_private::Stream::Indent
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
Definition: Stream.cpp:130
Log.h
lldb_private::BreakpointName::SetHelp
void SetHelp(const char *description)
Definition: BreakpointName.h:181
lldb_private::BreakpointName::Permissions::AnySet
bool AnySet()
Definition: BreakpointName.h:109
StreamString.h
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::BreakpointName::Permissions::GetAllowList
bool GetAllowList() const
Definition: BreakpointName.h:87
BreakpointOptions.h
uint32_t
lldb_private::Stream::IndentMore
void IndentMore(unsigned amount=2)
Increment the current indentation level.
Definition: Stream.cpp:168
BreakpointLocationCollection.h
lldb_private::Stream::Printf
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::BreakpointName::GetPermissions
Permissions & GetPermissions()
Definition: BreakpointName.h:170
Breakpoint.h
lldb_private::BreakpointName::Permissions::deletePerm
@ deletePerm
Definition: BreakpointName.h:37
lldb_private::BreakpointName::Permissions::listPerm
@ listPerm
Definition: BreakpointName.h:36
Stream.h
lldb_private::Stream::PutCString
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:63
lldb_private::BreakpointName::Permissions::GetAllowDisable
bool GetAllowDisable() const
Definition: BreakpointName.h:93
lldb_private::BreakpointName::ConfigureBreakpoint
void ConfigureBreakpoint(lldb::BreakpointSP bp_sp)
Definition: BreakpointName.cpp:82
lldb
Definition: SBAddress.h:15
BreakpointResolverFileLine.h
lldb_private::BreakpointName::Permissions::IsSet
bool IsSet(enum PermissionKinds permission) const
Definition: BreakpointName.h:104
lldb_private::BreakpointName::GetOptions
BreakpointOptions & GetOptions()
Definition: BreakpointName.h:163
lldb::DescriptionLevel
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
Definition: lldb-enumerations.h:207
lldb_private::Breakpoint
General Outline: A breakpoint has four main parts, a filter, a resolver, the list of breakpoint locat...
Definition: Breakpoint.h:80