[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / lldb / source / API / SBUnixSignals.cpp
blob277a92d21ae982578cabb8af2131454e9d7c1c6b
1 //===-- SBUnixSignals.cpp -------------------------------------------*- C++
2 //-*-===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
10 #include "SBReproducerPrivate.h"
11 #include "lldb/Target/Platform.h"
12 #include "lldb/Target/Process.h"
13 #include "lldb/Target/UnixSignals.h"
14 #include "lldb/lldb-defines.h"
16 #include "lldb/API/SBUnixSignals.h"
18 using namespace lldb;
19 using namespace lldb_private;
21 SBUnixSignals::SBUnixSignals() {
22 LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBUnixSignals);
25 SBUnixSignals::SBUnixSignals(const SBUnixSignals &rhs)
26 : m_opaque_wp(rhs.m_opaque_wp) {
27 LLDB_RECORD_CONSTRUCTOR(SBUnixSignals, (const lldb::SBUnixSignals &), rhs);
30 SBUnixSignals::SBUnixSignals(ProcessSP &process_sp)
31 : m_opaque_wp(process_sp ? process_sp->GetUnixSignals() : nullptr) {}
33 SBUnixSignals::SBUnixSignals(PlatformSP &platform_sp)
34 : m_opaque_wp(platform_sp ? platform_sp->GetUnixSignals() : nullptr) {}
36 const SBUnixSignals &SBUnixSignals::operator=(const SBUnixSignals &rhs) {
37 LLDB_RECORD_METHOD(const lldb::SBUnixSignals &,
38 SBUnixSignals, operator=,(const lldb::SBUnixSignals &),
39 rhs);
41 if (this != &rhs)
42 m_opaque_wp = rhs.m_opaque_wp;
43 return LLDB_RECORD_RESULT(*this);
46 SBUnixSignals::~SBUnixSignals() {}
48 UnixSignalsSP SBUnixSignals::GetSP() const { return m_opaque_wp.lock(); }
50 void SBUnixSignals::SetSP(const UnixSignalsSP &signals_sp) {
51 m_opaque_wp = signals_sp;
54 void SBUnixSignals::Clear() {
55 LLDB_RECORD_METHOD_NO_ARGS(void, SBUnixSignals, Clear);
57 m_opaque_wp.reset();
60 bool SBUnixSignals::IsValid() const {
61 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBUnixSignals, IsValid);
62 return this->operator bool();
64 SBUnixSignals::operator bool() const {
65 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBUnixSignals, operator bool);
67 return static_cast<bool>(GetSP());
70 const char *SBUnixSignals::GetSignalAsCString(int32_t signo) const {
71 LLDB_RECORD_METHOD_CONST(const char *, SBUnixSignals, GetSignalAsCString,
72 (int32_t), signo);
74 if (auto signals_sp = GetSP())
75 return signals_sp->GetSignalAsCString(signo);
77 return nullptr;
80 int32_t SBUnixSignals::GetSignalNumberFromName(const char *name) const {
81 LLDB_RECORD_METHOD_CONST(int32_t, SBUnixSignals, GetSignalNumberFromName,
82 (const char *), name);
84 if (auto signals_sp = GetSP())
85 return signals_sp->GetSignalNumberFromName(name);
87 return LLDB_INVALID_SIGNAL_NUMBER;
90 bool SBUnixSignals::GetShouldSuppress(int32_t signo) const {
91 LLDB_RECORD_METHOD_CONST(bool, SBUnixSignals, GetShouldSuppress, (int32_t),
92 signo);
94 if (auto signals_sp = GetSP())
95 return signals_sp->GetShouldSuppress(signo);
97 return false;
100 bool SBUnixSignals::SetShouldSuppress(int32_t signo, bool value) {
101 LLDB_RECORD_METHOD(bool, SBUnixSignals, SetShouldSuppress, (int32_t, bool),
102 signo, value);
104 auto signals_sp = GetSP();
106 if (signals_sp)
107 return signals_sp->SetShouldSuppress(signo, value);
109 return false;
112 bool SBUnixSignals::GetShouldStop(int32_t signo) const {
113 LLDB_RECORD_METHOD_CONST(bool, SBUnixSignals, GetShouldStop, (int32_t),
114 signo);
116 if (auto signals_sp = GetSP())
117 return signals_sp->GetShouldStop(signo);
119 return false;
122 bool SBUnixSignals::SetShouldStop(int32_t signo, bool value) {
123 LLDB_RECORD_METHOD(bool, SBUnixSignals, SetShouldStop, (int32_t, bool), signo,
124 value);
126 auto signals_sp = GetSP();
128 if (signals_sp)
129 return signals_sp->SetShouldStop(signo, value);
131 return false;
134 bool SBUnixSignals::GetShouldNotify(int32_t signo) const {
135 LLDB_RECORD_METHOD_CONST(bool, SBUnixSignals, GetShouldNotify, (int32_t),
136 signo);
138 if (auto signals_sp = GetSP())
139 return signals_sp->GetShouldNotify(signo);
141 return false;
144 bool SBUnixSignals::SetShouldNotify(int32_t signo, bool value) {
145 LLDB_RECORD_METHOD(bool, SBUnixSignals, SetShouldNotify, (int32_t, bool),
146 signo, value);
148 auto signals_sp = GetSP();
150 if (signals_sp)
151 return signals_sp->SetShouldNotify(signo, value);
153 return false;
156 int32_t SBUnixSignals::GetNumSignals() const {
157 LLDB_RECORD_METHOD_CONST_NO_ARGS(int32_t, SBUnixSignals, GetNumSignals);
159 if (auto signals_sp = GetSP())
160 return signals_sp->GetNumSignals();
162 return -1;
165 int32_t SBUnixSignals::GetSignalAtIndex(int32_t index) const {
166 LLDB_RECORD_METHOD_CONST(int32_t, SBUnixSignals, GetSignalAtIndex, (int32_t),
167 index);
169 if (auto signals_sp = GetSP())
170 return signals_sp->GetSignalAtIndex(index);
172 return LLDB_INVALID_SIGNAL_NUMBER;
175 namespace lldb_private {
176 namespace repro {
178 template <>
179 void RegisterMethods<SBUnixSignals>(Registry &R) {
180 LLDB_REGISTER_CONSTRUCTOR(SBUnixSignals, ());
181 LLDB_REGISTER_CONSTRUCTOR(SBUnixSignals, (const lldb::SBUnixSignals &));
182 LLDB_REGISTER_METHOD(
183 const lldb::SBUnixSignals &,
184 SBUnixSignals, operator=,(const lldb::SBUnixSignals &));
185 LLDB_REGISTER_METHOD(void, SBUnixSignals, Clear, ());
186 LLDB_REGISTER_METHOD_CONST(bool, SBUnixSignals, IsValid, ());
187 LLDB_REGISTER_METHOD_CONST(bool, SBUnixSignals, operator bool, ());
188 LLDB_REGISTER_METHOD_CONST(const char *, SBUnixSignals, GetSignalAsCString,
189 (int32_t));
190 LLDB_REGISTER_METHOD_CONST(int32_t, SBUnixSignals, GetSignalNumberFromName,
191 (const char *));
192 LLDB_REGISTER_METHOD_CONST(bool, SBUnixSignals, GetShouldSuppress,
193 (int32_t));
194 LLDB_REGISTER_METHOD(bool, SBUnixSignals, SetShouldSuppress,
195 (int32_t, bool));
196 LLDB_REGISTER_METHOD_CONST(bool, SBUnixSignals, GetShouldStop, (int32_t));
197 LLDB_REGISTER_METHOD(bool, SBUnixSignals, SetShouldStop, (int32_t, bool));
198 LLDB_REGISTER_METHOD_CONST(bool, SBUnixSignals, GetShouldNotify, (int32_t));
199 LLDB_REGISTER_METHOD(bool, SBUnixSignals, SetShouldNotify, (int32_t, bool));
200 LLDB_REGISTER_METHOD_CONST(int32_t, SBUnixSignals, GetNumSignals, ());
201 LLDB_REGISTER_METHOD_CONST(int32_t, SBUnixSignals, GetSignalAtIndex,
202 (int32_t));