1 //===-- SoftwareBreakpoint.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_SoftwareBreakpoint_h_ 11 #define liblldb_SoftwareBreakpoint_h_ 12 13 #include "lldb/lldb-private-forward.h" 14 #include "NativeBreakpoint.h" 15 16 namespace lldb_private 17 { 18 class SoftwareBreakpoint : public NativeBreakpoint 19 { 20 friend class NativeBreakpointList; 21 22 public: 23 static Error 24 CreateSoftwareBreakpoint (NativeProcessProtocol &process, lldb::addr_t addr, size_t size_hint, NativeBreakpointSP &breakpoint_spn); 25 26 SoftwareBreakpoint (NativeProcessProtocol &process, lldb::addr_t addr, const uint8_t *saved_opcodes, const uint8_t *trap_opcodes, size_t opcode_size); 27 28 protected: 29 Error 30 DoEnable () override; 31 32 Error 33 DoDisable () override; 34 35 bool 36 IsSoftwareBreakpoint () const override; 37 38 private: 39 /// Max number of bytes that a software trap opcode sequence can occupy. 40 static const size_t MAX_TRAP_OPCODE_SIZE = 8; 41 42 NativeProcessProtocol &m_process; 43 uint8_t m_saved_opcodes [MAX_TRAP_OPCODE_SIZE]; 44 uint8_t m_trap_opcodes [MAX_TRAP_OPCODE_SIZE]; 45 const size_t m_opcode_size; 46 47 static Error 48 EnableSoftwareBreakpoint (NativeProcessProtocol &process, lldb::addr_t addr, size_t bp_opcode_size, const uint8_t *bp_opcode_bytes, uint8_t *saved_opcode_bytes); 49 50 }; 51 } 52 53 #endif // #ifndef liblldb_SoftwareBreakpoint_h_ 54