Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- SBBreakpoint.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/SBBreakpoint.h" |
| 11 | #include "lldb/API/SBBreakpointLocation.h" |
| 12 | #include "lldb/API/SBDebugger.h" |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 13 | #include "lldb/API/SBEvent.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 14 | #include "lldb/API/SBProcess.h" |
Caroline Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 15 | #include "lldb/API/SBStream.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 16 | #include "lldb/API/SBThread.h" |
| 17 | |
| 18 | #include "lldb/Breakpoint/Breakpoint.h" |
| 19 | #include "lldb/Breakpoint/BreakpointLocation.h" |
| 20 | #include "lldb/Breakpoint/StoppointCallbackContext.h" |
| 21 | #include "lldb/Core/Address.h" |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 22 | #include "lldb/Core/Log.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 23 | #include "lldb/Core/Stream.h" |
| 24 | #include "lldb/Core/StreamFile.h" |
| 25 | #include "lldb/Target/Process.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 26 | #include "lldb/Target/Target.h" |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 27 | #include "lldb/Target/Thread.h" |
| 28 | #include "lldb/Target/ThreadSpec.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 29 | |
| 30 | |
| 31 | #include "lldb/lldb-enumerations.h" |
| 32 | |
| 33 | using namespace lldb; |
| 34 | using namespace lldb_private; |
| 35 | |
| 36 | struct CallbackData |
| 37 | { |
| 38 | SBBreakpoint::BreakpointHitCallback callback; |
| 39 | void *callback_baton; |
| 40 | }; |
| 41 | |
| 42 | class SBBreakpointCallbackBaton : public Baton |
| 43 | { |
| 44 | public: |
| 45 | |
| 46 | SBBreakpointCallbackBaton (SBBreakpoint::BreakpointHitCallback callback, void *baton) : |
| 47 | Baton (new CallbackData) |
| 48 | { |
| 49 | CallbackData *data = (CallbackData *)m_data; |
| 50 | data->callback = callback; |
| 51 | data->callback_baton = baton; |
| 52 | } |
| 53 | |
| 54 | virtual ~SBBreakpointCallbackBaton() |
| 55 | { |
| 56 | CallbackData *data = (CallbackData *)m_data; |
| 57 | |
| 58 | if (data) |
| 59 | { |
| 60 | delete data; |
| 61 | m_data = NULL; |
| 62 | } |
| 63 | } |
| 64 | }; |
| 65 | |
| 66 | |
| 67 | SBBreakpoint::SBBreakpoint () : |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 68 | m_opaque_sp () |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 69 | { |
| 70 | } |
| 71 | |
| 72 | SBBreakpoint::SBBreakpoint (const SBBreakpoint& rhs) : |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 73 | m_opaque_sp (rhs.m_opaque_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 74 | { |
| 75 | } |
| 76 | |
| 77 | |
| 78 | SBBreakpoint::SBBreakpoint (const lldb::BreakpointSP &bp_sp) : |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 79 | m_opaque_sp (bp_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 80 | { |
| 81 | } |
| 82 | |
| 83 | SBBreakpoint::~SBBreakpoint() |
| 84 | { |
| 85 | } |
| 86 | |
| 87 | const SBBreakpoint & |
| 88 | SBBreakpoint::operator = (const SBBreakpoint& rhs) |
| 89 | { |
| 90 | if (this != &rhs) |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 91 | m_opaque_sp = rhs.m_opaque_sp; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 92 | return *this; |
| 93 | } |
| 94 | |
Greg Clayton | ea49cc7 | 2010-12-12 19:25:26 +0000 | [diff] [blame] | 95 | bool |
| 96 | SBBreakpoint::operator == (const lldb::SBBreakpoint& rhs) |
| 97 | { |
| 98 | if (m_opaque_sp && rhs.m_opaque_sp) |
| 99 | return m_opaque_sp.get() == rhs.m_opaque_sp.get(); |
| 100 | return false; |
| 101 | } |
| 102 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 103 | break_id_t |
| 104 | SBBreakpoint::GetID () const |
| 105 | { |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 106 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 107 | |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 108 | break_id_t break_id = LLDB_INVALID_BREAK_ID; |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 109 | if (m_opaque_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 110 | break_id = m_opaque_sp->GetID(); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 111 | |
| 112 | if (log) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 113 | { |
| 114 | if (break_id == LLDB_INVALID_BREAK_ID) |
| 115 | log->Printf ("SBBreakpoint(%p)::GetID () => LLDB_INVALID_BREAK_ID", m_opaque_sp.get()); |
| 116 | else |
| 117 | log->Printf ("SBBreakpoint(%p)::GetID () => %u", m_opaque_sp.get(), break_id); |
| 118 | } |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 119 | |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 120 | return break_id; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 121 | } |
| 122 | |
| 123 | |
| 124 | bool |
| 125 | SBBreakpoint::IsValid() const |
| 126 | { |
Jim Ingham | 9880efa | 2012-08-11 00:35:26 +0000 | [diff] [blame] | 127 | return (bool) m_opaque_sp; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | void |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 131 | SBBreakpoint::ClearAllBreakpointSites () |
| 132 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 133 | if (m_opaque_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 134 | { |
| 135 | Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 136 | m_opaque_sp->ClearAllBreakpointSites (); |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 137 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | SBBreakpointLocation |
| 141 | SBBreakpoint::FindLocationByAddress (addr_t vm_addr) |
| 142 | { |
| 143 | SBBreakpointLocation sb_bp_location; |
| 144 | |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 145 | if (m_opaque_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 146 | { |
| 147 | if (vm_addr != LLDB_INVALID_ADDRESS) |
| 148 | { |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 149 | Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 150 | Address address; |
Greg Clayton | eea2640 | 2010-09-14 23:36:40 +0000 | [diff] [blame] | 151 | Target &target = m_opaque_sp->GetTarget(); |
| 152 | if (target.GetSectionLoadList().ResolveLoadAddress (vm_addr, address) == false) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 153 | { |
Greg Clayton | 3508c38 | 2012-02-24 01:59:29 +0000 | [diff] [blame] | 154 | address.SetRawAddress (vm_addr); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 155 | } |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 156 | sb_bp_location.SetLocation (m_opaque_sp->FindLocationByAddress (address)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 157 | } |
| 158 | } |
| 159 | return sb_bp_location; |
| 160 | } |
| 161 | |
| 162 | break_id_t |
| 163 | SBBreakpoint::FindLocationIDByAddress (addr_t vm_addr) |
| 164 | { |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 165 | break_id_t break_id = LLDB_INVALID_BREAK_ID; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 166 | |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 167 | if (m_opaque_sp && vm_addr != LLDB_INVALID_ADDRESS) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 168 | { |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 169 | Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); |
| 170 | Address address; |
| 171 | Target &target = m_opaque_sp->GetTarget(); |
| 172 | if (target.GetSectionLoadList().ResolveLoadAddress (vm_addr, address) == false) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 173 | { |
Greg Clayton | 3508c38 | 2012-02-24 01:59:29 +0000 | [diff] [blame] | 174 | address.SetRawAddress (vm_addr); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 175 | } |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 176 | break_id = m_opaque_sp->FindLocationIDByAddress (address); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 177 | } |
| 178 | |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 179 | return break_id; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | SBBreakpointLocation |
| 183 | SBBreakpoint::FindLocationByID (break_id_t bp_loc_id) |
| 184 | { |
| 185 | SBBreakpointLocation sb_bp_location; |
| 186 | |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 187 | if (m_opaque_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 188 | { |
| 189 | Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 190 | sb_bp_location.SetLocation (m_opaque_sp->FindLocationByID (bp_loc_id)); |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 191 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 192 | |
| 193 | return sb_bp_location; |
| 194 | } |
| 195 | |
| 196 | SBBreakpointLocation |
| 197 | SBBreakpoint::GetLocationAtIndex (uint32_t index) |
| 198 | { |
| 199 | SBBreakpointLocation sb_bp_location; |
| 200 | |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 201 | if (m_opaque_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 202 | { |
| 203 | Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 204 | sb_bp_location.SetLocation (m_opaque_sp->GetLocationAtIndex (index)); |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 205 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 206 | |
| 207 | return sb_bp_location; |
| 208 | } |
| 209 | |
| 210 | void |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 211 | SBBreakpoint::SetEnabled (bool enable) |
| 212 | { |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 213 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 214 | |
| 215 | if (log) |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 216 | log->Printf ("SBBreakpoint(%p)::SetEnabled (enabled=%i)", m_opaque_sp.get(), enable); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 217 | |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 218 | if (m_opaque_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 219 | { |
| 220 | Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 221 | m_opaque_sp->SetEnabled (enable); |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 222 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | bool |
| 226 | SBBreakpoint::IsEnabled () |
| 227 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 228 | if (m_opaque_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 229 | { |
| 230 | Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 231 | return m_opaque_sp->IsEnabled(); |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 232 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 233 | else |
| 234 | return false; |
| 235 | } |
| 236 | |
Jim Ingham | 2753a02 | 2012-10-05 19:16:31 +0000 | [diff] [blame] | 237 | void |
| 238 | SBBreakpoint::SetOneShot (bool one_shot) |
| 239 | { |
| 240 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 241 | |
| 242 | if (log) |
| 243 | log->Printf ("SBBreakpoint(%p)::SetOneShot (one_shot=%i)", m_opaque_sp.get(), one_shot); |
| 244 | |
| 245 | if (m_opaque_sp) |
| 246 | { |
| 247 | Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); |
| 248 | m_opaque_sp->SetOneShot (one_shot); |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | bool |
| 253 | SBBreakpoint::IsOneShot () const |
| 254 | { |
| 255 | if (m_opaque_sp) |
| 256 | { |
| 257 | Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); |
| 258 | return m_opaque_sp->IsOneShot(); |
| 259 | } |
| 260 | else |
| 261 | return false; |
| 262 | } |
| 263 | |
Jim Ingham | 3fcc297 | 2012-09-25 23:55:19 +0000 | [diff] [blame] | 264 | bool |
| 265 | SBBreakpoint::IsInternal () |
| 266 | { |
| 267 | if (m_opaque_sp) |
| 268 | { |
| 269 | Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); |
| 270 | return m_opaque_sp->IsInternal(); |
| 271 | } |
| 272 | else |
| 273 | return false; |
| 274 | } |
| 275 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 276 | void |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 277 | SBBreakpoint::SetIgnoreCount (uint32_t count) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 278 | { |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 279 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 280 | |
| 281 | if (log) |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 282 | log->Printf ("SBBreakpoint(%p)::SetIgnoreCount (count=%u)", m_opaque_sp.get(), count); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 283 | |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 284 | if (m_opaque_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 285 | { |
| 286 | Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 287 | m_opaque_sp->SetIgnoreCount (count); |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 288 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 289 | } |
| 290 | |
Jim Ingham | e374083 | 2010-10-22 01:15:49 +0000 | [diff] [blame] | 291 | void |
| 292 | SBBreakpoint::SetCondition (const char *condition) |
| 293 | { |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 294 | if (m_opaque_sp) |
| 295 | { |
| 296 | Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); |
| 297 | m_opaque_sp->SetCondition (condition); |
| 298 | } |
Jim Ingham | e374083 | 2010-10-22 01:15:49 +0000 | [diff] [blame] | 299 | } |
| 300 | |
| 301 | const char * |
| 302 | SBBreakpoint::GetCondition () |
| 303 | { |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 304 | if (m_opaque_sp) |
| 305 | { |
| 306 | Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); |
| 307 | return m_opaque_sp->GetConditionText (); |
| 308 | } |
| 309 | return NULL; |
Jim Ingham | e374083 | 2010-10-22 01:15:49 +0000 | [diff] [blame] | 310 | } |
| 311 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 312 | uint32_t |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 313 | SBBreakpoint::GetHitCount () const |
| 314 | { |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 315 | uint32_t count = 0; |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 316 | if (m_opaque_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 317 | { |
| 318 | Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 319 | count = m_opaque_sp->GetHitCount(); |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 320 | } |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 321 | |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 322 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 323 | if (log) |
| 324 | log->Printf ("SBBreakpoint(%p)::GetHitCount () => %u", m_opaque_sp.get(), count); |
| 325 | |
| 326 | return count; |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 327 | } |
| 328 | |
| 329 | uint32_t |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 330 | SBBreakpoint::GetIgnoreCount () const |
| 331 | { |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 332 | uint32_t count = 0; |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 333 | if (m_opaque_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 334 | { |
| 335 | Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 336 | count = m_opaque_sp->GetIgnoreCount(); |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 337 | } |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 338 | |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 339 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 340 | if (log) |
| 341 | log->Printf ("SBBreakpoint(%p)::GetIgnoreCount () => %u", m_opaque_sp.get(), count); |
| 342 | |
| 343 | return count; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | void |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 347 | SBBreakpoint::SetThreadID (tid_t tid) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 348 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 349 | if (m_opaque_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 350 | { |
| 351 | Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 352 | m_opaque_sp->SetThreadID (tid); |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 353 | } |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 354 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 355 | if (log) |
Daniel Malea | 5f35a4b | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 356 | log->Printf ("SBBreakpoint(%p)::SetThreadID (tid=0x%4.4" PRIx64 ")", m_opaque_sp.get(), tid); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 357 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | tid_t |
| 361 | SBBreakpoint::GetThreadID () |
| 362 | { |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 363 | tid_t tid = LLDB_INVALID_THREAD_ID; |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 364 | if (m_opaque_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 365 | { |
| 366 | Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 367 | tid = m_opaque_sp->GetThreadID(); |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 368 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 369 | |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 370 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 371 | if (log) |
Daniel Malea | 5f35a4b | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 372 | log->Printf ("SBBreakpoint(%p)::GetThreadID () => 0x%4.4" PRIx64, m_opaque_sp.get(), tid); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 373 | return tid; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 374 | } |
| 375 | |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 376 | void |
| 377 | SBBreakpoint::SetThreadIndex (uint32_t index) |
| 378 | { |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 379 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 380 | if (log) |
| 381 | log->Printf ("SBBreakpoint(%p)::SetThreadIndex (%u)", m_opaque_sp.get(), index); |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 382 | if (m_opaque_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 383 | { |
| 384 | Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 385 | m_opaque_sp->GetOptions()->GetThreadSpec()->SetIndex (index); |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 386 | } |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 387 | } |
| 388 | |
| 389 | uint32_t |
| 390 | SBBreakpoint::GetThreadIndex() const |
| 391 | { |
Greg Clayton | a625387 | 2010-12-15 20:50:06 +0000 | [diff] [blame] | 392 | uint32_t thread_idx = UINT32_MAX; |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 393 | if (m_opaque_sp) |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 394 | { |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 395 | Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); |
| 396 | const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate(); |
Johnny Chen | b3e7181 | 2010-12-15 21:39:37 +0000 | [diff] [blame] | 397 | if (thread_spec != NULL) |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 398 | thread_idx = thread_spec->GetIndex(); |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 399 | } |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 400 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 401 | if (log) |
Greg Clayton | a625387 | 2010-12-15 20:50:06 +0000 | [diff] [blame] | 402 | log->Printf ("SBBreakpoint(%p)::GetThreadIndex () => %u", m_opaque_sp.get(), thread_idx); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 403 | |
Johnny Chen | b3e7181 | 2010-12-15 21:39:37 +0000 | [diff] [blame] | 404 | return thread_idx; |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 405 | } |
| 406 | |
| 407 | |
| 408 | void |
| 409 | SBBreakpoint::SetThreadName (const char *thread_name) |
| 410 | { |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 411 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 412 | if (log) |
| 413 | log->Printf ("SBBreakpoint(%p)::SetThreadName (%s)", m_opaque_sp.get(), thread_name); |
| 414 | |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 415 | if (m_opaque_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 416 | { |
| 417 | Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 418 | m_opaque_sp->GetOptions()->GetThreadSpec()->SetName (thread_name); |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 419 | } |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | const char * |
| 423 | SBBreakpoint::GetThreadName () const |
| 424 | { |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 425 | const char *name = NULL; |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 426 | if (m_opaque_sp) |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 427 | { |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 428 | Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); |
| 429 | const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate(); |
Johnny Chen | b3e7181 | 2010-12-15 21:39:37 +0000 | [diff] [blame] | 430 | if (thread_spec != NULL) |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 431 | name = thread_spec->GetName(); |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 432 | } |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 433 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 434 | if (log) |
| 435 | log->Printf ("SBBreakpoint(%p)::GetThreadName () => %s", m_opaque_sp.get(), name); |
| 436 | |
| 437 | return name; |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 438 | } |
| 439 | |
| 440 | void |
| 441 | SBBreakpoint::SetQueueName (const char *queue_name) |
| 442 | { |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 443 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 444 | if (log) |
| 445 | log->Printf ("SBBreakpoint(%p)::SetQueueName (%s)", m_opaque_sp.get(), queue_name); |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 446 | if (m_opaque_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 447 | { |
| 448 | Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 449 | m_opaque_sp->GetOptions()->GetThreadSpec()->SetQueueName (queue_name); |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 450 | } |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 451 | } |
| 452 | |
| 453 | const char * |
| 454 | SBBreakpoint::GetQueueName () const |
| 455 | { |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 456 | const char *name = NULL; |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 457 | if (m_opaque_sp) |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 458 | { |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 459 | Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); |
| 460 | const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate(); |
| 461 | if (thread_spec) |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 462 | name = thread_spec->GetQueueName(); |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 463 | } |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 464 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 465 | if (log) |
| 466 | log->Printf ("SBBreakpoint(%p)::GetQueueName () => %s", m_opaque_sp.get(), name); |
| 467 | |
| 468 | return name; |
Jim Ingham | 8e5e38f | 2010-06-18 01:47:08 +0000 | [diff] [blame] | 469 | } |
| 470 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 471 | size_t |
| 472 | SBBreakpoint::GetNumResolvedLocations() const |
| 473 | { |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 474 | size_t num_resolved = 0; |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 475 | if (m_opaque_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 476 | { |
| 477 | Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 478 | num_resolved = m_opaque_sp->GetNumResolvedLocations(); |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 479 | } |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 480 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 481 | if (log) |
Daniel Malea | 5f35a4b | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 482 | log->Printf ("SBBreakpoint(%p)::GetNumResolvedLocations () => %" PRIu64, m_opaque_sp.get(), (uint64_t)num_resolved); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 483 | return num_resolved; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 484 | } |
| 485 | |
| 486 | size_t |
| 487 | SBBreakpoint::GetNumLocations() const |
| 488 | { |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 489 | size_t num_locs = 0; |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 490 | if (m_opaque_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 491 | { |
| 492 | Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 493 | num_locs = m_opaque_sp->GetNumLocations(); |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 494 | } |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 495 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 496 | if (log) |
Daniel Malea | 5f35a4b | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 497 | log->Printf ("SBBreakpoint(%p)::GetNumLocations () => %" PRIu64, m_opaque_sp.get(), (uint64_t)num_locs); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 498 | return num_locs; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 499 | } |
| 500 | |
Caroline Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 501 | bool |
Greg Clayton | d8c6253 | 2010-10-07 04:19:01 +0000 | [diff] [blame] | 502 | SBBreakpoint::GetDescription (SBStream &s) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 503 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 504 | if (m_opaque_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 505 | { |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 506 | Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); |
Greg Clayton | d8c6253 | 2010-10-07 04:19:01 +0000 | [diff] [blame] | 507 | s.Printf("SBBreakpoint: id = %i, ", m_opaque_sp->GetID()); |
| 508 | m_opaque_sp->GetResolverDescription (s.get()); |
| 509 | m_opaque_sp->GetFilterDescription (s.get()); |
| 510 | const size_t num_locations = m_opaque_sp->GetNumLocations (); |
Daniel Malea | 5f35a4b | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 511 | s.Printf(", locations = %" PRIu64, (uint64_t)num_locations); |
Greg Clayton | d8c6253 | 2010-10-07 04:19:01 +0000 | [diff] [blame] | 512 | return true; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 513 | } |
Greg Clayton | d8c6253 | 2010-10-07 04:19:01 +0000 | [diff] [blame] | 514 | s.Printf ("No value"); |
| 515 | return false; |
Caroline Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 516 | } |
| 517 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 518 | bool |
| 519 | SBBreakpoint::PrivateBreakpointHitCallback |
| 520 | ( |
| 521 | void *baton, |
| 522 | StoppointCallbackContext *ctx, |
| 523 | lldb::user_id_t break_id, |
| 524 | lldb::user_id_t break_loc_id |
| 525 | ) |
| 526 | { |
Greg Clayton | f4124de | 2012-02-21 00:09:25 +0000 | [diff] [blame] | 527 | ExecutionContext exe_ctx (ctx->exe_ctx_ref); |
| 528 | BreakpointSP bp_sp(exe_ctx.GetTargetRef().GetBreakpointList().FindBreakpointByID(break_id)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 529 | if (baton && bp_sp) |
| 530 | { |
| 531 | CallbackData *data = (CallbackData *)baton; |
| 532 | lldb_private::Breakpoint *bp = bp_sp.get(); |
| 533 | if (bp && data->callback) |
| 534 | { |
Greg Clayton | f4124de | 2012-02-21 00:09:25 +0000 | [diff] [blame] | 535 | Process *process = exe_ctx.GetProcessPtr(); |
Greg Clayton | 567e7f3 | 2011-09-22 04:58:26 +0000 | [diff] [blame] | 536 | if (process) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 537 | { |
Greg Clayton | 13d24fb | 2012-01-29 20:56:30 +0000 | [diff] [blame] | 538 | SBProcess sb_process (process->shared_from_this()); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 539 | SBThread sb_thread; |
| 540 | SBBreakpointLocation sb_location; |
| 541 | assert (bp_sp); |
| 542 | sb_location.SetLocation (bp_sp->FindLocationByID (break_loc_id)); |
Greg Clayton | f4124de | 2012-02-21 00:09:25 +0000 | [diff] [blame] | 543 | Thread *thread = exe_ctx.GetThreadPtr(); |
Greg Clayton | 567e7f3 | 2011-09-22 04:58:26 +0000 | [diff] [blame] | 544 | if (thread) |
Greg Clayton | 13d24fb | 2012-01-29 20:56:30 +0000 | [diff] [blame] | 545 | sb_thread.SetThread(thread->shared_from_this()); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 546 | |
| 547 | return data->callback (data->callback_baton, |
| 548 | sb_process, |
| 549 | sb_thread, |
| 550 | sb_location); |
| 551 | } |
| 552 | } |
| 553 | } |
| 554 | return true; // Return true if we should stop at this breakpoint |
| 555 | } |
| 556 | |
| 557 | void |
| 558 | SBBreakpoint::SetCallback (BreakpointHitCallback callback, void *baton) |
| 559 | { |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 560 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 561 | |
| 562 | if (log) |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 563 | log->Printf ("SBBreakpoint(%p)::SetCallback (callback=%p, baton=%p)", m_opaque_sp.get(), callback, baton); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 564 | |
Greg Clayton | 567e7f3 | 2011-09-22 04:58:26 +0000 | [diff] [blame] | 565 | if (m_opaque_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 566 | { |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 567 | Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 568 | BatonSP baton_sp(new SBBreakpointCallbackBaton (callback, baton)); |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 569 | m_opaque_sp->SetCallback (SBBreakpoint::PrivateBreakpointHitCallback, baton_sp, false); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 570 | } |
| 571 | } |
| 572 | |
| 573 | |
| 574 | lldb_private::Breakpoint * |
| 575 | SBBreakpoint::operator->() const |
| 576 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 577 | return m_opaque_sp.get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 578 | } |
| 579 | |
| 580 | lldb_private::Breakpoint * |
| 581 | SBBreakpoint::get() const |
| 582 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 583 | return m_opaque_sp.get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 584 | } |
| 585 | |
| 586 | lldb::BreakpointSP & |
| 587 | SBBreakpoint::operator *() |
| 588 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 589 | return m_opaque_sp; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 590 | } |
| 591 | |
| 592 | const lldb::BreakpointSP & |
| 593 | SBBreakpoint::operator *() const |
| 594 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 595 | return m_opaque_sp; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 596 | } |
| 597 | |
Jim Ingham | 28e2386 | 2012-02-08 05:23:15 +0000 | [diff] [blame] | 598 | bool |
| 599 | SBBreakpoint::EventIsBreakpointEvent (const lldb::SBEvent &event) |
| 600 | { |
| 601 | return Breakpoint::BreakpointEventData::GetEventDataFromEvent(event.get()) != NULL; |
| 602 | |
| 603 | } |
| 604 | |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 605 | BreakpointEventType |
| 606 | SBBreakpoint::GetBreakpointEventTypeFromEvent (const SBEvent& event) |
| 607 | { |
| 608 | if (event.IsValid()) |
| 609 | return Breakpoint::BreakpointEventData::GetBreakpointEventTypeFromEvent (event.GetSP()); |
| 610 | return eBreakpointEventTypeInvalidType; |
| 611 | } |
| 612 | |
| 613 | SBBreakpoint |
| 614 | SBBreakpoint::GetBreakpointFromEvent (const lldb::SBEvent& event) |
| 615 | { |
| 616 | SBBreakpoint sb_breakpoint; |
| 617 | if (event.IsValid()) |
| 618 | sb_breakpoint.m_opaque_sp = Breakpoint::BreakpointEventData::GetBreakpointFromEvent (event.GetSP()); |
| 619 | return sb_breakpoint; |
| 620 | } |
| 621 | |
| 622 | SBBreakpointLocation |
| 623 | SBBreakpoint::GetBreakpointLocationAtIndexFromEvent (const lldb::SBEvent& event, uint32_t loc_idx) |
| 624 | { |
| 625 | SBBreakpointLocation sb_breakpoint_loc; |
| 626 | if (event.IsValid()) |
| 627 | sb_breakpoint_loc.SetLocation (Breakpoint::BreakpointEventData::GetBreakpointLocationAtIndexFromEvent (event.GetSP(), loc_idx)); |
| 628 | return sb_breakpoint_loc; |
| 629 | } |
| 630 | |
Jim Ingham | 28e2386 | 2012-02-08 05:23:15 +0000 | [diff] [blame] | 631 | uint32_t |
| 632 | SBBreakpoint::GetNumBreakpointLocationsFromEvent (const lldb::SBEvent &event) |
| 633 | { |
| 634 | uint32_t num_locations = 0; |
| 635 | if (event.IsValid()) |
| 636 | num_locations = (Breakpoint::BreakpointEventData::GetNumBreakpointLocationsFromEvent (event.GetSP())); |
| 637 | return num_locations; |
| 638 | } |
| 639 | |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 640 | |