blob: b0e3eb827b87adcfb3e489c9b385a3eb403e2f41 [file] [log] [blame]
Johnny Chen096c2932011-09-26 22:40:50 +00001//===-- SBWatchpointLocation.cpp --------------------------------*- 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#include "lldb/API/SBWatchpointLocation.h"
11#include "lldb/API/SBDefines.h"
12#include "lldb/API/SBAddress.h"
13#include "lldb/API/SBDebugger.h"
14#include "lldb/API/SBStream.h"
15
16#include "lldb/lldb-types.h"
17#include "lldb/lldb-defines.h"
18#include "lldb/Breakpoint/WatchpointLocation.h"
19#include "lldb/Breakpoint/WatchpointLocationList.h"
20#include "lldb/Core/Log.h"
21#include "lldb/Core/Stream.h"
22#include "lldb/Core/StreamFile.h"
23#include "lldb/Target/Target.h"
24
25using namespace lldb;
26using namespace lldb_private;
27
28
29SBWatchpointLocation::SBWatchpointLocation () :
30 m_opaque_sp ()
31{
32}
33
34SBWatchpointLocation::SBWatchpointLocation (const lldb::WatchpointLocationSP &watch_loc_sp) :
35 m_opaque_sp (watch_loc_sp)
36{
37 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
38
39 if (log)
40 {
41 SBStream sstr;
42 GetDescription (sstr, lldb::eDescriptionLevelBrief);
43 log->Printf ("SBWatchpointLocation::SBWatchpointLocation (const lldb::WatchpointLocationsSP &watch_loc_sp"
44 "=%p) => this.sp = %p (%s)", watch_loc_sp.get(), m_opaque_sp.get(), sstr.GetData());
45 }
46}
47
48SBWatchpointLocation::SBWatchpointLocation(const SBWatchpointLocation &rhs) :
49 m_opaque_sp (rhs.m_opaque_sp)
50{
51}
52
53const SBWatchpointLocation &
54SBWatchpointLocation::operator = (const SBWatchpointLocation &rhs)
55{
56 if (this != &rhs)
57 m_opaque_sp = rhs.m_opaque_sp;
58 return *this;
59}
60
61
62SBWatchpointLocation::~SBWatchpointLocation ()
63{
64}
65
66bool
67SBWatchpointLocation::IsValid() const
68{
69 return m_opaque_sp.get() != NULL;
70}
71
72addr_t
73SBWatchpointLocation::GetWatchAddress () const
74{
75 addr_t ret_addr = LLDB_INVALID_ADDRESS;
76
77 if (m_opaque_sp)
78 {
79 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
80 ret_addr = m_opaque_sp->GetLoadAddress();
81 }
82
83 return ret_addr;
84}
85
86size_t
87SBWatchpointLocation::GetWatchSize () const
88{
89 size_t watch_size = 0;
90
91 if (m_opaque_sp)
92 {
93 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
94 watch_size = m_opaque_sp->GetByteSize();
95 }
96
97 return watch_size;
98}
99
100void
101SBWatchpointLocation::SetEnabled (bool enabled)
102{
103 if (m_opaque_sp)
104 {
105 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
106 m_opaque_sp->SetEnabled (enabled);
107 }
108}
109
110bool
111SBWatchpointLocation::IsEnabled ()
112{
113 if (m_opaque_sp)
114 {
115 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
116 return m_opaque_sp->IsEnabled();
117 }
118 else
119 return false;
120}
121
122uint32_t
123SBWatchpointLocation::GetIgnoreCount ()
124{
125 if (m_opaque_sp)
126 {
127 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
128 return m_opaque_sp->GetIgnoreCount();
129 }
130 else
131 return 0;
132}
133
134void
135SBWatchpointLocation::SetIgnoreCount (uint32_t n)
136{
137 if (m_opaque_sp)
138 {
139 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
140 m_opaque_sp->SetIgnoreCount (n);
141 }
142}
143
144bool
145SBWatchpointLocation::GetDescription (SBStream &description, DescriptionLevel level)
146{
147 if (m_opaque_sp)
148 {
149 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
150 description.ref();
151 m_opaque_sp->GetDescription (description.get(), level);
152 description.get()->EOL();
153 }
154 else
155 description.Printf ("No value");
156
157 return true;
158}
159
160lldb_private::WatchpointLocation *
161SBWatchpointLocation::operator->() const
162{
163 return m_opaque_sp.get();
164}
165
166lldb_private::WatchpointLocation *
167SBWatchpointLocation::get() const
168{
169 return m_opaque_sp.get();
170}
171
172lldb::WatchpointLocationSP &
173SBWatchpointLocation::operator *()
174{
175 return m_opaque_sp;
176}
177
178const lldb::WatchpointLocationSP &
179SBWatchpointLocation::operator *() const
180{
181 return m_opaque_sp;
182}
183