blob: 5a924cfae031f97899d7b3b0aac394e77be57fb5 [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
Daniel Malead891f9b2012-12-05 00:20:57 +000010#include "lldb/lldb-python.h"
11
Chris Lattner24943d22010-06-08 16:52:24 +000012// C Includes
13// C++ Includes
14#include <string>
15
16// Other libraries and framework includes
17// Project includes
Greg Clayton49ce8962012-08-29 21:13:06 +000018#include "lldb/lldb-private-log.h"
Chris Lattner24943d22010-06-08 16:52:24 +000019#include "lldb/Breakpoint/BreakpointLocation.h"
20#include "lldb/Breakpoint/BreakpointID.h"
21#include "lldb/Breakpoint/StoppointCallbackContext.h"
Jim Inghame5ed8e92011-06-02 23:58:26 +000022#include "lldb/Core/Debugger.h"
Chris Lattner24943d22010-06-08 16:52:24 +000023#include "lldb/Core/Log.h"
Greg Clayton49ce8962012-08-29 21:13:06 +000024#include "lldb/Core/Module.h"
Chris Lattner24943d22010-06-08 16:52:24 +000025#include "lldb/Core/StreamString.h"
Greg Clayton49ce8962012-08-29 21:13:06 +000026#include "lldb/Symbol/CompileUnit.h"
27#include "lldb/Symbol/Symbol.h"
28#include "lldb/Target/Target.h"
29#include "lldb/Target/Process.h"
Chris Lattner24943d22010-06-08 16:52:24 +000030#include "lldb/Target/Thread.h"
Jim Ingham3c7b5b92010-06-16 02:00:15 +000031#include "lldb/Target/ThreadSpec.h"
Chris Lattner24943d22010-06-08 16:52:24 +000032
33using namespace lldb;
34using namespace lldb_private;
35
36BreakpointLocation::BreakpointLocation
37(
38 break_id_t loc_id,
39 Breakpoint &owner,
Greg Clayton19a1ab82011-02-05 00:38:04 +000040 const Address &addr,
Chris Lattner24943d22010-06-08 16:52:24 +000041 lldb::tid_t tid,
42 bool hardware
43) :
Greg Claytonc0fa5332011-05-22 22:46:53 +000044 StoppointLocation (loc_id, addr.GetOpcodeLoadAddress(&owner.GetTarget()), hardware),
Jim Ingham28e23862012-02-08 05:23:15 +000045 m_being_created(true),
Chris Lattner24943d22010-06-08 16:52:24 +000046 m_address (addr),
47 m_owner (owner),
48 m_options_ap (),
49 m_bp_site_sp ()
50{
Jim Ingham3c7b5b92010-06-16 02:00:15 +000051 SetThreadID (tid);
Jim Ingham28e23862012-02-08 05:23:15 +000052 m_being_created = false;
Chris Lattner24943d22010-06-08 16:52:24 +000053}
54
55BreakpointLocation::~BreakpointLocation()
56{
57 ClearBreakpointSite();
58}
59
60lldb::addr_t
Greg Clayton273a8e52010-06-14 04:18:27 +000061BreakpointLocation::GetLoadAddress () const
Chris Lattner24943d22010-06-08 16:52:24 +000062{
Greg Claytonc0fa5332011-05-22 22:46:53 +000063 return m_address.GetOpcodeLoadAddress (&m_owner.GetTarget());
Chris Lattner24943d22010-06-08 16:52:24 +000064}
65
66Address &
67BreakpointLocation::GetAddress ()
68{
69 return m_address;
70}
71
72Breakpoint &
73BreakpointLocation::GetBreakpoint ()
74{
75 return m_owner;
76}
77
78bool
Johnny Chenca4fe802012-02-01 19:05:20 +000079BreakpointLocation::IsEnabled () const
Chris Lattner24943d22010-06-08 16:52:24 +000080{
Johnny Chenfd60a602012-01-30 22:48:10 +000081 if (!m_owner.IsEnabled())
82 return false;
83 else if (m_options_ap.get() != NULL)
Chris Lattner24943d22010-06-08 16:52:24 +000084 return m_options_ap->IsEnabled();
85 else
Johnny Chenfd60a602012-01-30 22:48:10 +000086 return true;
Chris Lattner24943d22010-06-08 16:52:24 +000087}
88
89void
90BreakpointLocation::SetEnabled (bool enabled)
91{
92 GetLocationOptions()->SetEnabled(enabled);
93 if (enabled)
94 {
95 ResolveBreakpointSite();
96 }
97 else
98 {
99 ClearBreakpointSite();
100 }
Jim Ingham28e23862012-02-08 05:23:15 +0000101 SendBreakpointLocationChangedEvent (enabled ? eBreakpointEventTypeEnabled : eBreakpointEventTypeDisabled);
Chris Lattner24943d22010-06-08 16:52:24 +0000102}
103
104void
105BreakpointLocation::SetThreadID (lldb::tid_t thread_id)
106{
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000107 if (thread_id != LLDB_INVALID_THREAD_ID)
108 GetLocationOptions()->SetThreadID(thread_id);
109 else
110 {
111 // If we're resetting this to an invalid thread id, then
112 // don't make an options pointer just to do that.
113 if (m_options_ap.get() != NULL)
114 m_options_ap->SetThreadID (thread_id);
115 }
Jim Ingham28e23862012-02-08 05:23:15 +0000116 SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged);
117}
118
119lldb::tid_t
120BreakpointLocation::GetThreadID ()
121{
122 if (GetOptionsNoCreate()->GetThreadSpecNoCreate())
123 return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetTID();
124 else
125 return LLDB_INVALID_THREAD_ID;
126}
127
128void
129BreakpointLocation::SetThreadIndex (uint32_t index)
130{
131 if (index != 0)
132 GetLocationOptions()->GetThreadSpec()->SetIndex(index);
133 else
134 {
135 // If we're resetting this to an invalid thread id, then
136 // don't make an options pointer just to do that.
137 if (m_options_ap.get() != NULL)
138 m_options_ap->GetThreadSpec()->SetIndex(index);
139 }
140 SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged);
141
142}
143
144uint32_t
145BreakpointLocation::GetThreadIndex() const
146{
147 if (GetOptionsNoCreate()->GetThreadSpecNoCreate())
148 return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetIndex();
149 else
150 return 0;
151}
152
153void
154BreakpointLocation::SetThreadName (const char *thread_name)
155{
156 if (thread_name != NULL)
157 GetLocationOptions()->GetThreadSpec()->SetName(thread_name);
158 else
159 {
160 // If we're resetting this to an invalid thread id, then
161 // don't make an options pointer just to do that.
162 if (m_options_ap.get() != NULL)
163 m_options_ap->GetThreadSpec()->SetName(thread_name);
164 }
165 SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged);
166}
167
168const char *
169BreakpointLocation::GetThreadName () const
170{
171 if (GetOptionsNoCreate()->GetThreadSpecNoCreate())
172 return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetName();
173 else
174 return NULL;
175}
176
177void
178BreakpointLocation::SetQueueName (const char *queue_name)
179{
180 if (queue_name != NULL)
181 GetLocationOptions()->GetThreadSpec()->SetQueueName(queue_name);
182 else
183 {
184 // If we're resetting this to an invalid thread id, then
185 // don't make an options pointer just to do that.
186 if (m_options_ap.get() != NULL)
187 m_options_ap->GetThreadSpec()->SetQueueName(queue_name);
188 }
189 SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged);
190}
191
192const char *
193BreakpointLocation::GetQueueName () const
194{
195 if (GetOptionsNoCreate()->GetThreadSpecNoCreate())
196 return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetQueueName();
197 else
198 return NULL;
Chris Lattner24943d22010-06-08 16:52:24 +0000199}
200
201bool
202BreakpointLocation::InvokeCallback (StoppointCallbackContext *context)
203{
Jim Ingham649492b2010-06-18 01:00:58 +0000204 if (m_options_ap.get() != NULL && m_options_ap->HasCallback())
Chris Lattner24943d22010-06-08 16:52:24 +0000205 return m_options_ap->InvokeCallback (context, m_owner.GetID(), GetID());
Jim Ingham649492b2010-06-18 01:00:58 +0000206 else
207 return m_owner.InvokeCallback (context, GetID());
Chris Lattner24943d22010-06-08 16:52:24 +0000208}
209
210void
211BreakpointLocation::SetCallback (BreakpointHitCallback callback, void *baton,
212 bool is_synchronous)
213{
214 // The default "Baton" class will keep a copy of "baton" and won't free
215 // or delete it when it goes goes out of scope.
216 GetLocationOptions()->SetCallback(callback, BatonSP (new Baton(baton)), is_synchronous);
Jim Ingham28e23862012-02-08 05:23:15 +0000217 SendBreakpointLocationChangedEvent (eBreakpointEventTypeCommandChanged);
Chris Lattner24943d22010-06-08 16:52:24 +0000218}
219
220void
221BreakpointLocation::SetCallback (BreakpointHitCallback callback, const BatonSP &baton_sp,
222 bool is_synchronous)
223{
224 GetLocationOptions()->SetCallback (callback, baton_sp, is_synchronous);
Jim Ingham28e23862012-02-08 05:23:15 +0000225 SendBreakpointLocationChangedEvent (eBreakpointEventTypeCommandChanged);
Chris Lattner24943d22010-06-08 16:52:24 +0000226}
227
Jim Inghamd1686902010-10-14 23:45:03 +0000228
Chris Lattner24943d22010-06-08 16:52:24 +0000229void
230BreakpointLocation::ClearCallback ()
231{
232 GetLocationOptions()->ClearCallback();
233}
234
Jim Inghamd1686902010-10-14 23:45:03 +0000235void
236BreakpointLocation::SetCondition (const char *condition)
237{
238 GetLocationOptions()->SetCondition (condition);
Jim Ingham28e23862012-02-08 05:23:15 +0000239 SendBreakpointLocationChangedEvent (eBreakpointEventTypeConditionChanged);
Jim Inghamd1686902010-10-14 23:45:03 +0000240}
241
Jim Inghamd1686902010-10-14 23:45:03 +0000242const char *
Jim Inghamac354422011-06-15 21:16:00 +0000243BreakpointLocation::GetConditionText () const
Jim Inghamd1686902010-10-14 23:45:03 +0000244{
Jim Inghamac354422011-06-15 21:16:00 +0000245 return GetOptionsNoCreate()->GetConditionText();
Jim Inghamd1686902010-10-14 23:45:03 +0000246}
247
Greg Clayton54e7afa2010-07-09 20:39:50 +0000248uint32_t
Chris Lattner24943d22010-06-08 16:52:24 +0000249BreakpointLocation::GetIgnoreCount ()
250{
Jim Ingham9c6898b2010-06-22 21:12:54 +0000251 return GetOptionsNoCreate()->GetIgnoreCount();
Chris Lattner24943d22010-06-08 16:52:24 +0000252}
253
254void
Greg Clayton54e7afa2010-07-09 20:39:50 +0000255BreakpointLocation::SetIgnoreCount (uint32_t n)
Chris Lattner24943d22010-06-08 16:52:24 +0000256{
257 GetLocationOptions()->SetIgnoreCount(n);
Jim Ingham28e23862012-02-08 05:23:15 +0000258 SendBreakpointLocationChangedEvent (eBreakpointEventTypeIgnoreChanged);
Chris Lattner24943d22010-06-08 16:52:24 +0000259}
260
Jim Inghamfdbd10a2012-06-26 22:27:55 +0000261void
262BreakpointLocation::DecrementIgnoreCount()
263{
264 if (m_options_ap.get() != NULL)
265 {
266 uint32_t loc_ignore = m_options_ap->GetIgnoreCount();
267 if (loc_ignore != 0)
268 m_options_ap->SetIgnoreCount(loc_ignore - 1);
269 }
270}
271
272bool
273BreakpointLocation::IgnoreCountShouldStop()
274{
275 if (m_options_ap.get() != NULL)
276 {
277 uint32_t loc_ignore = m_options_ap->GetIgnoreCount();
278 if (loc_ignore != 0)
279 {
280 m_owner.DecrementIgnoreCount();
281 DecrementIgnoreCount(); // Have to decrement our owners' ignore count, since it won't get a
282 // chance to.
283 return false;
284 }
285 }
286 return true;
287}
288
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000289const BreakpointOptions *
Jim Ingham9c6898b2010-06-22 21:12:54 +0000290BreakpointLocation::GetOptionsNoCreate () const
Chris Lattner24943d22010-06-08 16:52:24 +0000291{
292 if (m_options_ap.get() != NULL)
293 return m_options_ap.get();
294 else
295 return m_owner.GetOptions ();
296}
297
298BreakpointOptions *
299BreakpointLocation::GetLocationOptions ()
300{
Jim Ingham649492b2010-06-18 01:00:58 +0000301 // If we make the copy we don't copy the callbacks because that is potentially
302 // expensive and we don't want to do that for the simple case where someone is
303 // just disabling the location.
Chris Lattner24943d22010-06-08 16:52:24 +0000304 if (m_options_ap.get() == NULL)
Jim Ingham649492b2010-06-18 01:00:58 +0000305 m_options_ap.reset(BreakpointOptions::CopyOptionsNoCallback(*m_owner.GetOptions ()));
306
Chris Lattner24943d22010-06-08 16:52:24 +0000307 return m_options_ap.get();
308}
309
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000310bool
311BreakpointLocation::ValidForThisThread (Thread *thread)
312{
Jim Ingham9c6898b2010-06-22 21:12:54 +0000313 return thread->MatchesSpec(GetOptionsNoCreate()->GetThreadSpecNoCreate());
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000314}
315
Chris Lattner24943d22010-06-08 16:52:24 +0000316// RETURNS - true if we should stop at this breakpoint, false if we
Jim Ingham3c7b5b92010-06-16 02:00:15 +0000317// should continue. Note, we don't check the thread spec for the breakpoint
318// here, since if the breakpoint is not for this thread, then the event won't
319// even get reported, so the check is redundant.
Chris Lattner24943d22010-06-08 16:52:24 +0000320
321bool
322BreakpointLocation::ShouldStop (StoppointCallbackContext *context)
323{
324 bool should_stop = true;
Greg Claytone005f2c2010-11-06 01:53:30 +0000325 LogSP log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS);
Chris Lattner24943d22010-06-08 16:52:24 +0000326
Johnny Chen51b7c5f2012-01-23 23:03:59 +0000327 IncrementHitCount();
Chris Lattner24943d22010-06-08 16:52:24 +0000328
329 if (!IsEnabled())
330 return false;
331
Jim Inghamfdbd10a2012-06-26 22:27:55 +0000332 if (!IgnoreCountShouldStop())
333 return false;
334
335 if (!m_owner.IgnoreCountShouldStop())
Chris Lattner24943d22010-06-08 16:52:24 +0000336 return false;
337
Jim Inghamd1686902010-10-14 23:45:03 +0000338 // We only run synchronous callbacks in ShouldStop:
Chris Lattner24943d22010-06-08 16:52:24 +0000339 context->is_synchronous = true;
340 should_stop = InvokeCallback (context);
Jim Inghamd1686902010-10-14 23:45:03 +0000341
Jim Inghame5ed8e92011-06-02 23:58:26 +0000342 if (log)
Jim Inghamd1686902010-10-14 23:45:03 +0000343 {
Jim Inghame5ed8e92011-06-02 23:58:26 +0000344 StreamString s;
345 GetDescription (&s, lldb::eDescriptionLevelVerbose);
346 log->Printf ("Hit breakpoint location: %s, %s.\n", s.GetData(), should_stop ? "stopping" : "continuing");
Chris Lattner24943d22010-06-08 16:52:24 +0000347 }
Jim Inghame5ed8e92011-06-02 23:58:26 +0000348
Chris Lattner24943d22010-06-08 16:52:24 +0000349 return should_stop;
350}
351
352bool
353BreakpointLocation::IsResolved () const
354{
355 return m_bp_site_sp.get() != NULL;
356}
357
Jim Inghamd1686902010-10-14 23:45:03 +0000358lldb::BreakpointSiteSP
359BreakpointLocation::GetBreakpointSite() const
360{
361 return m_bp_site_sp;
362}
363
Chris Lattner24943d22010-06-08 16:52:24 +0000364bool
365BreakpointLocation::ResolveBreakpointSite ()
366{
367 if (m_bp_site_sp)
368 return true;
369
Greg Claytoneea26402010-09-14 23:36:40 +0000370 Process *process = m_owner.GetTarget().GetProcessSP().get();
Chris Lattner24943d22010-06-08 16:52:24 +0000371 if (process == NULL)
372 return false;
373
Greg Claytoneea26402010-09-14 23:36:40 +0000374 if (m_owner.GetTarget().GetSectionLoadList().IsEmpty())
375 return false;
376
Greg Clayton13d24fb2012-01-29 20:56:30 +0000377 lldb::break_id_t new_id = process->CreateBreakpointSite (shared_from_this(), false);
Chris Lattner24943d22010-06-08 16:52:24 +0000378
Stephen Wilson3fd1f362010-07-17 00:56:13 +0000379 if (new_id == LLDB_INVALID_BREAK_ID)
Chris Lattner24943d22010-06-08 16:52:24 +0000380 {
Greg Claytone005f2c2010-11-06 01:53:30 +0000381 LogSP log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS);
Chris Lattner24943d22010-06-08 16:52:24 +0000382 if (log)
Daniel Malea5f35a4b2012-11-29 21:49:15 +0000383 log->Warning ("Tried to add breakpoint site at 0x%" PRIx64 " but it was already present.\n",
Greg Claytonc0fa5332011-05-22 22:46:53 +0000384 m_address.GetOpcodeLoadAddress (&m_owner.GetTarget()));
Chris Lattner24943d22010-06-08 16:52:24 +0000385 return false;
386 }
387
388 return true;
389}
390
391bool
392BreakpointLocation::SetBreakpointSite (BreakpointSiteSP& bp_site_sp)
393{
394 m_bp_site_sp = bp_site_sp;
395 return true;
396}
397
398bool
399BreakpointLocation::ClearBreakpointSite ()
400{
401 if (m_bp_site_sp.get())
402 {
Jim Ingham649492b2010-06-18 01:00:58 +0000403 m_owner.GetTarget().GetProcessSP()->RemoveOwnerFromBreakpointSite (GetBreakpoint().GetID(),
404 GetID(), m_bp_site_sp);
Chris Lattner24943d22010-06-08 16:52:24 +0000405 m_bp_site_sp.reset();
406 return true;
407 }
408 return false;
409}
410
411void
412BreakpointLocation::GetDescription (Stream *s, lldb::DescriptionLevel level)
413{
414 SymbolContext sc;
Jim Ingham4f61ba92012-09-22 00:04:04 +0000415
416 // If the description level is "initial" then the breakpoint is printing out our initial state,
417 // and we should let it decide how it wants to print our label.
418 if (level != eDescriptionLevelInitial)
419 {
420 s->Indent();
421 BreakpointID::GetCanonicalReference(s, m_owner.GetID(), GetID());
422 }
423
Chris Lattner24943d22010-06-08 16:52:24 +0000424 if (level == lldb::eDescriptionLevelBrief)
425 return;
426
Jim Ingham4f61ba92012-09-22 00:04:04 +0000427 if (level != eDescriptionLevelInitial)
428 s->PutCString(": ");
Chris Lattner24943d22010-06-08 16:52:24 +0000429
430 if (level == lldb::eDescriptionLevelVerbose)
431 s->IndentMore();
432
433 if (m_address.IsSectionOffset())
434 {
435 m_address.CalculateSymbolContext(&sc);
436
Jim Ingham4f61ba92012-09-22 00:04:04 +0000437 if (level == lldb::eDescriptionLevelFull || level == eDescriptionLevelInitial)
Chris Lattner24943d22010-06-08 16:52:24 +0000438 {
439 s->PutCString("where = ");
Greg Clayton5205f0b2010-09-03 17:10:42 +0000440 sc.DumpStopContext (s, m_owner.GetTarget().GetProcessSP().get(), m_address, false, true, false);
Chris Lattner24943d22010-06-08 16:52:24 +0000441 }
442 else
443 {
444 if (sc.module_sp)
445 {
446 s->EOL();
447 s->Indent("module = ");
448 sc.module_sp->GetFileSpec().Dump (s);
449 }
450
451 if (sc.comp_unit != NULL)
452 {
453 s->EOL();
454 s->Indent("compile unit = ");
Jim Ingham7ea35232010-10-27 22:58:34 +0000455 static_cast<FileSpec*>(sc.comp_unit)->GetFilename().Dump (s);
Chris Lattner24943d22010-06-08 16:52:24 +0000456
457 if (sc.function != NULL)
458 {
459 s->EOL();
460 s->Indent("function = ");
461 s->PutCString (sc.function->GetMangled().GetName().AsCString("<unknown>"));
462 }
463
464 if (sc.line_entry.line > 0)
465 {
466 s->EOL();
467 s->Indent("location = ");
Greg Clayton72b71582010-09-02 21:44:10 +0000468 sc.line_entry.DumpStopContext (s, true);
Chris Lattner24943d22010-06-08 16:52:24 +0000469 }
470
471 }
472 else
473 {
474 // If we don't have a comp unit, see if we have a symbol we can print.
475 if (sc.symbol)
476 {
477 s->EOL();
478 s->Indent("symbol = ");
479 s->PutCString(sc.symbol->GetMangled().GetName().AsCString("<unknown>"));
480 }
481 }
482 }
483 }
484
485 if (level == lldb::eDescriptionLevelVerbose)
486 {
487 s->EOL();
488 s->Indent();
489 }
Jim Ingham4f61ba92012-09-22 00:04:04 +0000490
491 if (m_address.IsSectionOffset() && (level == eDescriptionLevelFull || level == eDescriptionLevelInitial))
492 s->Printf (", ");
493 s->Printf ("address = ");
494
Chris Lattner24943d22010-06-08 16:52:24 +0000495 ExecutionContextScope *exe_scope = NULL;
496 Target *target = &m_owner.GetTarget();
497 if (target)
498 exe_scope = target->GetProcessSP().get();
499 if (exe_scope == NULL)
500 exe_scope = target;
501
Jim Ingham4f61ba92012-09-22 00:04:04 +0000502 if (eDescriptionLevelInitial)
503 m_address.Dump(s, exe_scope, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress);
504 else
505 m_address.Dump(s, exe_scope, Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress);
Chris Lattner24943d22010-06-08 16:52:24 +0000506
507 if (level == lldb::eDescriptionLevelVerbose)
508 {
509 s->EOL();
510 s->Indent();
511 s->Printf("resolved = %s\n", IsResolved() ? "true" : "false");
512
513 s->Indent();
Chris Lattner24943d22010-06-08 16:52:24 +0000514 s->Printf ("hit count = %-4u\n", GetHitCount());
515
516 if (m_options_ap.get())
517 {
Jim Ingham649492b2010-06-18 01:00:58 +0000518 s->Indent();
519 m_options_ap->GetDescription (s, level);
520 s->EOL();
Chris Lattner24943d22010-06-08 16:52:24 +0000521 }
522 s->IndentLess();
523 }
Jim Ingham4f61ba92012-09-22 00:04:04 +0000524 else if (level != eDescriptionLevelInitial)
Chris Lattner24943d22010-06-08 16:52:24 +0000525 {
Jim Ingham649492b2010-06-18 01:00:58 +0000526 s->Printf(", %sresolved, hit count = %u ",
Chris Lattner24943d22010-06-08 16:52:24 +0000527 (IsResolved() ? "" : "un"),
Chris Lattner24943d22010-06-08 16:52:24 +0000528 GetHitCount());
Jim Ingham649492b2010-06-18 01:00:58 +0000529 if (m_options_ap.get())
530 {
531 m_options_ap->GetDescription (s, level);
532 }
Chris Lattner24943d22010-06-08 16:52:24 +0000533 }
534}
535
536void
537BreakpointLocation::Dump(Stream *s) const
538{
539 if (s == NULL)
540 return;
541
Daniel Malea5f35a4b2012-11-29 21:49:15 +0000542 s->Printf("BreakpointLocation %u: tid = %4.4" PRIx64 " load addr = 0x%8.8" PRIx64 " state = %s type = %s breakpoint "
Jim Ingham649492b2010-06-18 01:00:58 +0000543 "hw_index = %i hit_count = %-4u ignore_count = %-4u",
Johnny Chenf8c0fc52012-01-26 00:08:14 +0000544 GetID(),
545 GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetTID(),
546 (uint64_t) m_address.GetOpcodeLoadAddress (&m_owner.GetTarget()),
Johnny Chenfd60a602012-01-30 22:48:10 +0000547 (m_options_ap.get() ? m_options_ap->IsEnabled() : m_owner.IsEnabled()) ? "enabled " : "disabled",
Johnny Chenf8c0fc52012-01-26 00:08:14 +0000548 IsHardware() ? "hardware" : "software",
549 GetHardwareIndex(),
550 GetHitCount(),
551 GetOptionsNoCreate()->GetIgnoreCount());
Chris Lattner24943d22010-06-08 16:52:24 +0000552}
Jim Ingham28e23862012-02-08 05:23:15 +0000553
554void
555BreakpointLocation::SendBreakpointLocationChangedEvent (lldb::BreakpointEventType eventKind)
556{
557 if (!m_being_created
558 && !m_owner.IsInternal()
559 && m_owner.GetTarget().EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged))
560 {
561 Breakpoint::BreakpointEventData *data = new Breakpoint::BreakpointEventData (eventKind,
562 m_owner.shared_from_this());
563 data->GetBreakpointLocationCollection().Add (shared_from_this());
564 m_owner.GetTarget().BroadcastEvent (Target::eBroadcastBitBreakpointChanged, data);
565 }
566}
567