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