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