blob: 202898c19ab19a6c91c297579699339d9f570b01 [file] [log] [blame]
Chris Lattner24943d22010-06-08 16:52:24 +00001//===-- BreakpointLocation.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// C Includes
11// C++ Includes
12#include <string>
13
14// Other libraries and framework includes
15// Project includes
Greg Clayton49ce8962012-08-29 21:13:06 +000016#include "lldb/lldb-private-log.h"
Chris Lattner24943d22010-06-08 16:52:24 +000017#include "lldb/Breakpoint/BreakpointLocation.h"
18#include "lldb/Breakpoint/BreakpointID.h"
19#include "lldb/Breakpoint/StoppointCallbackContext.h"
Jim Inghame5ed8e92011-06-02 23:58:26 +000020#include "lldb/Core/Debugger.h"
Chris Lattner24943d22010-06-08 16:52:24 +000021#include "lldb/Core/Log.h"
Greg Clayton49ce8962012-08-29 21:13:06 +000022#include "lldb/Core/Module.h"
Chris Lattner24943d22010-06-08 16:52:24 +000023#include "lldb/Core/StreamString.h"
Greg Clayton49ce8962012-08-29 21:13:06 +000024#include "lldb/Symbol/CompileUnit.h"
25#include "lldb/Symbol/Symbol.h"
26#include "lldb/Target/Target.h"
27#include "lldb/Target/Process.h"
Chris Lattner24943d22010-06-08 16:52:24 +000028#include "lldb/Target/Thread.h"
Jim Ingham3c7b5b92010-06-16 02:00:15 +000029#include "lldb/Target/ThreadSpec.h"
Chris Lattner24943d22010-06-08 16:52:24 +000030
31using namespace lldb;
32using namespace lldb_private;
33
34BreakpointLocation::BreakpointLocation
35(
36 break_id_t loc_id,
37 Breakpoint &owner,
Greg Clayton19a1ab82011-02-05 00:38:04 +000038 const Address &addr,
Chris Lattner24943d22010-06-08 16:52:24 +000039 lldb::tid_t tid,
40 bool hardware
41) :
Greg Claytonc0fa5332011-05-22 22:46:53 +000042 StoppointLocation (loc_id, addr.GetOpcodeLoadAddress(&owner.GetTarget()), hardware),
Jim Ingham28e23862012-02-08 05:23:15 +000043 m_being_created(true),
Chris Lattner24943d22010-06-08 16:52:24 +000044 m_address (addr),
45 m_owner (owner),
46 m_options_ap (),
47 m_bp_site_sp ()
48{
Jim Ingham3c7b5b92010-06-16 02:00:15 +000049 SetThreadID (tid);
Jim Ingham28e23862012-02-08 05:23:15 +000050 m_being_created = false;
Chris Lattner24943d22010-06-08 16:52:24 +000051}
52
53BreakpointLocation::~BreakpointLocation()
54{
55 ClearBreakpointSite();
56}
57
58lldb::addr_t
Greg Clayton273a8e52010-06-14 04:18:27 +000059BreakpointLocation::GetLoadAddress () const
Chris Lattner24943d22010-06-08 16:52:24 +000060{
Greg Claytonc0fa5332011-05-22 22:46:53 +000061 return m_address.GetOpcodeLoadAddress (&m_owner.GetTarget());
Chris Lattner24943d22010-06-08 16:52:24 +000062}
63
64Address &
65BreakpointLocation::GetAddress ()
66{
67 return m_address;
68}
69
70Breakpoint &
71BreakpointLocation::GetBreakpoint ()
72{
73 return m_owner;
74}
75
76bool
Johnny Chenca4fe802012-02-01 19:05:20 +000077BreakpointLocation::IsEnabled () const
Chris Lattner24943d22010-06-08 16:52:24 +000078{
Johnny Chenfd60a602012-01-30 22:48:10 +000079 if (!m_owner.IsEnabled())
80 return false;
81 else if (m_options_ap.get() != NULL)
Chris Lattner24943d22010-06-08 16:52:24 +000082 return m_options_ap->IsEnabled();
83 else
Johnny Chenfd60a602012-01-30 22:48:10 +000084 return true;
Chris Lattner24943d22010-06-08 16:52:24 +000085}
86
87void
88BreakpointLocation::SetEnabled (bool enabled)
89{
90 GetLocationOptions()->SetEnabled(enabled);
91 if (enabled)
92 {
93 ResolveBreakpointSite();
94 }
95 else
96 {
97 ClearBreakpointSite();
98 }
Jim Ingham28e23862012-02-08 05:23:15 +000099 SendBreakpointLocationChangedEvent (enabled ? eBreakpointEventTypeEnabled : eBreakpointEventTypeDisabled);
Chris Lattner24943d22010-06-08 16:52:24 +0000100}
101
102void
103BreakpointLocation::SetThreadID (lldb::tid_t thread_id)
104{
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000105 if (thread_id != LLDB_INVALID_THREAD_ID)
106 GetLocationOptions()->SetThreadID(thread_id);
107 else
108 {
109 // If we're resetting this to an invalid thread id, then
110 // don't make an options pointer just to do that.
111 if (m_options_ap.get() != NULL)
112 m_options_ap->SetThreadID (thread_id);
113 }
Jim Ingham28e23862012-02-08 05:23:15 +0000114 SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged);
115}
116
117lldb::tid_t
118BreakpointLocation::GetThreadID ()
119{
120 if (GetOptionsNoCreate()->GetThreadSpecNoCreate())
121 return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetTID();
122 else
123 return LLDB_INVALID_THREAD_ID;
124}
125
126void
127BreakpointLocation::SetThreadIndex (uint32_t index)
128{
129 if (index != 0)
130 GetLocationOptions()->GetThreadSpec()->SetIndex(index);
131 else
132 {
133 // If we're resetting this to an invalid thread id, then
134 // don't make an options pointer just to do that.
135 if (m_options_ap.get() != NULL)
136 m_options_ap->GetThreadSpec()->SetIndex(index);
137 }
138 SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged);
139
140}
141
142uint32_t
143BreakpointLocation::GetThreadIndex() const
144{
145 if (GetOptionsNoCreate()->GetThreadSpecNoCreate())
146 return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetIndex();
147 else
148 return 0;
149}
150
151void
152BreakpointLocation::SetThreadName (const char *thread_name)
153{
154 if (thread_name != NULL)
155 GetLocationOptions()->GetThreadSpec()->SetName(thread_name);
156 else
157 {
158 // If we're resetting this to an invalid thread id, then
159 // don't make an options pointer just to do that.
160 if (m_options_ap.get() != NULL)
161 m_options_ap->GetThreadSpec()->SetName(thread_name);
162 }
163 SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged);
164}
165
166const char *
167BreakpointLocation::GetThreadName () const
168{
169 if (GetOptionsNoCreate()->GetThreadSpecNoCreate())
170 return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetName();
171 else
172 return NULL;
173}
174
175void
176BreakpointLocation::SetQueueName (const char *queue_name)
177{
178 if (queue_name != NULL)
179 GetLocationOptions()->GetThreadSpec()->SetQueueName(queue_name);
180 else
181 {
182 // If we're resetting this to an invalid thread id, then
183 // don't make an options pointer just to do that.
184 if (m_options_ap.get() != NULL)
185 m_options_ap->GetThreadSpec()->SetQueueName(queue_name);
186 }
187 SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged);
188}
189
190const char *
191BreakpointLocation::GetQueueName () const
192{
193 if (GetOptionsNoCreate()->GetThreadSpecNoCreate())
194 return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetQueueName();
195 else
196 return NULL;
Chris Lattner24943d22010-06-08 16:52:24 +0000197}
198
199bool
200BreakpointLocation::InvokeCallback (StoppointCallbackContext *context)
201{
Jim Ingham649492b2010-06-18 01:00:58 +0000202 if (m_options_ap.get() != NULL && m_options_ap->HasCallback())
Chris Lattner24943d22010-06-08 16:52:24 +0000203 return m_options_ap->InvokeCallback (context, m_owner.GetID(), GetID());
Jim Ingham649492b2010-06-18 01:00:58 +0000204 else
205 return m_owner.InvokeCallback (context, GetID());
Chris Lattner24943d22010-06-08 16:52:24 +0000206}
207
208void
209BreakpointLocation::SetCallback (BreakpointHitCallback callback, void *baton,
210 bool is_synchronous)
211{
212 // The default "Baton" class will keep a copy of "baton" and won't free
213 // or delete it when it goes goes out of scope.
214 GetLocationOptions()->SetCallback(callback, BatonSP (new Baton(baton)), is_synchronous);
Jim Ingham28e23862012-02-08 05:23:15 +0000215 SendBreakpointLocationChangedEvent (eBreakpointEventTypeCommandChanged);
Chris Lattner24943d22010-06-08 16:52:24 +0000216}
217
218void
219BreakpointLocation::SetCallback (BreakpointHitCallback callback, const BatonSP &baton_sp,
220 bool is_synchronous)
221{
222 GetLocationOptions()->SetCallback (callback, baton_sp, is_synchronous);
Jim Ingham28e23862012-02-08 05:23:15 +0000223 SendBreakpointLocationChangedEvent (eBreakpointEventTypeCommandChanged);
Chris Lattner24943d22010-06-08 16:52:24 +0000224}
225
Jim Inghamd1686902010-10-14 23:45:03 +0000226
Chris Lattner24943d22010-06-08 16:52:24 +0000227void
228BreakpointLocation::ClearCallback ()
229{
230 GetLocationOptions()->ClearCallback();
231}
232
Jim Inghamd1686902010-10-14 23:45:03 +0000233void
234BreakpointLocation::SetCondition (const char *condition)
235{
236 GetLocationOptions()->SetCondition (condition);
Jim Ingham28e23862012-02-08 05:23:15 +0000237 SendBreakpointLocationChangedEvent (eBreakpointEventTypeConditionChanged);
Jim Inghamd1686902010-10-14 23:45:03 +0000238}
239
Jim Inghamd1686902010-10-14 23:45:03 +0000240const char *
Jim Inghamac354422011-06-15 21:16:00 +0000241BreakpointLocation::GetConditionText () const
Jim Inghamd1686902010-10-14 23:45:03 +0000242{
Jim Inghamac354422011-06-15 21:16:00 +0000243 return GetOptionsNoCreate()->GetConditionText();
Jim Inghamd1686902010-10-14 23:45:03 +0000244}
245
Greg Clayton54e7afa2010-07-09 20:39:50 +0000246uint32_t
Chris Lattner24943d22010-06-08 16:52:24 +0000247BreakpointLocation::GetIgnoreCount ()
248{
Jim Ingham9c6898b2010-06-22 21:12:54 +0000249 return GetOptionsNoCreate()->GetIgnoreCount();
Chris Lattner24943d22010-06-08 16:52:24 +0000250}
251
252void
Greg Clayton54e7afa2010-07-09 20:39:50 +0000253BreakpointLocation::SetIgnoreCount (uint32_t n)
Chris Lattner24943d22010-06-08 16:52:24 +0000254{
255 GetLocationOptions()->SetIgnoreCount(n);
Jim Ingham28e23862012-02-08 05:23:15 +0000256 SendBreakpointLocationChangedEvent (eBreakpointEventTypeIgnoreChanged);
Chris Lattner24943d22010-06-08 16:52:24 +0000257}
258
Jim Inghamfdbd10a2012-06-26 22:27:55 +0000259void
260BreakpointLocation::DecrementIgnoreCount()
261{
262 if (m_options_ap.get() != NULL)
263 {
264 uint32_t loc_ignore = m_options_ap->GetIgnoreCount();
265 if (loc_ignore != 0)
266 m_options_ap->SetIgnoreCount(loc_ignore - 1);
267 }
268}
269
270bool
271BreakpointLocation::IgnoreCountShouldStop()
272{
273 if (m_options_ap.get() != NULL)
274 {
275 uint32_t loc_ignore = m_options_ap->GetIgnoreCount();
276 if (loc_ignore != 0)
277 {
278 m_owner.DecrementIgnoreCount();
279 DecrementIgnoreCount(); // Have to decrement our owners' ignore count, since it won't get a
280 // chance to.
281 return false;
282 }
283 }
284 return true;
285}
286
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000287const BreakpointOptions *
Jim Ingham9c6898b2010-06-22 21:12:54 +0000288BreakpointLocation::GetOptionsNoCreate () const
Chris Lattner24943d22010-06-08 16:52:24 +0000289{
290 if (m_options_ap.get() != NULL)
291 return m_options_ap.get();
292 else
293 return m_owner.GetOptions ();
294}
295
296BreakpointOptions *
297BreakpointLocation::GetLocationOptions ()
298{
Jim Ingham649492b2010-06-18 01:00:58 +0000299 // If we make the copy we don't copy the callbacks because that is potentially
300 // expensive and we don't want to do that for the simple case where someone is
301 // just disabling the location.
Chris Lattner24943d22010-06-08 16:52:24 +0000302 if (m_options_ap.get() == NULL)
Jim Ingham649492b2010-06-18 01:00:58 +0000303 m_options_ap.reset(BreakpointOptions::CopyOptionsNoCallback(*m_owner.GetOptions ()));
304
Chris Lattner24943d22010-06-08 16:52:24 +0000305 return m_options_ap.get();
306}
307
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000308bool
309BreakpointLocation::ValidForThisThread (Thread *thread)
310{
Jim Ingham9c6898b2010-06-22 21:12:54 +0000311 return thread->MatchesSpec(GetOptionsNoCreate()->GetThreadSpecNoCreate());
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000312}
313
Chris Lattner24943d22010-06-08 16:52:24 +0000314// RETURNS - true if we should stop at this breakpoint, false if we
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000315// should continue. Note, we don't check the thread spec for the breakpoint
316// here, since if the breakpoint is not for this thread, then the event won't
317// even get reported, so the check is redundant.
Chris Lattner24943d22010-06-08 16:52:24 +0000318
319bool
320BreakpointLocation::ShouldStop (StoppointCallbackContext *context)
321{
322 bool should_stop = true;
Greg Claytone005f2c2010-11-06 01:53:30 +0000323 LogSP log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS);
Chris Lattner24943d22010-06-08 16:52:24 +0000324
Johnny Chen51b7c5f2012-01-23 23:03:59 +0000325 IncrementHitCount();
Chris Lattner24943d22010-06-08 16:52:24 +0000326
327 if (!IsEnabled())
328 return false;
329
Jim Inghamfdbd10a2012-06-26 22:27:55 +0000330 if (!IgnoreCountShouldStop())
331 return false;
332
333 if (!m_owner.IgnoreCountShouldStop())
Chris Lattner24943d22010-06-08 16:52:24 +0000334 return false;
335
Jim Inghamd1686902010-10-14 23:45:03 +0000336 // We only run synchronous callbacks in ShouldStop:
Chris Lattner24943d22010-06-08 16:52:24 +0000337 context->is_synchronous = true;
338 should_stop = InvokeCallback (context);
Jim Inghamd1686902010-10-14 23:45:03 +0000339
Jim Inghame5ed8e92011-06-02 23:58:26 +0000340 if (log)
Jim Inghamd1686902010-10-14 23:45:03 +0000341 {
Jim Inghame5ed8e92011-06-02 23:58:26 +0000342 StreamString s;
343 GetDescription (&s, lldb::eDescriptionLevelVerbose);
344 log->Printf ("Hit breakpoint location: %s, %s.\n", s.GetData(), should_stop ? "stopping" : "continuing");
Chris Lattner24943d22010-06-08 16:52:24 +0000345 }
Jim Inghame5ed8e92011-06-02 23:58:26 +0000346
Chris Lattner24943d22010-06-08 16:52:24 +0000347 return should_stop;
348}
349
350bool
351BreakpointLocation::IsResolved () const
352{
353 return m_bp_site_sp.get() != NULL;
354}
355
Jim Inghamd1686902010-10-14 23:45:03 +0000356lldb::BreakpointSiteSP
357BreakpointLocation::GetBreakpointSite() const
358{
359 return m_bp_site_sp;
360}
361
Chris Lattner24943d22010-06-08 16:52:24 +0000362bool
363BreakpointLocation::ResolveBreakpointSite ()
364{
365 if (m_bp_site_sp)
366 return true;
367
Greg Claytoneea26402010-09-14 23:36:40 +0000368 Process *process = m_owner.GetTarget().GetProcessSP().get();
Chris Lattner24943d22010-06-08 16:52:24 +0000369 if (process == NULL)
370 return false;
371
Greg Claytoneea26402010-09-14 23:36:40 +0000372 if (m_owner.GetTarget().GetSectionLoadList().IsEmpty())
373 return false;
374
Greg Clayton13d24fb2012-01-29 20:56:30 +0000375 lldb::break_id_t new_id = process->CreateBreakpointSite (shared_from_this(), false);
Chris Lattner24943d22010-06-08 16:52:24 +0000376
Stephen Wilson3fd1f362010-07-17 00:56:13 +0000377 if (new_id == LLDB_INVALID_BREAK_ID)
Chris Lattner24943d22010-06-08 16:52:24 +0000378 {
Greg Claytone005f2c2010-11-06 01:53:30 +0000379 LogSP log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS);
Chris Lattner24943d22010-06-08 16:52:24 +0000380 if (log)
381 log->Warning ("Tried to add breakpoint site at 0x%llx but it was already present.\n",
Greg Claytonc0fa5332011-05-22 22:46:53 +0000382 m_address.GetOpcodeLoadAddress (&m_owner.GetTarget()));
Chris Lattner24943d22010-06-08 16:52:24 +0000383 return false;
384 }
385
386 return true;
387}
388
389bool
390BreakpointLocation::SetBreakpointSite (BreakpointSiteSP& bp_site_sp)
391{
392 m_bp_site_sp = bp_site_sp;
393 return true;
394}
395
396bool
397BreakpointLocation::ClearBreakpointSite ()
398{
399 if (m_bp_site_sp.get())
400 {
Jim Ingham649492b2010-06-18 01:00:58 +0000401 m_owner.GetTarget().GetProcessSP()->RemoveOwnerFromBreakpointSite (GetBreakpoint().GetID(),
402 GetID(), m_bp_site_sp);
Chris Lattner24943d22010-06-08 16:52:24 +0000403 m_bp_site_sp.reset();
404 return true;
405 }
406 return false;
407}
408
409void
410BreakpointLocation::GetDescription (Stream *s, lldb::DescriptionLevel level)
411{
412 SymbolContext sc;
Jim Ingham4f61ba92012-09-22 00:04:04 +0000413
414 // If the description level is "initial" then the breakpoint is printing out our initial state,
415 // and we should let it decide how it wants to print our label.
416 if (level != eDescriptionLevelInitial)
417 {
418 s->Indent();
419 BreakpointID::GetCanonicalReference(s, m_owner.GetID(), GetID());
420 }
421
Chris Lattner24943d22010-06-08 16:52:24 +0000422 if (level == lldb::eDescriptionLevelBrief)
423 return;
424
Jim Ingham4f61ba92012-09-22 00:04:04 +0000425 if (level != eDescriptionLevelInitial)
426 s->PutCString(": ");
Chris Lattner24943d22010-06-08 16:52:24 +0000427
428 if (level == lldb::eDescriptionLevelVerbose)
429 s->IndentMore();
430
431 if (m_address.IsSectionOffset())
432 {
433 m_address.CalculateSymbolContext(&sc);
434
Jim Ingham4f61ba92012-09-22 00:04:04 +0000435 if (level == lldb::eDescriptionLevelFull || level == eDescriptionLevelInitial)
Chris Lattner24943d22010-06-08 16:52:24 +0000436 {
437 s->PutCString("where = ");
Greg Clayton5205f0b2010-09-03 17:10:42 +0000438 sc.DumpStopContext (s, m_owner.GetTarget().GetProcessSP().get(), m_address, false, true, false);
Chris Lattner24943d22010-06-08 16:52:24 +0000439 }
440 else
441 {
442 if (sc.module_sp)
443 {
444 s->EOL();
445 s->Indent("module = ");
446 sc.module_sp->GetFileSpec().Dump (s);
447 }
448
449 if (sc.comp_unit != NULL)
450 {
451 s->EOL();
452 s->Indent("compile unit = ");
Jim Ingham7ea35232010-10-27 22:58:34 +0000453 static_cast<FileSpec*>(sc.comp_unit)->GetFilename().Dump (s);
Chris Lattner24943d22010-06-08 16:52:24 +0000454
455 if (sc.function != NULL)
456 {
457 s->EOL();
458 s->Indent("function = ");
459 s->PutCString (sc.function->GetMangled().GetName().AsCString("<unknown>"));
460 }
461
462 if (sc.line_entry.line > 0)
463 {
464 s->EOL();
465 s->Indent("location = ");
Greg Clayton72b71582010-09-02 21:44:10 +0000466 sc.line_entry.DumpStopContext (s, true);
Chris Lattner24943d22010-06-08 16:52:24 +0000467 }
468
469 }
470 else
471 {
472 // If we don't have a comp unit, see if we have a symbol we can print.
473 if (sc.symbol)
474 {
475 s->EOL();
476 s->Indent("symbol = ");
477 s->PutCString(sc.symbol->GetMangled().GetName().AsCString("<unknown>"));
478 }
479 }
480 }
481 }
482
483 if (level == lldb::eDescriptionLevelVerbose)
484 {
485 s->EOL();
486 s->Indent();
487 }
Jim Ingham4f61ba92012-09-22 00:04:04 +0000488
489 if (m_address.IsSectionOffset() && (level == eDescriptionLevelFull || level == eDescriptionLevelInitial))
490 s->Printf (", ");
491 s->Printf ("address = ");
492
Chris Lattner24943d22010-06-08 16:52:24 +0000493 ExecutionContextScope *exe_scope = NULL;
494 Target *target = &m_owner.GetTarget();
495 if (target)
496 exe_scope = target->GetProcessSP().get();
497 if (exe_scope == NULL)
498 exe_scope = target;
499
Jim Ingham4f61ba92012-09-22 00:04:04 +0000500 if (eDescriptionLevelInitial)
501 m_address.Dump(s, exe_scope, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress);
502 else
503 m_address.Dump(s, exe_scope, Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress);
Chris Lattner24943d22010-06-08 16:52:24 +0000504
505 if (level == lldb::eDescriptionLevelVerbose)
506 {
507 s->EOL();
508 s->Indent();
509 s->Printf("resolved = %s\n", IsResolved() ? "true" : "false");
510
511 s->Indent();
Chris Lattner24943d22010-06-08 16:52:24 +0000512 s->Printf ("hit count = %-4u\n", GetHitCount());
513
514 if (m_options_ap.get())
515 {
Jim Ingham649492b2010-06-18 01:00:58 +0000516 s->Indent();
517 m_options_ap->GetDescription (s, level);
518 s->EOL();
Chris Lattner24943d22010-06-08 16:52:24 +0000519 }
520 s->IndentLess();
521 }
Jim Ingham4f61ba92012-09-22 00:04:04 +0000522 else if (level != eDescriptionLevelInitial)
Chris Lattner24943d22010-06-08 16:52:24 +0000523 {
Jim Ingham649492b2010-06-18 01:00:58 +0000524 s->Printf(", %sresolved, hit count = %u ",
Chris Lattner24943d22010-06-08 16:52:24 +0000525 (IsResolved() ? "" : "un"),
Chris Lattner24943d22010-06-08 16:52:24 +0000526 GetHitCount());
Jim Ingham649492b2010-06-18 01:00:58 +0000527 if (m_options_ap.get())
528 {
529 m_options_ap->GetDescription (s, level);
530 }
Chris Lattner24943d22010-06-08 16:52:24 +0000531 }
532}
533
534void
535BreakpointLocation::Dump(Stream *s) const
536{
537 if (s == NULL)
538 return;
539
Greg Claytond9919d32011-12-01 23:28:38 +0000540 s->Printf("BreakpointLocation %u: tid = %4.4llx load addr = 0x%8.8llx state = %s type = %s breakpoint "
Jim Ingham649492b2010-06-18 01:00:58 +0000541 "hw_index = %i hit_count = %-4u ignore_count = %-4u",
Johnny Chenf8c0fc52012-01-26 00:08:14 +0000542 GetID(),
543 GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetTID(),
544 (uint64_t) m_address.GetOpcodeLoadAddress (&m_owner.GetTarget()),
Johnny Chenfd60a602012-01-30 22:48:10 +0000545 (m_options_ap.get() ? m_options_ap->IsEnabled() : m_owner.IsEnabled()) ? "enabled " : "disabled",
Johnny Chenf8c0fc52012-01-26 00:08:14 +0000546 IsHardware() ? "hardware" : "software",
547 GetHardwareIndex(),
548 GetHitCount(),
549 GetOptionsNoCreate()->GetIgnoreCount());
Chris Lattner24943d22010-06-08 16:52:24 +0000550}
Jim Ingham28e23862012-02-08 05:23:15 +0000551
552void
553BreakpointLocation::SendBreakpointLocationChangedEvent (lldb::BreakpointEventType eventKind)
554{
555 if (!m_being_created
556 && !m_owner.IsInternal()
557 && m_owner.GetTarget().EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged))
558 {
559 Breakpoint::BreakpointEventData *data = new Breakpoint::BreakpointEventData (eventKind,
560 m_owner.shared_from_this());
561 data->GetBreakpointLocationCollection().Add (shared_from_this());
562 m_owner.GetTarget().BroadcastEvent (Target::eBroadcastBitBreakpointChanged, data);
563 }
564}
565