blob: 5791b20edc599e6a69cbdd0e3d9e97fc7a0fe6d8 [file] [log] [blame]
Chris Lattner24943d22010-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
10#include "lldb/API/SBBreakpoint.h"
11#include "lldb/API/SBBreakpointLocation.h"
12#include "lldb/API/SBDebugger.h"
Greg Claytonc7f5d5c2010-07-23 23:33:17 +000013#include "lldb/API/SBEvent.h"
Chris Lattner24943d22010-06-08 16:52:24 +000014#include "lldb/API/SBProcess.h"
Caroline Tice98f930f2010-09-20 05:20:02 +000015#include "lldb/API/SBStream.h"
Chris Lattner24943d22010-06-08 16:52:24 +000016#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 Tice7826c882010-10-26 03:11:13 +000022#include "lldb/Core/Log.h"
Chris Lattner24943d22010-06-08 16:52:24 +000023#include "lldb/Core/Stream.h"
24#include "lldb/Core/StreamFile.h"
25#include "lldb/Target/Process.h"
Chris Lattner24943d22010-06-08 16:52:24 +000026#include "lldb/Target/Target.h"
Jim Ingham8e5e38f2010-06-18 01:47:08 +000027#include "lldb/Target/Thread.h"
28#include "lldb/Target/ThreadSpec.h"
Chris Lattner24943d22010-06-08 16:52:24 +000029
30
31#include "lldb/lldb-enumerations.h"
32
33using namespace lldb;
34using namespace lldb_private;
35
36struct CallbackData
37{
38 SBBreakpoint::BreakpointHitCallback callback;
39 void *callback_baton;
40};
41
42class SBBreakpointCallbackBaton : public Baton
43{
44public:
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
67SBBreakpoint::SBBreakpoint () :
Greg Clayton63094e02010-06-23 01:19:29 +000068 m_opaque_sp ()
Chris Lattner24943d22010-06-08 16:52:24 +000069{
70}
71
72SBBreakpoint::SBBreakpoint (const SBBreakpoint& rhs) :
Greg Clayton63094e02010-06-23 01:19:29 +000073 m_opaque_sp (rhs.m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +000074{
75}
76
77
78SBBreakpoint::SBBreakpoint (const lldb::BreakpointSP &bp_sp) :
Greg Clayton63094e02010-06-23 01:19:29 +000079 m_opaque_sp (bp_sp)
Chris Lattner24943d22010-06-08 16:52:24 +000080{
81}
82
83SBBreakpoint::~SBBreakpoint()
84{
85}
86
87const SBBreakpoint &
88SBBreakpoint::operator = (const SBBreakpoint& rhs)
89{
90 if (this != &rhs)
Greg Clayton63094e02010-06-23 01:19:29 +000091 m_opaque_sp = rhs.m_opaque_sp;
Chris Lattner24943d22010-06-08 16:52:24 +000092 return *this;
93}
94
95break_id_t
96SBBreakpoint::GetID () const
97{
Caroline Tice7826c882010-10-26 03:11:13 +000098 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
99
Greg Clayton63094e02010-06-23 01:19:29 +0000100 if (m_opaque_sp)
Caroline Tice7826c882010-10-26 03:11:13 +0000101 {
Greg Claytona66ba462010-10-30 04:51:46 +0000102 break_id_t break_id = m_opaque_sp->GetID();
Caroline Tice7826c882010-10-26 03:11:13 +0000103 if (log)
Greg Claytona66ba462010-10-30 04:51:46 +0000104 log->Printf ("SBBreakpoint(%p)::GetID () => %u", m_opaque_sp.get(), break_id);
105 return break_id;
Caroline Tice7826c882010-10-26 03:11:13 +0000106 }
107
108 if (log)
Greg Claytona66ba462010-10-30 04:51:46 +0000109 log->Printf ("SBBreakpoint(%p)::GetID () => LLDB_INVALID_BREAK_ID", m_opaque_sp.get());
Caroline Tice7826c882010-10-26 03:11:13 +0000110
Chris Lattner24943d22010-06-08 16:52:24 +0000111 return LLDB_INVALID_BREAK_ID;
112}
113
114
115bool
116SBBreakpoint::IsValid() const
117{
Greg Clayton63094e02010-06-23 01:19:29 +0000118 return m_opaque_sp;
Chris Lattner24943d22010-06-08 16:52:24 +0000119}
120
121void
Chris Lattner24943d22010-06-08 16:52:24 +0000122SBBreakpoint::ClearAllBreakpointSites ()
123{
Greg Clayton63094e02010-06-23 01:19:29 +0000124 if (m_opaque_sp)
125 m_opaque_sp->ClearAllBreakpointSites ();
Chris Lattner24943d22010-06-08 16:52:24 +0000126}
127
128SBBreakpointLocation
129SBBreakpoint::FindLocationByAddress (addr_t vm_addr)
130{
131 SBBreakpointLocation sb_bp_location;
132
Greg Clayton63094e02010-06-23 01:19:29 +0000133 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000134 {
135 if (vm_addr != LLDB_INVALID_ADDRESS)
136 {
137 Address address;
Greg Claytoneea26402010-09-14 23:36:40 +0000138 Target &target = m_opaque_sp->GetTarget();
139 if (target.GetSectionLoadList().ResolveLoadAddress (vm_addr, address) == false)
Chris Lattner24943d22010-06-08 16:52:24 +0000140 {
141 address.SetSection (NULL);
142 address.SetOffset (vm_addr);
143 }
Greg Clayton63094e02010-06-23 01:19:29 +0000144 sb_bp_location.SetLocation (m_opaque_sp->FindLocationByAddress (address));
Chris Lattner24943d22010-06-08 16:52:24 +0000145 }
146 }
147 return sb_bp_location;
148}
149
150break_id_t
151SBBreakpoint::FindLocationIDByAddress (addr_t vm_addr)
152{
153 break_id_t lldb_id = (break_id_t) 0;
154
Greg Clayton63094e02010-06-23 01:19:29 +0000155 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000156 {
157 if (vm_addr != LLDB_INVALID_ADDRESS)
158 {
159 Address address;
Greg Claytoneea26402010-09-14 23:36:40 +0000160 Target &target = m_opaque_sp->GetTarget();
161 if (target.GetSectionLoadList().ResolveLoadAddress (vm_addr, address) == false)
Chris Lattner24943d22010-06-08 16:52:24 +0000162 {
163 address.SetSection (NULL);
164 address.SetOffset (vm_addr);
165 }
Greg Clayton63094e02010-06-23 01:19:29 +0000166 lldb_id = m_opaque_sp->FindLocationIDByAddress (address);
Chris Lattner24943d22010-06-08 16:52:24 +0000167 }
168 }
169
170 return lldb_id;
171}
172
173SBBreakpointLocation
174SBBreakpoint::FindLocationByID (break_id_t bp_loc_id)
175{
176 SBBreakpointLocation sb_bp_location;
177
Greg Clayton63094e02010-06-23 01:19:29 +0000178 if (m_opaque_sp)
179 sb_bp_location.SetLocation (m_opaque_sp->FindLocationByID (bp_loc_id));
Chris Lattner24943d22010-06-08 16:52:24 +0000180
181 return sb_bp_location;
182}
183
184SBBreakpointLocation
185SBBreakpoint::GetLocationAtIndex (uint32_t index)
186{
187 SBBreakpointLocation sb_bp_location;
188
Greg Clayton63094e02010-06-23 01:19:29 +0000189 if (m_opaque_sp)
190 sb_bp_location.SetLocation (m_opaque_sp->GetLocationAtIndex (index));
Chris Lattner24943d22010-06-08 16:52:24 +0000191
192 return sb_bp_location;
193}
194
195void
Chris Lattner24943d22010-06-08 16:52:24 +0000196SBBreakpoint::SetEnabled (bool enable)
197{
Caroline Tice7826c882010-10-26 03:11:13 +0000198 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
199
200 if (log)
Greg Claytona66ba462010-10-30 04:51:46 +0000201 log->Printf ("SBBreakpoint(%p)::SetEnabled (enabled=%i)", m_opaque_sp.get(), enable);
Caroline Tice7826c882010-10-26 03:11:13 +0000202
Greg Clayton63094e02010-06-23 01:19:29 +0000203 if (m_opaque_sp)
204 m_opaque_sp->SetEnabled (enable);
Chris Lattner24943d22010-06-08 16:52:24 +0000205}
206
207bool
208SBBreakpoint::IsEnabled ()
209{
Greg Clayton63094e02010-06-23 01:19:29 +0000210 if (m_opaque_sp)
211 return m_opaque_sp->IsEnabled();
Chris Lattner24943d22010-06-08 16:52:24 +0000212 else
213 return false;
214}
215
216void
Greg Clayton54e7afa2010-07-09 20:39:50 +0000217SBBreakpoint::SetIgnoreCount (uint32_t count)
Chris Lattner24943d22010-06-08 16:52:24 +0000218{
Caroline Tice7826c882010-10-26 03:11:13 +0000219 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
220
221 if (log)
Greg Claytona66ba462010-10-30 04:51:46 +0000222 log->Printf ("SBBreakpoint(%p)::SetIgnoreCount (count=%u)", m_opaque_sp.get(), count);
Caroline Tice7826c882010-10-26 03:11:13 +0000223
Greg Clayton63094e02010-06-23 01:19:29 +0000224 if (m_opaque_sp)
225 m_opaque_sp->SetIgnoreCount (count);
Chris Lattner24943d22010-06-08 16:52:24 +0000226}
227
Jim Inghame3740832010-10-22 01:15:49 +0000228void
229SBBreakpoint::SetCondition (const char *condition)
230{
231 m_opaque_sp->SetCondition (condition);
232}
233
234const char *
235SBBreakpoint::GetCondition ()
236{
237 return m_opaque_sp->GetConditionText ();
238}
239
Greg Clayton54e7afa2010-07-09 20:39:50 +0000240uint32_t
Greg Claytonc7f5d5c2010-07-23 23:33:17 +0000241SBBreakpoint::GetHitCount () const
242{
Greg Claytona66ba462010-10-30 04:51:46 +0000243 uint32_t count = 0;
Greg Claytonc7f5d5c2010-07-23 23:33:17 +0000244 if (m_opaque_sp)
Greg Claytona66ba462010-10-30 04:51:46 +0000245 count = m_opaque_sp->GetHitCount();
246
247 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
248 if (log)
249 log->Printf ("SBBreakpoint(%p)::GetHitCount () => %u", m_opaque_sp.get(), count);
250
251 return count;
Greg Claytonc7f5d5c2010-07-23 23:33:17 +0000252}
253
254uint32_t
Chris Lattner24943d22010-06-08 16:52:24 +0000255SBBreakpoint::GetIgnoreCount () const
256{
Greg Claytona66ba462010-10-30 04:51:46 +0000257 uint32_t count = 0;
Greg Clayton63094e02010-06-23 01:19:29 +0000258 if (m_opaque_sp)
Greg Claytona66ba462010-10-30 04:51:46 +0000259 count = m_opaque_sp->GetIgnoreCount();
260
261 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
262 if (log)
263 log->Printf ("SBBreakpoint(%p)::GetIgnoreCount () => %u", m_opaque_sp.get(), count);
264
265 return count;
Chris Lattner24943d22010-06-08 16:52:24 +0000266}
267
268void
Greg Claytona66ba462010-10-30 04:51:46 +0000269SBBreakpoint::SetThreadID (tid_t tid)
Chris Lattner24943d22010-06-08 16:52:24 +0000270{
Greg Clayton63094e02010-06-23 01:19:29 +0000271 if (m_opaque_sp)
Greg Claytona66ba462010-10-30 04:51:46 +0000272 m_opaque_sp->SetThreadID (tid);
273 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
274 if (log)
275 log->Printf ("SBBreakpoint(%p)::SetThreadID (tid=0x%4.4x)", m_opaque_sp.get(), tid);
276
Chris Lattner24943d22010-06-08 16:52:24 +0000277}
278
279tid_t
280SBBreakpoint::GetThreadID ()
281{
Greg Claytona66ba462010-10-30 04:51:46 +0000282 tid_t tid = LLDB_INVALID_THREAD_ID;
Greg Clayton63094e02010-06-23 01:19:29 +0000283 if (m_opaque_sp)
Greg Claytona66ba462010-10-30 04:51:46 +0000284 tid = m_opaque_sp->GetThreadID();
Chris Lattner24943d22010-06-08 16:52:24 +0000285
Greg Claytona66ba462010-10-30 04:51:46 +0000286 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
287 if (log)
288 log->Printf ("SBBreakpoint(%p)::GetThreadID () => 0x%4.4x", m_opaque_sp.get(), tid);
289 return tid;
Chris Lattner24943d22010-06-08 16:52:24 +0000290}
291
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000292void
293SBBreakpoint::SetThreadIndex (uint32_t index)
294{
Greg Claytona66ba462010-10-30 04:51:46 +0000295 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
296 if (log)
297 log->Printf ("SBBreakpoint(%p)::SetThreadIndex (%u)", m_opaque_sp.get(), index);
Greg Clayton63094e02010-06-23 01:19:29 +0000298 if (m_opaque_sp)
299 m_opaque_sp->GetOptions()->GetThreadSpec()->SetIndex (index);
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000300}
301
302uint32_t
303SBBreakpoint::GetThreadIndex() const
304{
Greg Claytona66ba462010-10-30 04:51:46 +0000305 uint32_t thread_idx = 0;
Greg Clayton63094e02010-06-23 01:19:29 +0000306 if (m_opaque_sp)
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000307 {
Greg Clayton63094e02010-06-23 01:19:29 +0000308 const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpec();
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000309 if (thread_spec == NULL)
Greg Claytona66ba462010-10-30 04:51:46 +0000310 thread_idx = thread_spec->GetIndex();
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000311 }
Greg Claytona66ba462010-10-30 04:51:46 +0000312 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
313 if (log)
314 log->Printf ("SBBreakpoint(%p)::GetThreadIndex () => %u", m_opaque_sp.get(), index);
315
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000316 return 0;
317}
318
319
320void
321SBBreakpoint::SetThreadName (const char *thread_name)
322{
Greg Claytona66ba462010-10-30 04:51:46 +0000323 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
324 if (log)
325 log->Printf ("SBBreakpoint(%p)::SetThreadName (%s)", m_opaque_sp.get(), thread_name);
326
Greg Clayton63094e02010-06-23 01:19:29 +0000327 if (m_opaque_sp)
328 m_opaque_sp->GetOptions()->GetThreadSpec()->SetName (thread_name);
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000329}
330
331const char *
332SBBreakpoint::GetThreadName () const
333{
Greg Claytona66ba462010-10-30 04:51:46 +0000334 const char *name = NULL;
Greg Clayton63094e02010-06-23 01:19:29 +0000335 if (m_opaque_sp)
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000336 {
Greg Clayton63094e02010-06-23 01:19:29 +0000337 const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpec();
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000338 if (thread_spec == NULL)
Greg Claytona66ba462010-10-30 04:51:46 +0000339 name = thread_spec->GetName();
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000340 }
Greg Claytona66ba462010-10-30 04:51:46 +0000341 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
342 if (log)
343 log->Printf ("SBBreakpoint(%p)::GetThreadName () => %s", m_opaque_sp.get(), name);
344
345 return name;
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000346}
347
348void
349SBBreakpoint::SetQueueName (const char *queue_name)
350{
Greg Claytona66ba462010-10-30 04:51:46 +0000351 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
352 if (log)
353 log->Printf ("SBBreakpoint(%p)::SetQueueName (%s)", m_opaque_sp.get(), queue_name);
Greg Clayton63094e02010-06-23 01:19:29 +0000354 if (m_opaque_sp)
355 m_opaque_sp->GetOptions()->GetThreadSpec()->SetQueueName (queue_name);
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000356}
357
358const char *
359SBBreakpoint::GetQueueName () const
360{
Greg Claytona66ba462010-10-30 04:51:46 +0000361 const char *name = NULL;
Greg Clayton63094e02010-06-23 01:19:29 +0000362 if (m_opaque_sp)
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000363 {
Greg Clayton63094e02010-06-23 01:19:29 +0000364 const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpec();
Greg Claytona66ba462010-10-30 04:51:46 +0000365 name = thread_spec->GetQueueName();
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000366 }
Greg Claytona66ba462010-10-30 04:51:46 +0000367 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
368 if (log)
369 log->Printf ("SBBreakpoint(%p)::GetQueueName () => %s", m_opaque_sp.get(), name);
370
371 return name;
Jim Ingham8e5e38f2010-06-18 01:47:08 +0000372}
373
Chris Lattner24943d22010-06-08 16:52:24 +0000374size_t
375SBBreakpoint::GetNumResolvedLocations() const
376{
Greg Claytona66ba462010-10-30 04:51:46 +0000377 size_t num_resolved = 0;
Greg Clayton63094e02010-06-23 01:19:29 +0000378 if (m_opaque_sp)
Greg Claytona66ba462010-10-30 04:51:46 +0000379 num_resolved = m_opaque_sp->GetNumResolvedLocations();
380 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
381 if (log)
382 log->Printf ("SBBreakpoint(%p)::GetNumResolvedLocations () => %zu", m_opaque_sp.get(), num_resolved);
383 return num_resolved;
Chris Lattner24943d22010-06-08 16:52:24 +0000384}
385
386size_t
387SBBreakpoint::GetNumLocations() const
388{
Greg Claytona66ba462010-10-30 04:51:46 +0000389 size_t num_locs = 0;
Greg Clayton63094e02010-06-23 01:19:29 +0000390 if (m_opaque_sp)
Greg Claytona66ba462010-10-30 04:51:46 +0000391 num_locs = m_opaque_sp->GetNumLocations();
392 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
393 if (log)
394 log->Printf ("SBBreakpoint(%p)::GetNumLocations () => %zu", m_opaque_sp.get(), num_locs);
395 return num_locs;
Chris Lattner24943d22010-06-08 16:52:24 +0000396}
397
Caroline Tice98f930f2010-09-20 05:20:02 +0000398bool
Greg Claytond8c62532010-10-07 04:19:01 +0000399SBBreakpoint::GetDescription (SBStream &s)
Chris Lattner24943d22010-06-08 16:52:24 +0000400{
Greg Clayton63094e02010-06-23 01:19:29 +0000401 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000402 {
Greg Claytond8c62532010-10-07 04:19:01 +0000403 s.Printf("SBBreakpoint: id = %i, ", m_opaque_sp->GetID());
404 m_opaque_sp->GetResolverDescription (s.get());
405 m_opaque_sp->GetFilterDescription (s.get());
406 const size_t num_locations = m_opaque_sp->GetNumLocations ();
407 s.Printf(", locations = %zu", num_locations);
408 return true;
Chris Lattner24943d22010-06-08 16:52:24 +0000409 }
Greg Claytond8c62532010-10-07 04:19:01 +0000410 s.Printf ("No value");
411 return false;
Caroline Tice98f930f2010-09-20 05:20:02 +0000412}
413
Chris Lattner24943d22010-06-08 16:52:24 +0000414bool
415SBBreakpoint::PrivateBreakpointHitCallback
416(
417 void *baton,
418 StoppointCallbackContext *ctx,
419 lldb::user_id_t break_id,
420 lldb::user_id_t break_loc_id
421)
422{
Greg Clayton63094e02010-06-23 01:19:29 +0000423 BreakpointSP bp_sp(ctx->exe_ctx.target->GetBreakpointList().FindBreakpointByID(break_id));
Chris Lattner24943d22010-06-08 16:52:24 +0000424 if (baton && bp_sp)
425 {
426 CallbackData *data = (CallbackData *)baton;
427 lldb_private::Breakpoint *bp = bp_sp.get();
428 if (bp && data->callback)
429 {
Greg Clayton63094e02010-06-23 01:19:29 +0000430 if (ctx->exe_ctx.process)
Chris Lattner24943d22010-06-08 16:52:24 +0000431 {
Greg Clayton63094e02010-06-23 01:19:29 +0000432 SBProcess sb_process (ctx->exe_ctx.process->GetSP());
Chris Lattner24943d22010-06-08 16:52:24 +0000433 SBThread sb_thread;
434 SBBreakpointLocation sb_location;
435 assert (bp_sp);
436 sb_location.SetLocation (bp_sp->FindLocationByID (break_loc_id));
Greg Clayton63094e02010-06-23 01:19:29 +0000437 if (ctx->exe_ctx.thread)
438 sb_thread.SetThread(ctx->exe_ctx.thread->GetSP());
Chris Lattner24943d22010-06-08 16:52:24 +0000439
440 return data->callback (data->callback_baton,
441 sb_process,
442 sb_thread,
443 sb_location);
444 }
445 }
446 }
447 return true; // Return true if we should stop at this breakpoint
448}
449
450void
451SBBreakpoint::SetCallback (BreakpointHitCallback callback, void *baton)
452{
Caroline Tice7826c882010-10-26 03:11:13 +0000453 Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
454
455 if (log)
Greg Claytona66ba462010-10-30 04:51:46 +0000456 log->Printf ("SBBreakpoint(%p)::SetCallback (callback=%p, baton=%p)", m_opaque_sp.get(), callback, baton);
Caroline Tice7826c882010-10-26 03:11:13 +0000457
Greg Clayton63094e02010-06-23 01:19:29 +0000458 if (m_opaque_sp.get())
Chris Lattner24943d22010-06-08 16:52:24 +0000459 {
460 BatonSP baton_sp(new SBBreakpointCallbackBaton (callback, baton));
Greg Clayton63094e02010-06-23 01:19:29 +0000461 m_opaque_sp->SetCallback (SBBreakpoint::PrivateBreakpointHitCallback, baton_sp, false);
Chris Lattner24943d22010-06-08 16:52:24 +0000462 }
463}
464
465
466lldb_private::Breakpoint *
467SBBreakpoint::operator->() const
468{
Greg Clayton63094e02010-06-23 01:19:29 +0000469 return m_opaque_sp.get();
Chris Lattner24943d22010-06-08 16:52:24 +0000470}
471
472lldb_private::Breakpoint *
473SBBreakpoint::get() const
474{
Greg Clayton63094e02010-06-23 01:19:29 +0000475 return m_opaque_sp.get();
Chris Lattner24943d22010-06-08 16:52:24 +0000476}
477
478lldb::BreakpointSP &
479SBBreakpoint::operator *()
480{
Greg Clayton63094e02010-06-23 01:19:29 +0000481 return m_opaque_sp;
Chris Lattner24943d22010-06-08 16:52:24 +0000482}
483
484const lldb::BreakpointSP &
485SBBreakpoint::operator *() const
486{
Greg Clayton63094e02010-06-23 01:19:29 +0000487 return m_opaque_sp;
Chris Lattner24943d22010-06-08 16:52:24 +0000488}
489
Greg Claytonc7f5d5c2010-07-23 23:33:17 +0000490BreakpointEventType
491SBBreakpoint::GetBreakpointEventTypeFromEvent (const SBEvent& event)
492{
493 if (event.IsValid())
494 return Breakpoint::BreakpointEventData::GetBreakpointEventTypeFromEvent (event.GetSP());
495 return eBreakpointEventTypeInvalidType;
496}
497
498SBBreakpoint
499SBBreakpoint::GetBreakpointFromEvent (const lldb::SBEvent& event)
500{
501 SBBreakpoint sb_breakpoint;
502 if (event.IsValid())
503 sb_breakpoint.m_opaque_sp = Breakpoint::BreakpointEventData::GetBreakpointFromEvent (event.GetSP());
504 return sb_breakpoint;
505}
506
507SBBreakpointLocation
508SBBreakpoint::GetBreakpointLocationAtIndexFromEvent (const lldb::SBEvent& event, uint32_t loc_idx)
509{
510 SBBreakpointLocation sb_breakpoint_loc;
511 if (event.IsValid())
512 sb_breakpoint_loc.SetLocation (Breakpoint::BreakpointEventData::GetBreakpointLocationAtIndexFromEvent (event.GetSP(), loc_idx));
513 return sb_breakpoint_loc;
514}
515
516