Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 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" |
Caroline Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 13 | #include "lldb/API/SBStream.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 14 | |
| 15 | #include "lldb/lldb-types.h" |
| 16 | #include "lldb/lldb-defines.h" |
Greg Clayton | 640dc6b | 2010-11-18 18:52:36 +0000 | [diff] [blame^] | 17 | #include "lldb/Breakpoint/Breakpoint.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 18 | #include "lldb/Breakpoint/BreakpointLocation.h" |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 19 | #include "lldb/Target/ThreadSpec.h" |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 20 | #include "lldb/Core/Log.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 21 | #include "lldb/Core/Stream.h" |
| 22 | #include "lldb/Core/StreamFile.h" |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 23 | #include "lldb/Target/ThreadSpec.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 24 | |
| 25 | using namespace lldb; |
| 26 | using namespace lldb_private; |
| 27 | |
| 28 | |
Greg Clayton | 538eb82 | 2010-11-05 23:17:00 +0000 | [diff] [blame] | 29 | SBBreakpointLocation::SBBreakpointLocation () : |
| 30 | m_opaque_sp () |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 31 | { |
| 32 | } |
| 33 | |
| 34 | SBBreakpointLocation::SBBreakpointLocation (const lldb::BreakpointLocationSP &break_loc_sp) : |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 35 | m_opaque_sp (break_loc_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 36 | { |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 37 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 38 | |
| 39 | if (log) |
| 40 | { |
| 41 | SBStream sstr; |
| 42 | GetDescription (lldb::eDescriptionLevelBrief, sstr); |
Caroline Tice | 61ba7ec | 2010-10-26 23:49:36 +0000 | [diff] [blame] | 43 | log->Printf ("SBBreakpointLocation::SBBreakpointLocaiton (const lldb::BreakpointLocationsSP &break_loc_sp" |
| 44 | "=%p) => this.sp = %p (%s)", break_loc_sp.get(), m_opaque_sp.get(), sstr.GetData()); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 45 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 46 | } |
| 47 | |
Greg Clayton | 538eb82 | 2010-11-05 23:17:00 +0000 | [diff] [blame] | 48 | SBBreakpointLocation::SBBreakpointLocation(const SBBreakpointLocation &rhs) : |
| 49 | m_opaque_sp (rhs.m_opaque_sp) |
| 50 | { |
| 51 | } |
| 52 | |
| 53 | const SBBreakpointLocation & |
| 54 | SBBreakpointLocation::operator = (const SBBreakpointLocation &rhs) |
| 55 | { |
| 56 | if (this != &rhs) |
| 57 | m_opaque_sp = rhs.m_opaque_sp; |
| 58 | return *this; |
| 59 | } |
| 60 | |
| 61 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 62 | SBBreakpointLocation::~SBBreakpointLocation () |
| 63 | { |
| 64 | } |
| 65 | |
| 66 | bool |
| 67 | SBBreakpointLocation::IsValid() const |
| 68 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 69 | return m_opaque_sp.get() != NULL; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | addr_t |
| 73 | SBBreakpointLocation::GetLoadAddress () |
| 74 | { |
| 75 | addr_t ret_addr = LLDB_INVALID_ADDRESS; |
| 76 | |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 77 | if (m_opaque_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 78 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 79 | ret_addr = m_opaque_sp->GetLoadAddress(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | return ret_addr; |
| 83 | } |
| 84 | |
| 85 | void |
| 86 | SBBreakpointLocation::SetEnabled (bool enabled) |
| 87 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 88 | if (m_opaque_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 89 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 90 | m_opaque_sp->SetEnabled (enabled); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 91 | } |
| 92 | } |
| 93 | |
| 94 | bool |
| 95 | SBBreakpointLocation::IsEnabled () |
| 96 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 97 | if (m_opaque_sp) |
| 98 | return m_opaque_sp->IsEnabled(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 99 | else |
| 100 | return false; |
| 101 | } |
| 102 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 103 | uint32_t |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 104 | SBBreakpointLocation::GetIgnoreCount () |
| 105 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 106 | if (m_opaque_sp) |
| 107 | return m_opaque_sp->GetIgnoreCount(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 108 | else |
| 109 | return 0; |
| 110 | } |
| 111 | |
| 112 | void |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 113 | SBBreakpointLocation::SetIgnoreCount (uint32_t n) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 114 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 115 | if (m_opaque_sp) |
| 116 | m_opaque_sp->SetIgnoreCount (n); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | void |
Jim Ingham | e374083 | 2010-10-22 01:15:49 +0000 | [diff] [blame] | 120 | SBBreakpointLocation::SetCondition (const char *condition) |
| 121 | { |
| 122 | m_opaque_sp->SetCondition (condition); |
| 123 | } |
| 124 | |
| 125 | const char * |
| 126 | SBBreakpointLocation::GetCondition () |
| 127 | { |
| 128 | return m_opaque_sp->GetConditionText (); |
| 129 | } |
| 130 | |
| 131 | void |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 132 | SBBreakpointLocation::SetThreadID (tid_t thread_id) |
| 133 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 134 | if (m_opaque_sp) |
| 135 | m_opaque_sp->SetThreadID (thread_id); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | tid_t |
| 139 | SBBreakpointLocation::GetThreadID () |
| 140 | { |
| 141 | tid_t sb_thread_id = (lldb::tid_t) LLDB_INVALID_THREAD_ID; |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 142 | if (m_opaque_sp) |
| 143 | sb_thread_id = m_opaque_sp->GetLocationOptions()->GetThreadSpecNoCreate()->GetTID(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 144 | return sb_thread_id; |
| 145 | } |
| 146 | |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 147 | void |
| 148 | SBBreakpointLocation::SetThreadIndex (uint32_t index) |
| 149 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 150 | if (m_opaque_sp) |
| 151 | m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetIndex (index); |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | uint32_t |
| 155 | SBBreakpointLocation::GetThreadIndex() const |
| 156 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 157 | if (m_opaque_sp) |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 158 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 159 | const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate(); |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 160 | if (thread_spec == NULL) |
| 161 | return 0; |
| 162 | else |
| 163 | return thread_spec->GetIndex(); |
| 164 | } |
| 165 | return 0; |
| 166 | } |
| 167 | |
| 168 | |
| 169 | void |
| 170 | SBBreakpointLocation::SetThreadName (const char *thread_name) |
| 171 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 172 | if (m_opaque_sp) |
| 173 | m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetName (thread_name); |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | const char * |
| 177 | SBBreakpointLocation::GetThreadName () const |
| 178 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 179 | if (m_opaque_sp) |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 180 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 181 | const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate(); |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 182 | if (thread_spec == NULL) |
| 183 | return NULL; |
| 184 | else |
| 185 | return thread_spec->GetName(); |
| 186 | } |
| 187 | return NULL; |
| 188 | } |
| 189 | |
| 190 | void |
| 191 | SBBreakpointLocation::SetQueueName (const char *queue_name) |
| 192 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 193 | if (m_opaque_sp) |
| 194 | m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetQueueName (queue_name); |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | const char * |
| 198 | SBBreakpointLocation::GetQueueName () const |
| 199 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 200 | if (m_opaque_sp) |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 201 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 202 | const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate(); |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 203 | if (thread_spec == NULL) |
| 204 | return NULL; |
| 205 | else |
| 206 | return thread_spec->GetQueueName(); |
| 207 | } |
| 208 | return NULL; |
| 209 | } |
| 210 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 211 | bool |
| 212 | SBBreakpointLocation::IsResolved () |
| 213 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 214 | if (m_opaque_sp) |
| 215 | return m_opaque_sp->IsResolved(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 216 | else |
| 217 | return false; |
| 218 | } |
| 219 | |
| 220 | void |
| 221 | SBBreakpointLocation::SetLocation (const lldb::BreakpointLocationSP &break_loc_sp) |
| 222 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 223 | if (m_opaque_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 224 | { |
| 225 | // Uninstall the callbacks? |
| 226 | } |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 227 | m_opaque_sp = break_loc_sp; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 228 | } |
| 229 | |
Caroline Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 230 | bool |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 231 | SBBreakpointLocation::GetDescription (DescriptionLevel level, SBStream &description) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 232 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 233 | if (m_opaque_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 234 | { |
Caroline Tice | e49ec18 | 2010-09-22 23:01:29 +0000 | [diff] [blame] | 235 | description.ref(); |
Caroline Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 236 | m_opaque_sp->GetDescription (description.get(), level); |
| 237 | description.get()->EOL(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 238 | } |
Caroline Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 239 | else |
| 240 | description.Printf ("No value"); |
| 241 | |
| 242 | return true; |
| 243 | } |
| 244 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 245 | SBBreakpoint |
| 246 | SBBreakpointLocation::GetBreakpoint () |
| 247 | { |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 248 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 249 | |
Caroline Tice | 61ba7ec | 2010-10-26 23:49:36 +0000 | [diff] [blame] | 250 | //if (log) |
| 251 | // log->Printf ("SBBreakpointLocation::GetBreakpoint ()"); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 252 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 253 | SBBreakpoint sb_bp; |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 254 | if (m_opaque_sp) |
| 255 | *sb_bp = m_opaque_sp->GetBreakpoint ().GetSP(); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 256 | |
| 257 | if (log) |
| 258 | { |
| 259 | SBStream sstr; |
| 260 | sb_bp.GetDescription (sstr); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 261 | log->Printf ("SBBreakpointLocation(%p)::GetBreakpoint () => SBBreakpoint(%p) %s", |
Caroline Tice | 61ba7ec | 2010-10-26 23:49:36 +0000 | [diff] [blame] | 262 | m_opaque_sp.get(), sb_bp.get(), sstr.GetData()); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 263 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 264 | return sb_bp; |
| 265 | } |
| 266 | |