1//===-- StoppointLocation.h -------------------------------------*- C++ -*-===// 2// 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 6// 7//===----------------------------------------------------------------------===// 8 9#ifndef liblldb_StoppointLocation_h_ 10#define liblldb_StoppointLocation_h_ 11 12#include "lldb/Utility/UserID.h" 13#include "lldb/lldb-private.h" 14// #include "lldb/Breakpoint/BreakpointOptions.h" 15 16namespace lldb_private { 17 18class StoppointLocation { 19public: 20 // Constructors and Destructors 21 StoppointLocation(lldb::break_id_t bid, lldb::addr_t m_addr, bool hardware); 22 23 StoppointLocation(lldb::break_id_t bid, lldb::addr_t m_addr, 24 uint32_t byte_size, bool hardware); 25 26 virtual ~StoppointLocation(); 27 28 // Operators 29 30 // Methods 31 virtual lldb::addr_t GetLoadAddress() const { return m_addr; } 32 33 virtual void SetLoadAddress(lldb::addr_t addr) { m_addr = addr; } 34 35 uint32_t GetByteSize() const { return m_byte_size; } 36 37 uint32_t GetHitCount() const { return m_hit_count; } 38 39 uint32_t GetHardwareIndex() const { return m_hardware_index; } 40 41 bool HardwareRequired() const { return m_hardware; } 42 43 virtual bool IsHardware() const { 44 return m_hardware_index != LLDB_INVALID_INDEX32; 45 } 46 47 virtual bool ShouldStop(StoppointCallbackContext *context) { return true; } 48 49 virtual void Dump(Stream *stream) const {} 50 51 void SetHardwareIndex(uint32_t index) { m_hardware_index = index; } 52 53 lldb::break_id_t GetID() const { return m_loc_id; } 54 55protected: 56 // Classes that inherit from StoppointLocation can see and modify these 57 lldb::break_id_t m_loc_id; // Stoppoint location ID 58 lldb::addr_t 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. 69 uint32_t 70 m_hit_count; // Number of times this breakpoint/watchpoint has been hit 71 72 // If you override this, be sure to call the base class to increment the 73 // internal counter. 74 void IncrementHitCount() { ++m_hit_count; } 75 76 void DecrementHitCount(); 77 78private: 79 // For StoppointLocation only 80 DISALLOW_COPY_AND_ASSIGN(StoppointLocation); 81 StoppointLocation() = delete; 82}; 83 84} // namespace lldb_private 85 86#endif // liblldb_StoppointLocation_h_ 87