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