]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Breakpoint/BreakpointName.cpp
Import tzdata 2018d
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / Breakpoint / BreakpointName.cpp
1 //===-- Breakpoint.cpp ------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details->
7 //
8 //===----------------------------------------------------------------------===//
9
10 // C Includes
11 // C++ Includes
12 // Other libraries and framework includes
13 #include "llvm/Support/Casting.h"
14
15 // Project includes
16 #include "lldb/Breakpoint/Breakpoint.h"
17 #include "lldb/Breakpoint/BreakpointOptions.h"
18 #include "lldb/Breakpoint/BreakpointLocationCollection.h"
19 #include "lldb/Breakpoint/BreakpointResolver.h"
20 #include "lldb/Breakpoint/BreakpointResolverFileLine.h"
21 #include "lldb/Utility/Log.h"
22 #include "lldb/Utility/Stream.h"
23 #include "lldb/Utility/StreamString.h"
24
25 using namespace lldb;
26 using namespace lldb_private;
27
28 const Flags::ValueType BreakpointName::Permissions::permissions_mask
29     [BreakpointName::Permissions::PermissionKinds::allPerms + 1] =  { 
30       (1u << 0),
31       (1u << 1),
32       (1u << 2),
33       (0x5u)
34 };
35
36 BreakpointName::BreakpointName(const ConstString &name, const Breakpoint &bkpt,
37                  const char *help) :
38       m_name(name), m_options(bkpt.GetOptions())
39 {
40   SetHelp(help);
41 }
42
43 bool BreakpointName::Permissions::GetDescription(Stream *s,
44                                                  lldb::DescriptionLevel level) {
45     if (!AnySet())
46       return false;
47     s->IndentMore();
48     s->Indent();
49     if (IsSet(listPerm))
50       s->Printf("list: %s", GetAllowList() ? "allowed" : "disallowed");
51   
52     if (IsSet(disablePerm))
53       s->Printf("disable: %s", GetAllowDisable() ? "allowed" : "disallowed");
54   
55     if (IsSet(deletePerm))
56       s->Printf("delete: %s", GetAllowDelete() ? "allowed" : "disallowed");
57     s->IndentLess();
58     return true;
59 }
60
61 bool BreakpointName::GetDescription(Stream *s, lldb::DescriptionLevel level) {
62   bool printed_any = false;
63   if (!m_help.empty())
64     s->Printf("Help: %s\n", m_help.c_str());
65
66   if (GetOptions().AnySet())
67   {
68     s->PutCString("Options: \n");
69     s->IndentMore();
70     s->Indent();
71     GetOptions().GetDescription(s, level);
72     printed_any = true;
73     s->IndentLess();
74   }
75   if (GetPermissions().AnySet())
76   {
77     s->PutCString("Permissions: \n");
78     s->IndentMore();
79     s->Indent();
80     GetPermissions().GetDescription(s, level);
81     printed_any = true;
82     s->IndentLess();
83  }
84   return printed_any;
85 }
86
87 void BreakpointName::ConfigureBreakpoint(lldb::BreakpointSP bp_sp)
88 {
89    bp_sp->GetOptions()->CopyOverSetOptions(GetOptions());
90    bp_sp->GetPermissions().MergeInto(GetPermissions());
91 }