1254721Semaste//===-- StoppointLocation.h -------------------------------------*- C++ -*-===//
2254721Semaste//
3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4353358Sdim// See https://llvm.org/LICENSE.txt for license information.
5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6254721Semaste//
7254721Semaste//===----------------------------------------------------------------------===//
8254721Semaste
9254721Semaste#ifndef liblldb_StoppointLocation_h_
10254721Semaste#define liblldb_StoppointLocation_h_
11254721Semaste
12321369Sdim#include "lldb/Utility/UserID.h"
13254721Semaste#include "lldb/lldb-private.h"
14254721Semaste// #include "lldb/Breakpoint/BreakpointOptions.h"
15254721Semaste
16254721Semastenamespace lldb_private {
17254721Semaste
18314564Sdimclass StoppointLocation {
19254721Semastepublic:
20314564Sdim  // Constructors and Destructors
21314564Sdim  StoppointLocation(lldb::break_id_t bid, lldb::addr_t m_addr, bool hardware);
22254721Semaste
23314564Sdim  StoppointLocation(lldb::break_id_t bid, lldb::addr_t m_addr,
24314564Sdim                    uint32_t byte_size, bool hardware);
25254721Semaste
26314564Sdim  virtual ~StoppointLocation();
27254721Semaste
28314564Sdim  // Operators
29254721Semaste
30314564Sdim  // Methods
31314564Sdim  virtual lldb::addr_t GetLoadAddress() const { return m_addr; }
32254721Semaste
33314564Sdim  virtual void SetLoadAddress(lldb::addr_t addr) { m_addr = addr; }
34254721Semaste
35314564Sdim  uint32_t GetByteSize() const { return m_byte_size; }
36254721Semaste
37314564Sdim  uint32_t GetHitCount() const { return m_hit_count; }
38254721Semaste
39314564Sdim  uint32_t GetHardwareIndex() const { return m_hardware_index; }
40254721Semaste
41314564Sdim  bool HardwareRequired() const { return m_hardware; }
42254721Semaste
43314564Sdim  virtual bool IsHardware() const {
44314564Sdim    return m_hardware_index != LLDB_INVALID_INDEX32;
45314564Sdim  }
46254721Semaste
47314564Sdim  virtual bool ShouldStop(StoppointCallbackContext *context) { return true; }
48254721Semaste
49314564Sdim  virtual void Dump(Stream *stream) const {}
50254721Semaste
51314564Sdim  void SetHardwareIndex(uint32_t index) { m_hardware_index = index; }
52254721Semaste
53314564Sdim  lldb::break_id_t GetID() const { return m_loc_id; }
54254721Semaste
55254721Semasteprotected:
56314564Sdim  // Classes that inherit from StoppointLocation can see and modify these
57314564Sdim  lldb::break_id_t m_loc_id; // Stoppoint location ID
58314564Sdim  lldb::addr_t
59314564Sdim      m_addr; // The load address of this stop point. The base Stoppoint doesn't
60314564Sdim  // store a full Address since that's not needed for the breakpoint sites.
61314564Sdim  bool m_hardware; // True if this point has been is required to use hardware
62314564Sdim                   // (which may fail due to lack of resources)
63314564Sdim  uint32_t m_hardware_index; // The hardware resource index for this
64314564Sdim                             // breakpoint/watchpoint
65314564Sdim  uint32_t m_byte_size; // The size in bytes of stop location.  e.g. the length
66314564Sdim                        // of the trap opcode for
67341825Sdim  // software breakpoints, or the optional length in bytes for hardware
68341825Sdim  // breakpoints, or the length of the watchpoint.
69314564Sdim  uint32_t
70314564Sdim      m_hit_count; // Number of times this breakpoint/watchpoint has been hit
71254721Semaste
72314564Sdim  // If you override this, be sure to call the base class to increment the
73314564Sdim  // internal counter.
74314564Sdim  void IncrementHitCount() { ++m_hit_count; }
75254721Semaste
76314564Sdim  void DecrementHitCount();
77288943Sdim
78254721Semasteprivate:
79314564Sdim  // For StoppointLocation only
80314564Sdim  DISALLOW_COPY_AND_ASSIGN(StoppointLocation);
81353358Sdim  StoppointLocation() = delete;
82254721Semaste};
83254721Semaste
84254721Semaste} // namespace lldb_private
85254721Semaste
86314564Sdim#endif // liblldb_StoppointLocation_h_
87