1*e8d8bef9SDimitry Andric //===-- StoppointSite.h -----------------------------------------*- C++ -*-===//
2*e8d8bef9SDimitry Andric //
3*e8d8bef9SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*e8d8bef9SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*e8d8bef9SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*e8d8bef9SDimitry Andric //
7*e8d8bef9SDimitry Andric //===----------------------------------------------------------------------===//
8*e8d8bef9SDimitry Andric 
9*e8d8bef9SDimitry Andric #ifndef LLDB_BREAKPOINT_STOPPOINTSITE_H
10*e8d8bef9SDimitry Andric #define LLDB_BREAKPOINT_STOPPOINTSITE_H
11*e8d8bef9SDimitry Andric 
12*e8d8bef9SDimitry Andric #include "lldb/Breakpoint/StoppointHitCounter.h"
13*e8d8bef9SDimitry Andric #include "lldb/Utility/UserID.h"
14*e8d8bef9SDimitry Andric #include "lldb/lldb-private.h"
15*e8d8bef9SDimitry Andric 
16*e8d8bef9SDimitry Andric namespace lldb_private {
17*e8d8bef9SDimitry Andric 
18*e8d8bef9SDimitry Andric class StoppointSite {
19*e8d8bef9SDimitry Andric public:
20*e8d8bef9SDimitry Andric   StoppointSite(lldb::break_id_t bid, lldb::addr_t m_addr, bool hardware);
21*e8d8bef9SDimitry Andric 
22*e8d8bef9SDimitry Andric   StoppointSite(lldb::break_id_t bid, lldb::addr_t m_addr,
23*e8d8bef9SDimitry Andric                 uint32_t byte_size, bool hardware);
24*e8d8bef9SDimitry Andric 
25*e8d8bef9SDimitry Andric   virtual ~StoppointSite() = default;
26*e8d8bef9SDimitry Andric 
GetLoadAddress()27*e8d8bef9SDimitry Andric   virtual lldb::addr_t GetLoadAddress() const { return m_addr; }
28*e8d8bef9SDimitry Andric 
SetLoadAddress(lldb::addr_t addr)29*e8d8bef9SDimitry Andric   virtual void SetLoadAddress(lldb::addr_t addr) { m_addr = addr; }
30*e8d8bef9SDimitry Andric 
GetByteSize()31*e8d8bef9SDimitry Andric   uint32_t GetByteSize() const { return m_byte_size; }
32*e8d8bef9SDimitry Andric 
GetHitCount()33*e8d8bef9SDimitry Andric   uint32_t GetHitCount() const { return m_hit_counter.GetValue(); }
34*e8d8bef9SDimitry Andric 
ResetHitCount()35*e8d8bef9SDimitry Andric   void ResetHitCount() { m_hit_counter.Reset(); }
36*e8d8bef9SDimitry Andric 
HardwareRequired()37*e8d8bef9SDimitry Andric   bool HardwareRequired() const { return m_is_hardware_required; }
38*e8d8bef9SDimitry Andric 
39*e8d8bef9SDimitry Andric   virtual bool IsHardware() const = 0;
40*e8d8bef9SDimitry Andric 
41*e8d8bef9SDimitry Andric   virtual bool ShouldStop(StoppointCallbackContext* context) = 0;
42*e8d8bef9SDimitry Andric 
43*e8d8bef9SDimitry Andric   virtual void Dump(Stream* stream) const = 0;
44*e8d8bef9SDimitry Andric 
GetID()45*e8d8bef9SDimitry Andric   lldb::break_id_t GetID() const { return m_id; }
46*e8d8bef9SDimitry Andric 
47*e8d8bef9SDimitry Andric protected:
48*e8d8bef9SDimitry Andric   /// Stoppoint site ID.
49*e8d8bef9SDimitry Andric   lldb::break_id_t m_id;
50*e8d8bef9SDimitry Andric 
51*e8d8bef9SDimitry Andric   /// The load address of this stop point.
52*e8d8bef9SDimitry Andric   lldb::addr_t m_addr;
53*e8d8bef9SDimitry Andric 
54*e8d8bef9SDimitry Andric   /// True if this point is required to use hardware (which may fail due to
55*e8d8bef9SDimitry Andric   /// the lack of resources).
56*e8d8bef9SDimitry Andric   bool m_is_hardware_required;
57*e8d8bef9SDimitry Andric 
58*e8d8bef9SDimitry Andric   /// The size in bytes of stoppoint, e.g. the length of the trap opcode for
59*e8d8bef9SDimitry Andric   /// software breakpoints, or the optional length in bytes for hardware
60*e8d8bef9SDimitry Andric   /// breakpoints, or the length of the watchpoint.
61*e8d8bef9SDimitry Andric   uint32_t m_byte_size;
62*e8d8bef9SDimitry Andric 
63*e8d8bef9SDimitry Andric   /// Number of times this breakpoint/watchpoint has been hit.
64*e8d8bef9SDimitry Andric   StoppointHitCounter m_hit_counter;
65*e8d8bef9SDimitry Andric 
66*e8d8bef9SDimitry Andric private:
67*e8d8bef9SDimitry Andric   StoppointSite(const StoppointSite &) = delete;
68*e8d8bef9SDimitry Andric   const StoppointSite &operator=(const StoppointSite &) = delete;
69*e8d8bef9SDimitry Andric   StoppointSite() = delete;
70*e8d8bef9SDimitry Andric };
71*e8d8bef9SDimitry Andric 
72*e8d8bef9SDimitry Andric } // namespace lldb_private
73*e8d8bef9SDimitry Andric 
74*e8d8bef9SDimitry Andric #endif // LLDB_BREAKPOINT_STOPPOINTSITE_H
75