Breakpoint.h 24 KB

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