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