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
485// This function is used when "baton" doesn't need to be freed
487 bool is_synchronous) {
488 // The default "Baton" class will keep a copy of "baton" and won't free or
489 // delete it when it goes out of scope.
490 m_options.SetCallback(callback, std::make_shared<UntypedBaton>(baton),
491 is_synchronous);
492
493 SendBreakpointChangedEvent(eBreakpointEventTypeCommandChanged);
494}
495
496// This function is used when a baton needs to be freed and therefore is
497// contained in a "Baton" subclass.
499 const BatonSP &callback_baton_sp,
500 bool is_synchronous) {
501 m_options.SetCallback(callback, callback_baton_sp, is_synchronous);
502}
503
504void Breakpoint::ClearCallback() { m_options.ClearCallback(); }
505
507 break_id_t bp_loc_id) {
508 return m_options.InvokeCallback(context, GetID(), bp_loc_id);
509}
510
512
514
516 if (m_resolver_sp) {
518 m_resolver_sp->ResolveBreakpoint(*m_filter_sp);
519 }
520}
521
523 ModuleList &module_list, BreakpointLocationCollection &new_locations) {
525 m_locations.StartRecordingNewLocations(new_locations);
526
527 m_resolver_sp->ResolveBreakpointInModules(*m_filter_sp, module_list);
528
529 m_locations.StopRecordingNewLocations();
530}
531
533 bool send_event) {
534 if (m_resolver_sp) {
535 // If this is not an internal breakpoint, set up to record the new
536 // locations, then dispatch an event with the new locations.
537 if (!IsInternal() && send_event) {
538 std::shared_ptr<BreakpointEventData> new_locations_event =
539 std::make_shared<BreakpointEventData>(
540 eBreakpointEventTypeLocationsAdded, shared_from_this());
542 module_list, new_locations_event->GetBreakpointLocationCollection());
543 if (new_locations_event->GetBreakpointLocationCollection().GetSize() != 0)
544 SendBreakpointChangedEvent(new_locations_event);
545 } else {
547 m_resolver_sp->ResolveBreakpointInModules(*m_filter_sp, module_list);
548 }
549 }
550}
551
553 m_locations.ClearAllBreakpointSites();
554}
555
556// ModulesChanged: Pass in a list of new modules, and
557
558void Breakpoint::ModulesChanged(ModuleList &module_list, bool load,
559 bool delete_locations) {
561 LLDB_LOGF(log,
562 "Breakpoint::ModulesChanged: num_modules: %zu load: %i "
563 "delete_locations: %i\n",
564 module_list.GetSize(), load, delete_locations);
565
566 if (load) {
567 // The logic for handling new modules is:
568 // 1) If the filter rejects this module, then skip it. 2) Run through the
569 // current location list and if there are any locations
570 // for that module, we mark the module as "seen" and we don't try to
571 // re-resolve
572 // breakpoint locations for that module.
573 // However, we do add breakpoint sites to these locations if needed.
574 // 3) If we don't see this module in our breakpoint location list, call
575 // ResolveInModules.
576
577 ModuleList new_modules; // We'll stuff the "unseen" modules in this list,
578 // and then resolve
579 // them after the locations pass. Have to do it this way because resolving
580 // breakpoints will add new locations potentially.
581
582 for (ModuleSP module_sp : module_list.Modules()) {
583 bool seen = false;
584 if (!m_filter_sp->ModulePasses(module_sp))
585 continue;
586
587 BreakpointLocationCollection locations_with_no_section;
588 for (BreakpointLocationSP break_loc_sp :
589 m_locations.BreakpointLocations()) {
590
591 // If the section for this location was deleted, that means it's Module
592 // has gone away but somebody forgot to tell us. Let's clean it up
593 // here.
594 Address section_addr(break_loc_sp->GetAddress());
595 if (section_addr.SectionWasDeleted()) {
596 locations_with_no_section.Add(break_loc_sp);
597 continue;
598 }
599
600 if (!break_loc_sp->IsEnabled())
601 continue;
602
603 SectionSP section_sp(section_addr.GetSection());
604
605 // If we don't have a Section, that means this location is a raw
606 // address that we haven't resolved to a section yet. So we'll have to
607 // look in all the new modules to resolve this location. Otherwise, if
608 // it was set in this module, re-resolve it here.
609 if (section_sp && section_sp->GetModule() == module_sp) {
610 if (!seen)
611 seen = true;
612
613 if (llvm::Error error = break_loc_sp->ResolveBreakpointSite()) {
614 LLDB_LOG_ERROR(log, std::move(error),
615 "could not set breakpoint site for "
616 "breakpoint location {1} of breakpoint {2}: {0}",
617 break_loc_sp->GetID(), GetID());
618 }
619 }
620 }
621
622 size_t num_to_delete = locations_with_no_section.GetSize();
623
624 for (size_t i = 0; i < num_to_delete; i++)
625 m_locations.RemoveLocation(locations_with_no_section.GetByIndex(i));
626
627 if (!seen)
628 new_modules.AppendIfNeeded(module_sp);
629 }
630
631 if (new_modules.GetSize() > 0) {
632 ResolveBreakpointInModules(new_modules);
633 }
634 } else {
635 // Go through the currently set locations and if any have breakpoints in
636 // the module list, then remove their breakpoint sites, and their locations
637 // if asked to.
638
639 std::shared_ptr<BreakpointEventData> removed_locations_event;
640 if (!IsInternal())
641 removed_locations_event = std::make_shared<BreakpointEventData>(
642 eBreakpointEventTypeLocationsRemoved, shared_from_this());
643
644 for (ModuleSP module_sp : module_list.Modules()) {
645 if (m_filter_sp->ModulePasses(module_sp)) {
646 size_t loc_idx = 0;
647 size_t num_locations = m_locations.GetSize();
648 BreakpointLocationCollection locations_to_remove;
649 for (loc_idx = 0; loc_idx < num_locations; loc_idx++) {
650 BreakpointLocationSP break_loc_sp(m_locations.GetByIndex(loc_idx));
651 SectionSP section_sp(break_loc_sp->GetAddress().GetSection());
652 if (section_sp && section_sp->GetModule() == module_sp) {
653 // Remove this breakpoint since the shared library is unloaded, but
654 // keep the breakpoint location around so we always get complete
655 // hit count and breakpoint lifetime info
656 if (llvm::Error error = break_loc_sp->ClearBreakpointSite())
657 LLDB_LOG_ERROR(log, std::move(error),
658 "Failed to clear breakpoint locations on library "
659 "unload: {0}");
660 if (removed_locations_event) {
661 removed_locations_event->GetBreakpointLocationCollection().Add(
662 break_loc_sp);
663 }
664 if (delete_locations)
665 locations_to_remove.Add(break_loc_sp);
666 }
667 }
668
669 if (delete_locations) {
670 size_t num_locations_to_remove = locations_to_remove.GetSize();
671 for (loc_idx = 0; loc_idx < num_locations_to_remove; loc_idx++)
672 m_locations.RemoveLocation(locations_to_remove.GetByIndex(loc_idx));
673 }
674 }
675 }
676 SendBreakpointChangedEvent(removed_locations_event);
677 }
678}
679
681 SymbolContext &new_sc) {
682 bool equivalent_scs = false;
683
684 if (old_sc.module_sp.get() == new_sc.module_sp.get()) {
685 // If these come from the same module, we can directly compare the
686 // pointers:
687 if (old_sc.comp_unit && new_sc.comp_unit &&
688 (old_sc.comp_unit == new_sc.comp_unit)) {
689 if (old_sc.function && new_sc.function &&
690 (old_sc.function == new_sc.function)) {
691 equivalent_scs = true;
692 }
693 } else if (old_sc.symbol && new_sc.symbol &&
694 (old_sc.symbol == new_sc.symbol)) {
695 equivalent_scs = true;
696 }
697 } else {
698 // Otherwise we will compare by name...
699 if (old_sc.comp_unit && new_sc.comp_unit) {
700 if (old_sc.comp_unit->GetPrimaryFile() ==
701 new_sc.comp_unit->GetPrimaryFile()) {
702 // Now check the functions:
703 if (old_sc.function && new_sc.function &&
704 (old_sc.function->GetName() == new_sc.function->GetName())) {
705 equivalent_scs = true;
706 }
707 }
708 } else if (old_sc.symbol && new_sc.symbol) {
709 if (Mangled::Compare(old_sc.symbol->GetMangled(),
710 new_sc.symbol->GetMangled()) == 0) {
711 equivalent_scs = true;
712 }
713 }
714 }
715 return equivalent_scs;
716}
717
719 ModuleSP new_module_sp) {
721 LLDB_LOGF(log, "Breakpoint::ModulesReplaced for %s\n",
722 old_module_sp->GetSpecificationDescription().c_str());
723 // First find all the locations that are in the old module
724
725 BreakpointLocationCollection old_break_locs;
726 for (BreakpointLocationSP break_loc_sp : m_locations.BreakpointLocations()) {
727 SectionSP section_sp = break_loc_sp->GetAddress().GetSection();
728 if (section_sp && section_sp->GetModule() == old_module_sp) {
729 old_break_locs.Add(break_loc_sp);
730 }
731 }
732
733 size_t num_old_locations = old_break_locs.GetSize();
734
735 if (num_old_locations == 0) {
736 // There were no locations in the old module, so we just need to check if
737 // there were any in the new module.
738 ModuleList temp_list;
739 temp_list.Append(new_module_sp);
741 } else {
742 // First search the new module for locations. Then compare this with the
743 // old list, copy over locations that "look the same" Then delete the old
744 // locations. Finally remember to post the creation event.
745 //
746 // Two locations are the same if they have the same comp unit & function
747 // (by name) and there are the same number of locations in the old function
748 // as in the new one.
749
750 ModuleList temp_list;
751 temp_list.Append(new_module_sp);
752 BreakpointLocationCollection new_break_locs;
753 ResolveBreakpointInModules(temp_list, new_break_locs);
754 BreakpointLocationCollection locations_to_remove;
755 BreakpointLocationCollection locations_to_announce;
756
757 size_t num_new_locations = new_break_locs.GetSize();
758
759 if (num_new_locations > 0) {
760 // Break out the case of one location -> one location since that's the
761 // most common one, and there's no need to build up the structures needed
762 // for the merge in that case.
763 if (num_new_locations == 1 && num_old_locations == 1) {
764 bool equivalent_locations = false;
765 SymbolContext old_sc, new_sc;
766 // The only way the old and new location can be equivalent is if they
767 // have the same amount of information:
768 BreakpointLocationSP old_loc_sp = old_break_locs.GetByIndex(0);
769 BreakpointLocationSP new_loc_sp = new_break_locs.GetByIndex(0);
770
771 if (old_loc_sp->GetAddress().CalculateSymbolContext(&old_sc) ==
772 new_loc_sp->GetAddress().CalculateSymbolContext(&new_sc)) {
773 equivalent_locations =
774 SymbolContextsMightBeEquivalent(old_sc, new_sc);
775 }
776
777 if (equivalent_locations) {
778 m_locations.SwapLocation(old_loc_sp, new_loc_sp);
779 } else {
780 locations_to_remove.Add(old_loc_sp);
781 locations_to_announce.Add(new_loc_sp);
782 }
783 } else {
784 // We don't want to have to keep computing the SymbolContexts for these
785 // addresses over and over, so lets get them up front:
786
787 typedef std::map<lldb::break_id_t, SymbolContext> IDToSCMap;
788 IDToSCMap old_sc_map;
789 for (size_t idx = 0; idx < num_old_locations; idx++) {
790 SymbolContext sc;
791 BreakpointLocationSP bp_loc_sp = old_break_locs.GetByIndex(idx);
792 lldb::break_id_t loc_id = bp_loc_sp->GetID();
793 bp_loc_sp->GetAddress().CalculateSymbolContext(&old_sc_map[loc_id]);
794 }
795
796 std::map<lldb::break_id_t, SymbolContext> new_sc_map;
797 for (size_t idx = 0; idx < num_new_locations; idx++) {
798 SymbolContext sc;
799 BreakpointLocationSP bp_loc_sp = new_break_locs.GetByIndex(idx);
800 lldb::break_id_t loc_id = bp_loc_sp->GetID();
801 bp_loc_sp->GetAddress().CalculateSymbolContext(&new_sc_map[loc_id]);
802 }
803 // Take an element from the old Symbol Contexts
804 while (old_sc_map.size() > 0) {
805 lldb::break_id_t old_id = old_sc_map.begin()->first;
806 SymbolContext &old_sc = old_sc_map.begin()->second;
807
808 // Count the number of entries equivalent to this SC for the old
809 // list:
810 std::vector<lldb::break_id_t> old_id_vec;
811 old_id_vec.push_back(old_id);
812
813 IDToSCMap::iterator tmp_iter;
814 for (tmp_iter = ++old_sc_map.begin(); tmp_iter != old_sc_map.end();
815 tmp_iter++) {
816 if (SymbolContextsMightBeEquivalent(old_sc, tmp_iter->second))
817 old_id_vec.push_back(tmp_iter->first);
818 }
819
820 // Now find all the equivalent locations in the new list.
821 std::vector<lldb::break_id_t> new_id_vec;
822 for (tmp_iter = new_sc_map.begin(); tmp_iter != new_sc_map.end();
823 tmp_iter++) {
824 if (SymbolContextsMightBeEquivalent(old_sc, tmp_iter->second))
825 new_id_vec.push_back(tmp_iter->first);
826 }
827
828 // Alright, if we have the same number of potentially equivalent
829 // locations in the old and new modules, we'll just map them one to
830 // one in ascending ID order (assuming the resolver's order would
831 // match the equivalent ones. Otherwise, we'll dump all the old ones,
832 // and just take the new ones, erasing the elements from both maps as
833 // we go.
834
835 if (old_id_vec.size() == new_id_vec.size()) {
836 llvm::sort(old_id_vec);
837 llvm::sort(new_id_vec);
838 size_t num_elements = old_id_vec.size();
839 for (size_t idx = 0; idx < num_elements; idx++) {
840 BreakpointLocationSP old_loc_sp =
841 old_break_locs.FindByIDPair(GetID(), old_id_vec[idx]);
842 BreakpointLocationSP new_loc_sp =
843 new_break_locs.FindByIDPair(GetID(), new_id_vec[idx]);
844 m_locations.SwapLocation(old_loc_sp, new_loc_sp);
845 old_sc_map.erase(old_id_vec[idx]);
846 new_sc_map.erase(new_id_vec[idx]);
847 }
848 } else {
849 for (lldb::break_id_t old_id : old_id_vec) {
850 locations_to_remove.Add(
851 old_break_locs.FindByIDPair(GetID(), old_id));
852 old_sc_map.erase(old_id);
853 }
854 for (lldb::break_id_t new_id : new_id_vec) {
855 locations_to_announce.Add(
856 new_break_locs.FindByIDPair(GetID(), new_id));
857 new_sc_map.erase(new_id);
858 }
859 }
860 }
861 }
862 }
863
864 // Now remove the remaining old locations, and cons up a removed locations
865 // event. Note, we don't put the new locations that were swapped with an
866 // old location on the locations_to_remove list, so we don't need to worry
867 // about telling the world about removing a location we didn't tell them
868 // about adding.
869
870 std::shared_ptr<BreakpointEventData> removed_locations_event;
871 if (!IsInternal())
872 removed_locations_event = std::make_shared<BreakpointEventData>(
873 eBreakpointEventTypeLocationsRemoved, shared_from_this());
874
875 for (BreakpointLocationSP loc_sp :
876 locations_to_remove.BreakpointLocations()) {
877 m_locations.RemoveLocation(loc_sp);
878 if (removed_locations_event)
879 removed_locations_event->GetBreakpointLocationCollection().Add(loc_sp);
880 }
881 SendBreakpointChangedEvent(removed_locations_event);
882
883 // And announce the new ones.
884
885 if (!IsInternal()) {
886 std::shared_ptr<BreakpointEventData> added_locations_event =
887 std::make_shared<BreakpointEventData>(
888 eBreakpointEventTypeLocationsAdded, shared_from_this());
889 for (BreakpointLocationSP loc_sp :
890 locations_to_announce.BreakpointLocations())
891 added_locations_event->GetBreakpointLocationCollection().Add(loc_sp);
892
893 SendBreakpointChangedEvent(added_locations_event);
894 }
895 m_locations.Compact();
896 }
897}
898
900
901size_t Breakpoint::GetNumResolvedLocations(bool use_facade) const {
902 // Return the number of breakpoints that are actually resolved and set down
903 // in the inferior process.
904 // All facade locations are considered to be resolved:
905 if (use_facade) {
906 size_t num_facade_locs = m_facade_locations.GetSize();
907 if (num_facade_locs)
908 return num_facade_locs;
909 }
910 return m_locations.GetNumResolvedLocations();
911}
912
914 return GetNumResolvedLocations() > 0;
915}
916
917size_t Breakpoint::GetNumLocations(bool use_facade) const {
918 if (use_facade) {
919 size_t num_facade_locs = m_facade_locations.GetSize();
920 if (num_facade_locs > 0)
921 return num_facade_locs;
922 }
923 return m_locations.GetSize();
924}
925
926void Breakpoint::AddName(llvm::StringRef new_name) {
927 m_name_list.insert(new_name.str());
928}
929
931 bool show_locations) {
932 assert(s != nullptr);
933
934 const bool dim_breakpoint_description =
935 !IsEnabled() && s->AsRawOstream().colors_enabled();
936 if (dim_breakpoint_description)
938 GetTarget().GetDebugger().GetDisabledAnsiPrefix())
939 .c_str());
940
941 if (!m_kind_description.empty()) {
942 if (level == eDescriptionLevelBrief) {
944 return;
945 }
946 s->Printf("Kind: %s\n", GetBreakpointKind());
947 }
948
949 bool show_both_types = level == eDescriptionLevelVerbose &&
950 HasFacadeLocations() && show_locations;
951 uint8_t display_mask = eDisplayFacade;
952 if (show_both_types)
953 display_mask |= eDisplayHeader;
954
955 GetDescriptionForType(s, level, display_mask, show_locations);
956
957 if (show_both_types) {
958 display_mask = eDisplayReal | eDisplayHeader;
959 GetDescriptionForType(s, level, display_mask, show_locations);
960 }
961 // Reset the colors back to normal if they were previously greyed out.
962 if (dim_breakpoint_description)
964 GetTarget().GetDebugger().GetDisabledAnsiSuffix())
965 .c_str());
966}
967
969 uint8_t display_type,
970 bool show_locations) {
971 bool use_facade = (display_type & eDisplayFacade) != 0;
972 const size_t num_locations = GetNumLocations(use_facade);
973 const size_t num_resolved_locations = GetNumResolvedLocations(use_facade);
974
975 // They just made the breakpoint, they don't need to be told HOW they made
976 // it... Also, we'll print the breakpoint number differently depending on
977 // whether there is 1 or more locations.
978 if (level != eDescriptionLevelInitial) {
979 s->Printf("%i: ", GetID());
982 }
983
984 switch (level) {
987 if (num_locations > 0) {
988 s->Printf(", locations = %" PRIu64, (uint64_t)num_locations);
989 if (num_resolved_locations > 0)
990 s->Printf(", resolved = %" PRIu64 ", hit count = %d",
991 (uint64_t)num_resolved_locations, GetHitCount());
992 } else {
993 // Don't print the pending notification for exception resolvers since we
994 // don't generally know how to set them until the target is run.
995 if (m_resolver_sp->getResolverID() !=
997 s->PutCString(", locations = 0 (pending)");
998 }
999
1000 m_options.GetDescription(s, level);
1001
1003 m_precondition_sp->GetDescription(*s, level);
1004
1005 if (level == lldb::eDescriptionLevelFull) {
1006 if (!m_name_list.empty()) {
1007 s->EOL();
1008 s->Indent();
1009 s->PutCString("Names:");
1010 s->EOL();
1011 s->IndentMore();
1012 for (llvm::StringRef name : m_name_list.keys()) {
1013 s->Indent();
1014 s->Format("{0}\n", name);
1015 }
1016 s->IndentLess();
1017 }
1018 s->IndentLess();
1019 s->EOL();
1020 }
1021 break;
1022
1024 s->Printf("Breakpoint %i: ", GetID());
1025 if (num_locations == 0) {
1026 s->PutCString("no locations (pending).");
1027 } else if (num_locations == 1 && !show_locations) {
1028 // There is only one location, so we'll just print that location
1029 // information.
1030 GetLocationAtIndex(0, use_facade)->GetDescription(s, level);
1031 } else {
1032 s->Printf("%" PRIu64 " locations.", static_cast<uint64_t>(num_locations));
1033 }
1034 s->EOL();
1035 break;
1036
1038 // Verbose mode does a debug dump of the breakpoint
1039 Dump(s);
1040 s->EOL();
1041 // s->Indent();
1042 m_options.GetDescription(s, level);
1043 break;
1044
1045 default:
1046 break;
1047 }
1048
1049 // The brief description is just the location name (1.2 or whatever). That's
1050 // pointless to show in the breakpoint's description, so suppress it.
1051 if (show_locations && level != lldb::eDescriptionLevelBrief) {
1052 if ((display_type & eDisplayHeader) != 0) {
1053 if ((display_type & eDisplayFacade) != 0)
1054 s->PutCString("Facade locations:\n");
1055 else
1056 s->PutCString("Implementation Locations\n");
1057 }
1058 s->IndentMore();
1059 for (size_t i = 0; i < num_locations; ++i) {
1060 BreakpointLocation *loc = GetLocationAtIndex(i, use_facade).get();
1061 loc->GetDescription(s, level);
1062 s->EOL();
1063 }
1064 s->IndentLess();
1065 }
1066}
1067
1069 if (m_resolver_sp)
1070 m_resolver_sp->GetDescription(s);
1071}
1072
1073bool Breakpoint::GetMatchingFileLine(llvm::StringRef filename,
1074 uint32_t line_number,
1075 BreakpointLocationCollection &loc_coll) {
1076 // TODO: To be correct, this method needs to fill the breakpoint location
1077 // collection
1078 // with the location IDs which match the filename and line_number.
1079 //
1080
1081 if (m_resolver_sp) {
1082 BreakpointResolverFileLine *resolverFileLine =
1083 dyn_cast<BreakpointResolverFileLine>(m_resolver_sp.get());
1084
1085 // TODO: Handle SourceLocationSpec column information
1086 if (resolverFileLine &&
1087 resolverFileLine->m_location_spec.GetFileSpec().GetFilename() ==
1088 filename &&
1089 resolverFileLine->m_location_spec.GetLine() == line_number) {
1090 return true;
1091 }
1092 }
1093 return false;
1094}
1095
1097 m_filter_sp->GetDescription(s);
1098}
1099
1101 if (!m_precondition_sp)
1102 return true;
1103
1104 return m_precondition_sp->EvaluatePrecondition(context);
1105}
1106
1108 lldb::BreakpointEventType event_kind) {
1109 if (!IsInternal())
1110 GetTarget().NotifyBreakpointChanged(*this, event_kind);
1111}
1112
1114 const lldb::EventDataSP &breakpoint_data_sp) {
1115 if (!breakpoint_data_sp)
1116 return;
1117
1118 if (!IsInternal())
1119 GetTarget().NotifyBreakpointChanged(*this, breakpoint_data_sp);
1120}
1121
1122const char *Breakpoint::BreakpointEventTypeAsCString(BreakpointEventType type) {
1123 switch (type) {
1124 case eBreakpointEventTypeInvalidType:
1125 return "invalid";
1126 case eBreakpointEventTypeAdded:
1127 return "breakpoint added";
1128 case eBreakpointEventTypeRemoved:
1129 return "breakpoint removed";
1130 case eBreakpointEventTypeLocationsAdded:
1131 return "locations added";
1132 case eBreakpointEventTypeLocationsRemoved:
1133 return "locations removed";
1134 case eBreakpointEventTypeLocationsResolved:
1135 return "locations resolved";
1136 case eBreakpointEventTypeEnabled:
1137 return "breakpoint enabled";
1138 case eBreakpointEventTypeDisabled:
1139 return "breakpoint disabled";
1140 case eBreakpointEventTypeCommandChanged:
1141 return "command changed";
1142 case eBreakpointEventTypeConditionChanged:
1143 return "condition changed";
1144 case eBreakpointEventTypeIgnoreChanged:
1145 return "ignore count changed";
1146 case eBreakpointEventTypeThreadChanged:
1147 return "thread changed";
1148 case eBreakpointEventTypeAutoContinueChanged:
1149 return "autocontinue changed";
1150 };
1151 llvm_unreachable("Fully covered switch above!");
1152}
1153
1157
1159 BreakpointEventType sub_type, const BreakpointSP &new_breakpoint_sp)
1160 : m_breakpoint_event(sub_type), m_new_breakpoint_sp(new_breakpoint_sp) {}
1161
1163
1165 return "Breakpoint::BreakpointEventData";
1166}
1167
1171
1175
1176BreakpointEventType
1180
1182 if (!s)
1183 return;
1184 BreakpointEventType event_type = GetBreakpointEventType();
1185 break_id_t bkpt_id = GetBreakpoint()->GetID();
1186 s->Format("bkpt: {0} type: {1}", bkpt_id,
1187 BreakpointEventTypeAsCString(event_type));
1188}
1189
1192 if (event) {
1193 const EventData *event_data = event->GetData();
1194 if (event_data &&
1196 return static_cast<const BreakpointEventData *>(event->GetData());
1197 }
1198 return nullptr;
1199}
1200
1201BreakpointEventType
1203 const EventSP &event_sp) {
1204 const BreakpointEventData *data = GetEventDataFromEvent(event_sp.get());
1205
1206 if (data == nullptr)
1207 return eBreakpointEventTypeInvalidType;
1208 return data->GetBreakpointEventType();
1209}
1210
1212 const EventSP &event_sp) {
1213 BreakpointSP bp_sp;
1214
1215 const BreakpointEventData *data = GetEventDataFromEvent(event_sp.get());
1216 if (data)
1217 bp_sp = data->m_new_breakpoint_sp;
1218
1219 return bp_sp;
1220}
1221
1223 const EventSP &event_sp) {
1224 const BreakpointEventData *data = GetEventDataFromEvent(event_sp.get());
1225 if (data)
1226 return data->m_locations.GetSize();
1227
1228 return 0;
1229}
1230
1233 const lldb::EventSP &event_sp, uint32_t bp_loc_idx) {
1235
1236 const BreakpointEventData *data = GetEventDataFromEvent(event_sp.get());
1237 if (data) {
1238 bp_loc_sp = data->m_locations.GetByIndex(bp_loc_idx);
1239 }
1240
1241 return bp_loc_sp;
1242}
1243
1245 json::Object bp;
1246 bp.try_emplace("id", GetID());
1247 bp.try_emplace("resolveTime", m_resolve_time.get().count());
1248 bp.try_emplace("numLocations", (int64_t)GetNumLocations());
1249 bp.try_emplace("numResolvedLocations", (int64_t)GetNumResolvedLocations());
1250 bp.try_emplace("hitCount", (int64_t)GetHitCount());
1251 bp.try_emplace("internal", IsInternal());
1252 if (!m_kind_description.empty())
1253 bp.try_emplace("kindDescription", m_kind_description);
1254 // Put the full structured data for reproducing this breakpoint in a key/value
1255 // pair named "details". This allows the breakpoint's details to be visible
1256 // in the stats in case we need to reproduce a breakpoint that has long
1257 // resolve times
1259 if (bp_data_sp) {
1260 std::string buffer;
1261 llvm::raw_string_ostream ss(buffer);
1262 json::OStream json_os(ss);
1263 bp_data_sp->Serialize(json_os);
1264 if (auto expected_value = llvm::json::parse(buffer)) {
1265 bp.try_emplace("details", std::move(*expected_value));
1266 } else {
1267 std::string details_error = toString(expected_value.takeError());
1268 json::Object details;
1269 details.try_emplace("error", details_error);
1270 bp.try_emplace("details", std::move(details));
1271 }
1272 }
1273 return json::Value(std::move(bp));
1274}
1275
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:799
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:720
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:716
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:679
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:707
const char * GetBreakpointKind() const
Return the "kind" description for a breakpoint.
Definition Breakpoint.h:490
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:708
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:699
BreakpointOptions m_options
Definition Breakpoint.h:705
Target & GetTarget()
Accessor for the breakpoint Target.
Definition Breakpoint.h:495
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:698
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:696
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:694
size_t GetNumLocations(bool use_facade=true) const
Return the number of breakpoint locations.
std::string m_kind_description
Definition Breakpoint.h:710
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:249
ConstString GetName() const
Definition Function.cpp:726
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:570
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:147
void AddNameToBreakpoint(BreakpointID &id, llvm::StringRef name, Status &error)
Definition Target.cpp:853
void NotifyBreakpointChanged(Breakpoint &bp, lldb::BreakpointEventType event_kind)
Sends a breakpoint notification event.
Definition Target.cpp:6044
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:504
#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:87
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:84
std::shared_ptr< lldb_private::Module > ModuleSP
std::shared_ptr< lldb_private::EventData > EventDataSP