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// C Includes
14// C++ Includes
15// Other libraries and framework includes
16// Project includes
17#include "lldb/lldb-private.h"
18#include "lldb/Core/UserID.h"
19// #include "lldb/Breakpoint/BreakpointOptions.h"
20
21namespace lldb_private {
22
23class StoppointLocation
24{
25public:
26    //------------------------------------------------------------------
27    // Constructors and Destructors
28    //------------------------------------------------------------------
29    StoppointLocation (lldb::break_id_t bid,
30                       lldb::addr_t m_addr,
31                       bool hardware);
32
33    StoppointLocation (lldb::break_id_t bid,
34                       lldb::addr_t m_addr,
35                       uint32_t byte_size,
36                       bool hardware);
37
38    virtual
39    ~StoppointLocation ();
40
41    //------------------------------------------------------------------
42    // Operators
43    //------------------------------------------------------------------
44
45    //------------------------------------------------------------------
46    // Methods
47    //------------------------------------------------------------------
48    virtual lldb::addr_t
49    GetLoadAddress() const
50    {
51        return m_addr;
52    }
53
54    virtual void
55    SetLoadAddress (lldb::addr_t addr)
56    {
57        m_addr = addr;
58    }
59
60    uint32_t
61    GetByteSize () const
62    {
63        return m_byte_size;
64    }
65
66    uint32_t
67    GetHitCount () const
68    {
69        return m_hit_count;
70    }
71
72    uint32_t
73    GetHardwareIndex () const
74    {
75        return m_hw_index;
76    }
77
78
79    bool
80    HardwarePreferred () const
81    {
82        return m_hw_preferred;
83    }
84
85    virtual bool
86    IsHardware () const
87    {
88        return m_hw_index != LLDB_INVALID_INDEX32;
89    }
90
91
92    virtual bool
93    ShouldStop (StoppointCallbackContext *context)
94    {
95        return true;
96    }
97
98    virtual void
99    Dump (Stream *stream) const
100    {
101    }
102
103    void
104    SetHardwareIndex (uint32_t index)
105    {
106        m_hw_index = index;
107    }
108
109
110    lldb::break_id_t
111    GetID () const
112    {
113        return m_loc_id;
114    }
115
116protected:
117    //------------------------------------------------------------------
118    // Classes that inherit from StoppointLocation can see and modify these
119    //------------------------------------------------------------------
120    lldb::break_id_t  m_loc_id;     // Stoppoint location ID
121    lldb::addr_t      m_addr;       // The load address of this stop point. The base Stoppoint doesn't
122                                    // store a full Address since that's not needed for the breakpoint sites.
123    bool        m_hw_preferred;     // 1 if this point has been requested to be set using hardware (which may fail due to lack of resources)
124    uint32_t    m_hw_index;         // The hardware resource index for this breakpoint/watchpoint
125    uint32_t    m_byte_size;        // The size in bytes of stop location.  e.g. the length of the trap opcode for
126                                    // software breakpoints, or the optional length in bytes for
127                                    // hardware breakpoints, or the length of the watchpoint.
128    uint32_t    m_hit_count;        // Number of times this breakpoint/watchpoint has been hit
129
130    // If you override this, be sure to call the base class to increment the internal counter.
131    void
132    IncrementHitCount ()
133    {
134        ++m_hit_count;
135    }
136
137private:
138    //------------------------------------------------------------------
139    // For StoppointLocation only
140    //------------------------------------------------------------------
141    DISALLOW_COPY_AND_ASSIGN(StoppointLocation);
142    StoppointLocation(); // Disallow default constructor
143};
144
145} // namespace lldb_private
146
147#endif  // liblldb_StoppointLocation_h_
148