blob: ec3a3de4a7886a0276a197bf19a4abac6c331b0e [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- 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
Eugene Zelenkodbb0abb2015-10-31 01:22:59 +000010// C Includes
11// C++ Includes
12// Other libraries and framework includes
13// Project includes
Chris Lattner30fdc8d2010-06-08 16:52:24 +000014#include "lldb/API/SBBreakpoint.h"
15#include "lldb/API/SBBreakpointLocation.h"
16#include "lldb/API/SBDebugger.h"
Greg Clayton9fed0d82010-07-23 23:33:17 +000017#include "lldb/API/SBEvent.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000018#include "lldb/API/SBProcess.h"
Caroline Ticedde9cff2010-09-20 05:20:02 +000019#include "lldb/API/SBStream.h"
Jim Ingham5e09c8c2014-12-16 23:40:14 +000020#include "lldb/API/SBStringList.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000021#include "lldb/API/SBThread.h"
22
23#include "lldb/Breakpoint/Breakpoint.h"
24#include "lldb/Breakpoint/BreakpointLocation.h"
25#include "lldb/Breakpoint/StoppointCallbackContext.h"
26#include "lldb/Core/Address.h"
Jim Inghamd80102e2014-04-02 01:04:55 +000027#include "lldb/Core/Debugger.h"
Caroline Ticeceb6b132010-10-26 03:11:13 +000028#include "lldb/Core/Log.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000029#include "lldb/Core/Stream.h"
30#include "lldb/Core/StreamFile.h"
Jim Inghamd80102e2014-04-02 01:04:55 +000031#include "lldb/Interpreter/CommandInterpreter.h"
32#include "lldb/Interpreter/ScriptInterpreter.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000033#include "lldb/Target/Process.h"
Greg Claytond5944cd2013-12-06 01:12:00 +000034#include "lldb/Target/SectionLoadList.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000035#include "lldb/Target/Target.h"
Jim Ingham62b02c62010-06-18 01:47:08 +000036#include "lldb/Target/Thread.h"
37#include "lldb/Target/ThreadSpec.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000038
Chris Lattner30fdc8d2010-06-08 16:52:24 +000039#include "lldb/lldb-enumerations.h"
40
41using namespace lldb;
42using namespace lldb_private;
43
44struct CallbackData
45{
46 SBBreakpoint::BreakpointHitCallback callback;
47 void *callback_baton;
48};
49
50class SBBreakpointCallbackBaton : public Baton
51{
52public:
Chris Lattner30fdc8d2010-06-08 16:52:24 +000053 SBBreakpointCallbackBaton (SBBreakpoint::BreakpointHitCallback callback, void *baton) :
54 Baton (new CallbackData)
55 {
56 CallbackData *data = (CallbackData *)m_data;
57 data->callback = callback;
58 data->callback_baton = baton;
59 }
60
Eugene Zelenkodbb0abb2015-10-31 01:22:59 +000061 ~SBBreakpointCallbackBaton() override
Chris Lattner30fdc8d2010-06-08 16:52:24 +000062 {
63 CallbackData *data = (CallbackData *)m_data;
64
65 if (data)
66 {
67 delete data;
Eugene Zelenkodbb0abb2015-10-31 01:22:59 +000068 m_data = nullptr;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000069 }
70 }
71};
72
Chris Lattner30fdc8d2010-06-08 16:52:24 +000073SBBreakpoint::SBBreakpoint () :
Greg Clayton66111032010-06-23 01:19:29 +000074 m_opaque_sp ()
Chris Lattner30fdc8d2010-06-08 16:52:24 +000075{
76}
77
78SBBreakpoint::SBBreakpoint (const SBBreakpoint& rhs) :
Greg Clayton66111032010-06-23 01:19:29 +000079 m_opaque_sp (rhs.m_opaque_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +000080{
81}
82
Chris Lattner30fdc8d2010-06-08 16:52:24 +000083SBBreakpoint::SBBreakpoint (const lldb::BreakpointSP &bp_sp) :
Greg Clayton66111032010-06-23 01:19:29 +000084 m_opaque_sp (bp_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +000085{
86}
87
Eugene Zelenkodbb0abb2015-10-31 01:22:59 +000088SBBreakpoint::~SBBreakpoint() = default;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000089
90const SBBreakpoint &
91SBBreakpoint::operator = (const SBBreakpoint& rhs)
92{
93 if (this != &rhs)
Greg Clayton66111032010-06-23 01:19:29 +000094 m_opaque_sp = rhs.m_opaque_sp;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000095 return *this;
96}
97
Greg Claytonac2eb9b2010-12-12 19:25:26 +000098bool
99SBBreakpoint::operator == (const lldb::SBBreakpoint& rhs)
100{
101 if (m_opaque_sp && rhs.m_opaque_sp)
102 return m_opaque_sp.get() == rhs.m_opaque_sp.get();
103 return false;
104}
105
Enrico Granatac3387332013-05-03 01:29:27 +0000106bool
107SBBreakpoint::operator != (const lldb::SBBreakpoint& rhs)
108{
109 if (m_opaque_sp && rhs.m_opaque_sp)
110 return m_opaque_sp.get() != rhs.m_opaque_sp.get();
111 return (m_opaque_sp && !rhs.m_opaque_sp) || (rhs.m_opaque_sp && !m_opaque_sp);
112}
113
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000114break_id_t
115SBBreakpoint::GetID () const
116{
Greg Clayton5160ce52013-03-27 23:08:40 +0000117 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Ticeceb6b132010-10-26 03:11:13 +0000118
Greg Claytonaf67cec2010-12-20 20:49:23 +0000119 break_id_t break_id = LLDB_INVALID_BREAK_ID;
Greg Clayton66111032010-06-23 01:19:29 +0000120 if (m_opaque_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000121 break_id = m_opaque_sp->GetID();
Caroline Ticeceb6b132010-10-26 03:11:13 +0000122
123 if (log)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000124 {
125 if (break_id == LLDB_INVALID_BREAK_ID)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000126 log->Printf ("SBBreakpoint(%p)::GetID () => LLDB_INVALID_BREAK_ID",
127 static_cast<void*>(m_opaque_sp.get()));
Greg Claytonaf67cec2010-12-20 20:49:23 +0000128 else
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000129 log->Printf ("SBBreakpoint(%p)::GetID () => %u",
130 static_cast<void*>(m_opaque_sp.get()), break_id);
Greg Claytonaf67cec2010-12-20 20:49:23 +0000131 }
Caroline Ticeceb6b132010-10-26 03:11:13 +0000132
Greg Claytonaf67cec2010-12-20 20:49:23 +0000133 return break_id;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000134}
135
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000136bool
137SBBreakpoint::IsValid() const
138{
Jim Inghame029fa52014-07-02 18:44:43 +0000139 if (!m_opaque_sp)
140 return false;
141 else if (m_opaque_sp->GetTarget().GetBreakpointByID(m_opaque_sp->GetID()))
142 return true;
143 else
144 return false;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000145}
146
147void
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000148SBBreakpoint::ClearAllBreakpointSites ()
149{
Greg Clayton66111032010-06-23 01:19:29 +0000150 if (m_opaque_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000151 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000152 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Greg Clayton66111032010-06-23 01:19:29 +0000153 m_opaque_sp->ClearAllBreakpointSites ();
Greg Claytonaf67cec2010-12-20 20:49:23 +0000154 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000155}
156
157SBBreakpointLocation
158SBBreakpoint::FindLocationByAddress (addr_t vm_addr)
159{
160 SBBreakpointLocation sb_bp_location;
161
Greg Clayton66111032010-06-23 01:19:29 +0000162 if (m_opaque_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000163 {
164 if (vm_addr != LLDB_INVALID_ADDRESS)
165 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000166 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000167 Address address;
Greg Claytonf5e56de2010-09-14 23:36:40 +0000168 Target &target = m_opaque_sp->GetTarget();
Eugene Zelenkodbb0abb2015-10-31 01:22:59 +0000169 if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address))
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000170 {
Greg Claytone72dfb32012-02-24 01:59:29 +0000171 address.SetRawAddress (vm_addr);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000172 }
Greg Clayton66111032010-06-23 01:19:29 +0000173 sb_bp_location.SetLocation (m_opaque_sp->FindLocationByAddress (address));
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000174 }
175 }
176 return sb_bp_location;
177}
178
179break_id_t
180SBBreakpoint::FindLocationIDByAddress (addr_t vm_addr)
181{
Greg Claytonaf67cec2010-12-20 20:49:23 +0000182 break_id_t break_id = LLDB_INVALID_BREAK_ID;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000183
Greg Claytonaf67cec2010-12-20 20:49:23 +0000184 if (m_opaque_sp && vm_addr != LLDB_INVALID_ADDRESS)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000185 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000186 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Greg Claytonaf67cec2010-12-20 20:49:23 +0000187 Address address;
188 Target &target = m_opaque_sp->GetTarget();
Eugene Zelenkodbb0abb2015-10-31 01:22:59 +0000189 if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address))
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000190 {
Greg Claytone72dfb32012-02-24 01:59:29 +0000191 address.SetRawAddress (vm_addr);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000192 }
Greg Claytonaf67cec2010-12-20 20:49:23 +0000193 break_id = m_opaque_sp->FindLocationIDByAddress (address);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000194 }
195
Greg Claytonaf67cec2010-12-20 20:49:23 +0000196 return break_id;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000197}
198
199SBBreakpointLocation
200SBBreakpoint::FindLocationByID (break_id_t bp_loc_id)
201{
202 SBBreakpointLocation sb_bp_location;
203
Greg Clayton66111032010-06-23 01:19:29 +0000204 if (m_opaque_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000205 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000206 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Greg Clayton66111032010-06-23 01:19:29 +0000207 sb_bp_location.SetLocation (m_opaque_sp->FindLocationByID (bp_loc_id));
Greg Claytonaf67cec2010-12-20 20:49:23 +0000208 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000209
210 return sb_bp_location;
211}
212
213SBBreakpointLocation
214SBBreakpoint::GetLocationAtIndex (uint32_t index)
215{
216 SBBreakpointLocation sb_bp_location;
217
Greg Clayton66111032010-06-23 01:19:29 +0000218 if (m_opaque_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000219 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000220 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Greg Clayton66111032010-06-23 01:19:29 +0000221 sb_bp_location.SetLocation (m_opaque_sp->GetLocationAtIndex (index));
Greg Claytonaf67cec2010-12-20 20:49:23 +0000222 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000223
224 return sb_bp_location;
225}
226
227void
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000228SBBreakpoint::SetEnabled (bool enable)
229{
Greg Clayton5160ce52013-03-27 23:08:40 +0000230 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Ticeceb6b132010-10-26 03:11:13 +0000231
232 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000233 log->Printf ("SBBreakpoint(%p)::SetEnabled (enabled=%i)",
234 static_cast<void*>(m_opaque_sp.get()), enable);
Caroline Ticeceb6b132010-10-26 03:11:13 +0000235
Greg Clayton66111032010-06-23 01:19:29 +0000236 if (m_opaque_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000237 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000238 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Greg Clayton66111032010-06-23 01:19:29 +0000239 m_opaque_sp->SetEnabled (enable);
Greg Claytonaf67cec2010-12-20 20:49:23 +0000240 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000241}
242
243bool
244SBBreakpoint::IsEnabled ()
245{
Greg Clayton66111032010-06-23 01:19:29 +0000246 if (m_opaque_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000247 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000248 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Greg Clayton66111032010-06-23 01:19:29 +0000249 return m_opaque_sp->IsEnabled();
Greg Claytonaf67cec2010-12-20 20:49:23 +0000250 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000251 else
252 return false;
253}
254
Jim Inghamca36cd12012-10-05 19:16:31 +0000255void
256SBBreakpoint::SetOneShot (bool one_shot)
257{
Greg Clayton5160ce52013-03-27 23:08:40 +0000258 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Jim Inghamca36cd12012-10-05 19:16:31 +0000259
260 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000261 log->Printf ("SBBreakpoint(%p)::SetOneShot (one_shot=%i)",
262 static_cast<void*>(m_opaque_sp.get()), one_shot);
Jim Inghamca36cd12012-10-05 19:16:31 +0000263
264 if (m_opaque_sp)
265 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000266 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Jim Inghamca36cd12012-10-05 19:16:31 +0000267 m_opaque_sp->SetOneShot (one_shot);
268 }
269}
270
271bool
272SBBreakpoint::IsOneShot () const
273{
274 if (m_opaque_sp)
275 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000276 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Jim Inghamca36cd12012-10-05 19:16:31 +0000277 return m_opaque_sp->IsOneShot();
278 }
279 else
280 return false;
281}
282
Jim Ingham11c81082012-09-25 23:55:19 +0000283bool
284SBBreakpoint::IsInternal ()
285{
286 if (m_opaque_sp)
287 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000288 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Jim Ingham11c81082012-09-25 23:55:19 +0000289 return m_opaque_sp->IsInternal();
290 }
291 else
292 return false;
293}
294
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000295void
Greg Claytonc982c762010-07-09 20:39:50 +0000296SBBreakpoint::SetIgnoreCount (uint32_t count)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000297{
Greg Clayton5160ce52013-03-27 23:08:40 +0000298 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Ticeceb6b132010-10-26 03:11:13 +0000299
300 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000301 log->Printf ("SBBreakpoint(%p)::SetIgnoreCount (count=%u)",
302 static_cast<void*>(m_opaque_sp.get()), count);
303
Greg Clayton66111032010-06-23 01:19:29 +0000304 if (m_opaque_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000305 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000306 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Greg Clayton66111032010-06-23 01:19:29 +0000307 m_opaque_sp->SetIgnoreCount (count);
Greg Claytonaf67cec2010-12-20 20:49:23 +0000308 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000309}
310
Jim Ingham041a12f2010-10-22 01:15:49 +0000311void
312SBBreakpoint::SetCondition (const char *condition)
313{
Greg Claytonaf67cec2010-12-20 20:49:23 +0000314 if (m_opaque_sp)
315 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000316 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Greg Claytonaf67cec2010-12-20 20:49:23 +0000317 m_opaque_sp->SetCondition (condition);
318 }
Jim Ingham041a12f2010-10-22 01:15:49 +0000319}
320
321const char *
322SBBreakpoint::GetCondition ()
323{
Greg Claytonaf67cec2010-12-20 20:49:23 +0000324 if (m_opaque_sp)
325 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000326 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Greg Claytonaf67cec2010-12-20 20:49:23 +0000327 return m_opaque_sp->GetConditionText ();
328 }
Eugene Zelenkodbb0abb2015-10-31 01:22:59 +0000329 return nullptr;
Jim Ingham041a12f2010-10-22 01:15:49 +0000330}
331
Greg Claytonc982c762010-07-09 20:39:50 +0000332uint32_t
Greg Clayton9fed0d82010-07-23 23:33:17 +0000333SBBreakpoint::GetHitCount () const
334{
Greg Clayton48381312010-10-30 04:51:46 +0000335 uint32_t count = 0;
Greg Clayton9fed0d82010-07-23 23:33:17 +0000336 if (m_opaque_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000337 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000338 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Greg Clayton48381312010-10-30 04:51:46 +0000339 count = m_opaque_sp->GetHitCount();
Greg Claytonaf67cec2010-12-20 20:49:23 +0000340 }
Greg Clayton48381312010-10-30 04:51:46 +0000341
Greg Clayton5160ce52013-03-27 23:08:40 +0000342 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton48381312010-10-30 04:51:46 +0000343 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000344 log->Printf ("SBBreakpoint(%p)::GetHitCount () => %u",
345 static_cast<void*>(m_opaque_sp.get()), count);
Greg Clayton48381312010-10-30 04:51:46 +0000346
347 return count;
Greg Clayton9fed0d82010-07-23 23:33:17 +0000348}
349
350uint32_t
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000351SBBreakpoint::GetIgnoreCount () const
352{
Greg Clayton48381312010-10-30 04:51:46 +0000353 uint32_t count = 0;
Greg Clayton66111032010-06-23 01:19:29 +0000354 if (m_opaque_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000355 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000356 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Greg Clayton48381312010-10-30 04:51:46 +0000357 count = m_opaque_sp->GetIgnoreCount();
Greg Claytonaf67cec2010-12-20 20:49:23 +0000358 }
Greg Clayton48381312010-10-30 04:51:46 +0000359
Greg Clayton5160ce52013-03-27 23:08:40 +0000360 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton48381312010-10-30 04:51:46 +0000361 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000362 log->Printf ("SBBreakpoint(%p)::GetIgnoreCount () => %u",
363 static_cast<void*>(m_opaque_sp.get()), count);
Greg Clayton48381312010-10-30 04:51:46 +0000364
365 return count;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000366}
367
368void
Greg Clayton48381312010-10-30 04:51:46 +0000369SBBreakpoint::SetThreadID (tid_t tid)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000370{
Greg Clayton66111032010-06-23 01:19:29 +0000371 if (m_opaque_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000372 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000373 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Greg Clayton48381312010-10-30 04:51:46 +0000374 m_opaque_sp->SetThreadID (tid);
Greg Claytonaf67cec2010-12-20 20:49:23 +0000375 }
Greg Clayton5160ce52013-03-27 23:08:40 +0000376 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton48381312010-10-30 04:51:46 +0000377 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000378 log->Printf ("SBBreakpoint(%p)::SetThreadID (tid=0x%4.4" PRIx64 ")",
379 static_cast<void*>(m_opaque_sp.get()), tid);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000380}
381
382tid_t
383SBBreakpoint::GetThreadID ()
384{
Greg Clayton48381312010-10-30 04:51:46 +0000385 tid_t tid = LLDB_INVALID_THREAD_ID;
Greg Clayton66111032010-06-23 01:19:29 +0000386 if (m_opaque_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000387 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000388 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Greg Clayton48381312010-10-30 04:51:46 +0000389 tid = m_opaque_sp->GetThreadID();
Greg Claytonaf67cec2010-12-20 20:49:23 +0000390 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000391
Greg Clayton5160ce52013-03-27 23:08:40 +0000392 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton48381312010-10-30 04:51:46 +0000393 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000394 log->Printf ("SBBreakpoint(%p)::GetThreadID () => 0x%4.4" PRIx64,
395 static_cast<void*>(m_opaque_sp.get()), tid);
Greg Clayton48381312010-10-30 04:51:46 +0000396 return tid;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000397}
398
Jim Ingham62b02c62010-06-18 01:47:08 +0000399void
400SBBreakpoint::SetThreadIndex (uint32_t index)
401{
Greg Clayton5160ce52013-03-27 23:08:40 +0000402 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton48381312010-10-30 04:51:46 +0000403 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000404 log->Printf ("SBBreakpoint(%p)::SetThreadIndex (%u)",
405 static_cast<void*>(m_opaque_sp.get()), index);
Greg Clayton66111032010-06-23 01:19:29 +0000406 if (m_opaque_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000407 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000408 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Greg Clayton66111032010-06-23 01:19:29 +0000409 m_opaque_sp->GetOptions()->GetThreadSpec()->SetIndex (index);
Greg Claytonaf67cec2010-12-20 20:49:23 +0000410 }
Jim Ingham62b02c62010-06-18 01:47:08 +0000411}
412
413uint32_t
414SBBreakpoint::GetThreadIndex() const
415{
Greg Claytonbdf4c6a2010-12-15 20:50:06 +0000416 uint32_t thread_idx = UINT32_MAX;
Greg Clayton66111032010-06-23 01:19:29 +0000417 if (m_opaque_sp)
Jim Ingham62b02c62010-06-18 01:47:08 +0000418 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000419 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Greg Claytonaf67cec2010-12-20 20:49:23 +0000420 const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate();
Eugene Zelenkodbb0abb2015-10-31 01:22:59 +0000421 if (thread_spec != nullptr)
Greg Clayton48381312010-10-30 04:51:46 +0000422 thread_idx = thread_spec->GetIndex();
Jim Ingham62b02c62010-06-18 01:47:08 +0000423 }
Greg Clayton5160ce52013-03-27 23:08:40 +0000424 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton48381312010-10-30 04:51:46 +0000425 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000426 log->Printf ("SBBreakpoint(%p)::GetThreadIndex () => %u",
427 static_cast<void*>(m_opaque_sp.get()), thread_idx);
Greg Clayton48381312010-10-30 04:51:46 +0000428
Johnny Chen763d1a12010-12-15 21:39:37 +0000429 return thread_idx;
Jim Ingham62b02c62010-06-18 01:47:08 +0000430}
Jim Ingham62b02c62010-06-18 01:47:08 +0000431
432void
433SBBreakpoint::SetThreadName (const char *thread_name)
434{
Greg Clayton5160ce52013-03-27 23:08:40 +0000435 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton48381312010-10-30 04:51:46 +0000436 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000437 log->Printf ("SBBreakpoint(%p)::SetThreadName (%s)",
438 static_cast<void*>(m_opaque_sp.get()), thread_name);
Greg Clayton48381312010-10-30 04:51:46 +0000439
Greg Clayton66111032010-06-23 01:19:29 +0000440 if (m_opaque_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000441 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000442 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Greg Clayton66111032010-06-23 01:19:29 +0000443 m_opaque_sp->GetOptions()->GetThreadSpec()->SetName (thread_name);
Greg Claytonaf67cec2010-12-20 20:49:23 +0000444 }
Jim Ingham62b02c62010-06-18 01:47:08 +0000445}
446
447const char *
448SBBreakpoint::GetThreadName () const
449{
Eugene Zelenkodbb0abb2015-10-31 01:22:59 +0000450 const char *name = nullptr;
Greg Clayton66111032010-06-23 01:19:29 +0000451 if (m_opaque_sp)
Jim Ingham62b02c62010-06-18 01:47:08 +0000452 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000453 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Greg Claytonaf67cec2010-12-20 20:49:23 +0000454 const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate();
Eugene Zelenkodbb0abb2015-10-31 01:22:59 +0000455 if (thread_spec != nullptr)
Greg Clayton48381312010-10-30 04:51:46 +0000456 name = thread_spec->GetName();
Jim Ingham62b02c62010-06-18 01:47:08 +0000457 }
Greg Clayton5160ce52013-03-27 23:08:40 +0000458 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton48381312010-10-30 04:51:46 +0000459 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000460 log->Printf ("SBBreakpoint(%p)::GetThreadName () => %s",
461 static_cast<void*>(m_opaque_sp.get()), name);
Greg Clayton48381312010-10-30 04:51:46 +0000462
463 return name;
Jim Ingham62b02c62010-06-18 01:47:08 +0000464}
465
466void
467SBBreakpoint::SetQueueName (const char *queue_name)
468{
Greg Clayton5160ce52013-03-27 23:08:40 +0000469 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton48381312010-10-30 04:51:46 +0000470 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000471 log->Printf ("SBBreakpoint(%p)::SetQueueName (%s)",
472 static_cast<void*>(m_opaque_sp.get()), queue_name);
Greg Clayton66111032010-06-23 01:19:29 +0000473 if (m_opaque_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000474 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000475 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Greg Clayton66111032010-06-23 01:19:29 +0000476 m_opaque_sp->GetOptions()->GetThreadSpec()->SetQueueName (queue_name);
Greg Claytonaf67cec2010-12-20 20:49:23 +0000477 }
Jim Ingham62b02c62010-06-18 01:47:08 +0000478}
479
480const char *
481SBBreakpoint::GetQueueName () const
482{
Eugene Zelenkodbb0abb2015-10-31 01:22:59 +0000483 const char *name = nullptr;
Greg Clayton66111032010-06-23 01:19:29 +0000484 if (m_opaque_sp)
Jim Ingham62b02c62010-06-18 01:47:08 +0000485 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000486 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Greg Claytonaf67cec2010-12-20 20:49:23 +0000487 const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate();
488 if (thread_spec)
Greg Clayton48381312010-10-30 04:51:46 +0000489 name = thread_spec->GetQueueName();
Jim Ingham62b02c62010-06-18 01:47:08 +0000490 }
Greg Clayton5160ce52013-03-27 23:08:40 +0000491 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton48381312010-10-30 04:51:46 +0000492 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000493 log->Printf ("SBBreakpoint(%p)::GetQueueName () => %s",
494 static_cast<void*>(m_opaque_sp.get()), name);
Greg Clayton48381312010-10-30 04:51:46 +0000495
496 return name;
Jim Ingham62b02c62010-06-18 01:47:08 +0000497}
498
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000499size_t
500SBBreakpoint::GetNumResolvedLocations() const
501{
Greg Clayton48381312010-10-30 04:51:46 +0000502 size_t num_resolved = 0;
Greg Clayton66111032010-06-23 01:19:29 +0000503 if (m_opaque_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000504 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000505 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Greg Clayton48381312010-10-30 04:51:46 +0000506 num_resolved = m_opaque_sp->GetNumResolvedLocations();
Greg Claytonaf67cec2010-12-20 20:49:23 +0000507 }
Greg Clayton5160ce52013-03-27 23:08:40 +0000508 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton48381312010-10-30 04:51:46 +0000509 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000510 log->Printf ("SBBreakpoint(%p)::GetNumResolvedLocations () => %" PRIu64,
511 static_cast<void*>(m_opaque_sp.get()),
512 static_cast<uint64_t>(num_resolved));
Greg Clayton48381312010-10-30 04:51:46 +0000513 return num_resolved;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000514}
515
516size_t
517SBBreakpoint::GetNumLocations() const
518{
Greg Clayton48381312010-10-30 04:51:46 +0000519 size_t num_locs = 0;
Greg Clayton66111032010-06-23 01:19:29 +0000520 if (m_opaque_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000521 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000522 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Greg Clayton48381312010-10-30 04:51:46 +0000523 num_locs = m_opaque_sp->GetNumLocations();
Greg Claytonaf67cec2010-12-20 20:49:23 +0000524 }
Greg Clayton5160ce52013-03-27 23:08:40 +0000525 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton48381312010-10-30 04:51:46 +0000526 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000527 log->Printf ("SBBreakpoint(%p)::GetNumLocations () => %" PRIu64,
528 static_cast<void*>(m_opaque_sp.get()),
529 static_cast<uint64_t>(num_locs));
Greg Clayton48381312010-10-30 04:51:46 +0000530 return num_locs;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000531}
532
Caroline Ticedde9cff2010-09-20 05:20:02 +0000533bool
Greg Clayton05faeb72010-10-07 04:19:01 +0000534SBBreakpoint::GetDescription (SBStream &s)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000535{
Greg Clayton66111032010-06-23 01:19:29 +0000536 if (m_opaque_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000537 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000538 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Greg Clayton05faeb72010-10-07 04:19:01 +0000539 s.Printf("SBBreakpoint: id = %i, ", m_opaque_sp->GetID());
540 m_opaque_sp->GetResolverDescription (s.get());
541 m_opaque_sp->GetFilterDescription (s.get());
542 const size_t num_locations = m_opaque_sp->GetNumLocations ();
Daniel Malead01b2952012-11-29 21:49:15 +0000543 s.Printf(", locations = %" PRIu64, (uint64_t)num_locations);
Greg Clayton05faeb72010-10-07 04:19:01 +0000544 return true;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000545 }
Greg Clayton05faeb72010-10-07 04:19:01 +0000546 s.Printf ("No value");
547 return false;
Caroline Ticedde9cff2010-09-20 05:20:02 +0000548}
549
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000550bool
Eugene Zelenkodbb0abb2015-10-31 01:22:59 +0000551SBBreakpoint::PrivateBreakpointHitCallback(void *baton,
552 StoppointCallbackContext *ctx,
553 lldb::user_id_t break_id,
554 lldb::user_id_t break_loc_id)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000555{
Greg Clayton1ac04c32012-02-21 00:09:25 +0000556 ExecutionContext exe_ctx (ctx->exe_ctx_ref);
557 BreakpointSP bp_sp(exe_ctx.GetTargetRef().GetBreakpointList().FindBreakpointByID(break_id));
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000558 if (baton && bp_sp)
559 {
560 CallbackData *data = (CallbackData *)baton;
561 lldb_private::Breakpoint *bp = bp_sp.get();
562 if (bp && data->callback)
563 {
Greg Clayton1ac04c32012-02-21 00:09:25 +0000564 Process *process = exe_ctx.GetProcessPtr();
Greg Claytonc14ee322011-09-22 04:58:26 +0000565 if (process)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000566 {
Greg Claytone1cd1be2012-01-29 20:56:30 +0000567 SBProcess sb_process (process->shared_from_this());
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000568 SBThread sb_thread;
569 SBBreakpointLocation sb_location;
570 assert (bp_sp);
571 sb_location.SetLocation (bp_sp->FindLocationByID (break_loc_id));
Greg Clayton1ac04c32012-02-21 00:09:25 +0000572 Thread *thread = exe_ctx.GetThreadPtr();
Greg Claytonc14ee322011-09-22 04:58:26 +0000573 if (thread)
Greg Claytone1cd1be2012-01-29 20:56:30 +0000574 sb_thread.SetThread(thread->shared_from_this());
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000575
576 return data->callback (data->callback_baton,
577 sb_process,
578 sb_thread,
579 sb_location);
580 }
581 }
582 }
583 return true; // Return true if we should stop at this breakpoint
584}
585
586void
587SBBreakpoint::SetCallback (BreakpointHitCallback callback, void *baton)
588{
Greg Clayton5160ce52013-03-27 23:08:40 +0000589 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000590
Caroline Ticeceb6b132010-10-26 03:11:13 +0000591 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000592 {
593 void *pointer = &callback;
594 log->Printf ("SBBreakpoint(%p)::SetCallback (callback=%p, baton=%p)",
595 static_cast<void*>(m_opaque_sp.get()),
596 *static_cast<void**>(&pointer), static_cast<void*>(baton));
597 }
Caroline Ticeceb6b132010-10-26 03:11:13 +0000598
Greg Claytonc14ee322011-09-22 04:58:26 +0000599 if (m_opaque_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000600 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000601 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000602 BatonSP baton_sp(new SBBreakpointCallbackBaton (callback, baton));
Greg Clayton66111032010-06-23 01:19:29 +0000603 m_opaque_sp->SetCallback (SBBreakpoint::PrivateBreakpointHitCallback, baton_sp, false);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000604 }
605}
606
Jim Inghamd80102e2014-04-02 01:04:55 +0000607void
608SBBreakpoint::SetScriptCallbackFunction (const char *callback_function_name)
609{
610 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000611
Jim Inghamd80102e2014-04-02 01:04:55 +0000612 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000613 log->Printf ("SBBreakpoint(%p)::SetScriptCallbackFunction (callback=%s)",
614 static_cast<void*>(m_opaque_sp.get()),
615 callback_function_name);
Jim Inghamd80102e2014-04-02 01:04:55 +0000616
617 if (m_opaque_sp)
618 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000619 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Jim Inghamd80102e2014-04-02 01:04:55 +0000620 BreakpointOptions *bp_options = m_opaque_sp->GetOptions();
621 m_opaque_sp->GetTarget().GetDebugger().GetCommandInterpreter().GetScriptInterpreter()->SetBreakpointCommandCallbackFunction (bp_options,
622 callback_function_name);
623 }
624}
625
626SBError
627SBBreakpoint::SetScriptCallbackBody (const char *callback_body_text)
628{
629 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000630
Jim Inghamd80102e2014-04-02 01:04:55 +0000631 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000632 log->Printf ("SBBreakpoint(%p)::SetScriptCallbackBody: callback body:\n%s)",
633 static_cast<void*>(m_opaque_sp.get()), callback_body_text);
Jim Inghamd80102e2014-04-02 01:04:55 +0000634
635 SBError sb_error;
636 if (m_opaque_sp)
637 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000638 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Jim Inghamd80102e2014-04-02 01:04:55 +0000639 BreakpointOptions *bp_options = m_opaque_sp->GetOptions();
640 Error error = m_opaque_sp->GetTarget().GetDebugger().GetCommandInterpreter().GetScriptInterpreter()->SetBreakpointCommandCallback (bp_options,
641 callback_body_text);
642 sb_error.SetError(error);
643 }
644 else
645 sb_error.SetErrorString("invalid breakpoint");
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000646
Jim Inghamd80102e2014-04-02 01:04:55 +0000647 return sb_error;
648}
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000649
Jim Ingham5e09c8c2014-12-16 23:40:14 +0000650bool
651SBBreakpoint::AddName (const char *new_name)
652{
653 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
654
655 if (log)
656 log->Printf ("SBBreakpoint(%p)::AddName (name=%s)",
657 static_cast<void*>(m_opaque_sp.get()),
658 new_name);
659
660 if (m_opaque_sp)
661 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000662 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Jim Ingham5e09c8c2014-12-16 23:40:14 +0000663 Error error; // Think I'm just going to swallow the error here, it's probably more annoying to have to provide it.
664 return m_opaque_sp->AddName(new_name, error);
665 }
666
667 return false;
668}
669
670void
671SBBreakpoint::RemoveName (const char *name_to_remove)
672{
673 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
674
675 if (log)
676 log->Printf ("SBBreakpoint(%p)::RemoveName (name=%s)",
677 static_cast<void*>(m_opaque_sp.get()),
678 name_to_remove);
679
680 if (m_opaque_sp)
681 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000682 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Jim Ingham5e09c8c2014-12-16 23:40:14 +0000683 m_opaque_sp->RemoveName(name_to_remove);
684 }
685}
686
687bool
688SBBreakpoint::MatchesName (const char *name)
689{
690 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
691
692 if (log)
693 log->Printf ("SBBreakpoint(%p)::MatchesName (name=%s)",
694 static_cast<void*>(m_opaque_sp.get()),
695 name);
696
697 if (m_opaque_sp)
698 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000699 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Jim Ingham5e09c8c2014-12-16 23:40:14 +0000700 return m_opaque_sp->MatchesName(name);
701 }
702
703 return false;
704}
705
706void
707SBBreakpoint::GetNames (SBStringList &names)
708{
709 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
710
711 if (log)
712 log->Printf ("SBBreakpoint(%p)::GetNames ()",
713 static_cast<void*>(m_opaque_sp.get()));
714
715 if (m_opaque_sp)
716 {
Saleem Abdulrasoolbb19a132016-05-19 05:13:57 +0000717 std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
Jim Ingham5e09c8c2014-12-16 23:40:14 +0000718 std::vector<std::string> names_vec;
719 m_opaque_sp->GetNames(names_vec);
720 for (std::string name : names_vec)
721 {
722 names.AppendString (name.c_str());
723 }
724 }
725}
726
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000727lldb_private::Breakpoint *
728SBBreakpoint::operator->() const
729{
Greg Clayton66111032010-06-23 01:19:29 +0000730 return m_opaque_sp.get();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000731}
732
733lldb_private::Breakpoint *
734SBBreakpoint::get() const
735{
Greg Clayton66111032010-06-23 01:19:29 +0000736 return m_opaque_sp.get();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000737}
738
739lldb::BreakpointSP &
740SBBreakpoint::operator *()
741{
Greg Clayton66111032010-06-23 01:19:29 +0000742 return m_opaque_sp;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000743}
744
745const lldb::BreakpointSP &
746SBBreakpoint::operator *() const
747{
Greg Clayton66111032010-06-23 01:19:29 +0000748 return m_opaque_sp;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000749}
750
Jim Inghame6bc6cb2012-02-08 05:23:15 +0000751bool
752SBBreakpoint::EventIsBreakpointEvent (const lldb::SBEvent &event)
753{
Eugene Zelenkodbb0abb2015-10-31 01:22:59 +0000754 return Breakpoint::BreakpointEventData::GetEventDataFromEvent(event.get()) != nullptr;
Jim Inghame6bc6cb2012-02-08 05:23:15 +0000755}
756
Greg Clayton9fed0d82010-07-23 23:33:17 +0000757BreakpointEventType
758SBBreakpoint::GetBreakpointEventTypeFromEvent (const SBEvent& event)
759{
760 if (event.IsValid())
761 return Breakpoint::BreakpointEventData::GetBreakpointEventTypeFromEvent (event.GetSP());
762 return eBreakpointEventTypeInvalidType;
763}
764
765SBBreakpoint
766SBBreakpoint::GetBreakpointFromEvent (const lldb::SBEvent& event)
767{
768 SBBreakpoint sb_breakpoint;
769 if (event.IsValid())
770 sb_breakpoint.m_opaque_sp = Breakpoint::BreakpointEventData::GetBreakpointFromEvent (event.GetSP());
771 return sb_breakpoint;
772}
773
774SBBreakpointLocation
775SBBreakpoint::GetBreakpointLocationAtIndexFromEvent (const lldb::SBEvent& event, uint32_t loc_idx)
776{
777 SBBreakpointLocation sb_breakpoint_loc;
778 if (event.IsValid())
779 sb_breakpoint_loc.SetLocation (Breakpoint::BreakpointEventData::GetBreakpointLocationAtIndexFromEvent (event.GetSP(), loc_idx));
780 return sb_breakpoint_loc;
781}
782
Jim Inghame6bc6cb2012-02-08 05:23:15 +0000783uint32_t
784SBBreakpoint::GetNumBreakpointLocationsFromEvent (const lldb::SBEvent &event)
785{
786 uint32_t num_locations = 0;
787 if (event.IsValid())
788 num_locations = (Breakpoint::BreakpointEventData::GetNumBreakpointLocationsFromEvent (event.GetSP()));
789 return num_locations;
790}