LLDB mainline
Breakpoint.cpp
Go to the documentation of this file.
1//===-- Breakpoint.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
9#include "llvm/Support/Casting.h"
10
17#include "lldb/Core/Address.h"
18#include "lldb/Core/Module.h"
21#include "lldb/Core/Section.h"
24#include "lldb/Symbol/Symbol.h"
27#include "lldb/Target/Target.h"
30#include "lldb/Utility/Log.h"
31#include "lldb/Utility/Stream.h"
33
34#include <memory>
35
36using namespace lldb;
37using namespace lldb_private;
38using namespace llvm;
39
41 static ConstString g_identifier("event-identifier.breakpoint.changed");
42 return g_identifier;
43}
44
45const char *Breakpoint::g_option_names[static_cast<uint32_t>(
46 Breakpoint::OptionNames::LastOptionName)]{"Names", "Hardware"};
47
48// Breakpoint constructor
49Breakpoint::Breakpoint(Target &target, SearchFilterSP &filter_sp,
50 BreakpointResolverSP &resolver_sp, bool hardware,
51 bool resolve_indirect_symbols)
52 : m_being_created(true), m_hardware(hardware), m_target(target),
53 m_filter_sp(filter_sp), m_resolver_sp(resolver_sp), m_options(true),
54 m_locations(*this), m_resolve_indirect_symbols(resolve_indirect_symbols),
55 m_hit_counter() {
56 m_being_created = false;
57}
58
59Breakpoint::Breakpoint(Target &new_target, const Breakpoint &source_bp)
60 : m_being_created(true), m_hardware(source_bp.m_hardware),
61 m_target(new_target), m_name_list(source_bp.m_name_list),
62 m_options(source_bp.m_options), m_locations(*this),
63 m_resolve_indirect_symbols(source_bp.m_resolve_indirect_symbols),
64 m_hit_counter() {}
65
66// Destructor
67Breakpoint::~Breakpoint() = default;
68
69BreakpointSP Breakpoint::CopyFromBreakpoint(TargetSP new_target,
70 const Breakpoint& bp_to_copy_from) {
71 if (!new_target)
72 return BreakpointSP();
73
74 BreakpointSP bp(new Breakpoint(*new_target, bp_to_copy_from));
75 // Now go through and copy the filter & resolver:
76 bp->m_resolver_sp = bp_to_copy_from.m_resolver_sp->CopyForBreakpoint(bp);
77 bp->m_filter_sp = bp_to_copy_from.m_filter_sp->CreateCopy(new_target);
78 return bp;
79}
80
81// Serialization
83 // Serialize the resolver:
84 StructuredData::DictionarySP breakpoint_dict_sp(
86 StructuredData::DictionarySP breakpoint_contents_sp(
88
89 if (!m_name_list.empty()) {
91 for (auto name : m_name_list) {
92 names_array_sp->AddItem(
94 }
95 breakpoint_contents_sp->AddItem(Breakpoint::GetKey(OptionNames::Names),
96 names_array_sp);
97 }
98
99 breakpoint_contents_sp->AddBooleanItem(
101
102 StructuredData::ObjectSP resolver_dict_sp(
103 m_resolver_sp->SerializeToStructuredData());
104 if (!resolver_dict_sp)
106
107 breakpoint_contents_sp->AddItem(BreakpointResolver::GetSerializationKey(),
108 resolver_dict_sp);
109
110 StructuredData::ObjectSP filter_dict_sp(
111 m_filter_sp->SerializeToStructuredData());
112 if (!filter_dict_sp)
114
115 breakpoint_contents_sp->AddItem(SearchFilter::GetSerializationKey(),
116 filter_dict_sp);
117
118 StructuredData::ObjectSP options_dict_sp(
120 if (!options_dict_sp)
122
123 breakpoint_contents_sp->AddItem(BreakpointOptions::GetSerializationKey(),
124 options_dict_sp);
125
126 breakpoint_dict_sp->AddItem(GetSerializationKey(), breakpoint_contents_sp);
127 return breakpoint_dict_sp;
128}
129
131 TargetSP target_sp, StructuredData::ObjectSP &object_data, Status &error) {
132 BreakpointSP result_sp;
133 if (!target_sp)
134 return result_sp;
135
136 StructuredData::Dictionary *breakpoint_dict = object_data->GetAsDictionary();
137
138 if (!breakpoint_dict || !breakpoint_dict->IsValid()) {
139 error.SetErrorString("Can't deserialize from an invalid data object.");
140 return result_sp;
141 }
142
143 StructuredData::Dictionary *resolver_dict;
144 bool success = breakpoint_dict->GetValueForKeyAsDictionary(
146 if (!success) {
147 error.SetErrorString("Breakpoint data missing toplevel resolver key");
148 return result_sp;
149 }
150
151 Status create_error;
152 BreakpointResolverSP resolver_sp =
154 create_error);
155 if (create_error.Fail()) {
156 error.SetErrorStringWithFormat(
157 "Error creating breakpoint resolver from data: %s.",
158 create_error.AsCString());
159 return result_sp;
160 }
161
162 StructuredData::Dictionary *filter_dict;
163 success = breakpoint_dict->GetValueForKeyAsDictionary(
164 SearchFilter::GetSerializationKey(), filter_dict);
165 SearchFilterSP filter_sp;
166 if (!success)
167 filter_sp =
168 std::make_shared<SearchFilterForUnconstrainedSearches>(target_sp);
169 else {
170 filter_sp = SearchFilter::CreateFromStructuredData(target_sp, *filter_dict,
171 create_error);
172 if (create_error.Fail()) {
173 error.SetErrorStringWithFormat(
174 "Error creating breakpoint filter from data: %s.",
175 create_error.AsCString());
176 return result_sp;
177 }
178 }
179
180 std::unique_ptr<BreakpointOptions> options_up;
181 StructuredData::Dictionary *options_dict;
182 Target& target = *target_sp;
183 success = breakpoint_dict->GetValueForKeyAsDictionary(
185 if (success) {
187 target, *options_dict, create_error);
188 if (create_error.Fail()) {
189 error.SetErrorStringWithFormat(
190 "Error creating breakpoint options from data: %s.",
191 create_error.AsCString());
192 return result_sp;
193 }
194 }
195
196 bool hardware = false;
197 success = breakpoint_dict->GetValueForKeyAsBoolean(
199
200 result_sp = target.CreateBreakpoint(filter_sp, resolver_sp, false,
201 hardware, true);
202
203 if (result_sp && options_up) {
204 result_sp->m_options = *options_up;
205 }
206
207 StructuredData::Array *names_array;
208 success = breakpoint_dict->GetValueForKeyAsArray(
210 if (success && names_array) {
211 size_t num_names = names_array->GetSize();
212 for (size_t i = 0; i < num_names; i++) {
213 llvm::StringRef name;
215 success = names_array->GetItemAtIndexAsString(i, name);
216 target.AddNameToBreakpoint(result_sp, name.str().c_str(), error);
217 }
218 }
219
220 return result_sp;
221}
222
224 StructuredData::ObjectSP &bkpt_object_sp, std::vector<std::string> &names) {
225 if (!bkpt_object_sp)
226 return false;
227
228 StructuredData::Dictionary *bkpt_dict = bkpt_object_sp->GetAsDictionary();
229 if (!bkpt_dict)
230 return false;
231
232 if (names.empty())
233 return true;
234
235 StructuredData::Array *names_array;
236
237 bool success =
238 bkpt_dict->GetValueForKeyAsArray(GetKey(OptionNames::Names), names_array);
239 // If there are no names, it can't match these names;
240 if (!success)
241 return false;
242
243 size_t num_names = names_array->GetSize();
244
245 for (size_t i = 0; i < num_names; i++) {
246 llvm::StringRef name;
247 if (names_array->GetItemAtIndexAsString(i, name)) {
248 if (llvm::is_contained(names, name))
249 return true;
250 }
251 }
252 return false;
253}
254
255const lldb::TargetSP Breakpoint::GetTargetSP() {
256 return m_target.shared_from_this();
257}
258
260
261BreakpointLocationSP Breakpoint::AddLocation(const Address &addr,
262 bool *new_location) {
264 new_location);
265}
266
267BreakpointLocationSP Breakpoint::FindLocationByAddress(const Address &addr) {
268 return m_locations.FindByAddress(addr);
269}
270
272 return m_locations.FindIDByAddress(addr);
273}
274
275BreakpointLocationSP Breakpoint::FindLocationByID(break_id_t bp_loc_id) {
276 return m_locations.FindByID(bp_loc_id);
277}
278
279BreakpointLocationSP Breakpoint::GetLocationAtIndex(size_t index) {
280 return m_locations.GetByIndex(index);
281}
282
285}
286
287// For each of the overall options we need to decide how they propagate to the
288// location options. This will determine the precedence of options on the
289// breakpoint vs. its locations.
290
291// Disable at the breakpoint level should override the location settings. That
292// way you can conveniently turn off a whole breakpoint without messing up the
293// individual settings.
294
295void Breakpoint::SetEnabled(bool enable) {
296 if (enable == m_options.IsEnabled())
297 return;
298
299 m_options.SetEnabled(enable);
300 if (enable)
302 else
304
305 SendBreakpointChangedEvent(enable ? eBreakpointEventTypeEnabled
306 : eBreakpointEventTypeDisabled);
307}
308
310
312 if (m_options.GetIgnoreCount() == n)
313 return;
314
316 SendBreakpointChangedEvent(eBreakpointEventTypeIgnoreChanged);
317}
318
321 if (ignore != 0)
322 m_options.SetIgnoreCount(ignore - 1);
323}
324
326 return m_options.GetIgnoreCount();
327}
328
330
334}
335
336bool Breakpoint::IsOneShot() const { return m_options.IsOneShot(); }
337
338void Breakpoint::SetOneShot(bool one_shot) { m_options.SetOneShot(one_shot); }
339
341
342void Breakpoint::SetAutoContinue(bool auto_continue) {
343 m_options.SetAutoContinue(auto_continue);
344}
345
347 if (m_options.GetThreadSpec()->GetTID() == thread_id)
348 return;
349
350 m_options.GetThreadSpec()->SetTID(thread_id);
351 SendBreakpointChangedEvent(eBreakpointEventTypeThreadChanged);
352}
353
355 if (m_options.GetThreadSpecNoCreate() == nullptr)
357 else
359}
360
362 if (m_options.GetThreadSpec()->GetIndex() == index)
363 return;
364
366 SendBreakpointChangedEvent(eBreakpointEventTypeThreadChanged);
367}
368
370 if (m_options.GetThreadSpecNoCreate() == nullptr)
371 return 0;
372 else
374}
375
376void Breakpoint::SetThreadName(const char *thread_name) {
377 if (m_options.GetThreadSpec()->GetName() != nullptr &&
378 ::strcmp(m_options.GetThreadSpec()->GetName(), thread_name) == 0)
379 return;
380
381 m_options.GetThreadSpec()->SetName(thread_name);
382 SendBreakpointChangedEvent(eBreakpointEventTypeThreadChanged);
383}
384
385const char *Breakpoint::GetThreadName() const {
386 if (m_options.GetThreadSpecNoCreate() == nullptr)
387 return nullptr;
388 else
390}
391
392void Breakpoint::SetQueueName(const char *queue_name) {
393 if (m_options.GetThreadSpec()->GetQueueName() != nullptr &&
394 ::strcmp(m_options.GetThreadSpec()->GetQueueName(), queue_name) == 0)
395 return;
396
397 m_options.GetThreadSpec()->SetQueueName(queue_name);
398 SendBreakpointChangedEvent(eBreakpointEventTypeThreadChanged);
399}
400
401const char *Breakpoint::GetQueueName() const {
402 if (m_options.GetThreadSpecNoCreate() == nullptr)
403 return nullptr;
404 else
406}
407
408void Breakpoint::SetCondition(const char *condition) {
409 m_options.SetCondition(condition);
410 SendBreakpointChangedEvent(eBreakpointEventTypeConditionChanged);
411}
412
413const char *Breakpoint::GetConditionText() const {
415}
416
417// This function is used when "baton" doesn't need to be freed
418void Breakpoint::SetCallback(BreakpointHitCallback callback, void *baton,
419 bool is_synchronous) {
420 // The default "Baton" class will keep a copy of "baton" and won't free or
421 // delete it when it goes goes out of scope.
422 m_options.SetCallback(callback, std::make_shared<UntypedBaton>(baton),
423 is_synchronous);
424
425 SendBreakpointChangedEvent(eBreakpointEventTypeCommandChanged);
426}
427
428// This function is used when a baton needs to be freed and therefore is
429// contained in a "Baton" subclass.
430void Breakpoint::SetCallback(BreakpointHitCallback callback,
431 const BatonSP &callback_baton_sp,
432 bool is_synchronous) {
433 m_options.SetCallback(callback, callback_baton_sp, is_synchronous);
434}
435
437
439 break_id_t bp_loc_id) {
440 return m_options.InvokeCallback(context, GetID(), bp_loc_id);
441}
442
444
446
448 if (m_resolver_sp) {
450 m_resolver_sp->ResolveBreakpoint(*m_filter_sp);
451 }
452}
453
455 ModuleList &module_list, BreakpointLocationCollection &new_locations) {
458
459 m_resolver_sp->ResolveBreakpointInModules(*m_filter_sp, module_list);
460
462}
463
465 bool send_event) {
466 if (m_resolver_sp) {
467 // If this is not an internal breakpoint, set up to record the new
468 // locations, then dispatch an event with the new locations.
469 if (!IsInternal() && send_event) {
470 BreakpointEventData *new_locations_event = new BreakpointEventData(
471 eBreakpointEventTypeLocationsAdded, shared_from_this());
472
474 module_list, new_locations_event->GetBreakpointLocationCollection());
475
476 if (new_locations_event->GetBreakpointLocationCollection().GetSize() !=
477 0) {
478 SendBreakpointChangedEvent(new_locations_event);
479 } else
480 delete new_locations_event;
481 } else {
483 m_resolver_sp->ResolveBreakpointInModules(*m_filter_sp, module_list);
484 }
485 }
486}
487
490}
491
492// ModulesChanged: Pass in a list of new modules, and
493
494void Breakpoint::ModulesChanged(ModuleList &module_list, bool load,
495 bool delete_locations) {
497 LLDB_LOGF(log,
498 "Breakpoint::ModulesChanged: num_modules: %zu load: %i "
499 "delete_locations: %i\n",
500 module_list.GetSize(), load, delete_locations);
501
502 if (load) {
503 // The logic for handling new modules is:
504 // 1) If the filter rejects this module, then skip it. 2) Run through the
505 // current location list and if there are any locations
506 // for that module, we mark the module as "seen" and we don't try to
507 // re-resolve
508 // breakpoint locations for that module.
509 // However, we do add breakpoint sites to these locations if needed.
510 // 3) If we don't see this module in our breakpoint location list, call
511 // ResolveInModules.
512
513 ModuleList new_modules; // We'll stuff the "unseen" modules in this list,
514 // and then resolve
515 // them after the locations pass. Have to do it this way because resolving
516 // breakpoints will add new locations potentially.
517
518 for (ModuleSP module_sp : module_list.Modules()) {
519 bool seen = false;
520 if (!m_filter_sp->ModulePasses(module_sp))
521 continue;
522
523 BreakpointLocationCollection locations_with_no_section;
524 for (BreakpointLocationSP break_loc_sp :
526
527 // If the section for this location was deleted, that means it's Module
528 // has gone away but somebody forgot to tell us. Let's clean it up
529 // here.
530 Address section_addr(break_loc_sp->GetAddress());
531 if (section_addr.SectionWasDeleted()) {
532 locations_with_no_section.Add(break_loc_sp);
533 continue;
534 }
535
536 if (!break_loc_sp->IsEnabled())
537 continue;
538
539 SectionSP section_sp(section_addr.GetSection());
540
541 // If we don't have a Section, that means this location is a raw
542 // address that we haven't resolved to a section yet. So we'll have to
543 // look in all the new modules to resolve this location. Otherwise, if
544 // it was set in this module, re-resolve it here.
545 if (section_sp && section_sp->GetModule() == module_sp) {
546 if (!seen)
547 seen = true;
548
549 if (!break_loc_sp->ResolveBreakpointSite()) {
550 LLDB_LOGF(log,
551 "Warning: could not set breakpoint site for "
552 "breakpoint location %d of breakpoint %d.\n",
553 break_loc_sp->GetID(), GetID());
554 }
555 }
556 }
557
558 size_t num_to_delete = locations_with_no_section.GetSize();
559
560 for (size_t i = 0; i < num_to_delete; i++)
561 m_locations.RemoveLocation(locations_with_no_section.GetByIndex(i));
562
563 if (!seen)
564 new_modules.AppendIfNeeded(module_sp);
565 }
566
567 if (new_modules.GetSize() > 0) {
568 ResolveBreakpointInModules(new_modules);
569 }
570 } else {
571 // Go through the currently set locations and if any have breakpoints in
572 // the module list, then remove their breakpoint sites, and their locations
573 // if asked to.
574
575 BreakpointEventData *removed_locations_event;
576 if (!IsInternal())
577 removed_locations_event = new BreakpointEventData(
578 eBreakpointEventTypeLocationsRemoved, shared_from_this());
579 else
580 removed_locations_event = nullptr;
581
582 for (ModuleSP module_sp : module_list.Modules()) {
583 if (m_filter_sp->ModulePasses(module_sp)) {
584 size_t loc_idx = 0;
585 size_t num_locations = m_locations.GetSize();
586 BreakpointLocationCollection locations_to_remove;
587 for (loc_idx = 0; loc_idx < num_locations; loc_idx++) {
588 BreakpointLocationSP break_loc_sp(m_locations.GetByIndex(loc_idx));
589 SectionSP section_sp(break_loc_sp->GetAddress().GetSection());
590 if (section_sp && section_sp->GetModule() == module_sp) {
591 // Remove this breakpoint since the shared library is unloaded, but
592 // keep the breakpoint location around so we always get complete
593 // hit count and breakpoint lifetime info
594 break_loc_sp->ClearBreakpointSite();
595 if (removed_locations_event) {
596 removed_locations_event->GetBreakpointLocationCollection().Add(
597 break_loc_sp);
598 }
599 if (delete_locations)
600 locations_to_remove.Add(break_loc_sp);
601 }
602 }
603
604 if (delete_locations) {
605 size_t num_locations_to_remove = locations_to_remove.GetSize();
606 for (loc_idx = 0; loc_idx < num_locations_to_remove; loc_idx++)
607 m_locations.RemoveLocation(locations_to_remove.GetByIndex(loc_idx));
608 }
609 }
610 }
611 SendBreakpointChangedEvent(removed_locations_event);
612 }
613}
614
616 SymbolContext &new_sc) {
617 bool equivalent_scs = false;
618
619 if (old_sc.module_sp.get() == new_sc.module_sp.get()) {
620 // If these come from the same module, we can directly compare the
621 // pointers:
622 if (old_sc.comp_unit && new_sc.comp_unit &&
623 (old_sc.comp_unit == new_sc.comp_unit)) {
624 if (old_sc.function && new_sc.function &&
625 (old_sc.function == new_sc.function)) {
626 equivalent_scs = true;
627 }
628 } else if (old_sc.symbol && new_sc.symbol &&
629 (old_sc.symbol == new_sc.symbol)) {
630 equivalent_scs = true;
631 }
632 } else {
633 // Otherwise we will compare by name...
634 if (old_sc.comp_unit && new_sc.comp_unit) {
635 if (old_sc.comp_unit->GetPrimaryFile() ==
636 new_sc.comp_unit->GetPrimaryFile()) {
637 // Now check the functions:
638 if (old_sc.function && new_sc.function &&
639 (old_sc.function->GetName() == new_sc.function->GetName())) {
640 equivalent_scs = true;
641 }
642 }
643 } else if (old_sc.symbol && new_sc.symbol) {
644 if (Mangled::Compare(old_sc.symbol->GetMangled(),
645 new_sc.symbol->GetMangled()) == 0) {
646 equivalent_scs = true;
647 }
648 }
649 }
650 return equivalent_scs;
651}
652
653void Breakpoint::ModuleReplaced(ModuleSP old_module_sp,
654 ModuleSP new_module_sp) {
656 LLDB_LOGF(log, "Breakpoint::ModulesReplaced for %s\n",
657 old_module_sp->GetSpecificationDescription().c_str());
658 // First find all the locations that are in the old module
659
660 BreakpointLocationCollection old_break_locs;
661 for (BreakpointLocationSP break_loc_sp : m_locations.BreakpointLocations()) {
662 SectionSP section_sp = break_loc_sp->GetAddress().GetSection();
663 if (section_sp && section_sp->GetModule() == old_module_sp) {
664 old_break_locs.Add(break_loc_sp);
665 }
666 }
667
668 size_t num_old_locations = old_break_locs.GetSize();
669
670 if (num_old_locations == 0) {
671 // There were no locations in the old module, so we just need to check if
672 // there were any in the new module.
673 ModuleList temp_list;
674 temp_list.Append(new_module_sp);
676 } else {
677 // First search the new module for locations. Then compare this with the
678 // old list, copy over locations that "look the same" Then delete the old
679 // locations. Finally remember to post the creation event.
680 //
681 // Two locations are the same if they have the same comp unit & function
682 // (by name) and there are the same number of locations in the old function
683 // as in the new one.
684
685 ModuleList temp_list;
686 temp_list.Append(new_module_sp);
687 BreakpointLocationCollection new_break_locs;
688 ResolveBreakpointInModules(temp_list, new_break_locs);
689 BreakpointLocationCollection locations_to_remove;
690 BreakpointLocationCollection locations_to_announce;
691
692 size_t num_new_locations = new_break_locs.GetSize();
693
694 if (num_new_locations > 0) {
695 // Break out the case of one location -> one location since that's the
696 // most common one, and there's no need to build up the structures needed
697 // for the merge in that case.
698 if (num_new_locations == 1 && num_old_locations == 1) {
699 bool equivalent_locations = false;
700 SymbolContext old_sc, new_sc;
701 // The only way the old and new location can be equivalent is if they
702 // have the same amount of information:
703 BreakpointLocationSP old_loc_sp = old_break_locs.GetByIndex(0);
704 BreakpointLocationSP new_loc_sp = new_break_locs.GetByIndex(0);
705
706 if (old_loc_sp->GetAddress().CalculateSymbolContext(&old_sc) ==
707 new_loc_sp->GetAddress().CalculateSymbolContext(&new_sc)) {
708 equivalent_locations =
709 SymbolContextsMightBeEquivalent(old_sc, new_sc);
710 }
711
712 if (equivalent_locations) {
713 m_locations.SwapLocation(old_loc_sp, new_loc_sp);
714 } else {
715 locations_to_remove.Add(old_loc_sp);
716 locations_to_announce.Add(new_loc_sp);
717 }
718 } else {
719 // We don't want to have to keep computing the SymbolContexts for these
720 // addresses over and over, so lets get them up front:
721
722 typedef std::map<lldb::break_id_t, SymbolContext> IDToSCMap;
723 IDToSCMap old_sc_map;
724 for (size_t idx = 0; idx < num_old_locations; idx++) {
725 SymbolContext sc;
726 BreakpointLocationSP bp_loc_sp = old_break_locs.GetByIndex(idx);
727 lldb::break_id_t loc_id = bp_loc_sp->GetID();
728 bp_loc_sp->GetAddress().CalculateSymbolContext(&old_sc_map[loc_id]);
729 }
730
731 std::map<lldb::break_id_t, SymbolContext> new_sc_map;
732 for (size_t idx = 0; idx < num_new_locations; idx++) {
733 SymbolContext sc;
734 BreakpointLocationSP bp_loc_sp = new_break_locs.GetByIndex(idx);
735 lldb::break_id_t loc_id = bp_loc_sp->GetID();
736 bp_loc_sp->GetAddress().CalculateSymbolContext(&new_sc_map[loc_id]);
737 }
738 // Take an element from the old Symbol Contexts
739 while (old_sc_map.size() > 0) {
740 lldb::break_id_t old_id = old_sc_map.begin()->first;
741 SymbolContext &old_sc = old_sc_map.begin()->second;
742
743 // Count the number of entries equivalent to this SC for the old
744 // list:
745 std::vector<lldb::break_id_t> old_id_vec;
746 old_id_vec.push_back(old_id);
747
748 IDToSCMap::iterator tmp_iter;
749 for (tmp_iter = ++old_sc_map.begin(); tmp_iter != old_sc_map.end();
750 tmp_iter++) {
751 if (SymbolContextsMightBeEquivalent(old_sc, tmp_iter->second))
752 old_id_vec.push_back(tmp_iter->first);
753 }
754
755 // Now find all the equivalent locations in the new list.
756 std::vector<lldb::break_id_t> new_id_vec;
757 for (tmp_iter = new_sc_map.begin(); tmp_iter != new_sc_map.end();
758 tmp_iter++) {
759 if (SymbolContextsMightBeEquivalent(old_sc, tmp_iter->second))
760 new_id_vec.push_back(tmp_iter->first);
761 }
762
763 // Alright, if we have the same number of potentially equivalent
764 // locations in the old and new modules, we'll just map them one to
765 // one in ascending ID order (assuming the resolver's order would
766 // match the equivalent ones. Otherwise, we'll dump all the old ones,
767 // and just take the new ones, erasing the elements from both maps as
768 // we go.
769
770 if (old_id_vec.size() == new_id_vec.size()) {
771 llvm::sort(old_id_vec);
772 llvm::sort(new_id_vec);
773 size_t num_elements = old_id_vec.size();
774 for (size_t idx = 0; idx < num_elements; idx++) {
775 BreakpointLocationSP old_loc_sp =
776 old_break_locs.FindByIDPair(GetID(), old_id_vec[idx]);
777 BreakpointLocationSP new_loc_sp =
778 new_break_locs.FindByIDPair(GetID(), new_id_vec[idx]);
779 m_locations.SwapLocation(old_loc_sp, new_loc_sp);
780 old_sc_map.erase(old_id_vec[idx]);
781 new_sc_map.erase(new_id_vec[idx]);
782 }
783 } else {
784 for (lldb::break_id_t old_id : old_id_vec) {
785 locations_to_remove.Add(
786 old_break_locs.FindByIDPair(GetID(), old_id));
787 old_sc_map.erase(old_id);
788 }
789 for (lldb::break_id_t new_id : new_id_vec) {
790 locations_to_announce.Add(
791 new_break_locs.FindByIDPair(GetID(), new_id));
792 new_sc_map.erase(new_id);
793 }
794 }
795 }
796 }
797 }
798
799 // Now remove the remaining old locations, and cons up a removed locations
800 // event. Note, we don't put the new locations that were swapped with an
801 // old location on the locations_to_remove list, so we don't need to worry
802 // about telling the world about removing a location we didn't tell them
803 // about adding.
804
805 BreakpointEventData *locations_event;
806 if (!IsInternal())
807 locations_event = new BreakpointEventData(
808 eBreakpointEventTypeLocationsRemoved, shared_from_this());
809 else
810 locations_event = nullptr;
811
812 for (BreakpointLocationSP loc_sp :
813 locations_to_remove.BreakpointLocations()) {
815 if (locations_event)
816 locations_event->GetBreakpointLocationCollection().Add(loc_sp);
817 }
818 SendBreakpointChangedEvent(locations_event);
819
820 // And announce the new ones.
821
822 if (!IsInternal()) {
823 locations_event = new BreakpointEventData(
824 eBreakpointEventTypeLocationsAdded, shared_from_this());
825 for (BreakpointLocationSP loc_sp :
826 locations_to_announce.BreakpointLocations())
827 locations_event->GetBreakpointLocationCollection().Add(loc_sp);
828
829 SendBreakpointChangedEvent(locations_event);
830 }
832 }
833}
834
836
838 // Return the number of breakpoints that are actually resolved and set down
839 // in the inferior process.
841}
842
844 return GetNumResolvedLocations() > 0;
845}
846
848
849bool Breakpoint::AddName(llvm::StringRef new_name) {
850 m_name_list.insert(new_name.str().c_str());
851 return true;
852}
853
855 bool show_locations) {
856 assert(s != nullptr);
857
858 if (!m_kind_description.empty()) {
859 if (level == eDescriptionLevelBrief) {
861 return;
862 } else
863 s->Printf("Kind: %s\n", GetBreakpointKind());
864 }
865
866 const size_t num_locations = GetNumLocations();
867 const size_t num_resolved_locations = GetNumResolvedLocations();
868
869 // They just made the breakpoint, they don't need to be told HOW they made
870 // it... Also, we'll print the breakpoint number differently depending on
871 // whether there is 1 or more locations.
872 if (level != eDescriptionLevelInitial) {
873 s->Printf("%i: ", GetID());
876 }
877
878 switch (level) {
881 if (num_locations > 0) {
882 s->Printf(", locations = %" PRIu64, (uint64_t)num_locations);
883 if (num_resolved_locations > 0)
884 s->Printf(", resolved = %" PRIu64 ", hit count = %d",
885 (uint64_t)num_resolved_locations, GetHitCount());
886 } else {
887 // Don't print the pending notification for exception resolvers since we
888 // don't generally know how to set them until the target is run.
889 if (m_resolver_sp->getResolverID() !=
891 s->Printf(", locations = 0 (pending)");
892 }
893
894 m_options.GetDescription(s, level);
895
897 m_precondition_sp->GetDescription(*s, level);
898
899 if (level == lldb::eDescriptionLevelFull) {
900 if (!m_name_list.empty()) {
901 s->EOL();
902 s->Indent();
903 s->Printf("Names:");
904 s->EOL();
905 s->IndentMore();
906 for (std::string name : m_name_list) {
907 s->Indent();
908 s->Printf("%s\n", name.c_str());
909 }
910 s->IndentLess();
911 }
912 s->IndentLess();
913 s->EOL();
914 }
915 break;
916
918 s->Printf("Breakpoint %i: ", GetID());
919 if (num_locations == 0) {
920 s->Printf("no locations (pending).");
921 } else if (num_locations == 1 && !show_locations) {
922 // There is only one location, so we'll just print that location
923 // information.
924 GetLocationAtIndex(0)->GetDescription(s, level);
925 } else {
926 s->Printf("%" PRIu64 " locations.", static_cast<uint64_t>(num_locations));
927 }
928 s->EOL();
929 break;
930
932 // Verbose mode does a debug dump of the breakpoint
933 Dump(s);
934 s->EOL();
935 // s->Indent();
936 m_options.GetDescription(s, level);
937 break;
938
939 default:
940 break;
941 }
942
943 // The brief description is just the location name (1.2 or whatever). That's
944 // pointless to show in the breakpoint's description, so suppress it.
945 if (show_locations && level != lldb::eDescriptionLevelBrief) {
946 s->IndentMore();
947 for (size_t i = 0; i < num_locations; ++i) {
949 loc->GetDescription(s, level);
950 s->EOL();
951 }
952 s->IndentLess();
953 }
954}
955
957 if (m_resolver_sp)
958 m_resolver_sp->GetDescription(s);
959}
960
962 uint32_t line_number,
964 // TODO: To be correct, this method needs to fill the breakpoint location
965 // collection
966 // with the location IDs which match the filename and line_number.
967 //
968
969 if (m_resolver_sp) {
970 BreakpointResolverFileLine *resolverFileLine =
971 dyn_cast<BreakpointResolverFileLine>(m_resolver_sp.get());
972
973 // TODO: Handle SourceLocationSpec column information
974 if (resolverFileLine &&
975 resolverFileLine->m_location_spec.GetFileSpec().GetFilename() ==
976 filename &&
977 resolverFileLine->m_location_spec.GetLine() == line_number) {
978 return true;
979 }
980 }
981 return false;
982}
983
985 m_filter_sp->GetDescription(s);
986}
987
990 return true;
991
992 return m_precondition_sp->EvaluatePrecondition(context);
993}
994
996 lldb::BreakpointEventType eventKind) {
997 if (!m_being_created && !IsInternal() &&
998 GetTarget().EventTypeHasListeners(
1000 BreakpointEventData *data =
1001 new Breakpoint::BreakpointEventData(eventKind, shared_from_this());
1002
1004 }
1005}
1006
1008 if (data == nullptr)
1009 return;
1010
1011 if (!m_being_created && !IsInternal() &&
1012 GetTarget().EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged))
1014 else
1015 delete data;
1016}
1017
1018const char *Breakpoint::BreakpointEventTypeAsCString(BreakpointEventType type) {
1019 switch (type) {
1020 case eBreakpointEventTypeInvalidType: return "invalid";
1021 case eBreakpointEventTypeAdded: return "breakpoint added";
1022 case eBreakpointEventTypeRemoved: return "breakpoint removed";
1023 case eBreakpointEventTypeLocationsAdded: return "locations added";
1024 case eBreakpointEventTypeLocationsRemoved: return "locations removed";
1025 case eBreakpointEventTypeLocationsResolved: return "locations resolved";
1026 case eBreakpointEventTypeEnabled: return "breakpoint enabled";
1027 case eBreakpointEventTypeDisabled: return "breakpoint disabled";
1028 case eBreakpointEventTypeCommandChanged: return "command changed";
1029 case eBreakpointEventTypeConditionChanged: return "condition changed";
1030 case eBreakpointEventTypeIgnoreChanged: return "ignore count changed";
1031 case eBreakpointEventTypeThreadChanged: return "thread changed";
1032 case eBreakpointEventTypeAutoContinueChanged: return "autocontinue changed";
1033 };
1034 llvm_unreachable("Fully covered switch above!");
1035}
1036
1039}
1040
1042 BreakpointEventType sub_type, const BreakpointSP &new_breakpoint_sp)
1043 : m_breakpoint_event(sub_type), m_new_breakpoint_sp(new_breakpoint_sp) {}
1044
1046
1048 static ConstString g_flavor("Breakpoint::BreakpointEventData");
1049 return g_flavor;
1050}
1051
1054}
1055
1057 return m_new_breakpoint_sp;
1058}
1059
1060BreakpointEventType
1062 return m_breakpoint_event;
1063}
1064
1066 if (!s)
1067 return;
1068 BreakpointEventType event_type = GetBreakpointEventType();
1069 break_id_t bkpt_id = GetBreakpoint()->GetID();
1070 s->Format("bkpt: {0} type: {1}", bkpt_id,
1071 BreakpointEventTypeAsCString(event_type));
1072}
1073
1076 if (event) {
1077 const EventData *event_data = event->GetData();
1078 if (event_data &&
1080 return static_cast<const BreakpointEventData *>(event->GetData());
1081 }
1082 return nullptr;
1083}
1084
1085BreakpointEventType
1087 const EventSP &event_sp) {
1088 const BreakpointEventData *data = GetEventDataFromEvent(event_sp.get());
1089
1090 if (data == nullptr)
1091 return eBreakpointEventTypeInvalidType;
1092 else
1093 return data->GetBreakpointEventType();
1094}
1095
1097 const EventSP &event_sp) {
1098 BreakpointSP bp_sp;
1099
1100 const BreakpointEventData *data = GetEventDataFromEvent(event_sp.get());
1101 if (data)
1102 bp_sp = data->m_new_breakpoint_sp;
1103
1104 return bp_sp;
1105}
1106
1108 const EventSP &event_sp) {
1109 const BreakpointEventData *data = GetEventDataFromEvent(event_sp.get());
1110 if (data)
1111 return data->m_locations.GetSize();
1112
1113 return 0;
1114}
1115
1116lldb::BreakpointLocationSP
1118 const lldb::EventSP &event_sp, uint32_t bp_loc_idx) {
1119 lldb::BreakpointLocationSP bp_loc_sp;
1120
1121 const BreakpointEventData *data = GetEventDataFromEvent(event_sp.get());
1122 if (data) {
1123 bp_loc_sp = data->m_locations.GetByIndex(bp_loc_idx);
1124 }
1125
1126 return bp_loc_sp;
1127}
1128
1130 json::Object bp;
1131 bp.try_emplace("id", GetID());
1132 bp.try_emplace("resolveTime", m_resolve_time.get().count());
1133 bp.try_emplace("numLocations", (int64_t)GetNumLocations());
1134 bp.try_emplace("numResolvedLocations", (int64_t)GetNumResolvedLocations());
1135 bp.try_emplace("hitCount", (int64_t)GetHitCount());
1136 bp.try_emplace("internal", IsInternal());
1137 if (!m_kind_description.empty())
1138 bp.try_emplace("kindDescription", m_kind_description);
1139 // Put the full structured data for reproducing this breakpoint in a key/value
1140 // pair named "details". This allows the breakpoint's details to be visible
1141 // in the stats in case we need to reproduce a breakpoint that has long
1142 // resolve times
1144 if (bp_data_sp) {
1145 std::string buffer;
1146 llvm::raw_string_ostream ss(buffer);
1147 json::OStream json_os(ss);
1148 bp_data_sp->Serialize(json_os);
1149 if (auto expected_value = llvm::json::parse(ss.str())) {
1150 bp.try_emplace("details", std::move(*expected_value));
1151 } else {
1152 std::string details_error = toString(expected_value.takeError());
1153 json::Object details;
1154 details.try_emplace("error", details_error);
1155 bp.try_emplace("details", std::move(details));
1156 }
1157 }
1158 return json::Value(std::move(bp));
1159}
static bool SymbolContextsMightBeEquivalent(SymbolContext &old_sc, SymbolContext &new_sc)
Definition: Breakpoint.cpp:615
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGF(log,...)
Definition: Log.h:344
static double elapsed(const StatsTimepoint &start, const StatsTimepoint &end)
Definition: Statistics.cpp:36
A section + offset based address class.
Definition: Address.h:59
lldb::SectionSP GetSection() const
Get const accessor for the section.
Definition: Address.h:429
bool SectionWasDeleted() const
Definition: Address.cpp:805
An architecture specification class.
Definition: ArchSpec.h:32
lldb::BreakpointLocationSP FindByIDPair(lldb::break_id_t break_id, lldb::break_id_t break_loc_id)
Returns a shared pointer to the breakpoint location with id breakID.
BreakpointLocationCollectionIterable BreakpointLocations()
lldb::BreakpointLocationSP GetByIndex(size_t i)
Returns a shared pointer to the breakpoint location with index i.
void Add(const lldb::BreakpointLocationSP &bp_loc_sp)
Add the breakpoint bp_loc_sp to the list.
size_t GetSize() const
Returns the number of elements in this breakpoint location list.
void ResetHitCount()
Resets the hit count of all locations in this list.
void RemoveInvalidLocations(const ArchSpec &arch)
lldb::BreakpointLocationSP GetByIndex(size_t i)
Returns a shared pointer to the breakpoint location with index i.
bool RemoveLocation(const lldb::BreakpointLocationSP &bp_loc_sp)
void ClearAllBreakpointSites()
Removes all the locations in this list from their breakpoint site owners list.
const lldb::BreakpointLocationSP FindByAddress(const Address &addr) const
Returns a shared pointer to the breakpoint location at address addr - const version.
void ResolveAllBreakpointSites()
Tells all the breakpoint locations in this list to attempt to resolve any possible breakpoint sites.
size_t GetSize() const
Returns the number of elements in this breakpoint location list.
lldb::BreakpointLocationSP FindByID(lldb::break_id_t breakID) const
Returns a shared pointer to the breakpoint location with id breakID, const version.
lldb::BreakpointLocationSP AddLocation(const Address &addr, bool resolve_indirect_symbols, bool *new_location=nullptr)
void StartRecordingNewLocations(BreakpointLocationCollection &new_locations)
lldb::break_id_t FindIDByAddress(const Address &addr)
Returns the breakpoint location id to the breakpoint location at address addr.
size_t GetNumResolvedLocations() const
Returns the number of breakpoint locations in this list with resolved breakpoints.
BreakpointLocationIterable BreakpointLocations()
void SwapLocation(lldb::BreakpointLocationSP to_location_sp, lldb::BreakpointLocationSP from_location_sp)
General Outline: A breakpoint location is defined by the breakpoint that produces it,...
void GetDescription(Stream *s, lldb::DescriptionLevel level)
Print a description of this breakpoint location to the stream s.
"lldb/Breakpoint/BreakpointOptions.h" Class that manages the options on a breakpoint or breakpoint lo...
bool InvokeCallback(StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
Use this function to invoke the callback for a specific stop.
void ClearCallback()
Remove the callback from this option set.
void SetIgnoreCount(uint32_t n)
Set the breakpoint to ignore the next count breakpoint hits.
void SetEnabled(bool enabled)
If enable is true, enable the breakpoint, if false disable it.
void SetCondition(const char *condition)
Set the breakpoint option's condition.
bool IsOneShot() const
Check the One-shot state.
bool IsEnabled() const
Check the Enable/Disable state.
virtual StructuredData::ObjectSP SerializeToStructuredData()
void GetDescription(Stream *s, lldb::DescriptionLevel level) const
uint32_t GetIgnoreCount() const
Return the current Ignore Count.
bool IsAutoContinue() const
Check the auto-continue state.
ThreadSpec * GetThreadSpec()
Returns a pointer to the ThreadSpec for this option, creating it.
void SetOneShot(bool one_shot)
If enable is true, enable the breakpoint, if false disable it.
const ThreadSpec * GetThreadSpecNoCreate() const
Return the current thread spec for this option.
void SetAutoContinue(bool auto_continue)
Set the auto-continue state.
static std::unique_ptr< BreakpointOptions > CreateFromStructuredData(Target &target, const StructuredData::Dictionary &data_dict, Status &error)
const char * GetConditionText(size_t *hash=nullptr) const
Return a pointer to the text of the condition expression.
static const char * GetSerializationKey()
void SetCallback(BreakpointHitCallback callback, const lldb::BatonSP &baton_sp, bool synchronous=false)
Adds a callback to the breakpoint option set.
"lldb/Breakpoint/BreakpointResolverFileLine.h" This class sets breakpoints by file and line.
static lldb::BreakpointResolverSP CreateFromStructuredData(const StructuredData::Dictionary &resolver_dict, Status &error)
This section handles serializing and deserializing from StructuredData objects.
static const char * GetSerializationKey()
BreakpointEventData(lldb::BreakpointEventType sub_type, const lldb::BreakpointSP &new_breakpoint_sp)
void Dump(Stream *s) const override
BreakpointLocationCollection m_locations
Definition: Breakpoint.h:144
ConstString GetFlavor() const override
static lldb::BreakpointEventType GetBreakpointEventTypeFromEvent(const lldb::EventSP &event_sp)
BreakpointLocationCollection & GetBreakpointLocationCollection()
Definition: Breakpoint.h:119
static lldb::BreakpointLocationSP GetBreakpointLocationAtIndexFromEvent(const lldb::EventSP &event_sp, uint32_t loc_idx)
static lldb::BreakpointSP GetBreakpointFromEvent(const lldb::EventSP &event_sp)
lldb::BreakpointEventType GetBreakpointEventType() const
static const BreakpointEventData * GetEventDataFromEvent(const Event *event_sp)
static size_t GetNumBreakpointLocationsFromEvent(const lldb::EventSP &event_sp)
General Outline: A breakpoint has four main parts, a filter, a resolver, the list of breakpoint locat...
Definition: Breakpoint.h:81
bool AddName(llvm::StringRef new_name)
Definition: Breakpoint.cpp:849
void RemoveInvalidLocations(const ArchSpec &arch)
Removes all invalid breakpoint locations.
Definition: Breakpoint.cpp:283
virtual StructuredData::ObjectSP SerializeToStructuredData()
Definition: Breakpoint.cpp:82
lldb::BreakpointLocationSP AddLocation(const Address &addr, bool *new_location=nullptr)
Add a location to the breakpoint's location list.
Definition: Breakpoint.cpp:261
uint32_t GetThreadIndex() const
Definition: Breakpoint.cpp:369
StatsDuration m_resolve_time
Definition: Breakpoint.h:673
bool IsAutoContinue() const
Check the AutoContinue state.
Definition: Breakpoint.cpp:340
void SetOneShot(bool one_shot)
If one_shot is true, breakpoint will be deleted on first hit.
Definition: Breakpoint.cpp:338
void ModuleReplaced(lldb::ModuleSP old_module_sp, lldb::ModuleSP new_module_sp)
Tells the breakpoint the old module old_module_sp has been replaced by new_module_sp (usually because...
Definition: Breakpoint.cpp:653
~Breakpoint() override
Destructor.
lldb::tid_t GetThreadID() const
Return the current stop thread value.
Definition: Breakpoint.cpp:354
llvm::json::Value GetStatistics()
Get statistics associated with this breakpoint in JSON format.
void SetAutoContinue(bool auto_continue)
If auto_continue is true, breakpoint will auto-continue when on hit.
Definition: Breakpoint.cpp:342
bool InvokeCallback(StoppointCallbackContext *context, lldb::break_id_t bp_loc_id)
Invoke the callback action when the breakpoint is hit.
Definition: Breakpoint.cpp:438
StoppointHitCounter m_hit_counter
Number of times this breakpoint has been hit.
Definition: Breakpoint.h:669
static const char * GetKey(OptionNames enum_value)
Definition: Breakpoint.h:97
uint32_t GetIgnoreCount() const
Return the current ignore count/.
Definition: Breakpoint.cpp:325
bool EvaluatePrecondition(StoppointCallbackContext &context)
Definition: Breakpoint.cpp:988
void SetThreadIndex(uint32_t index)
Definition: Breakpoint.cpp:361
const char * GetConditionText() const
Return a pointer to the text of the condition expression.
Definition: Breakpoint.cpp:413
const char * GetQueueName() const
Definition: Breakpoint.cpp:401
const lldb::TargetSP GetTargetSP()
Definition: Breakpoint.cpp:255
static lldb::BreakpointSP CreateFromStructuredData(lldb::TargetSP target_sp, StructuredData::ObjectSP &data_object_sp, Status &error)
Definition: Breakpoint.cpp:130
void ResetHitCount()
Resets the current hit count for all locations.
Definition: Breakpoint.cpp:331
BreakpointLocationList m_locations
Definition: Breakpoint.h:662
const char * GetBreakpointKind() const
Return the "kind" description for a breakpoint.
Definition: Breakpoint.h:459
bool IsEnabled() override
Check the Enable/Disable state.
Definition: Breakpoint.cpp:309
void GetDescription(Stream *s, lldb::DescriptionLevel level, bool show_locations=false)
Put a description of this breakpoint into the stream s.
Definition: Breakpoint.cpp:854
void ClearAllBreakpointSites()
Tell this breakpoint to clear all its breakpoint sites.
Definition: Breakpoint.cpp:488
BreakpointOptions & GetOptions()
Returns the BreakpointOptions structure set at the breakpoint level.
Definition: Breakpoint.cpp:443
void SetQueueName(const char *queue_name)
Definition: Breakpoint.cpp:392
lldb::break_id_t FindLocationIDByAddress(const Address &addr)
Find a breakpoint location ID by Address.
Definition: Breakpoint.cpp:271
void ResolveBreakpointInModules(ModuleList &module_list, bool send_event=true)
Tell this breakpoint to scan a given module list and resolve any new locations that match the breakpo...
Definition: Breakpoint.cpp:464
static lldb::BreakpointSP CopyFromBreakpoint(lldb::TargetSP new_target, const Breakpoint &bp_to_copy_from)
Definition: Breakpoint.cpp:69
bool HasResolvedLocations() const
Return whether this breakpoint has any resolved locations.
Definition: Breakpoint.cpp:843
lldb::BreakpointLocationSP FindLocationByAddress(const Address &addr)
Find a breakpoint location by Address.
Definition: Breakpoint.cpp:267
static const char * g_option_names[static_cast< uint32_t >(OptionNames::LastOptionName)]
Definition: Breakpoint.h:95
void GetResolverDescription(Stream *s)
Definition: Breakpoint.cpp:956
static const char * GetSerializationKey()
Definition: Breakpoint.h:161
void ModulesChanged(ModuleList &changed_modules, bool load_event, bool delete_locations=false)
Like ResolveBreakpointInModules, but allows for "unload" events, in which case we will remove any loc...
Definition: Breakpoint.cpp:494
static bool SerializedBreakpointMatchesNames(StructuredData::ObjectSP &bkpt_object_sp, std::vector< std::string > &names)
Definition: Breakpoint.cpp:223
std::unordered_set< std::string > m_name_list
Definition: Breakpoint.h:646
static ConstString GetEventIdentifier()
Definition: Breakpoint.cpp:40
const char * GetThreadName() const
Definition: Breakpoint.cpp:385
bool GetMatchingFileLine(ConstString filename, uint32_t line_number, BreakpointLocationCollection &loc_coll)
Find breakpoint locations which match the (filename, line_number) description.
Definition: Breakpoint.cpp:961
lldb::BreakpointLocationSP FindLocationByID(lldb::break_id_t bp_loc_id)
Find a breakpoint location for a given breakpoint location ID.
Definition: Breakpoint.cpp:275
void SetCondition(const char *condition)
Set the breakpoint's condition.
Definition: Breakpoint.cpp:408
void SetThreadID(lldb::tid_t thread_id)
Set the valid thread to be checked when the breakpoint is hit.
Definition: Breakpoint.cpp:346
void GetFilterDescription(Stream *s)
Definition: Breakpoint.cpp:984
void ResolveBreakpoint()
Tell this breakpoint to scan it's target's module list and resolve any new locations that match the b...
Definition: Breakpoint.cpp:447
lldb::BreakpointLocationSP GetLocationAtIndex(size_t index)
Get breakpoint locations by index.
Definition: Breakpoint.cpp:279
lldb::BreakpointPreconditionSP m_precondition_sp
Definition: Breakpoint.h:654
BreakpointOptions m_options
Definition: Breakpoint.h:660
Target & GetTarget()
Accessor for the breakpoint Target.
Definition: Breakpoint.h:464
size_t GetNumLocations() const
Return the number of breakpoint locations.
Definition: Breakpoint.cpp:847
void SetIgnoreCount(uint32_t count)
Set the breakpoint to ignore the next count breakpoint hits.
Definition: Breakpoint.cpp:311
bool IsOneShot() const
Check the OneShot state.
Definition: Breakpoint.cpp:336
uint32_t GetHitCount() const
Return the current hit count for all locations.
Definition: Breakpoint.cpp:329
static const char * BreakpointEventTypeAsCString(lldb::BreakpointEventType type)
void SetCallback(BreakpointHitCallback callback, void *baton, bool is_synchronous=false)
Set the callback action invoked when the breakpoint is hit.
Definition: Breakpoint.cpp:418
void SetEnabled(bool enable) override
If enable is true, enable the breakpoint, if false disable it.
Definition: Breakpoint.cpp:295
lldb::BreakpointResolverSP m_resolver_sp
Definition: Breakpoint.h:653
void Dump(Stream *s) override
Standard "Dump" method. At present it does nothing.
Definition: Breakpoint.cpp:835
bool IsInternal() const
Tell whether this breakpoint is an "internal" breakpoint.
Definition: Breakpoint.cpp:259
lldb::SearchFilterSP m_filter_sp
Definition: Breakpoint.h:651
void SetThreadName(const char *thread_name)
Definition: Breakpoint.cpp:376
size_t GetNumResolvedLocations() const
Return the number of breakpoint locations that have resolved to actual breakpoint sites.
Definition: Breakpoint.cpp:837
std::string m_kind_description
Definition: Breakpoint.h:663
Breakpoint(Target &target, lldb::SearchFilterSP &filter_sp, lldb::BreakpointResolverSP &resolver_sp, bool hardware, bool resolve_indirect_symbols=true)
Constructors and Destructors Only the Target can make a breakpoint, and it owns the breakpoint lifesp...
void SendBreakpointChangedEvent(lldb::BreakpointEventType eventKind)
Definition: Breakpoint.cpp:995
void BroadcastEvent(lldb::EventSP &event_sp)
Broadcast an event which has no associated data.
Definition: Broadcaster.h:262
const FileSpec & GetPrimaryFile() const
Return the primary source file associated with this compile unit.
Definition: CompileUnit.h:227
A uniqued constant string class.
Definition: ConstString.h:39
A class that measures elapsed time in an exception safe way.
Definition: Statistics.h:68
virtual ConstString GetFlavor() const =0
const ConstString & GetFilename() const
Filename string const get accessor.
Definition: FileSpec.h:240
ConstString GetName() const
Definition: Function.cpp:654
A collection class for Module objects.
Definition: ModuleList.h:82
void Append(const lldb::ModuleSP &module_sp, bool notify=true)
Append a module to the module list.
bool AppendIfNeeded(const lldb::ModuleSP &new_module, bool notify=true)
Append a module to the module list, if it is not already there.
ModuleIterable Modules() const
Definition: ModuleList.h:507
size_t GetSize() const
Gets the size of the module list.
Definition: ModuleList.cpp:635
static const char * GetSerializationKey()
Definition: SearchFilter.h:211
static lldb::SearchFilterSP CreateFromStructuredData(const lldb::TargetSP &target_sp, const StructuredData::Dictionary &data_dict, Status &error)
std::optional< uint32_t > GetLine() const
Duration get() const
Definition: Statistics.h:33
An error handling class.
Definition: Status.h:44
bool Fail() const
Test for error condition.
Definition: Status.cpp:181
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
Definition: Status.cpp:130
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
lldb::break_id_t GetID() const
Definition: Stoppoint.cpp:22
lldb::break_id_t m_bid
Definition: Stoppoint.h:36
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
void Format(const char *format, Args &&... args)
Definition: Stream.h:309
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
Definition: Stream.cpp:130
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:63
size_t EOL()
Output and End of Line character to the stream.
Definition: Stream.cpp:128
void IndentLess(unsigned amount=2)
Decrement the current indentation level.
Definition: Stream.cpp:171
void IndentMore(unsigned amount=2)
Increment the current indentation level.
Definition: Stream.cpp:168
bool GetItemAtIndexAsString(size_t idx, llvm::StringRef &result) const
bool GetValueForKeyAsBoolean(llvm::StringRef key, bool &result) const
bool GetValueForKeyAsArray(llvm::StringRef key, Array *&result) const
bool GetValueForKeyAsDictionary(llvm::StringRef key, Dictionary *&result) const
std::shared_ptr< Dictionary > DictionarySP
std::shared_ptr< Object > ObjectSP
std::shared_ptr< String > StringSP
std::shared_ptr< Array > ArraySP
Defines a symbol context baton that can be handed other debug core functions.
Definition: SymbolContext.h:33
Function * function
The Function for a given query.
lldb::ModuleSP module_sp
The Module for a given query.
CompileUnit * comp_unit
The CompileUnit for a given query.
Symbol * symbol
The Symbol for a given query.
Mangled & GetMangled()
Definition: Symbol.h:145
@ eBroadcastBitBreakpointChanged
Definition: Target.h:482
lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules, const FileSpec &file, uint32_t line_no, uint32_t column, lldb::addr_t offset, LazyBool check_inlines, LazyBool skip_prologue, bool internal, bool request_hardware, LazyBool move_to_nearest_code)
Definition: Target.cpp:352
void AddNameToBreakpoint(BreakpointID &id, const char *name, Status &error)
Definition: Target.cpp:688
void SetIndex(uint32_t index)
Definition: ThreadSpec.h:45
void SetName(llvm::StringRef name)
Definition: ThreadSpec.h:49
uint32_t GetIndex() const
Definition: ThreadSpec.h:55
void SetTID(lldb::tid_t tid)
Definition: ThreadSpec.h:47
const char * GetName() const
Definition: ThreadSpec.cpp:68
void SetQueueName(llvm::StringRef queue_name)
Definition: ThreadSpec.h:51
const char * GetQueueName() const
Definition: ThreadSpec.cpp:72
lldb::tid_t GetTID() const
Definition: ThreadSpec.h:57
#define LLDB_INVALID_THREAD_ID
Definition: lldb-defines.h:82
#define LLDB_BREAK_ID_IS_INTERNAL(bid)
Definition: lldb-defines.h:40
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:309
const char * toString(AppleArm64ExceptionClass EC)
Definition: SBAddress.h:15
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
@ eDescriptionLevelBrief
@ eDescriptionLevelInitial
@ eDescriptionLevelFull
@ eDescriptionLevelVerbose
int32_t break_id_t
Definition: lldb-types.h:84
uint64_t tid_t
Definition: lldb-types.h:82
Definition: Debugger.h:52