1 //===-- NativeBreakpoint.cpp ------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/Host/common/NativeBreakpoint.h"
12 #include "lldb/Utility/Log.h"
13 #include "lldb/Utility/Status.h"
14 #include "lldb/lldb-defines.h"
16 using namespace lldb_private;
18 NativeBreakpoint::NativeBreakpoint(lldb::addr_t addr)
19 : m_addr(addr), m_ref_count(1), m_enabled(true) {
20 assert(addr != LLDB_INVALID_ADDRESS && "breakpoint set for invalid address");
23 NativeBreakpoint::~NativeBreakpoint() {}
25 void NativeBreakpoint::AddRef() {
28 Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
30 log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64
31 " bumped up, new ref count %" PRIu32,
32 __FUNCTION__, m_addr, m_ref_count);
35 int32_t NativeBreakpoint::DecRef() {
38 Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
40 log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64
41 " ref count decremented, new ref count %" PRIu32,
42 __FUNCTION__, m_addr, m_ref_count);
47 Status NativeBreakpoint::Enable() {
48 Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
51 // We're already enabled. Just log and exit.
53 log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64
54 " already enabled, ignoring.",
55 __FUNCTION__, m_addr);
61 log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64 " enabling...",
62 __FUNCTION__, m_addr);
64 Status error = DoEnable();
65 if (error.Success()) {
68 log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64 " enable SUCCESS.",
69 __FUNCTION__, m_addr);
72 log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64 " enable FAIL: %s",
73 __FUNCTION__, m_addr, error.AsCString());
79 Status NativeBreakpoint::Disable() {
80 Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
83 // We're already disabled. Just log and exit.
85 log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64
86 " already disabled, ignoring.",
87 __FUNCTION__, m_addr);
93 log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64 " disabling...",
94 __FUNCTION__, m_addr);
96 Status error = DoDisable();
97 if (error.Success()) {
100 log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64 " disable SUCCESS.",
101 __FUNCTION__, m_addr);
104 log->Printf("NativeBreakpoint::%s addr = 0x%" PRIx64 " disable FAIL: %s",
105 __FUNCTION__, m_addr, error.AsCString());