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