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