LLDB mainline
Breakpoint.h
Go to the documentation of this file.
1//===-- Breakpoint.h --------------------------------------------*- C++ -*-===//
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#ifndef LLDB_BREAKPOINT_BREAKPOINT_H
10#define LLDB_BREAKPOINT_BREAKPOINT_H
11
12#include <memory>
13#include <string>
14#include <unordered_set>
15#include <vector>
16
26#include "lldb/Utility/Event.h"
29
30#include "llvm/ADT/StringSet.h"
31
32namespace lldb_private {
33
34/// \class Breakpoint Breakpoint.h "lldb/Breakpoint/Breakpoint.h" Class that
35/// manages logical breakpoint setting.
36
37/// General Outline:
38/// A breakpoint has four main parts, a filter, a resolver, the list of
39/// breakpoint
40/// locations that have been determined for the filter/resolver pair, and
41/// finally a set of options for the breakpoint.
42///
43/// \b Filter:
44/// This is an object derived from SearchFilter. It manages the search for
45/// breakpoint location matches through the symbols in the module list of the
46/// target that owns it. It also filters out locations based on whatever
47/// logic it wants.
48///
49/// \b Resolver:
50/// This is an object derived from BreakpointResolver. It provides a callback
51/// to the filter that will find breakpoint locations. How it does this is
52/// determined by what kind of resolver it is.
53///
54/// The Breakpoint class also provides constructors for the common breakpoint
55/// cases which make the appropriate filter and resolver for you.
56///
57/// \b Location List:
58/// This stores the breakpoint locations that have been determined to date.
59/// For a given breakpoint, there will be only one location with a given
60/// address. Adding a location at an already taken address will just return
61/// the location already at that address. Locations can be looked up by ID,
62/// or by address.
63///
64/// \b Options:
65/// This includes:
66/// \b Enabled/Disabled
67/// \b Ignore Count
68/// \b Callback
69/// \b Condition
70/// Note, these options can be set on the breakpoint, and they can also be set
71/// on the individual locations. The options set on the breakpoint take
72/// precedence over the options set on the individual location. So for
73/// instance disabling the breakpoint will cause NONE of the locations to get
74/// hit. But if the breakpoint is enabled, then the location's enabled state
75/// will be checked to determine whether to insert that breakpoint location.
76/// Similarly, if the breakpoint condition says "stop", we won't check the
77/// location's condition. But if the breakpoint condition says "continue",
78/// then we will check the location for whether to actually stop or not. One
79/// subtle point worth observing here is that you don't actually stop at a
80/// Breakpoint, you always stop at one of its locations. So the "should stop"
81/// tests are done by the location, not by the breakpoint.
82class Breakpoint : public std::enable_shared_from_this<Breakpoint>,
83 public Stoppoint {
84public:
85 static const char *
86 BreakpointEventTypeAsCString(lldb::BreakpointEventType type);
87
88 /// An enum specifying the match style for breakpoint settings. At present
89 /// only used for function name style breakpoints.
91
92private:
93 enum class OptionNames : uint32_t { Names = 0, Hardware, LastOptionName };
94
95 static const char
97
98 static const char *GetKey(OptionNames enum_value) {
99 return g_option_names[static_cast<uint32_t>(enum_value)];
100 }
101
102public:
104 public:
105 BreakpointEventData(lldb::BreakpointEventType sub_type,
106 const lldb::BreakpointSP &new_breakpoint_sp);
107
109
110 static llvm::StringRef GetFlavorString();
111
112 Log *GetLogChannel() override;
113
114 llvm::StringRef GetFlavor() const override;
115
116 lldb::BreakpointEventType GetBreakpointEventType() const;
117
119
123
124 void Dump(Stream *s) const override;
125
126 static lldb::BreakpointEventType
128
129 static lldb::BreakpointSP
130 GetBreakpointFromEvent(const lldb::EventSP &event_sp);
131
134 uint32_t loc_idx);
135
136 static size_t
138
139 static const BreakpointEventData *
140 GetEventDataFromEvent(const Event *event_sp);
141
142 private:
143 lldb::BreakpointEventType m_breakpoint_event;
146
149 };
150
151 // Saving & restoring breakpoints:
153 lldb::TargetSP target_sp, StructuredData::ObjectSP &data_object_sp,
154 Status &error);
155
156 static bool
158 std::vector<std::string> &names);
159
161
162 static const char *GetSerializationKey() { return "Breakpoint"; }
163 /// Destructor.
164 ///
165 /// The destructor is not virtual since there should be no reason to
166 /// subclass breakpoints. The varieties of breakpoints are specified
167 /// instead by providing different resolvers & filters.
168 ~Breakpoint() override;
169
170 // Methods
171
172 /// Tell whether this breakpoint is an "internal" breakpoint. \return
173 /// Returns \b true if this is an internal breakpoint, \b false otherwise.
174 bool IsInternal() const;
175
176 /// Standard "Dump" method. At present it does nothing.
177 void Dump(Stream *s) override;
178
179 // The next set of methods provide ways to tell the breakpoint to update it's
180 // location list - usually done when modules appear or disappear.
181
182 /// Tell this breakpoint to clear all its breakpoint sites. Done when the
183 /// process holding the breakpoint sites is destroyed.
185
186 /// Tell this breakpoint to scan it's target's module list and resolve any
187 /// new locations that match the breakpoint's specifications.
188 void ResolveBreakpoint();
189
190 /// Tell this breakpoint to scan a given module list and resolve any new
191 /// locations that match the breakpoint's specifications.
192 ///
193 /// \param[in] module_list
194 /// The list of modules to look in for new locations.
195 ///
196 /// \param[in] send_event
197 /// If \b true, send a breakpoint location added event for non-internal
198 /// breakpoints.
199 void ResolveBreakpointInModules(ModuleList &module_list,
200 bool send_event = true);
201
202 /// Tell this breakpoint to scan a given module list and resolve any new
203 /// locations that match the breakpoint's specifications.
204 ///
205 /// \param[in] module_list
206 /// The list of modules to look in for new locations.
207 ///
208 /// \param[in] new_locations
209 /// Fills new_locations with the new locations that were made.
210 void ResolveBreakpointInModules(ModuleList &module_list,
211 BreakpointLocationCollection &new_locations);
212
213 /// Like ResolveBreakpointInModules, but allows for "unload" events, in
214 /// which case we will remove any locations that are in modules that got
215 /// unloaded.
216 ///
217 /// \param[in] changed_modules
218 /// The list of modules to look in for new locations.
219 /// \param[in] load_event
220 /// If \b true then the modules were loaded, if \b false, unloaded.
221 /// \param[in] delete_locations
222 /// If \b true then the modules were unloaded delete any locations in the
223 /// changed modules.
224 void ModulesChanged(ModuleList &changed_modules, bool load_event,
225 bool delete_locations = false);
226
227 /// Tells the breakpoint the old module \a old_module_sp has been replaced
228 /// by new_module_sp (usually because the underlying file has been rebuilt,
229 /// and the old version is gone.)
230 ///
231 /// \param[in] old_module_sp
232 /// The old module that is going away.
233 /// \param[in] new_module_sp
234 /// The new module that is replacing it.
235 void ModuleReplaced(lldb::ModuleSP old_module_sp,
236 lldb::ModuleSP new_module_sp);
237
238 // The next set of methods provide access to the breakpoint locations for
239 // this breakpoint.
240
241 /// Add a location to the breakpoint's location list. This is only meant to
242 /// be called by the breakpoint's resolver. FIXME: how do I ensure that?
243 ///
244 /// \param[in] addr
245 /// The Address specifying the new location.
246 /// \param[out] new_location
247 /// Set to \b true if a new location was created, to \b false if there
248 /// already was a location at this Address.
249 /// \return
250 /// Returns a pointer to the new location.
252 bool *new_location = nullptr);
253 /// Add a `facade` location to the breakpoint's collection of facade
254 /// locations. This is only meant to be called by the breakpoint's resolver.
255 /// Facade locations are placeholders that a scripted breakpoint can use to
256 /// represent the stop locations provided by the breakpoint. The scripted
257 /// breakpoint should record the id of the facade location, and provide
258 /// the description of the location in the GetDescription method
259 /// To emulate hitting a facade location, the breakpoint's WasHit should
260 /// return the ID of the facade that was "hit".
261 ///
262 /// \param[out] new_location
263 /// Set to \b true if a new location was created, to \b false if there
264 /// already was a location at this Address.
265 /// \return
266 /// Returns a pointer to the new location.
268
270
271 /// Find a breakpoint location by Address.
272 ///
273 /// \param[in] addr
274 /// The Address specifying the location.
275 /// \return
276 /// Returns a shared pointer to the location at \a addr. The pointer
277 /// in the shared pointer will be nullptr if there is no location at that
278 /// address.
280
281 /// Find a breakpoint location ID by Address.
282 ///
283 /// \param[in] addr
284 /// The Address specifying the location.
285 /// \return
286 /// Returns the UID of the location at \a addr, or \b LLDB_INVALID_ID if
287 /// there is no breakpoint location at that address.
289
290 /// Find a breakpoint location for a given breakpoint location ID. If there
291 /// are Facade Locations in the breakpoint, the facade locations will be
292 /// searched instead of the "real" ones.
293 ///
294 /// \param[in] bp_loc_id
295 /// The ID specifying the location.
296 ///
297 /// \param[in] use_facade
298 /// If \b true, then prefer facade locations over "real" ones if they exist.
299 ///
300 /// \return
301 /// Returns a shared pointer to the location with ID \a bp_loc_id. The
302 /// pointer
303 /// in the shared pointer will be nullptr if there is no location with that
304 /// ID.
306 bool use_facade = true);
307
308 /// Get breakpoint locations by index.
309 ///
310 /// \param[in] index
311 /// The location index.
312 ///
313 /// \param[in] use_facade
314 /// If \b true, then prefer facade locations over "real" ones if they exist.
315 ///
316 /// \return
317 /// Returns a shared pointer to the location with index \a
318 /// index. The shared pointer might contain nullptr if \a index is
319 /// greater than then number of actual locations.
321 bool use_facade = true);
322
323 /// Removes all invalid breakpoint locations.
324 ///
325 /// Removes all breakpoint locations with architectures that aren't
326 /// compatible with \a arch. Also remove any breakpoint locations with whose
327 /// locations have address where the section has been deleted (module and
328 /// object files no longer exist).
329 ///
330 /// This is typically used after the process calls exec, or anytime the
331 /// architecture of the target changes.
332 ///
333 /// \param[in] arch
334 /// If valid, check the module in each breakpoint to make sure
335 /// they are compatible, otherwise, ignore architecture.
336 void RemoveInvalidLocations(const ArchSpec &arch);
337
338 // The next section deals with various breakpoint options.
339
340 /// If \a enable is \b true, enable the breakpoint, if \b false disable it.
341 void SetEnabled(bool enable) override;
342
343 /// Check the Enable/Disable state.
344 /// \return
345 /// \b true if the breakpoint is enabled, \b false if disabled.
346 bool IsEnabled() override;
347
348 /// Set the breakpoint to ignore the next \a count breakpoint hits.
349 /// \param[in] count
350 /// The number of breakpoint hits to ignore.
351 void SetIgnoreCount(uint32_t count);
352
353 /// Return the current ignore count/
354 /// \return
355 /// The number of breakpoint hits to be ignored.
356 uint32_t GetIgnoreCount() const;
357
358 /// Return the current hit count for all locations. \return
359 /// The current hit count for all locations.
360 uint32_t GetHitCount() const;
361
362 /// Resets the current hit count for all locations.
363 void ResetHitCount();
364
365 /// If \a one_shot is \b true, breakpoint will be deleted on first hit.
366 void SetOneShot(bool one_shot);
367
368 /// Check the OneShot state.
369 /// \return
370 /// \b true if the breakpoint is one shot, \b false otherwise.
371 bool IsOneShot() const;
372
373 /// If \a auto_continue is \b true, breakpoint will auto-continue when on
374 /// hit.
375 void SetAutoContinue(bool auto_continue);
376
377 /// Check the AutoContinue state.
378 /// \return
379 /// \b true if the breakpoint is set to auto-continue, \b false otherwise.
380 bool IsAutoContinue() const;
381
382 /// Set the valid thread to be checked when the breakpoint is hit.
383 /// \param[in] thread_id
384 /// If this thread hits the breakpoint, we stop, otherwise not.
385 void SetThreadID(lldb::tid_t thread_id);
386
387 /// Return the current stop thread value.
388 /// \return
389 /// The thread id for which the breakpoint hit will stop,
390 /// LLDB_INVALID_THREAD_ID for all threads.
391 lldb::tid_t GetThreadID() const;
392
393 void SetThreadIndex(uint32_t index);
394
395 uint32_t GetThreadIndex() const;
396
397 void SetThreadName(const char *thread_name);
398
399 const char *GetThreadName() const;
400
401 void SetQueueName(const char *queue_name);
402
403 const char *GetQueueName() const;
404
405 /// Set the callback action invoked when the breakpoint is hit.
406 ///
407 /// \param[in] callback
408 /// The method that will get called when the breakpoint is hit.
409 /// \param[in] baton
410 /// A void * pointer that will get passed back to the callback function.
411 /// \param[in] is_synchronous
412 /// If \b true the callback will be run on the private event thread
413 /// before the stop event gets reported. If false, the callback will get
414 /// handled on the public event thread while the stop event is being
415 /// pulled off the event queue.
416 /// Note: synchronous callbacks cannot cause the target to run, in
417 /// particular, they should not try to run the expression evaluator.
418 void SetCallback(BreakpointHitCallback callback, void *baton,
419 bool is_synchronous = false);
420
422 const lldb::BatonSP &callback_baton_sp,
423 bool is_synchronous = false);
424
425 void ClearCallback();
426
427 /// Set the breakpoint's condition.
428 ///
429 /// \param[in] condition
430 /// The condition to evaluate when the breakpoint is hit.
431 /// Pass in an empty condition to clear the condition.
432 void SetCondition(StopCondition condition);
433
434 /// Return the breakpoint condition.
435 const StopCondition &GetCondition() const;
436
437 // The next section are various utility functions.
438
439 /// Return the number of breakpoint locations that have resolved to actual
440 /// breakpoint sites.
441 ///
442 /// \param[in] use_facade
443 /// If \b true, then prefer facade locations over "real" ones if they exist.
444 ///
445 /// \return
446 /// The number locations resolved breakpoint sites.
447 size_t GetNumResolvedLocations(bool use_facade = true) const;
448
449 /// Return whether this breakpoint has any resolved locations.
450 ///
451 /// \return
452 /// True if GetNumResolvedLocations > 0
453 bool HasResolvedLocations() const;
454
455 /// Return the number of breakpoint locations.
456 ///
457 /// \param[in] use_facade
458 /// If \b true, then prefer facade locations over "real" ones if they exist.
459 ///
460 /// \return
461 /// The number breakpoint locations.
462 size_t GetNumLocations(bool use_facade = true) const;
463
464 /// Put a description of this breakpoint into the stream \a s.
465 ///
466 /// \param[in] s
467 /// Stream into which to dump the description.
468 ///
469 /// \param[in] level
470 /// The description level that indicates the detail level to
471 /// provide.
472 ///
473 /// \see lldb::DescriptionLevel
475 bool show_locations = false);
476
477 /// Set the "kind" description for a breakpoint. If the breakpoint is hit
478 /// the stop info will show this "kind" description instead of the
479 /// breakpoint number. Mostly useful for internal breakpoints, where the
480 /// breakpoint number doesn't have meaning to the user.
481 ///
482 /// \param[in] kind
483 /// New "kind" description.
484 void SetBreakpointKind(const char *kind) { m_kind_description.assign(kind); }
485
486 /// Return the "kind" description for a breakpoint.
487 ///
488 /// \return
489 /// The breakpoint kind, or nullptr if none is set.
490 const char *GetBreakpointKind() const { return m_kind_description.c_str(); }
491
492 /// Accessor for the breakpoint Target.
493 /// \return
494 /// This breakpoint's Target.
495 Target &GetTarget() { return m_target; }
496
497 const Target &GetTarget() const { return m_target; }
498
500
502
503 /// Find breakpoint locations which match the (filename, line_number)
504 /// description. The breakpoint location collection is to be filled with the
505 /// matching locations. It should be initialized with 0 size by the API
506 /// client.
507 ///
508 /// \return
509 /// True if there is a match
510 ///
511 /// The locations which match the filename and line_number in loc_coll.
512 /// If its
513 /// size is 0 and true is returned, it means the breakpoint fully matches
514 /// the
515 /// description.
516 bool GetMatchingFileLine(llvm::StringRef filename, uint32_t line_number,
518
520
521 /// Returns the BreakpointOptions structure set at the breakpoint level.
522 ///
523 /// Meant to be used by the BreakpointLocation class.
524 ///
525 /// \return
526 /// A reference to this breakpoint's BreakpointOptions.
528
529 /// Returns the BreakpointOptions structure set at the breakpoint level.
530 ///
531 /// Meant to be used by the BreakpointLocation class.
532 ///
533 /// \return
534 /// A reference to this breakpoint's BreakpointOptions.
535 const BreakpointOptions &GetOptions() const;
536
537 /// Invoke the callback action when the breakpoint is hit.
538 ///
539 /// Meant to be used by the BreakpointLocation class.
540 ///
541 /// \param[in] context
542 /// Described the breakpoint event.
543 ///
544 /// \param[in] bp_loc_id
545 /// Which breakpoint location hit this breakpoint.
546 ///
547 /// \return
548 /// \b true if the target should stop at this breakpoint and \b false not.
550 lldb::break_id_t bp_loc_id);
551
552 bool IsHardware() const { return m_hardware; }
553
554 llvm::Error SetIsHardware(bool is_hardware);
555
557
559
560private:
561 void AddName(llvm::StringRef new_name);
562
563 void RemoveName(llvm::StringRef name_to_remove) {
564 if (!name_to_remove.empty())
565 m_name_list.erase(name_to_remove);
566 }
567
568 /// This controls whether to display information about
569 /// the facade locations or the real locations.
571 eDisplayFacade = 1, // Display facade locations
572 eDisplayReal = 1 << 1, // Display real locations
573 eDisplayHeader = 1 << 2 // Display compressed list of locations only
574 };
575
577 uint8_t display_type, bool show_locations);
578
579 bool HasFacadeLocations() { return m_facade_locations.GetSize() != 0; }
580
581public:
582 bool MatchesName(llvm::StringRef name) {
583 return m_name_list.find(name) != m_name_list.end();
584 }
585
586 void GetNames(std::vector<std::string> &names) {
587 names.clear();
588 for (auto name : m_name_list.keys()) {
589 names.push_back(name.str());
590 }
591 }
592
593 /// Set a pre-condition filter that overrides all user provided
594 /// filters/callbacks etc.
595 ///
596 /// Used to define fancy breakpoints that can do dynamic hit detection
597 /// without taking up the condition slot - which really belongs to the user
598 /// anyway...
599 ///
600 /// The Precondition should not continue the target, it should return true
601 /// if the condition says to stop and false otherwise.
602 ///
604 m_precondition_sp = std::move(precondition_sp);
605 }
606
608
610
611 // Produces the OR'ed values for all the names assigned to this breakpoint.
613 return m_permissions;
614 }
615
619
620 bool AllowList() const {
621 return GetPermissions().GetAllowList();
622 }
623 bool AllowDisable() const {
625 }
626 bool AllowDelete() const {
628 }
629
630 // This one should only be used by Target to copy breakpoints from target to
631 // target - primarily from the dummy target to prime new targets.
633 const Breakpoint &bp_to_copy_from);
634
635 /// Get statistics associated with this breakpoint in JSON format.
636 llvm::json::Value GetStatistics();
637
638 void ResetStatistics();
639
640 /// Get the time it took to resolve all locations in this breakpoint.
642
643protected:
644 friend class Target;
645 // Protected Methods
646
647 /// Constructors and Destructors
648 /// Only the Target can make a breakpoint, and it owns the breakpoint
649 /// lifespans. The constructor takes a filter and a resolver. Up in Target
650 /// there are convenience variants that make breakpoints for some common
651 /// cases.
652 ///
653 /// \param[in] target
654 /// The target in which the breakpoint will be set.
655 ///
656 /// \param[in] filter_sp
657 /// Shared pointer to the search filter that restricts the search domain of
658 /// the breakpoint.
659 ///
660 /// \param[in] resolver_sp
661 /// Shared pointer to the resolver object that will determine breakpoint
662 /// matches.
663 ///
664 /// \param hardware
665 /// If true, request a hardware breakpoint to be used to implement the
666 /// breakpoint locations.
667 ///
668 /// \param resolve_indirect_symbols
669 /// If true, and the address of a given breakpoint location in this
670 /// breakpoint is set on an
671 /// indirect symbol (i.e. Symbol::IsIndirect returns true) then the actual
672 /// breakpoint site will
673 /// be set on the target of the indirect symbol.
674 // This is the generic constructor
675 Breakpoint(Target &target, lldb::SearchFilterSP &filter_sp,
676 lldb::BreakpointResolverSP &resolver_sp, bool hardware,
677 bool resolve_indirect_symbols = true);
678
679 friend class BreakpointLocation; // To call the following two when determining
680 // whether to stop.
681
683
684private:
685 // To call from CopyFromBreakpoint.
686 Breakpoint(Target &new_target, const Breakpoint &bp_to_copy_from);
687
688 // For Breakpoint only
689 bool
690 m_hardware; // If this breakpoint is required to use a hardware breakpoint
691 Target &m_target; // The target that holds this breakpoint.
692 /// If not empty, this is the name of this breakpoint (many breakpoints can
693 /// share the same name.)
694 llvm::StringSet<> m_name_list;
696 m_filter_sp; // The filter that constrains the breakpoint's domain.
698 m_resolver_sp; // The resolver that defines this breakpoint.
700 // breakpoint-level hit
701 // filter that can be used
702 // to skip certain breakpoint hits. For instance, exception breakpoints use
703 // this to limit the stop to certain exception classes, while leaving the
704 // condition & callback free for user specification.
705 BreakpointOptions m_options; // Settable breakpoint options
707 m_locations; // The list of locations currently found for this breakpoint.
709
712
713 /// Number of times this breakpoint has been hit. This is kept separately
714 /// from the locations hit counts, since locations can go away when their
715 /// backing library gets unloaded, and we would lose hit counts.
717
719
721
722 void SendBreakpointChangedEvent(lldb::BreakpointEventType eventKind);
723
724 void SendBreakpointChangedEvent(const lldb::EventDataSP &breakpoint_data_sp);
725
726 Breakpoint(const Breakpoint &) = delete;
727 const Breakpoint &operator=(const Breakpoint &) = delete;
728};
729
730} // namespace lldb_private
731
732#endif // LLDB_BREAKPOINT_BREAKPOINT_H
static llvm::raw_ostream & error(Stream &strm)
A section + offset based address class.
Definition Address.h:62
An architecture specification class.
Definition ArchSpec.h:32
"lldb/Breakpoint/BreakpointLocationList.h" This class is used by Breakpoint to manage a list of break...
"lldb/Breakpoint/BreakpointOptions.h" Class that manages the options on a breakpoint or breakpoint lo...
BreakpointEventData(lldb::BreakpointEventType sub_type, const lldb::BreakpointSP &new_breakpoint_sp)
BreakpointLocationCollection m_locations
Definition Breakpoint.h:145
static lldb::BreakpointEventType GetBreakpointEventTypeFromEvent(const lldb::EventSP &event_sp)
lldb::BreakpointEventType m_breakpoint_event
Definition Breakpoint.h:143
BreakpointLocationCollection & GetBreakpointLocationCollection()
Definition Breakpoint.h:120
static lldb::BreakpointLocationSP GetBreakpointLocationAtIndexFromEvent(const lldb::EventSP &event_sp, uint32_t loc_idx)
const BreakpointEventData & operator=(const BreakpointEventData &)=delete
static lldb::BreakpointSP GetBreakpointFromEvent(const lldb::EventSP &event_sp)
llvm::StringRef GetFlavor() const override
lldb::BreakpointEventType GetBreakpointEventType() const
static const BreakpointEventData * GetEventDataFromEvent(const Event *event_sp)
static size_t GetNumBreakpointLocationsFromEvent(const lldb::EventSP &event_sp)
BreakpointEventData(const BreakpointEventData &)=delete
General Outline: A breakpoint has four main parts, a filter, a resolver, the list of breakpoint locat...
Definition Breakpoint.h:83
lldb::BreakpointLocationSP GetLocationAtIndex(size_t index, bool use_facade=true)
Get breakpoint locations by index.
void RemoveInvalidLocations(const ArchSpec &arch)
Removes all invalid breakpoint locations.
virtual StructuredData::ObjectSP SerializeToStructuredData()
lldb::BreakpointLocationSP AddLocation(const Address &addr, bool *new_location=nullptr)
Add a location to the breakpoint's location list.
uint32_t GetThreadIndex() const
StatsDuration m_resolve_time
Definition Breakpoint.h:720
lldb::BreakpointLocationSP FindLocationByID(lldb::break_id_t bp_loc_id, bool use_facade=true)
Find a breakpoint location for a given breakpoint location ID.
bool IsAutoContinue() const
Check the AutoContinue state.
void SetOneShot(bool one_shot)
If one_shot is true, breakpoint will be deleted on first hit.
void ModuleReplaced(lldb::ModuleSP old_module_sp, lldb::ModuleSP new_module_sp)
Tells the breakpoint the old module old_module_sp has been replaced by new_module_sp (usually because...
~Breakpoint() override
Destructor.
lldb::tid_t GetThreadID() const
Return the current stop thread value.
void RemoveName(llvm::StringRef name_to_remove)
Definition Breakpoint.h:563
llvm::json::Value GetStatistics()
Get statistics associated with this breakpoint in JSON format.
void SetAutoContinue(bool auto_continue)
If auto_continue is true, breakpoint will auto-continue when on hit.
bool InvokeCallback(StoppointCallbackContext *context, lldb::break_id_t bp_loc_id)
Invoke the callback action when the breakpoint is hit.
StoppointHitCounter m_hit_counter
Number of times this breakpoint has been hit.
Definition Breakpoint.h:716
static const char * GetKey(OptionNames enum_value)
Definition Breakpoint.h:98
uint32_t GetIgnoreCount() const
Return the current ignore count/.
const Breakpoint & operator=(const Breakpoint &)=delete
bool EvaluatePrecondition(StoppointCallbackContext &context)
void SetThreadIndex(uint32_t index)
const BreakpointName::Permissions & GetPermissions() const
Definition Breakpoint.h:612
const char * GetQueueName() const
lldb::BreakpointPreconditionSP GetPrecondition()
Definition Breakpoint.h:609
const lldb::TargetSP GetTargetSP()
friend class BreakpointLocation
Definition Breakpoint.h:679
static lldb::BreakpointSP CreateFromStructuredData(lldb::TargetSP target_sp, StructuredData::ObjectSP &data_object_sp, Status &error)
lldb::SearchFilterSP GetSearchFilter()
Definition Breakpoint.h:558
void ResetHitCount()
Resets the current hit count for all locations.
BreakpointLocationList m_locations
Definition Breakpoint.h:707
Breakpoint(const Breakpoint &)=delete
const char * GetBreakpointKind() const
Return the "kind" description for a breakpoint.
Definition Breakpoint.h:490
void GetDescriptionForType(Stream *s, lldb::DescriptionLevel level, uint8_t display_type, bool show_locations)
lldb::BreakpointLocationSP GetFacadeLocationByID(lldb::break_id_t)
lldb::BreakpointLocationSP AddFacadeLocation()
Add a facade location to the breakpoint's collection of facade locations.
const Target & GetTarget() const
Definition Breakpoint.h:497
bool IsEnabled() override
Check the Enable/Disable state.
void GetDescription(Stream *s, lldb::DescriptionLevel level, bool show_locations=false)
Put a description of this breakpoint into the stream s.
void SetBreakpointKind(const char *kind)
Set the "kind" description for a breakpoint.
Definition Breakpoint.h:484
void ClearAllBreakpointSites()
Tell this breakpoint to clear all its breakpoint sites.
BreakpointOptions & GetOptions()
Returns the BreakpointOptions structure set at the breakpoint level.
void SetQueueName(const char *queue_name)
bool MatchesName(llvm::StringRef name)
Definition Breakpoint.h:582
void SetPrecondition(lldb::BreakpointPreconditionSP precondition_sp)
Set a pre-condition filter that overrides all user provided filters/callbacks etc.
Definition Breakpoint.h:603
size_t GetNumResolvedLocations(bool use_facade=true) const
Return the number of breakpoint locations that have resolved to actual breakpoint sites.
lldb::BreakpointResolverSP GetResolver()
Definition Breakpoint.h:556
lldb::break_id_t FindLocationIDByAddress(const Address &addr)
Find a breakpoint location ID by Address.
void ResolveBreakpointInModules(ModuleList &module_list, bool send_event=true)
Tell this breakpoint to scan a given module list and resolve any new locations that match the breakpo...
static lldb::BreakpointSP CopyFromBreakpoint(lldb::TargetSP new_target, const Breakpoint &bp_to_copy_from)
BreakpointLocationCollection m_facade_locations
Definition Breakpoint.h:708
bool HasResolvedLocations() const
Return whether this breakpoint has any resolved locations.
void AddName(llvm::StringRef new_name)
DisplayType
This controls whether to display information about the facade locations or the real locations.
Definition Breakpoint.h:570
bool GetMatchingFileLine(llvm::StringRef filename, uint32_t line_number, BreakpointLocationCollection &loc_coll)
Find breakpoint locations which match the (filename, line_number) description.
lldb::BreakpointLocationSP FindLocationByAddress(const Address &addr)
Find a breakpoint location by Address.
static const char * g_option_names[static_cast< uint32_t >(OptionNames::LastOptionName)]
Definition Breakpoint.h:96
BreakpointName::Permissions & GetPermissions()
Definition Breakpoint.h:616
void GetResolverDescription(Stream *s)
static const char * GetSerializationKey()
Definition Breakpoint.h:162
void ModulesChanged(ModuleList &changed_modules, bool load_event, bool delete_locations=false)
Like ResolveBreakpointInModules, but allows for "unload" events, in which case we will remove any loc...
static bool SerializedBreakpointMatchesNames(StructuredData::ObjectSP &bkpt_object_sp, std::vector< std::string > &names)
BreakpointName::Permissions m_permissions
Definition Breakpoint.h:718
const StopCondition & GetCondition() const
Return the breakpoint condition.
const char * GetThreadName() const
void SetThreadID(lldb::tid_t thread_id)
Set the valid thread to be checked when the breakpoint is hit.
void GetFilterDescription(Stream *s)
void GetNames(std::vector< std::string > &names)
Definition Breakpoint.h:586
void ResolveBreakpoint()
Tell this breakpoint to scan it's target's module list and resolve any new locations that match the b...
lldb::BreakpointPreconditionSP m_precondition_sp
Definition Breakpoint.h:699
BreakpointOptions m_options
Definition Breakpoint.h:705
MatchType
An enum specifying the match style for breakpoint settings.
Definition Breakpoint.h:90
Target & GetTarget()
Accessor for the breakpoint Target.
Definition Breakpoint.h:495
void SetIgnoreCount(uint32_t count)
Set the breakpoint to ignore the next count breakpoint hits.
bool IsOneShot() const
Check the OneShot state.
uint32_t GetHitCount() const
Return the current hit count for all locations.
static const char * BreakpointEventTypeAsCString(lldb::BreakpointEventType type)
void SetCondition(StopCondition condition)
Set the breakpoint's condition.
void SetCallback(BreakpointHitCallback callback, void *baton, bool is_synchronous=false)
Set the callback action invoked when the breakpoint is hit.
StatsDuration::Duration GetResolveTime() const
Get the time it took to resolve all locations in this breakpoint.
Definition Breakpoint.h:641
void SetEnabled(bool enable) override
If enable is true, enable the breakpoint, if false disable it.
lldb::BreakpointResolverSP m_resolver_sp
Definition Breakpoint.h:698
void Dump(Stream *s) override
Standard "Dump" method. At present it does nothing.
bool IsInternal() const
Tell whether this breakpoint is an "internal" breakpoint.
lldb::SearchFilterSP m_filter_sp
Definition Breakpoint.h:696
void SetThreadName(const char *thread_name)
llvm::Error SetIsHardware(bool is_hardware)
llvm::StringSet m_name_list
If not empty, this is the name of this breakpoint (many breakpoints can share the same name....
Definition Breakpoint.h:694
size_t GetNumLocations(bool use_facade=true) const
Return the number of breakpoint locations.
bool AllowDisable() const
Definition Breakpoint.h:623
std::string m_kind_description
Definition Breakpoint.h:710
void SendBreakpointChangedEvent(lldb::BreakpointEventType eventKind)
Breakpoint(Target &target, lldb::SearchFilterSP &filter_sp, lldb::BreakpointResolverSP &resolver_sp, bool hardware, bool resolve_indirect_symbols=true)
Constructors and Destructors Only the Target can make a breakpoint, and it owns the breakpoint lifesp...
A collection class for Module objects.
Definition ModuleList.h:125
std::chrono::duration< double > Duration
Definition Statistics.h:37
An error handling class.
Definition Status.h:118
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
A stream class that can stream formatted output to a file.
Definition Stream.h:28
std::shared_ptr< Object > ObjectSP
A class that represents a running process on the host machine.
std::function< bool(void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)> BreakpointHitCallback
std::shared_ptr< lldb_private::SearchFilter > SearchFilterSP
std::shared_ptr< lldb_private::BreakpointResolver > BreakpointResolverSP
std::shared_ptr< lldb_private::BreakpointLocation > BreakpointLocationSP
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
std::shared_ptr< lldb_private::Breakpoint > BreakpointSP
int32_t break_id_t
Definition lldb-types.h:87
std::shared_ptr< lldb_private::Baton > BatonSP
std::shared_ptr< lldb_private::BreakpointPrecondition > BreakpointPreconditionSP
std::shared_ptr< lldb_private::Event > EventSP
std::shared_ptr< lldb_private::Target > TargetSP
uint64_t tid_t
Definition lldb-types.h:84
std::shared_ptr< lldb_private::Module > ModuleSP
std::shared_ptr< lldb_private::EventData > EventDataSP