1 //===-- StoppointLocation.h -------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef liblldb_StoppointLocation_h_
10 #define liblldb_StoppointLocation_h_
12 #include "lldb/Utility/UserID.h"
13 #include "lldb/lldb-private.h"
14 // #include "lldb/Breakpoint/BreakpointOptions.h"
16 namespace lldb_private {
18 class StoppointLocation {
20 // Constructors and Destructors
21 StoppointLocation(lldb::break_id_t bid, lldb::addr_t m_addr, bool hardware);
23 StoppointLocation(lldb::break_id_t bid, lldb::addr_t m_addr,
24 uint32_t byte_size, bool hardware);
26 virtual ~StoppointLocation();
31 virtual lldb::addr_t GetLoadAddress() const { return m_addr; }
33 virtual void SetLoadAddress(lldb::addr_t addr) { m_addr = addr; }
35 uint32_t GetByteSize() const { return m_byte_size; }
37 uint32_t GetHitCount() const { return m_hit_count; }
39 uint32_t GetHardwareIndex() const { return m_hardware_index; }
41 bool HardwareRequired() const { return m_hardware; }
43 virtual bool IsHardware() const {
44 return m_hardware_index != LLDB_INVALID_INDEX32;
47 virtual bool ShouldStop(StoppointCallbackContext *context) { return true; }
49 virtual void Dump(Stream *stream) const {}
51 void SetHardwareIndex(uint32_t index) { m_hardware_index = index; }
53 lldb::break_id_t GetID() const { return m_loc_id; }
56 // Classes that inherit from StoppointLocation can see and modify these
57 lldb::break_id_t m_loc_id; // Stoppoint location ID
59 m_addr; // The load address of this stop point. The base Stoppoint doesn't
60 // store a full Address since that's not needed for the breakpoint sites.
61 bool m_hardware; // True if this point has been is required to use hardware
62 // (which may fail due to lack of resources)
63 uint32_t m_hardware_index; // The hardware resource index for this
64 // breakpoint/watchpoint
65 uint32_t m_byte_size; // The size in bytes of stop location. e.g. the length
66 // of the trap opcode for
67 // software breakpoints, or the optional length in bytes for hardware
68 // breakpoints, or the length of the watchpoint.
70 m_hit_count; // Number of times this breakpoint/watchpoint has been hit
72 // If you override this, be sure to call the base class to increment the
74 void IncrementHitCount() { ++m_hit_count; }
76 void DecrementHitCount();
79 // For StoppointLocation only
80 DISALLOW_COPY_AND_ASSIGN(StoppointLocation);
81 StoppointLocation() = delete;
84 } // namespace lldb_private
86 #endif // liblldb_StoppointLocation_h_