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