1 //===-- SBWatchpointOptions.cpp -------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "lldb/API/SBWatchpointOptions.h"
10 #include "lldb/Breakpoint/Watchpoint.h"
11 #include "lldb/Utility/Instrumentation.h"
16 using namespace lldb_private
;
18 class WatchpointOptionsImpl
{
22 bool m_modify
= false;
26 SBWatchpointOptions::SBWatchpointOptions()
27 : m_opaque_up(new WatchpointOptionsImpl()) {
28 LLDB_INSTRUMENT_VA(this);
31 SBWatchpointOptions::SBWatchpointOptions(const SBWatchpointOptions
&rhs
) {
32 LLDB_INSTRUMENT_VA(this, rhs
);
34 m_opaque_up
= clone(rhs
.m_opaque_up
);
37 const SBWatchpointOptions
&
38 SBWatchpointOptions::operator=(const SBWatchpointOptions
&rhs
) {
39 LLDB_INSTRUMENT_VA(this, rhs
);
42 m_opaque_up
= clone(rhs
.m_opaque_up
);
46 SBWatchpointOptions::~SBWatchpointOptions() = default;
48 void SBWatchpointOptions::SetWatchpointTypeRead(bool read
) {
49 m_opaque_up
->m_read
= read
;
51 bool SBWatchpointOptions::GetWatchpointTypeRead() const {
52 return m_opaque_up
->m_read
;
55 void 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;
64 m_opaque_up
->m_write
= m_opaque_up
->m_modify
= false;
67 WatchpointWriteType
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
;