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