LLDB mainline
SBBreakpoint.cpp
Go to the documentation of this file.
1//===-- SBBreakpoint.cpp --------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
11#include "lldb/API/SBDebugger.h"
12#include "lldb/API/SBEvent.h"
13#include "lldb/API/SBProcess.h"
14#include "lldb/API/SBStream.h"
17#include "lldb/API/SBThread.h"
19
26#include "lldb/Core/Address.h"
27#include "lldb/Core/Debugger.h"
32#include "lldb/Target/Process.h"
34#include "lldb/Target/Target.h"
35#include "lldb/Target/Thread.h"
37#include "lldb/Utility/Stream.h"
38
40
42
43#include "llvm/ADT/STLExtras.h"
44
45using namespace lldb;
46using namespace lldb_private;
47
49
51 : m_opaque_wp(rhs.m_opaque_wp) {
52 LLDB_INSTRUMENT_VA(this, rhs);
53}
54
55SBBreakpoint::SBBreakpoint(const lldb::BreakpointSP &bp_sp)
56 : m_opaque_wp(bp_sp) {
57 LLDB_INSTRUMENT_VA(this, bp_sp);
58}
59
61
63 LLDB_INSTRUMENT_VA(this, rhs);
64
66 return *this;
67}
68
70 LLDB_INSTRUMENT_VA(this, rhs);
71
72 return m_opaque_wp.lock() == rhs.m_opaque_wp.lock();
73}
74
76 LLDB_INSTRUMENT_VA(this, rhs);
77
78 return m_opaque_wp.lock() != rhs.m_opaque_wp.lock();
79}
80
83
84 BreakpointSP bkpt_sp = GetSP();
85 if (bkpt_sp)
86 return SBTarget(bkpt_sp->GetTargetSP());
87
88 return SBTarget();
89}
90
93
95 BreakpointSP bkpt_sp = GetSP();
96 if (bkpt_sp)
97 break_id = bkpt_sp->GetID();
98
99 return break_id;
100}
101
103 LLDB_INSTRUMENT_VA(this);
104 return this->operator bool();
105}
106SBBreakpoint::operator bool() const {
107 LLDB_INSTRUMENT_VA(this);
108
109 BreakpointSP bkpt_sp = GetSP();
110 if (!bkpt_sp)
111 return false;
112 else if (bkpt_sp->GetTarget().GetBreakpointByID(bkpt_sp->GetID()))
113 return true;
114 else
115 return false;
116}
117
119 LLDB_INSTRUMENT_VA(this);
120
121 BreakpointSP bkpt_sp = GetSP();
122 if (bkpt_sp) {
123 std::lock_guard<std::recursive_mutex> guard(
124 bkpt_sp->GetTarget().GetAPIMutex());
125 bkpt_sp->ClearAllBreakpointSites();
126 }
127}
128
130 LLDB_INSTRUMENT_VA(this, vm_addr);
131
132 SBBreakpointLocation sb_bp_location;
133
134 BreakpointSP bkpt_sp = GetSP();
135 if (bkpt_sp) {
136 if (vm_addr != LLDB_INVALID_ADDRESS) {
137 std::lock_guard<std::recursive_mutex> guard(
138 bkpt_sp->GetTarget().GetAPIMutex());
139 Address address;
140 Target &target = bkpt_sp->GetTarget();
141 if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address)) {
142 address.SetRawAddress(vm_addr);
143 }
144 sb_bp_location.SetLocation(bkpt_sp->FindLocationByAddress(address));
145 }
146 }
147 return sb_bp_location;
148}
149
151 LLDB_INSTRUMENT_VA(this, vm_addr);
152
154 BreakpointSP bkpt_sp = GetSP();
155
156 if (bkpt_sp && vm_addr != LLDB_INVALID_ADDRESS) {
157 std::lock_guard<std::recursive_mutex> guard(
158 bkpt_sp->GetTarget().GetAPIMutex());
159 Address address;
160 Target &target = bkpt_sp->GetTarget();
161 if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address)) {
162 address.SetRawAddress(vm_addr);
163 }
164 break_id = bkpt_sp->FindLocationIDByAddress(address);
165 }
166
167 return break_id;
168}
169
171 LLDB_INSTRUMENT_VA(this, bp_loc_id);
172
173 SBBreakpointLocation sb_bp_location;
174 BreakpointSP bkpt_sp = GetSP();
175
176 if (bkpt_sp) {
177 std::lock_guard<std::recursive_mutex> guard(
178 bkpt_sp->GetTarget().GetAPIMutex());
179 sb_bp_location.SetLocation(bkpt_sp->FindLocationByID(bp_loc_id));
180 }
181
182 return sb_bp_location;
183}
184
186 LLDB_INSTRUMENT_VA(this, index);
187
188 SBBreakpointLocation sb_bp_location;
189 BreakpointSP bkpt_sp = GetSP();
190
191 if (bkpt_sp) {
192 std::lock_guard<std::recursive_mutex> guard(
193 bkpt_sp->GetTarget().GetAPIMutex());
194 sb_bp_location.SetLocation(bkpt_sp->GetLocationAtIndex(index));
195 }
196
197 return sb_bp_location;
198}
199
200void SBBreakpoint::SetEnabled(bool enable) {
201 LLDB_INSTRUMENT_VA(this, enable);
202
203 BreakpointSP bkpt_sp = GetSP();
204
205 if (bkpt_sp) {
206 std::lock_guard<std::recursive_mutex> guard(
207 bkpt_sp->GetTarget().GetAPIMutex());
208 bkpt_sp->SetEnabled(enable);
209 }
210}
211
213 LLDB_INSTRUMENT_VA(this);
214
215 BreakpointSP bkpt_sp = GetSP();
216 if (bkpt_sp) {
217 std::lock_guard<std::recursive_mutex> guard(
218 bkpt_sp->GetTarget().GetAPIMutex());
219 return bkpt_sp->IsEnabled();
220 } else
221 return false;
222}
223
224void SBBreakpoint::SetOneShot(bool one_shot) {
225 LLDB_INSTRUMENT_VA(this, one_shot);
226
227 BreakpointSP bkpt_sp = GetSP();
228
229 if (bkpt_sp) {
230 std::lock_guard<std::recursive_mutex> guard(
231 bkpt_sp->GetTarget().GetAPIMutex());
232 bkpt_sp->SetOneShot(one_shot);
233 }
234}
235
237 LLDB_INSTRUMENT_VA(this);
238
239 BreakpointSP bkpt_sp = GetSP();
240 if (bkpt_sp) {
241 std::lock_guard<std::recursive_mutex> guard(
242 bkpt_sp->GetTarget().GetAPIMutex());
243 return bkpt_sp->IsOneShot();
244 } else
245 return false;
246}
247
249 LLDB_INSTRUMENT_VA(this);
250
251 BreakpointSP bkpt_sp = GetSP();
252 if (bkpt_sp) {
253 std::lock_guard<std::recursive_mutex> guard(
254 bkpt_sp->GetTarget().GetAPIMutex());
255 return bkpt_sp->IsInternal();
256 } else
257 return false;
258}
259
261 LLDB_INSTRUMENT_VA(this, count);
262
263 BreakpointSP bkpt_sp = GetSP();
264
265 if (bkpt_sp) {
266 std::lock_guard<std::recursive_mutex> guard(
267 bkpt_sp->GetTarget().GetAPIMutex());
268 bkpt_sp->SetIgnoreCount(count);
269 }
270}
271
272void SBBreakpoint::SetCondition(const char *condition) {
273 LLDB_INSTRUMENT_VA(this, condition);
274
275 BreakpointSP bkpt_sp = GetSP();
276 if (bkpt_sp) {
277 std::lock_guard<std::recursive_mutex> guard(
278 bkpt_sp->GetTarget().GetAPIMutex());
279 bkpt_sp->SetCondition(condition);
280 }
281}
282
284 LLDB_INSTRUMENT_VA(this);
285
286 BreakpointSP bkpt_sp = GetSP();
287 if (bkpt_sp) {
288 std::lock_guard<std::recursive_mutex> guard(
289 bkpt_sp->GetTarget().GetAPIMutex());
290 return bkpt_sp->GetConditionText();
291 }
292 return nullptr;
293}
294
295void SBBreakpoint::SetAutoContinue(bool auto_continue) {
296 LLDB_INSTRUMENT_VA(this, auto_continue);
297
298 BreakpointSP bkpt_sp = GetSP();
299 if (bkpt_sp) {
300 std::lock_guard<std::recursive_mutex> guard(
301 bkpt_sp->GetTarget().GetAPIMutex());
302 bkpt_sp->SetAutoContinue(auto_continue);
303 }
304}
305
307 LLDB_INSTRUMENT_VA(this);
308
309 BreakpointSP bkpt_sp = GetSP();
310 if (bkpt_sp) {
311 std::lock_guard<std::recursive_mutex> guard(
312 bkpt_sp->GetTarget().GetAPIMutex());
313 return bkpt_sp->IsAutoContinue();
314 }
315 return false;
316}
317
319 LLDB_INSTRUMENT_VA(this);
320
321 uint32_t count = 0;
322 BreakpointSP bkpt_sp = GetSP();
323 if (bkpt_sp) {
324 std::lock_guard<std::recursive_mutex> guard(
325 bkpt_sp->GetTarget().GetAPIMutex());
326 count = bkpt_sp->GetHitCount();
327 }
328
329 return count;
330}
331
333 LLDB_INSTRUMENT_VA(this);
334
335 uint32_t count = 0;
336 BreakpointSP bkpt_sp = GetSP();
337 if (bkpt_sp) {
338 std::lock_guard<std::recursive_mutex> guard(
339 bkpt_sp->GetTarget().GetAPIMutex());
340 count = bkpt_sp->GetIgnoreCount();
341 }
342
343 return count;
344}
345
347 LLDB_INSTRUMENT_VA(this, tid);
348
349 BreakpointSP bkpt_sp = GetSP();
350 if (bkpt_sp) {
351 std::lock_guard<std::recursive_mutex> guard(
352 bkpt_sp->GetTarget().GetAPIMutex());
353 bkpt_sp->SetThreadID(tid);
354 }
355}
356
358 LLDB_INSTRUMENT_VA(this);
359
361 BreakpointSP bkpt_sp = GetSP();
362 if (bkpt_sp) {
363 std::lock_guard<std::recursive_mutex> guard(
364 bkpt_sp->GetTarget().GetAPIMutex());
365 tid = bkpt_sp->GetThreadID();
366 }
367
368 return tid;
369}
370
372 LLDB_INSTRUMENT_VA(this, index);
373
374 BreakpointSP bkpt_sp = GetSP();
375 if (bkpt_sp) {
376 std::lock_guard<std::recursive_mutex> guard(
377 bkpt_sp->GetTarget().GetAPIMutex());
378 bkpt_sp->GetOptions().GetThreadSpec()->SetIndex(index);
379 }
380}
381
383 LLDB_INSTRUMENT_VA(this);
384
385 uint32_t thread_idx = UINT32_MAX;
386 BreakpointSP bkpt_sp = GetSP();
387 if (bkpt_sp) {
388 std::lock_guard<std::recursive_mutex> guard(
389 bkpt_sp->GetTarget().GetAPIMutex());
390 const ThreadSpec *thread_spec =
391 bkpt_sp->GetOptions().GetThreadSpecNoCreate();
392 if (thread_spec != nullptr)
393 thread_idx = thread_spec->GetIndex();
394 }
395
396 return thread_idx;
397}
398
399void SBBreakpoint::SetThreadName(const char *thread_name) {
400 LLDB_INSTRUMENT_VA(this, thread_name);
401
402 BreakpointSP bkpt_sp = GetSP();
403
404 if (bkpt_sp) {
405 std::lock_guard<std::recursive_mutex> guard(
406 bkpt_sp->GetTarget().GetAPIMutex());
407 bkpt_sp->GetOptions().GetThreadSpec()->SetName(thread_name);
408 }
409}
410
411const char *SBBreakpoint::GetThreadName() const {
412 LLDB_INSTRUMENT_VA(this);
413
414 const char *name = nullptr;
415 BreakpointSP bkpt_sp = GetSP();
416 if (bkpt_sp) {
417 std::lock_guard<std::recursive_mutex> guard(
418 bkpt_sp->GetTarget().GetAPIMutex());
419 const ThreadSpec *thread_spec =
420 bkpt_sp->GetOptions().GetThreadSpecNoCreate();
421 if (thread_spec != nullptr)
422 name = thread_spec->GetName();
423 }
424
425 return name;
426}
427
428void SBBreakpoint::SetQueueName(const char *queue_name) {
429 LLDB_INSTRUMENT_VA(this, queue_name);
430
431 BreakpointSP bkpt_sp = GetSP();
432 if (bkpt_sp) {
433 std::lock_guard<std::recursive_mutex> guard(
434 bkpt_sp->GetTarget().GetAPIMutex());
435 bkpt_sp->GetOptions().GetThreadSpec()->SetQueueName(queue_name);
436 }
437}
438
439const char *SBBreakpoint::GetQueueName() const {
440 LLDB_INSTRUMENT_VA(this);
441
442 const char *name = nullptr;
443 BreakpointSP bkpt_sp = GetSP();
444 if (bkpt_sp) {
445 std::lock_guard<std::recursive_mutex> guard(
446 bkpt_sp->GetTarget().GetAPIMutex());
447 const ThreadSpec *thread_spec =
448 bkpt_sp->GetOptions().GetThreadSpecNoCreate();
449 if (thread_spec)
450 name = thread_spec->GetQueueName();
451 }
452
453 return name;
454}
455
457 LLDB_INSTRUMENT_VA(this);
458
459 size_t num_resolved = 0;
460 BreakpointSP bkpt_sp = GetSP();
461 if (bkpt_sp) {
462 std::lock_guard<std::recursive_mutex> guard(
463 bkpt_sp->GetTarget().GetAPIMutex());
464 num_resolved = bkpt_sp->GetNumResolvedLocations();
465 }
466 return num_resolved;
467}
468
470 LLDB_INSTRUMENT_VA(this);
471
472 BreakpointSP bkpt_sp = GetSP();
473 size_t num_locs = 0;
474 if (bkpt_sp) {
475 std::lock_guard<std::recursive_mutex> guard(
476 bkpt_sp->GetTarget().GetAPIMutex());
477 num_locs = bkpt_sp->GetNumLocations();
478 }
479 return num_locs;
480}
481
483 LLDB_INSTRUMENT_VA(this, commands);
484
485 BreakpointSP bkpt_sp = GetSP();
486 if (!bkpt_sp)
487 return;
488 if (commands.GetSize() == 0)
489 return;
490
491 std::lock_guard<std::recursive_mutex> guard(
492 bkpt_sp->GetTarget().GetAPIMutex());
493 std::unique_ptr<BreakpointOptions::CommandData> cmd_data_up(
495
496 bkpt_sp->GetOptions().SetCommandDataCallback(cmd_data_up);
497}
498
500 LLDB_INSTRUMENT_VA(this, commands);
501
502 BreakpointSP bkpt_sp = GetSP();
503 if (!bkpt_sp)
504 return false;
505 StringList command_list;
506 bool has_commands =
507 bkpt_sp->GetOptions().GetCommandLineCallbacks(command_list);
508 if (has_commands)
509 commands.AppendList(command_list);
510 return has_commands;
511}
512
514 LLDB_INSTRUMENT_VA(this, s);
515
516 return GetDescription(s, true);
517}
518
519bool SBBreakpoint::GetDescription(SBStream &s, bool include_locations) {
520 LLDB_INSTRUMENT_VA(this, s, include_locations);
521
522 BreakpointSP bkpt_sp = GetSP();
523 if (bkpt_sp) {
524 std::lock_guard<std::recursive_mutex> guard(
525 bkpt_sp->GetTarget().GetAPIMutex());
526 s.Printf("SBBreakpoint: id = %i, ", bkpt_sp->GetID());
527 bkpt_sp->GetResolverDescription(s.get());
528 bkpt_sp->GetFilterDescription(s.get());
529 if (include_locations) {
530 const size_t num_locations = bkpt_sp->GetNumLocations();
531 s.Printf(", locations = %" PRIu64, (uint64_t)num_locations);
532 }
533 return true;
534 }
535 s.Printf("No value");
536 return false;
537}
538
540 LLDB_INSTRUMENT_VA(this, address);
541
542 BreakpointSP bkpt_sp = GetSP();
544
545 if (!address.IsValid()) {
546 error.SetErrorString("Can't add an invalid address.");
547 return error;
548 }
549
550 if (!bkpt_sp) {
551 error.SetErrorString("No breakpoint to add a location to.");
552 return error;
553 }
554
555 if (!llvm::isa<BreakpointResolverScripted>(bkpt_sp->GetResolver().get())) {
556 error.SetErrorString("Only a scripted resolver can add locations.");
557 return error;
558 }
559
560 if (bkpt_sp->GetSearchFilter()->AddressPasses(address.ref()))
561 bkpt_sp->AddLocation(address.ref());
562 else {
563 StreamString s;
564 address.get()->Dump(&s, &bkpt_sp->GetTarget(),
566 error.SetErrorStringWithFormat("Address: %s didn't pass the filter.",
567 s.GetData());
568 }
569 return error;
570}
571
573 LLDB_INSTRUMENT_VA(this);
574
575 SBStructuredData data;
576 BreakpointSP bkpt_sp = GetSP();
577
578 if (!bkpt_sp)
579 return data;
580
581 StructuredData::ObjectSP bkpt_dict = bkpt_sp->SerializeToStructuredData();
582 data.m_impl_up->SetObjectSP(bkpt_dict);
583 return data;
584}
585
587 LLDB_INSTRUMENT_VA(this, callback, baton);
588
589 BreakpointSP bkpt_sp = GetSP();
590
591 if (bkpt_sp) {
592 std::lock_guard<std::recursive_mutex> guard(
593 bkpt_sp->GetTarget().GetAPIMutex());
594 BatonSP baton_sp(new SBBreakpointCallbackBaton(callback, baton));
595 bkpt_sp->SetCallback(SBBreakpointCallbackBaton
596 ::PrivateBreakpointHitCallback, baton_sp,
597 false);
598 }
599}
600
602 const char *callback_function_name) {
603 LLDB_INSTRUMENT_VA(this, callback_function_name);
604 SBStructuredData empty_args;
605 SetScriptCallbackFunction(callback_function_name, empty_args);
606}
607
609 const char *callback_function_name,
610 SBStructuredData &extra_args) {
611 LLDB_INSTRUMENT_VA(this, callback_function_name, extra_args);
612 SBError sb_error;
613 BreakpointSP bkpt_sp = GetSP();
614
615 if (bkpt_sp) {
617 std::lock_guard<std::recursive_mutex> guard(
618 bkpt_sp->GetTarget().GetAPIMutex());
619 BreakpointOptions &bp_options = bkpt_sp->GetOptions();
620 error = bkpt_sp->GetTarget()
621 .GetDebugger()
622 .GetScriptInterpreter()
623 ->SetBreakpointCommandCallbackFunction(bp_options,
624 callback_function_name,
625 extra_args.m_impl_up
626 ->GetObjectSP());
627 sb_error.SetError(error);
628 } else
629 sb_error.SetErrorString("invalid breakpoint");
630
631 return sb_error;
632}
633
634SBError SBBreakpoint::SetScriptCallbackBody(const char *callback_body_text) {
635 LLDB_INSTRUMENT_VA(this, callback_body_text);
636
637 BreakpointSP bkpt_sp = GetSP();
638
639 SBError sb_error;
640 if (bkpt_sp) {
641 std::lock_guard<std::recursive_mutex> guard(
642 bkpt_sp->GetTarget().GetAPIMutex());
643 BreakpointOptions &bp_options = bkpt_sp->GetOptions();
644 Status error =
645 bkpt_sp->GetTarget()
646 .GetDebugger()
647 .GetScriptInterpreter()
648 ->SetBreakpointCommandCallback(bp_options, callback_body_text,
649 /*is_callback=*/false);
650 sb_error.SetError(error);
651 } else
652 sb_error.SetErrorString("invalid breakpoint");
653
654 return sb_error;
655}
656
657bool SBBreakpoint::AddName(const char *new_name) {
658 LLDB_INSTRUMENT_VA(this, new_name);
659
660 SBError status = AddNameWithErrorHandling(new_name);
661 return status.Success();
662}
663
665 LLDB_INSTRUMENT_VA(this, new_name);
666
667 BreakpointSP bkpt_sp = GetSP();
668
669 SBError status;
670 if (bkpt_sp) {
671 std::lock_guard<std::recursive_mutex> guard(
672 bkpt_sp->GetTarget().GetAPIMutex());
674 bkpt_sp->GetTarget().AddNameToBreakpoint(bkpt_sp, new_name, error);
675 status.SetError(error);
676 } else {
677 status.SetErrorString("invalid breakpoint");
678 }
679
680 return status;
681}
682
683void SBBreakpoint::RemoveName(const char *name_to_remove) {
684 LLDB_INSTRUMENT_VA(this, name_to_remove);
685
686 BreakpointSP bkpt_sp = GetSP();
687
688 if (bkpt_sp) {
689 std::lock_guard<std::recursive_mutex> guard(
690 bkpt_sp->GetTarget().GetAPIMutex());
691 bkpt_sp->GetTarget().RemoveNameFromBreakpoint(bkpt_sp,
692 ConstString(name_to_remove));
693 }
694}
695
696bool SBBreakpoint::MatchesName(const char *name) {
697 LLDB_INSTRUMENT_VA(this, name);
698
699 BreakpointSP bkpt_sp = GetSP();
700
701 if (bkpt_sp) {
702 std::lock_guard<std::recursive_mutex> guard(
703 bkpt_sp->GetTarget().GetAPIMutex());
704 return bkpt_sp->MatchesName(name);
705 }
706
707 return false;
708}
709
711 LLDB_INSTRUMENT_VA(this, names);
712
713 BreakpointSP bkpt_sp = GetSP();
714
715 if (bkpt_sp) {
716 std::lock_guard<std::recursive_mutex> guard(
717 bkpt_sp->GetTarget().GetAPIMutex());
718 std::vector<std::string> names_vec;
719 bkpt_sp->GetNames(names_vec);
720 for (std::string name : names_vec) {
721 names.AppendString(name.c_str());
722 }
723 }
724}
725
727 LLDB_INSTRUMENT_VA(event);
728
730 nullptr;
731}
732
733BreakpointEventType
735 LLDB_INSTRUMENT_VA(event);
736
737 if (event.IsValid())
739 event.GetSP());
740 return eBreakpointEventTypeInvalidType;
741}
742
744 LLDB_INSTRUMENT_VA(event);
745
746 if (event.IsValid())
747 return SBBreakpoint(
749 return SBBreakpoint();
750}
751
754 uint32_t loc_idx) {
755 LLDB_INSTRUMENT_VA(event, loc_idx);
756
757 SBBreakpointLocation sb_breakpoint_loc;
758 if (event.IsValid())
759 sb_breakpoint_loc.SetLocation(
761 event.GetSP(), loc_idx));
762 return sb_breakpoint_loc;
763}
764
767 LLDB_INSTRUMENT_VA(event);
768
769 uint32_t num_locations = 0;
770 if (event.IsValid())
771 num_locations =
773 event.GetSP()));
774 return num_locations;
775}
776
778 LLDB_INSTRUMENT_VA(this);
779
780 BreakpointSP bkpt_sp = GetSP();
781 if (bkpt_sp)
782 return bkpt_sp->IsHardware();
783 return false;
784}
785
786BreakpointSP SBBreakpoint::GetSP() const { return m_opaque_wp.lock(); }
787
788// This is simple collection of breakpoint id's and their target.
790public:
791 SBBreakpointListImpl(lldb::TargetSP target_sp) {
792 if (target_sp && target_sp->IsValid())
793 m_target_wp = target_sp;
794 }
795
797
798 size_t GetSize() { return m_break_ids.size(); }
799
800 BreakpointSP GetBreakpointAtIndex(size_t idx) {
801 if (idx >= m_break_ids.size())
802 return BreakpointSP();
803 TargetSP target_sp = m_target_wp.lock();
804 if (!target_sp)
805 return BreakpointSP();
806 lldb::break_id_t bp_id = m_break_ids[idx];
807 return target_sp->GetBreakpointList().FindBreakpointByID(bp_id);
808 }
809
810 BreakpointSP FindBreakpointByID(lldb::break_id_t desired_id) {
811 TargetSP target_sp = m_target_wp.lock();
812 if (!target_sp)
813 return BreakpointSP();
814
815 for (lldb::break_id_t &break_id : m_break_ids) {
816 if (break_id == desired_id)
817 return target_sp->GetBreakpointList().FindBreakpointByID(break_id);
818 }
819 return BreakpointSP();
820 }
821
822 bool Append(BreakpointSP bkpt) {
823 TargetSP target_sp = m_target_wp.lock();
824 if (!target_sp || !bkpt)
825 return false;
826 if (bkpt->GetTargetSP() != target_sp)
827 return false;
828 m_break_ids.push_back(bkpt->GetID());
829 return true;
830 }
831
832 bool AppendIfUnique(BreakpointSP bkpt) {
833 TargetSP target_sp = m_target_wp.lock();
834 if (!target_sp || !bkpt)
835 return false;
836 if (bkpt->GetTargetSP() != target_sp)
837 return false;
838 lldb::break_id_t bp_id = bkpt->GetID();
839 if (!llvm::is_contained(m_break_ids, bp_id))
840 return false;
841
842 m_break_ids.push_back(bkpt->GetID());
843 return true;
844 }
845
847 TargetSP target_sp = m_target_wp.lock();
848 if (!target_sp)
849 return false;
850 if (id == LLDB_INVALID_BREAK_ID)
851 return false;
852 m_break_ids.push_back(id);
853 return true;
854 }
855
856 void Clear() { m_break_ids.clear(); }
857
859 for (lldb::break_id_t id : m_break_ids) {
860 bp_list.AddBreakpointID(BreakpointID(id));
861 }
862 }
863
864 TargetSP GetTarget() { return m_target_wp.lock(); }
865
866private:
867 std::vector<lldb::break_id_t> m_break_ids;
868 TargetWP m_target_wp;
869};
870
872 : m_opaque_sp(new SBBreakpointListImpl(target.GetSP())) {
873 LLDB_INSTRUMENT_VA(this, target);
874}
875
877
879 LLDB_INSTRUMENT_VA(this);
880
881 if (!m_opaque_sp)
882 return 0;
883 else
884 return m_opaque_sp->GetSize();
885}
886
888 LLDB_INSTRUMENT_VA(this, idx);
889
890 if (!m_opaque_sp)
891 return SBBreakpoint();
892
893 BreakpointSP bkpt_sp = m_opaque_sp->GetBreakpointAtIndex(idx);
894 return SBBreakpoint(bkpt_sp);
895}
896
898 LLDB_INSTRUMENT_VA(this, id);
899
900 if (!m_opaque_sp)
901 return SBBreakpoint();
902 BreakpointSP bkpt_sp = m_opaque_sp->FindBreakpointByID(id);
903 return SBBreakpoint(bkpt_sp);
904}
905
907 LLDB_INSTRUMENT_VA(this, sb_bkpt);
908
909 if (!sb_bkpt.IsValid())
910 return;
911 if (!m_opaque_sp)
912 return;
913 m_opaque_sp->Append(sb_bkpt.m_opaque_wp.lock());
914}
915
917 LLDB_INSTRUMENT_VA(this, id);
918
919 if (!m_opaque_sp)
920 return;
921 m_opaque_sp->AppendByID(id);
922}
923
925 LLDB_INSTRUMENT_VA(this, sb_bkpt);
926
927 if (!sb_bkpt.IsValid())
928 return false;
929 if (!m_opaque_sp)
930 return false;
931 return m_opaque_sp->AppendIfUnique(sb_bkpt.GetSP());
932}
933
935 LLDB_INSTRUMENT_VA(this);
936
937 if (m_opaque_sp)
938 m_opaque_sp->Clear();
939}
940
942 lldb_private::BreakpointIDList &bp_id_list) {
943 if (m_opaque_sp)
944 m_opaque_sp->CopyToBreakpointIDList(bp_id_list);
945}
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_INSTRUMENT_VA(...)
BreakpointSP GetBreakpointAtIndex(size_t idx)
SBBreakpointListImpl(lldb::TargetSP target_sp)
bool Append(BreakpointSP bkpt)
bool AppendIfUnique(BreakpointSP bkpt)
BreakpointSP FindBreakpointByID(lldb::break_id_t desired_id)
std::vector< lldb::break_id_t > m_break_ids
~SBBreakpointListImpl()=default
bool AppendByID(lldb::break_id_t id)
void CopyToBreakpointIDList(lldb_private::BreakpointIDList &bp_list)
lldb_private::Address * get()
Definition: SBAddress.cpp:186
lldb_private::Address & ref()
Definition: SBAddress.cpp:173
bool IsValid() const
Definition: SBAddress.cpp:72
size_t GetSize() const
std::shared_ptr< SBBreakpointListImpl > m_opaque_sp
Definition: SBBreakpoint.h:189
SBBreakpoint GetBreakpointAtIndex(size_t idx)
bool AppendIfUnique(const SBBreakpoint &sb_bkpt)
SBBreakpoint FindBreakpointByID(lldb::break_id_t)
SBBreakpointList(SBTarget &target)
void CopyToBreakpointIDList(lldb_private::BreakpointIDList &bp_id_list)
void Append(const SBBreakpoint &sb_bkpt)
void AppendByID(lldb::break_id_t id)
void SetLocation(const lldb::BreakpointLocationSP &break_loc_sp)
void SetOneShot(bool one_shot)
SBError SetScriptCallbackBody(const char *script_body_text)
uint32_t GetThreadIndex() const
lldb::SBBreakpointLocation FindLocationByID(lldb::break_id_t bp_loc_id)
void ClearAllBreakpointSites()
SBError AddLocation(SBAddress &address)
lldb::tid_t GetThreadID()
break_id_t GetID() const
void SetThreadID(lldb::tid_t sb_thread_id)
lldb::BreakpointWP m_opaque_wp
Definition: SBBreakpoint.h:160
bool GetCommandLineCommands(SBStringList &commands)
void SetAutoContinue(bool auto_continue)
void SetEnabled(bool enable)
void SetThreadName(const char *thread_name)
void SetThreadIndex(uint32_t index)
const char * GetThreadName() const
bool AddName(const char *new_name)
static lldb::BreakpointEventType GetBreakpointEventTypeFromEvent(const lldb::SBEvent &event)
friend class SBTarget
Definition: SBBreakpoint.h:156
uint32_t GetHitCount() const
static lldb::SBBreakpointLocation GetBreakpointLocationAtIndexFromEvent(const lldb::SBEvent &event, uint32_t loc_idx)
bool MatchesName(const char *name)
bool operator!=(const lldb::SBBreakpoint &rhs)
void SetIgnoreCount(uint32_t count)
lldb::break_id_t FindLocationIDByAddress(lldb::addr_t vm_addr)
bool IsValid() const
size_t GetNumLocations() const
SBStructuredData SerializeToStructuredData()
const lldb::SBBreakpoint & operator=(const lldb::SBBreakpoint &rhs)
lldb::SBTarget GetTarget() const
void SetScriptCallbackFunction(const char *callback_function_name)
lldb::BreakpointSP GetSP() const
static lldb::SBBreakpoint GetBreakpointFromEvent(const lldb::SBEvent &event)
bool GetDescription(lldb::SBStream &description)
static bool EventIsBreakpointEvent(const lldb::SBEvent &event)
void SetCommandLineCommands(SBStringList &commands)
size_t GetNumResolvedLocations() const
bool IsHardware() const
bool IsOneShot() const
void SetCondition(const char *condition)
void SetQueueName(const char *queue_name)
lldb::SBBreakpointLocation FindLocationByAddress(lldb::addr_t vm_addr)
const char * GetCondition()
const char * GetQueueName() const
void GetNames(SBStringList &names)
void RemoveName(const char *name_to_remove)
uint32_t GetIgnoreCount() const
static uint32_t GetNumBreakpointLocationsFromEvent(const lldb::SBEvent &event_sp)
SBError AddNameWithErrorHandling(const char *new_name)
lldb::SBBreakpointLocation GetLocationAtIndex(uint32_t index)
bool operator==(const lldb::SBBreakpoint &rhs)
void SetCallback(SBBreakpointHitCallback callback, void *baton)
bool Success() const
Definition: SBError.cpp:69
void SetErrorString(const char *err_str)
Definition: SBError.cpp:126
void SetError(uint32_t err, lldb::ErrorType type)
Definition: SBError.cpp:100
lldb_private::Event * get() const
Definition: SBEvent.cpp:133
bool IsValid() const
Definition: SBEvent.cpp:154
lldb::EventSP & GetSP() const
Definition: SBEvent.cpp:131
lldb_private::Stream * get()
Definition: SBStream.cpp:174
uint32_t GetSize() const
void AppendString(const char *str)
void AppendList(const char **strv, int strc)
StructuredDataImplUP m_impl_up
A section + offset based address class.
Definition: Address.h:59
void SetRawAddress(lldb::addr_t addr)
Definition: Address.h:444
@ DumpStyleModuleWithFileAddress
Display as the file address with the module name prepended (if any).
Definition: Address.h:90
bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, DumpStyle fallback_style=DumpStyleInvalid, uint32_t addr_byte_size=UINT32_MAX, bool all_ranges=false) const
Dump a description of this object to a Stream.
Definition: Address.cpp:406
bool AddBreakpointID(BreakpointID bp_id)
"lldb/Breakpoint/BreakpointOptions.h" Class that manages the options on a breakpoint or breakpoint lo...
static lldb::BreakpointEventType GetBreakpointEventTypeFromEvent(const lldb::EventSP &event_sp)
static lldb::BreakpointLocationSP GetBreakpointLocationAtIndexFromEvent(const lldb::EventSP &event_sp, uint32_t loc_idx)
static lldb::BreakpointSP GetBreakpointFromEvent(const lldb::EventSP &event_sp)
static const BreakpointEventData * GetEventDataFromEvent(const Event *event_sp)
static size_t GetNumBreakpointLocationsFromEvent(const lldb::EventSP &event_sp)
A uniqued constant string class.
Definition: ConstString.h:39
bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr, bool allow_section_end=false) const
An error handling class.
Definition: Status.h:44
const char * GetData() const
Definition: StreamString.h:43
std::shared_ptr< Object > ObjectSP
SectionLoadList & GetSectionLoadList()
Definition: Target.h:1103
uint32_t GetIndex() const
Definition: ThreadSpec.h:55
const char * GetName() const
Definition: ThreadSpec.cpp:68
const char * GetQueueName() const
Definition: ThreadSpec.cpp:72
#define LLDB_INVALID_BREAK_ID
Definition: lldb-defines.h:37
#define LLDB_INVALID_THREAD_ID
Definition: lldb-defines.h:82
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:74
#define UINT32_MAX
Definition: lldb-defines.h:19
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
Definition: SBAddress.h:15
@ eScriptLanguageNone
int32_t break_id_t
Definition: lldb-types.h:88
bool(* SBBreakpointHitCallback)(void *baton, SBProcess &process, SBThread &thread, lldb::SBBreakpointLocation &location)
Definition: SBDefines.h:110
uint64_t addr_t
Definition: lldb-types.h:83
uint64_t tid_t
Definition: lldb-types.h:86