Jim Ingham | b842f2e | 2017-09-14 20:22:49 +0000 | [diff] [blame^] | 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 (GetOptions().AnySet()) |
| 64 | { |
| 65 | s->PutCString("Options: \n"); |
| 66 | s->IndentMore(); |
| 67 | s->Indent(); |
| 68 | GetOptions().GetDescription(s, level); |
| 69 | printed_any = true; |
| 70 | s->IndentLess(); |
| 71 | } |
| 72 | if (GetPermissions().AnySet()) |
| 73 | { |
| 74 | s->PutCString("Permissions: \n"); |
| 75 | s->IndentMore(); |
| 76 | s->Indent(); |
| 77 | GetPermissions().GetDescription(s, level); |
| 78 | printed_any = true; |
| 79 | s->IndentLess(); |
| 80 | } |
| 81 | return printed_any; |
| 82 | } |
| 83 | |
| 84 | void BreakpointName::ConfigureBreakpoint(lldb::BreakpointSP bp_sp) |
| 85 | { |
| 86 | bp_sp->GetOptions()->CopyOverSetOptions(GetOptions()); |
| 87 | bp_sp->GetPermissions().MergeInto(GetPermissions()); |
| 88 | } |