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/Target/ThreadSpec.h" 18 #include "lldb/Core/Stream.h" 19 #include "lldb/Core/StreamFile.h" 20 #include "lldb/Target/ThreadSpec.h" 21 22 using namespace lldb; 23 using namespace lldb_private; 24 25 26 27 //class SBBreakpointLocation 28 29 SBBreakpointLocation::SBBreakpointLocation () 30 { 31 } 32 33 SBBreakpointLocation::SBBreakpointLocation (const lldb::BreakpointLocationSP &break_loc_sp) : 34 m_opaque_sp (break_loc_sp) 35 { 36 } 37 38 SBBreakpointLocation::~SBBreakpointLocation () 39 { 40 } 41 42 bool 43 SBBreakpointLocation::IsValid() const 44 { 45 return m_opaque_sp.get() != NULL; 46 } 47 48 addr_t 49 SBBreakpointLocation::GetLoadAddress () 50 { 51 addr_t ret_addr = LLDB_INVALID_ADDRESS; 52 53 if (m_opaque_sp) 54 { 55 ret_addr = m_opaque_sp->GetLoadAddress(); 56 } 57 58 return ret_addr; 59 } 60 61 void 62 SBBreakpointLocation::SetEnabled (bool enabled) 63 { 64 if (m_opaque_sp) 65 { 66 m_opaque_sp->SetEnabled (enabled); 67 } 68 } 69 70 bool 71 SBBreakpointLocation::IsEnabled () 72 { 73 if (m_opaque_sp) 74 return m_opaque_sp->IsEnabled(); 75 else 76 return false; 77 } 78 79 int32_t 80 SBBreakpointLocation::GetIgnoreCount () 81 { 82 if (m_opaque_sp) 83 return m_opaque_sp->GetIgnoreCount(); 84 else 85 return 0; 86 } 87 88 void 89 SBBreakpointLocation::SetIgnoreCount (int32_t n) 90 { 91 if (m_opaque_sp) 92 m_opaque_sp->SetIgnoreCount (n); 93 } 94 95 void 96 SBBreakpointLocation::SetThreadID (tid_t thread_id) 97 { 98 if (m_opaque_sp) 99 m_opaque_sp->SetThreadID (thread_id); 100 } 101 102 tid_t 103 SBBreakpointLocation::GetThreadID () 104 { 105 tid_t sb_thread_id = (lldb::tid_t) LLDB_INVALID_THREAD_ID; 106 if (m_opaque_sp) 107 sb_thread_id = m_opaque_sp->GetLocationOptions()->GetThreadSpecNoCreate()->GetTID(); 108 return sb_thread_id; 109 } 110 111 void 112 SBBreakpointLocation::SetThreadIndex (uint32_t index) 113 { 114 if (m_opaque_sp) 115 m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetIndex (index); 116 } 117 118 uint32_t 119 SBBreakpointLocation::GetThreadIndex() const 120 { 121 if (m_opaque_sp) 122 { 123 const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate(); 124 if (thread_spec == NULL) 125 return 0; 126 else 127 return thread_spec->GetIndex(); 128 } 129 return 0; 130 } 131 132 133 void 134 SBBreakpointLocation::SetThreadName (const char *thread_name) 135 { 136 if (m_opaque_sp) 137 m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetName (thread_name); 138 } 139 140 const char * 141 SBBreakpointLocation::GetThreadName () const 142 { 143 if (m_opaque_sp) 144 { 145 const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate(); 146 if (thread_spec == NULL) 147 return NULL; 148 else 149 return thread_spec->GetName(); 150 } 151 return NULL; 152 } 153 154 void 155 SBBreakpointLocation::SetQueueName (const char *queue_name) 156 { 157 if (m_opaque_sp) 158 m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetQueueName (queue_name); 159 } 160 161 const char * 162 SBBreakpointLocation::GetQueueName () const 163 { 164 if (m_opaque_sp) 165 { 166 const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate(); 167 if (thread_spec == NULL) 168 return NULL; 169 else 170 return thread_spec->GetQueueName(); 171 } 172 return NULL; 173 } 174 175 bool 176 SBBreakpointLocation::IsResolved () 177 { 178 if (m_opaque_sp) 179 return m_opaque_sp->IsResolved(); 180 else 181 return false; 182 } 183 184 void 185 SBBreakpointLocation::SetLocation (const lldb::BreakpointLocationSP &break_loc_sp) 186 { 187 if (m_opaque_sp) 188 { 189 // Uninstall the callbacks? 190 } 191 m_opaque_sp = break_loc_sp; 192 } 193 194 void 195 SBBreakpointLocation::GetDescription (FILE *f, const char *description_level) 196 { 197 if (f == NULL) 198 return; 199 200 if (m_opaque_sp) 201 { 202 DescriptionLevel level; 203 if (strcmp (description_level, "brief") == 0) 204 level = eDescriptionLevelBrief; 205 else if (strcmp (description_level, "full") == 0) 206 level = eDescriptionLevelFull; 207 else if (strcmp (description_level, "verbose") == 0) 208 level = eDescriptionLevelVerbose; 209 else 210 level = eDescriptionLevelBrief; 211 212 StreamFile str (f); 213 214 m_opaque_sp->GetDescription (&str, level); 215 str.EOL(); 216 } 217 } 218 219 SBBreakpoint 220 SBBreakpointLocation::GetBreakpoint () 221 { 222 SBBreakpoint sb_bp; 223 if (m_opaque_sp) 224 *sb_bp = m_opaque_sp->GetBreakpoint ().GetSP(); 225 return sb_bp; 226 } 227 228