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