15ffd83dbSDimitry Andric //===-- SBWatchpoint.cpp --------------------------------------------------===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric 
90b57cec5SDimitry Andric #include "lldb/API/SBWatchpoint.h"
100b57cec5SDimitry Andric #include "lldb/API/SBAddress.h"
110b57cec5SDimitry Andric #include "lldb/API/SBDebugger.h"
120b57cec5SDimitry Andric #include "lldb/API/SBDefines.h"
130b57cec5SDimitry Andric #include "lldb/API/SBEvent.h"
140b57cec5SDimitry Andric #include "lldb/API/SBStream.h"
1504eeddc0SDimitry Andric #include "lldb/Utility/Instrumentation.h"
160b57cec5SDimitry Andric 
170b57cec5SDimitry Andric #include "lldb/Breakpoint/Watchpoint.h"
180b57cec5SDimitry Andric #include "lldb/Breakpoint/WatchpointList.h"
19fe013be4SDimitry Andric #include "lldb/Symbol/CompilerType.h"
200b57cec5SDimitry Andric #include "lldb/Target/Process.h"
210b57cec5SDimitry Andric #include "lldb/Target/Target.h"
220b57cec5SDimitry Andric #include "lldb/Utility/Stream.h"
230b57cec5SDimitry Andric #include "lldb/lldb-defines.h"
240b57cec5SDimitry Andric #include "lldb/lldb-types.h"
250b57cec5SDimitry Andric 
260b57cec5SDimitry Andric using namespace lldb;
270b57cec5SDimitry Andric using namespace lldb_private;
280b57cec5SDimitry Andric 
SBWatchpoint()2904eeddc0SDimitry Andric SBWatchpoint::SBWatchpoint() { LLDB_INSTRUMENT_VA(this); }
300b57cec5SDimitry Andric 
SBWatchpoint(const lldb::WatchpointSP & wp_sp)310b57cec5SDimitry Andric SBWatchpoint::SBWatchpoint(const lldb::WatchpointSP &wp_sp)
320b57cec5SDimitry Andric     : m_opaque_wp(wp_sp) {
3304eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this, wp_sp);
340b57cec5SDimitry Andric }
350b57cec5SDimitry Andric 
SBWatchpoint(const SBWatchpoint & rhs)360b57cec5SDimitry Andric SBWatchpoint::SBWatchpoint(const SBWatchpoint &rhs)
370b57cec5SDimitry Andric     : m_opaque_wp(rhs.m_opaque_wp) {
3804eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this, rhs);
390b57cec5SDimitry Andric }
400b57cec5SDimitry Andric 
operator =(const SBWatchpoint & rhs)410b57cec5SDimitry Andric const SBWatchpoint &SBWatchpoint::operator=(const SBWatchpoint &rhs) {
4204eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this, rhs);
430b57cec5SDimitry Andric 
440b57cec5SDimitry Andric   m_opaque_wp = rhs.m_opaque_wp;
4504eeddc0SDimitry Andric   return *this;
460b57cec5SDimitry Andric }
470b57cec5SDimitry Andric 
485ffd83dbSDimitry Andric SBWatchpoint::~SBWatchpoint() = default;
490b57cec5SDimitry Andric 
GetID()500b57cec5SDimitry Andric watch_id_t SBWatchpoint::GetID() {
5104eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this);
520b57cec5SDimitry Andric 
530b57cec5SDimitry Andric   watch_id_t watch_id = LLDB_INVALID_WATCH_ID;
540b57cec5SDimitry Andric   lldb::WatchpointSP watchpoint_sp(GetSP());
550b57cec5SDimitry Andric   if (watchpoint_sp)
560b57cec5SDimitry Andric     watch_id = watchpoint_sp->GetID();
570b57cec5SDimitry Andric 
580b57cec5SDimitry Andric   return watch_id;
590b57cec5SDimitry Andric }
600b57cec5SDimitry Andric 
IsValid() const610b57cec5SDimitry Andric bool SBWatchpoint::IsValid() const {
6204eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this);
630b57cec5SDimitry Andric   return this->operator bool();
640b57cec5SDimitry Andric }
operator bool() const650b57cec5SDimitry Andric SBWatchpoint::operator bool() const {
6604eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this);
670b57cec5SDimitry Andric 
680b57cec5SDimitry Andric   return bool(m_opaque_wp.lock());
690b57cec5SDimitry Andric }
700b57cec5SDimitry Andric 
operator ==(const SBWatchpoint & rhs) const710b57cec5SDimitry Andric bool SBWatchpoint::operator==(const SBWatchpoint &rhs) const {
7204eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this, rhs);
730b57cec5SDimitry Andric 
740b57cec5SDimitry Andric   return GetSP() == rhs.GetSP();
750b57cec5SDimitry Andric }
760b57cec5SDimitry Andric 
operator !=(const SBWatchpoint & rhs) const770b57cec5SDimitry Andric bool SBWatchpoint::operator!=(const SBWatchpoint &rhs) const {
7804eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this, rhs);
790b57cec5SDimitry Andric 
800b57cec5SDimitry Andric   return !(*this == rhs);
810b57cec5SDimitry Andric }
820b57cec5SDimitry Andric 
GetError()830b57cec5SDimitry Andric SBError SBWatchpoint::GetError() {
8404eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this);
850b57cec5SDimitry Andric 
860b57cec5SDimitry Andric   SBError sb_error;
870b57cec5SDimitry Andric   lldb::WatchpointSP watchpoint_sp(GetSP());
880b57cec5SDimitry Andric   if (watchpoint_sp) {
890b57cec5SDimitry Andric     sb_error.SetError(watchpoint_sp->GetError());
900b57cec5SDimitry Andric   }
9104eeddc0SDimitry Andric   return sb_error;
920b57cec5SDimitry Andric }
930b57cec5SDimitry Andric 
GetHardwareIndex()940b57cec5SDimitry Andric int32_t SBWatchpoint::GetHardwareIndex() {
9504eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this);
960b57cec5SDimitry Andric 
97*c9157d92SDimitry Andric   // For processes using gdb remote protocol,
98*c9157d92SDimitry Andric   // we cannot determine the hardware breakpoint
99*c9157d92SDimitry Andric   // index reliably; providing possibly correct
100*c9157d92SDimitry Andric   // guesses is not useful to anyone.
101*c9157d92SDimitry Andric   return -1;
1020b57cec5SDimitry Andric }
1030b57cec5SDimitry Andric 
GetWatchAddress()1040b57cec5SDimitry Andric addr_t SBWatchpoint::GetWatchAddress() {
10504eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1060b57cec5SDimitry Andric 
1070b57cec5SDimitry Andric   addr_t ret_addr = LLDB_INVALID_ADDRESS;
1080b57cec5SDimitry Andric 
1090b57cec5SDimitry Andric   lldb::WatchpointSP watchpoint_sp(GetSP());
1100b57cec5SDimitry Andric   if (watchpoint_sp) {
1110b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
1120b57cec5SDimitry Andric         watchpoint_sp->GetTarget().GetAPIMutex());
1130b57cec5SDimitry Andric     ret_addr = watchpoint_sp->GetLoadAddress();
1140b57cec5SDimitry Andric   }
1150b57cec5SDimitry Andric 
1160b57cec5SDimitry Andric   return ret_addr;
1170b57cec5SDimitry Andric }
1180b57cec5SDimitry Andric 
GetWatchSize()1190b57cec5SDimitry Andric size_t SBWatchpoint::GetWatchSize() {
12004eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1210b57cec5SDimitry Andric 
1220b57cec5SDimitry Andric   size_t watch_size = 0;
1230b57cec5SDimitry Andric 
1240b57cec5SDimitry Andric   lldb::WatchpointSP watchpoint_sp(GetSP());
1250b57cec5SDimitry Andric   if (watchpoint_sp) {
1260b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
1270b57cec5SDimitry Andric         watchpoint_sp->GetTarget().GetAPIMutex());
1280b57cec5SDimitry Andric     watch_size = watchpoint_sp->GetByteSize();
1290b57cec5SDimitry Andric   }
1300b57cec5SDimitry Andric 
1310b57cec5SDimitry Andric   return watch_size;
1320b57cec5SDimitry Andric }
1330b57cec5SDimitry Andric 
SetEnabled(bool enabled)1340b57cec5SDimitry Andric void SBWatchpoint::SetEnabled(bool enabled) {
13504eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this, enabled);
1360b57cec5SDimitry Andric 
1370b57cec5SDimitry Andric   lldb::WatchpointSP watchpoint_sp(GetSP());
1380b57cec5SDimitry Andric   if (watchpoint_sp) {
1390b57cec5SDimitry Andric     Target &target = watchpoint_sp->GetTarget();
1400b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(target.GetAPIMutex());
1410b57cec5SDimitry Andric     ProcessSP process_sp = target.GetProcessSP();
1420b57cec5SDimitry Andric     const bool notify = true;
1430b57cec5SDimitry Andric     if (process_sp) {
1440b57cec5SDimitry Andric       if (enabled)
145*c9157d92SDimitry Andric         process_sp->EnableWatchpoint(watchpoint_sp, notify);
1460b57cec5SDimitry Andric       else
147*c9157d92SDimitry Andric         process_sp->DisableWatchpoint(watchpoint_sp, notify);
1480b57cec5SDimitry Andric     } else {
1490b57cec5SDimitry Andric       watchpoint_sp->SetEnabled(enabled, notify);
1500b57cec5SDimitry Andric     }
1510b57cec5SDimitry Andric   }
1520b57cec5SDimitry Andric }
1530b57cec5SDimitry Andric 
IsEnabled()1540b57cec5SDimitry Andric bool SBWatchpoint::IsEnabled() {
15504eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1560b57cec5SDimitry Andric 
1570b57cec5SDimitry Andric   lldb::WatchpointSP watchpoint_sp(GetSP());
1580b57cec5SDimitry Andric   if (watchpoint_sp) {
1590b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
1600b57cec5SDimitry Andric         watchpoint_sp->GetTarget().GetAPIMutex());
1610b57cec5SDimitry Andric     return watchpoint_sp->IsEnabled();
1620b57cec5SDimitry Andric   } else
1630b57cec5SDimitry Andric     return false;
1640b57cec5SDimitry Andric }
1650b57cec5SDimitry Andric 
GetHitCount()1660b57cec5SDimitry Andric uint32_t SBWatchpoint::GetHitCount() {
16704eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1680b57cec5SDimitry Andric 
1690b57cec5SDimitry Andric   uint32_t count = 0;
1700b57cec5SDimitry Andric   lldb::WatchpointSP watchpoint_sp(GetSP());
1710b57cec5SDimitry Andric   if (watchpoint_sp) {
1720b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
1730b57cec5SDimitry Andric         watchpoint_sp->GetTarget().GetAPIMutex());
1740b57cec5SDimitry Andric     count = watchpoint_sp->GetHitCount();
1750b57cec5SDimitry Andric   }
1760b57cec5SDimitry Andric 
1770b57cec5SDimitry Andric   return count;
1780b57cec5SDimitry Andric }
1790b57cec5SDimitry Andric 
GetIgnoreCount()1800b57cec5SDimitry Andric uint32_t SBWatchpoint::GetIgnoreCount() {
18104eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this);
1820b57cec5SDimitry Andric 
1830b57cec5SDimitry Andric   lldb::WatchpointSP watchpoint_sp(GetSP());
1840b57cec5SDimitry Andric   if (watchpoint_sp) {
1850b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
1860b57cec5SDimitry Andric         watchpoint_sp->GetTarget().GetAPIMutex());
1870b57cec5SDimitry Andric     return watchpoint_sp->GetIgnoreCount();
1880b57cec5SDimitry Andric   } else
1890b57cec5SDimitry Andric     return 0;
1900b57cec5SDimitry Andric }
1910b57cec5SDimitry Andric 
SetIgnoreCount(uint32_t n)1920b57cec5SDimitry Andric void SBWatchpoint::SetIgnoreCount(uint32_t n) {
19304eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this, n);
1940b57cec5SDimitry Andric 
1950b57cec5SDimitry Andric   lldb::WatchpointSP watchpoint_sp(GetSP());
1960b57cec5SDimitry Andric   if (watchpoint_sp) {
1970b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
1980b57cec5SDimitry Andric         watchpoint_sp->GetTarget().GetAPIMutex());
1990b57cec5SDimitry Andric     watchpoint_sp->SetIgnoreCount(n);
2000b57cec5SDimitry Andric   }
2010b57cec5SDimitry Andric }
2020b57cec5SDimitry Andric 
GetCondition()2030b57cec5SDimitry Andric const char *SBWatchpoint::GetCondition() {
20404eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this);
2050b57cec5SDimitry Andric 
2060b57cec5SDimitry Andric   lldb::WatchpointSP watchpoint_sp(GetSP());
207fe013be4SDimitry Andric   if (!watchpoint_sp)
208fe013be4SDimitry Andric     return nullptr;
209fe013be4SDimitry Andric 
2100b57cec5SDimitry Andric   std::lock_guard<std::recursive_mutex> guard(
2110b57cec5SDimitry Andric       watchpoint_sp->GetTarget().GetAPIMutex());
212fe013be4SDimitry Andric   return ConstString(watchpoint_sp->GetConditionText()).GetCString();
2130b57cec5SDimitry Andric }
2140b57cec5SDimitry Andric 
SetCondition(const char * condition)2150b57cec5SDimitry Andric void SBWatchpoint::SetCondition(const char *condition) {
21604eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this, condition);
2170b57cec5SDimitry Andric 
2180b57cec5SDimitry Andric   lldb::WatchpointSP watchpoint_sp(GetSP());
2190b57cec5SDimitry Andric   if (watchpoint_sp) {
2200b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
2210b57cec5SDimitry Andric         watchpoint_sp->GetTarget().GetAPIMutex());
2220b57cec5SDimitry Andric     watchpoint_sp->SetCondition(condition);
2230b57cec5SDimitry Andric   }
2240b57cec5SDimitry Andric }
2250b57cec5SDimitry Andric 
GetDescription(SBStream & description,DescriptionLevel level)2260b57cec5SDimitry Andric bool SBWatchpoint::GetDescription(SBStream &description,
2270b57cec5SDimitry Andric                                   DescriptionLevel level) {
22804eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this, description, level);
2290b57cec5SDimitry Andric 
2300b57cec5SDimitry Andric   Stream &strm = description.ref();
2310b57cec5SDimitry Andric 
2320b57cec5SDimitry Andric   lldb::WatchpointSP watchpoint_sp(GetSP());
2330b57cec5SDimitry Andric   if (watchpoint_sp) {
2340b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
2350b57cec5SDimitry Andric         watchpoint_sp->GetTarget().GetAPIMutex());
2360b57cec5SDimitry Andric     watchpoint_sp->GetDescription(&strm, level);
2370b57cec5SDimitry Andric     strm.EOL();
2380b57cec5SDimitry Andric   } else
2390b57cec5SDimitry Andric     strm.PutCString("No value");
2400b57cec5SDimitry Andric 
2410b57cec5SDimitry Andric   return true;
2420b57cec5SDimitry Andric }
2430b57cec5SDimitry Andric 
Clear()2440b57cec5SDimitry Andric void SBWatchpoint::Clear() {
24504eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this);
2460b57cec5SDimitry Andric 
2470b57cec5SDimitry Andric   m_opaque_wp.reset();
2480b57cec5SDimitry Andric }
2490b57cec5SDimitry Andric 
GetSP() const2500b57cec5SDimitry Andric lldb::WatchpointSP SBWatchpoint::GetSP() const {
25104eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this);
2520b57cec5SDimitry Andric 
25304eeddc0SDimitry Andric   return m_opaque_wp.lock();
2540b57cec5SDimitry Andric }
2550b57cec5SDimitry Andric 
SetSP(const lldb::WatchpointSP & sp)2560b57cec5SDimitry Andric void SBWatchpoint::SetSP(const lldb::WatchpointSP &sp) {
25704eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(this, sp);
2580b57cec5SDimitry Andric 
2590b57cec5SDimitry Andric   m_opaque_wp = sp;
2600b57cec5SDimitry Andric }
2610b57cec5SDimitry Andric 
EventIsWatchpointEvent(const lldb::SBEvent & event)2620b57cec5SDimitry Andric bool SBWatchpoint::EventIsWatchpointEvent(const lldb::SBEvent &event) {
26304eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(event);
2640b57cec5SDimitry Andric 
2650b57cec5SDimitry Andric   return Watchpoint::WatchpointEventData::GetEventDataFromEvent(event.get()) !=
2660b57cec5SDimitry Andric          nullptr;
2670b57cec5SDimitry Andric }
2680b57cec5SDimitry Andric 
2690b57cec5SDimitry Andric WatchpointEventType
GetWatchpointEventTypeFromEvent(const SBEvent & event)2700b57cec5SDimitry Andric SBWatchpoint::GetWatchpointEventTypeFromEvent(const SBEvent &event) {
27104eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(event);
2720b57cec5SDimitry Andric 
2730b57cec5SDimitry Andric   if (event.IsValid())
2740b57cec5SDimitry Andric     return Watchpoint::WatchpointEventData::GetWatchpointEventTypeFromEvent(
2750b57cec5SDimitry Andric         event.GetSP());
2760b57cec5SDimitry Andric   return eWatchpointEventTypeInvalidType;
2770b57cec5SDimitry Andric }
2780b57cec5SDimitry Andric 
GetWatchpointFromEvent(const lldb::SBEvent & event)2790b57cec5SDimitry Andric SBWatchpoint SBWatchpoint::GetWatchpointFromEvent(const lldb::SBEvent &event) {
28004eeddc0SDimitry Andric   LLDB_INSTRUMENT_VA(event);
2810b57cec5SDimitry Andric 
2820b57cec5SDimitry Andric   SBWatchpoint sb_watchpoint;
2830b57cec5SDimitry Andric   if (event.IsValid())
2840b57cec5SDimitry Andric     sb_watchpoint =
2850b57cec5SDimitry Andric         Watchpoint::WatchpointEventData::GetWatchpointFromEvent(event.GetSP());
28604eeddc0SDimitry Andric   return sb_watchpoint;
2870b57cec5SDimitry Andric }
288fe013be4SDimitry Andric 
GetType()289fe013be4SDimitry Andric lldb::SBType SBWatchpoint::GetType() {
290fe013be4SDimitry Andric   LLDB_INSTRUMENT_VA(this);
291fe013be4SDimitry Andric 
292fe013be4SDimitry Andric   lldb::WatchpointSP watchpoint_sp(GetSP());
293fe013be4SDimitry Andric   if (watchpoint_sp) {
294fe013be4SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
295fe013be4SDimitry Andric         watchpoint_sp->GetTarget().GetAPIMutex());
296fe013be4SDimitry Andric     const CompilerType &type = watchpoint_sp->GetCompilerType();
297fe013be4SDimitry Andric     return lldb::SBType(type);
298fe013be4SDimitry Andric   }
299fe013be4SDimitry Andric   return lldb::SBType();
300fe013be4SDimitry Andric }
301fe013be4SDimitry Andric 
GetWatchValueKind()302fe013be4SDimitry Andric WatchpointValueKind SBWatchpoint::GetWatchValueKind() {
303fe013be4SDimitry Andric   LLDB_INSTRUMENT_VA(this);
304fe013be4SDimitry Andric 
305fe013be4SDimitry Andric   lldb::WatchpointSP watchpoint_sp(GetSP());
306fe013be4SDimitry Andric   if (watchpoint_sp) {
307fe013be4SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
308fe013be4SDimitry Andric         watchpoint_sp->GetTarget().GetAPIMutex());
309fe013be4SDimitry Andric     if (watchpoint_sp->IsWatchVariable())
310fe013be4SDimitry Andric       return WatchpointValueKind::eWatchPointValueKindVariable;
311fe013be4SDimitry Andric     return WatchpointValueKind::eWatchPointValueKindExpression;
312fe013be4SDimitry Andric   }
313fe013be4SDimitry Andric   return WatchpointValueKind::eWatchPointValueKindInvalid;
314fe013be4SDimitry Andric }
315fe013be4SDimitry Andric 
GetWatchSpec()316fe013be4SDimitry Andric const char *SBWatchpoint::GetWatchSpec() {
317fe013be4SDimitry Andric   LLDB_INSTRUMENT_VA(this);
318fe013be4SDimitry Andric 
319fe013be4SDimitry Andric   lldb::WatchpointSP watchpoint_sp(GetSP());
320fe013be4SDimitry Andric   if (!watchpoint_sp)
321fe013be4SDimitry Andric     return nullptr;
322fe013be4SDimitry Andric 
323fe013be4SDimitry Andric   std::lock_guard<std::recursive_mutex> guard(
324fe013be4SDimitry Andric       watchpoint_sp->GetTarget().GetAPIMutex());
325fe013be4SDimitry Andric   // Store the result of `GetWatchSpec()` as a ConstString
326fe013be4SDimitry Andric   // so that the C string we return has a sufficiently long
327fe013be4SDimitry Andric   // lifetime. Note this a memory leak but should be fairly
328fe013be4SDimitry Andric   // low impact.
329fe013be4SDimitry Andric   return ConstString(watchpoint_sp->GetWatchSpec()).AsCString();
330fe013be4SDimitry Andric }
331fe013be4SDimitry Andric 
IsWatchingReads()332fe013be4SDimitry Andric bool SBWatchpoint::IsWatchingReads() {
333fe013be4SDimitry Andric   LLDB_INSTRUMENT_VA(this);
334fe013be4SDimitry Andric   lldb::WatchpointSP watchpoint_sp(GetSP());
335fe013be4SDimitry Andric   if (watchpoint_sp) {
336fe013be4SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
337fe013be4SDimitry Andric         watchpoint_sp->GetTarget().GetAPIMutex());
338fe013be4SDimitry Andric 
339fe013be4SDimitry Andric     return watchpoint_sp->WatchpointRead();
340fe013be4SDimitry Andric   }
341fe013be4SDimitry Andric 
342fe013be4SDimitry Andric   return false;
343fe013be4SDimitry Andric }
344fe013be4SDimitry Andric 
IsWatchingWrites()345fe013be4SDimitry Andric bool SBWatchpoint::IsWatchingWrites() {
346fe013be4SDimitry Andric   LLDB_INSTRUMENT_VA(this);
347fe013be4SDimitry Andric   lldb::WatchpointSP watchpoint_sp(GetSP());
348fe013be4SDimitry Andric   if (watchpoint_sp) {
349fe013be4SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
350fe013be4SDimitry Andric         watchpoint_sp->GetTarget().GetAPIMutex());
351fe013be4SDimitry Andric 
352*c9157d92SDimitry Andric     return watchpoint_sp->WatchpointWrite() ||
353*c9157d92SDimitry Andric            watchpoint_sp->WatchpointModify();
354fe013be4SDimitry Andric   }
355fe013be4SDimitry Andric 
356fe013be4SDimitry Andric   return false;
357fe013be4SDimitry Andric }
358