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