StoppointSite.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //===-- StoppointSite.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_STOPPOINTSITE_H
  9. #define LLDB_BREAKPOINT_STOPPOINTSITE_H
  10. #include "lldb/Breakpoint/StoppointHitCounter.h"
  11. #include "lldb/Utility/UserID.h"
  12. #include "lldb/lldb-private.h"
  13. namespace lldb_private {
  14. class StoppointSite {
  15. public:
  16. StoppointSite(lldb::break_id_t bid, lldb::addr_t m_addr, bool hardware);
  17. StoppointSite(lldb::break_id_t bid, lldb::addr_t m_addr,
  18. uint32_t byte_size, bool hardware);
  19. virtual ~StoppointSite() = default;
  20. virtual lldb::addr_t GetLoadAddress() const { return m_addr; }
  21. virtual void SetLoadAddress(lldb::addr_t addr) { m_addr = addr; }
  22. uint32_t GetByteSize() const { return m_byte_size; }
  23. uint32_t GetHitCount() const { return m_hit_counter.GetValue(); }
  24. void ResetHitCount() { m_hit_counter.Reset(); }
  25. bool HardwareRequired() const { return m_is_hardware_required; }
  26. virtual bool IsHardware() const = 0;
  27. uint32_t GetHardwareIndex() const { return m_hardware_index; }
  28. void SetHardwareIndex(uint32_t index) { m_hardware_index = index; }
  29. virtual bool ShouldStop(StoppointCallbackContext* context) = 0;
  30. virtual void Dump(Stream* stream) const = 0;
  31. lldb::break_id_t GetID() const { return m_id; }
  32. protected:
  33. /// Stoppoint site ID.
  34. lldb::break_id_t m_id;
  35. /// The load address of this stop point.
  36. lldb::addr_t m_addr;
  37. /// True if this point is required to use hardware (which may fail due to
  38. /// the lack of resources).
  39. bool m_is_hardware_required;
  40. /// The hardware resource index for this breakpoint/watchpoint.
  41. uint32_t m_hardware_index;
  42. /// The size in bytes of stoppoint, e.g. the length of the trap opcode for
  43. /// software breakpoints, or the optional length in bytes for hardware
  44. /// breakpoints, or the length of the watchpoint.
  45. uint32_t m_byte_size;
  46. /// Number of times this breakpoint/watchpoint has been hit.
  47. StoppointHitCounter m_hit_counter;
  48. private:
  49. StoppointSite(const StoppointSite &) = delete;
  50. const StoppointSite &operator=(const StoppointSite &) = delete;
  51. StoppointSite() = delete;
  52. };
  53. } // namespace lldb_private
  54. #endif // LLDB_BREAKPOINT_STOPPOINTSITE_H