1 //===-- SBWatchpointOptions.cpp -------------------------------------------===// 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 #include "lldb/API/SBWatchpointOptions.h" 10 #include "lldb/Breakpoint/Watchpoint.h" 11 #include "lldb/Utility/Instrumentation.h" 12 13 #include "Utils.h" 14 15 using namespace lldb; 16 using namespace lldb_private; 17 18 class WatchpointOptionsImpl { 19 public: 20 bool m_read = false; 21 bool m_write = false; 22 bool m_modify = false; 23 }; 24 25 SBWatchpointOptions()26SBWatchpointOptions::SBWatchpointOptions() 27 : m_opaque_up(new WatchpointOptionsImpl()) { 28 LLDB_INSTRUMENT_VA(this); 29 } 30 SBWatchpointOptions(const SBWatchpointOptions & rhs)31SBWatchpointOptions::SBWatchpointOptions(const SBWatchpointOptions &rhs) { 32 LLDB_INSTRUMENT_VA(this, rhs); 33 34 m_opaque_up = clone(rhs.m_opaque_up); 35 } 36 37 const SBWatchpointOptions & operator =(const SBWatchpointOptions & rhs)38SBWatchpointOptions::operator=(const SBWatchpointOptions &rhs) { 39 LLDB_INSTRUMENT_VA(this, rhs); 40 41 if (this != &rhs) 42 m_opaque_up = clone(rhs.m_opaque_up); 43 return *this; 44 } 45 46 SBWatchpointOptions::~SBWatchpointOptions() = default; 47 SetWatchpointTypeRead(bool read)48void SBWatchpointOptions::SetWatchpointTypeRead(bool read) { 49 m_opaque_up->m_read = read; 50 } GetWatchpointTypeRead() const51bool SBWatchpointOptions::GetWatchpointTypeRead() const { 52 return m_opaque_up->m_read; 53 } 54 SetWatchpointTypeWrite(WatchpointWriteType write_type)55void SBWatchpointOptions::SetWatchpointTypeWrite( 56 WatchpointWriteType write_type) { 57 if (write_type == eWatchpointWriteTypeOnModify) { 58 m_opaque_up->m_write = false; 59 m_opaque_up->m_modify = true; 60 } else if (write_type == eWatchpointWriteTypeAlways) { 61 m_opaque_up->m_write = true; 62 m_opaque_up->m_modify = false; 63 } else 64 m_opaque_up->m_write = m_opaque_up->m_modify = false; 65 } 66 GetWatchpointTypeWrite() const67WatchpointWriteType SBWatchpointOptions::GetWatchpointTypeWrite() const { 68 if (m_opaque_up->m_modify) 69 return eWatchpointWriteTypeOnModify; 70 if (m_opaque_up->m_write) 71 return eWatchpointWriteTypeAlways; 72 return eWatchpointWriteTypeDisabled; 73 } 74