1 //===-- SBBreakpointLocation.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 "lldb/API/SBBreakpointLocation.h" 11 #include "lldb/API/SBDefines.h" 12 #include "lldb/API/SBDebugger.h" 13 14 #include "lldb/lldb-types.h" 15 #include "lldb/lldb-defines.h" 16 #include "lldb/Breakpoint/BreakpointLocation.h" 17 #include "lldb/Core/Stream.h" 18 #include "lldb/Core/StreamFile.h" 19 20 using namespace lldb; 21 using namespace lldb_private; 22 23 24 25 //class SBBreakpointLocation 26 27 SBBreakpointLocation::SBBreakpointLocation () 28 { 29 } 30 31 SBBreakpointLocation::SBBreakpointLocation (const lldb::BreakpointLocationSP &break_loc_sp) : 32 m_break_loc_sp (break_loc_sp) 33 { 34 } 35 36 SBBreakpointLocation::~SBBreakpointLocation () 37 { 38 } 39 40 bool 41 SBBreakpointLocation::IsValid() const 42 { 43 return m_break_loc_sp.get() != NULL; 44 } 45 46 addr_t 47 SBBreakpointLocation::GetLoadAddress () 48 { 49 addr_t ret_addr = LLDB_INVALID_ADDRESS; 50 51 if (m_break_loc_sp) 52 { 53 ret_addr = m_break_loc_sp->GetLoadAddress(); 54 } 55 56 return ret_addr; 57 } 58 59 void 60 SBBreakpointLocation::SetEnabled (bool enabled) 61 { 62 if (m_break_loc_sp) 63 { 64 m_break_loc_sp->SetEnabled (enabled); 65 } 66 } 67 68 bool 69 SBBreakpointLocation::IsEnabled () 70 { 71 if (m_break_loc_sp) 72 return m_break_loc_sp->IsEnabled(); 73 else 74 return false; 75 } 76 77 int32_t 78 SBBreakpointLocation::GetIgnoreCount () 79 { 80 if (m_break_loc_sp) 81 return m_break_loc_sp->GetIgnoreCount(); 82 else 83 return 0; 84 } 85 86 void 87 SBBreakpointLocation::SetIgnoreCount (int32_t n) 88 { 89 if (m_break_loc_sp) 90 m_break_loc_sp->SetIgnoreCount (n); 91 } 92 93 void 94 SBBreakpointLocation::SetThreadID (tid_t thread_id) 95 { 96 if (m_break_loc_sp) 97 m_break_loc_sp->SetThreadID (thread_id); 98 } 99 100 tid_t 101 SBBreakpointLocation::GetThreadID () 102 { 103 tid_t sb_thread_id = (lldb::tid_t) LLDB_INVALID_THREAD_ID; 104 if (m_break_loc_sp) 105 sb_thread_id = m_break_loc_sp->GetThreadID(); 106 107 return sb_thread_id; 108 } 109 110 bool 111 SBBreakpointLocation::IsResolved () 112 { 113 if (m_break_loc_sp) 114 return m_break_loc_sp->IsResolved(); 115 else 116 return false; 117 } 118 119 void 120 SBBreakpointLocation::SetLocation (const lldb::BreakpointLocationSP &break_loc_sp) 121 { 122 if (m_break_loc_sp) 123 { 124 // Uninstall the callbacks? 125 } 126 m_break_loc_sp = break_loc_sp; 127 } 128 129 void 130 SBBreakpointLocation::GetDescription (FILE *f, const char *description_level) 131 { 132 if (f == NULL) 133 return; 134 135 if (m_break_loc_sp) 136 { 137 DescriptionLevel level; 138 if (strcmp (description_level, "brief") == 0) 139 level = eDescriptionLevelBrief; 140 else if (strcmp (description_level, "full") == 0) 141 level = eDescriptionLevelFull; 142 else if (strcmp (description_level, "verbose") == 0) 143 level = eDescriptionLevelVerbose; 144 else 145 level = eDescriptionLevelBrief; 146 147 StreamFile str (f); 148 149 m_break_loc_sp->GetDescription (&str, level); 150 str.EOL(); 151 } 152 } 153 154 SBBreakpoint 155 SBBreakpointLocation::GetBreakpoint () 156 { 157 SBBreakpoint sb_bp; 158 if (m_break_loc_sp) 159 *sb_bp = m_break_loc_sp->GetBreakpoint ().GetSP(); 160 return sb_bp; 161 } 162 163