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