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