1353358Sdim//===-- BreakpointName.cpp --------------------------------------*- C++ -*-===// 2326949Sdim// 3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4353358Sdim// See https://llvm.org/LICENSE.txt for license information. 5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6326949Sdim// 7326949Sdim//===----------------------------------------------------------------------===// 8326949Sdim 9326949Sdim#include "llvm/Support/Casting.h" 10326949Sdim 11326949Sdim#include "lldb/Breakpoint/Breakpoint.h" 12326949Sdim#include "lldb/Breakpoint/BreakpointOptions.h" 13326949Sdim#include "lldb/Breakpoint/BreakpointLocationCollection.h" 14326949Sdim#include "lldb/Breakpoint/BreakpointResolver.h" 15326949Sdim#include "lldb/Breakpoint/BreakpointResolverFileLine.h" 16326949Sdim#include "lldb/Utility/Log.h" 17326949Sdim#include "lldb/Utility/Stream.h" 18326949Sdim#include "lldb/Utility/StreamString.h" 19326949Sdim 20326949Sdimusing namespace lldb; 21326949Sdimusing namespace lldb_private; 22326949Sdim 23326949Sdimconst Flags::ValueType BreakpointName::Permissions::permissions_mask 24326949Sdim [BreakpointName::Permissions::PermissionKinds::allPerms + 1] = { 25326949Sdim (1u << 0), 26326949Sdim (1u << 1), 27326949Sdim (1u << 2), 28326949Sdim (0x5u) 29326949Sdim}; 30326949Sdim 31353358SdimBreakpointName::BreakpointName(ConstString name, const Breakpoint &bkpt, 32326949Sdim const char *help) : 33326949Sdim m_name(name), m_options(bkpt.GetOptions()) 34326949Sdim{ 35326949Sdim SetHelp(help); 36326949Sdim} 37326949Sdim 38326949Sdimbool BreakpointName::Permissions::GetDescription(Stream *s, 39326949Sdim lldb::DescriptionLevel level) { 40326949Sdim if (!AnySet()) 41326949Sdim return false; 42326949Sdim s->IndentMore(); 43326949Sdim s->Indent(); 44326949Sdim if (IsSet(listPerm)) 45326949Sdim s->Printf("list: %s", GetAllowList() ? "allowed" : "disallowed"); 46326949Sdim 47326949Sdim if (IsSet(disablePerm)) 48326949Sdim s->Printf("disable: %s", GetAllowDisable() ? "allowed" : "disallowed"); 49326949Sdim 50326949Sdim if (IsSet(deletePerm)) 51326949Sdim s->Printf("delete: %s", GetAllowDelete() ? "allowed" : "disallowed"); 52326949Sdim s->IndentLess(); 53326949Sdim return true; 54326949Sdim} 55326949Sdim 56326949Sdimbool BreakpointName::GetDescription(Stream *s, lldb::DescriptionLevel level) { 57326949Sdim bool printed_any = false; 58326949Sdim if (!m_help.empty()) 59326949Sdim s->Printf("Help: %s\n", m_help.c_str()); 60326949Sdim 61326949Sdim if (GetOptions().AnySet()) 62326949Sdim { 63326949Sdim s->PutCString("Options: \n"); 64326949Sdim s->IndentMore(); 65326949Sdim s->Indent(); 66326949Sdim GetOptions().GetDescription(s, level); 67326949Sdim printed_any = true; 68326949Sdim s->IndentLess(); 69326949Sdim } 70326949Sdim if (GetPermissions().AnySet()) 71326949Sdim { 72326949Sdim s->PutCString("Permissions: \n"); 73326949Sdim s->IndentMore(); 74326949Sdim s->Indent(); 75326949Sdim GetPermissions().GetDescription(s, level); 76326949Sdim printed_any = true; 77326949Sdim s->IndentLess(); 78326949Sdim } 79326949Sdim return printed_any; 80326949Sdim} 81326949Sdim 82326949Sdimvoid BreakpointName::ConfigureBreakpoint(lldb::BreakpointSP bp_sp) 83326949Sdim{ 84326949Sdim bp_sp->GetOptions()->CopyOverSetOptions(GetOptions()); 85326949Sdim bp_sp->GetPermissions().MergeInto(GetPermissions()); 86326949Sdim} 87