]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Breakpoint/StoppointLocation.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Breakpoint / StoppointLocation.h
1 //===-- StoppointLocation.h -------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef liblldb_StoppointLocation_h_
11 #define liblldb_StoppointLocation_h_
12
13 #include "lldb/Utility/UserID.h"
14 #include "lldb/lldb-private.h"
15 // #include "lldb/Breakpoint/BreakpointOptions.h"
16
17 namespace lldb_private {
18
19 class StoppointLocation {
20 public:
21   //------------------------------------------------------------------
22   // Constructors and Destructors
23   //------------------------------------------------------------------
24   StoppointLocation(lldb::break_id_t bid, lldb::addr_t m_addr, bool hardware);
25
26   StoppointLocation(lldb::break_id_t bid, lldb::addr_t m_addr,
27                     uint32_t byte_size, bool hardware);
28
29   virtual ~StoppointLocation();
30
31   //------------------------------------------------------------------
32   // Operators
33   //------------------------------------------------------------------
34
35   //------------------------------------------------------------------
36   // Methods
37   //------------------------------------------------------------------
38   virtual lldb::addr_t GetLoadAddress() const { return m_addr; }
39
40   virtual void SetLoadAddress(lldb::addr_t addr) { m_addr = addr; }
41
42   uint32_t GetByteSize() const { return m_byte_size; }
43
44   uint32_t GetHitCount() const { return m_hit_count; }
45
46   uint32_t GetHardwareIndex() const { return m_hardware_index; }
47
48   bool HardwareRequired() const { return m_hardware; }
49
50   virtual bool IsHardware() const {
51     return m_hardware_index != LLDB_INVALID_INDEX32;
52   }
53
54   virtual bool ShouldStop(StoppointCallbackContext *context) { return true; }
55
56   virtual void Dump(Stream *stream) const {}
57
58   void SetHardwareIndex(uint32_t index) { m_hardware_index = index; }
59
60   lldb::break_id_t GetID() const { return m_loc_id; }
61
62 protected:
63   //------------------------------------------------------------------
64   // Classes that inherit from StoppointLocation can see and modify these
65   //------------------------------------------------------------------
66   lldb::break_id_t m_loc_id; // Stoppoint location ID
67   lldb::addr_t
68       m_addr; // The load address of this stop point. The base Stoppoint doesn't
69   // store a full Address since that's not needed for the breakpoint sites.
70   bool m_hardware; // True if this point has been is required to use hardware
71                    // (which may fail due to lack of resources)
72   uint32_t m_hardware_index; // The hardware resource index for this
73                              // breakpoint/watchpoint
74   uint32_t m_byte_size; // The size in bytes of stop location.  e.g. the length
75                         // of the trap opcode for
76   // software breakpoints, or the optional length in bytes for hardware
77   // breakpoints, or the length of the watchpoint.
78   uint32_t
79       m_hit_count; // Number of times this breakpoint/watchpoint has been hit
80
81   // If you override this, be sure to call the base class to increment the
82   // internal counter.
83   void IncrementHitCount() { ++m_hit_count; }
84
85   void DecrementHitCount();
86
87 private:
88   //------------------------------------------------------------------
89   // For StoppointLocation only
90   //------------------------------------------------------------------
91   DISALLOW_COPY_AND_ASSIGN(StoppointLocation);
92   StoppointLocation(); // Disallow default constructor
93 };
94
95 } // namespace lldb_private
96
97 #endif // liblldb_StoppointLocation_h_