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 #include "llvm/Support/Casting.h" 11 12 #include "lldb/Breakpoint/Breakpoint.h" 13 #include "lldb/Breakpoint/BreakpointOptions.h" 14 #include "lldb/Breakpoint/BreakpointLocationCollection.h" 15 #include "lldb/Breakpoint/BreakpointResolver.h" 16 #include "lldb/Breakpoint/BreakpointResolverFileLine.h" 17 #include "lldb/Utility/Log.h" 18 #include "lldb/Utility/Stream.h" 19 #include "lldb/Utility/StreamString.h" 20 21 using namespace lldb; 22 using namespace lldb_private; 23 24 const Flags::ValueType BreakpointName::Permissions::permissions_mask 25 [BreakpointName::Permissions::PermissionKinds::allPerms + 1] = { 26 (1u << 0), 27 (1u << 1), 28 (1u << 2), 29 (0x5u) 30 }; 31 32 BreakpointName::BreakpointName(const ConstString &name, const Breakpoint &bkpt, 33 const char *help) : 34 m_name(name), m_options(bkpt.GetOptions()) 35 { 36 SetHelp(help); 37 } 38 39 bool BreakpointName::Permissions::GetDescription(Stream *s, 40 lldb::DescriptionLevel level) { 41 if (!AnySet()) 42 return false; 43 s->IndentMore(); 44 s->Indent(); 45 if (IsSet(listPerm)) 46 s->Printf("list: %s", GetAllowList() ? "allowed" : "disallowed"); 47 48 if (IsSet(disablePerm)) 49 s->Printf("disable: %s", GetAllowDisable() ? "allowed" : "disallowed"); 50 51 if (IsSet(deletePerm)) 52 s->Printf("delete: %s", GetAllowDelete() ? "allowed" : "disallowed"); 53 s->IndentLess(); 54 return true; 55 } 56 57 bool BreakpointName::GetDescription(Stream *s, lldb::DescriptionLevel level) { 58 bool printed_any = false; 59 if (!m_help.empty()) 60 s->Printf("Help: %s\n", m_help.c_str()); 61 62 if (GetOptions().AnySet()) 63 { 64 s->PutCString("Options: \n"); 65 s->IndentMore(); 66 s->Indent(); 67 GetOptions().GetDescription(s, level); 68 printed_any = true; 69 s->IndentLess(); 70 } 71 if (GetPermissions().AnySet()) 72 { 73 s->PutCString("Permissions: \n"); 74 s->IndentMore(); 75 s->Indent(); 76 GetPermissions().GetDescription(s, level); 77 printed_any = true; 78 s->IndentLess(); 79 } 80 return printed_any; 81 } 82 83 void BreakpointName::ConfigureBreakpoint(lldb::BreakpointSP bp_sp) 84 { 85 bp_sp->GetOptions()->CopyOverSetOptions(GetOptions()); 86 bp_sp->GetPermissions().MergeInto(GetPermissions()); 87 } 88