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