LLDB  mainline
SBUnixSignals.cpp
Go to the documentation of this file.
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 //===----------------------------------------------------------------------===//
9 
10 #include "SBReproducerPrivate.h"
11 #include "lldb/Target/Platform.h"
12 #include "lldb/Target/Process.h"
14 #include "lldb/lldb-defines.h"
15 
16 #include "lldb/API/SBUnixSignals.h"
17 
18 using namespace lldb;
19 using namespace lldb_private;
20 
23 }
24 
26  : m_opaque_wp(rhs.m_opaque_wp) {
28 }
29 
30 SBUnixSignals::SBUnixSignals(ProcessSP &process_sp)
31  : m_opaque_wp(process_sp ? process_sp->GetUnixSignals() : nullptr) {}
32 
33 SBUnixSignals::SBUnixSignals(PlatformSP &platform_sp)
34  : m_opaque_wp(platform_sp ? platform_sp->GetUnixSignals() : nullptr) {}
35 
38  SBUnixSignals, operator=,(const lldb::SBUnixSignals &),
39  rhs);
40 
41  if (this != &rhs)
42  m_opaque_wp = rhs.m_opaque_wp;
43  return LLDB_RECORD_RESULT(*this);
44 }
45 
47 
48 UnixSignalsSP SBUnixSignals::GetSP() const { return m_opaque_wp.lock(); }
49 
50 void SBUnixSignals::SetSP(const UnixSignalsSP &signals_sp) {
51  m_opaque_wp = signals_sp;
52 }
53 
56 
57  m_opaque_wp.reset();
58 }
59 
60 bool SBUnixSignals::IsValid() const {
62  return this->operator bool();
63 }
64 SBUnixSignals::operator bool() const {
65  LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBUnixSignals, operator bool);
66 
67  return static_cast<bool>(GetSP());
68 }
69 
70 const char *SBUnixSignals::GetSignalAsCString(int32_t signo) const {
72  (int32_t), signo);
73 
74  if (auto signals_sp = GetSP())
75  return signals_sp->GetSignalAsCString(signo);
76 
77  return nullptr;
78 }
79 
80 int32_t SBUnixSignals::GetSignalNumberFromName(const char *name) const {
82  (const char *), name);
83 
84  if (auto signals_sp = GetSP())
85  return signals_sp->GetSignalNumberFromName(name);
86 
88 }
89 
90 bool SBUnixSignals::GetShouldSuppress(int32_t signo) const {
92  signo);
93 
94  if (auto signals_sp = GetSP())
95  return signals_sp->GetShouldSuppress(signo);
96 
97  return false;
98 }
99 
100 bool SBUnixSignals::SetShouldSuppress(int32_t signo, bool value) {
101  LLDB_RECORD_METHOD(bool, SBUnixSignals, SetShouldSuppress, (int32_t, bool),
102  signo, value);
103 
104  auto signals_sp = GetSP();
105 
106  if (signals_sp)
107  return signals_sp->SetShouldSuppress(signo, value);
108 
109  return false;
110 }
111 
112 bool SBUnixSignals::GetShouldStop(int32_t signo) const {
114  signo);
115 
116  if (auto signals_sp = GetSP())
117  return signals_sp->GetShouldStop(signo);
118 
119  return false;
120 }
121 
122 bool SBUnixSignals::SetShouldStop(int32_t signo, bool value) {
123  LLDB_RECORD_METHOD(bool, SBUnixSignals, SetShouldStop, (int32_t, bool), signo,
124  value);
125 
126  auto signals_sp = GetSP();
127 
128  if (signals_sp)
129  return signals_sp->SetShouldStop(signo, value);
130 
131  return false;
132 }
133 
134 bool SBUnixSignals::GetShouldNotify(int32_t signo) const {
136  signo);
137 
138  if (auto signals_sp = GetSP())
139  return signals_sp->GetShouldNotify(signo);
140 
141  return false;
142 }
143 
144 bool SBUnixSignals::SetShouldNotify(int32_t signo, bool value) {
145  LLDB_RECORD_METHOD(bool, SBUnixSignals, SetShouldNotify, (int32_t, bool),
146  signo, value);
147 
148  auto signals_sp = GetSP();
149 
150  if (signals_sp)
151  return signals_sp->SetShouldNotify(signo, value);
152 
153  return false;
154 }
155 
158 
159  if (auto signals_sp = GetSP())
160  return signals_sp->GetNumSignals();
161 
162  return -1;
163 }
164 
165 int32_t SBUnixSignals::GetSignalAtIndex(int32_t index) const {
167  index);
168 
169  if (auto signals_sp = GetSP())
170  return signals_sp->GetSignalAtIndex(index);
171 
173 }
174 
175 namespace lldb_private {
176 namespace repro {
177 
178 template <>
183  const lldb::SBUnixSignals &,
184  SBUnixSignals, operator=,(const lldb::SBUnixSignals &));
187  LLDB_REGISTER_METHOD_CONST(bool, SBUnixSignals, operator bool, ());
189  (int32_t));
191  (const char *));
193  (int32_t));
195  (int32_t, bool));
197  LLDB_REGISTER_METHOD(bool, SBUnixSignals, SetShouldStop, (int32_t, bool));
199  LLDB_REGISTER_METHOD(bool, SBUnixSignals, SetShouldNotify, (int32_t, bool));
202  (int32_t));
203 }
204 
205 }
206 }
The registry contains a unique mapping between functions and their ID.
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
#define LLDB_RECORD_CONSTRUCTOR_NO_ARGS(Class)
#define LLDB_INVALID_SIGNAL_NUMBER
Definition: lldb-defines.h:95
bool SetShouldStop(int32_t signo, bool value)
bool GetShouldStop(int32_t signo) const
int32_t GetSignalAtIndex(int32_t index) const
bool SetShouldSuppress(int32_t signo, bool value)
void RegisterMethods< SBUnixSignals >(Registry &R)
const char * GetSignalAsCString(int32_t signo) const
bool GetShouldSuppress(int32_t signo) const
#define LLDB_REGISTER_CONSTRUCTOR(Class, Signature)
#define LLDB_RECORD_METHOD_NO_ARGS(Result, Class, Method)
bool IsValid() const
#define LLDB_RECORD_CONSTRUCTOR(Class, Signature,...)
#define LLDB_RECORD_METHOD(Result, Class, Method, Signature,...)
const SBUnixSignals & operator=(const lldb::SBUnixSignals &rhs)
#define LLDB_RECORD_METHOD_CONST(Result, Class, Method, Signature,...)
lldb::UnixSignalsSP GetSP() const
Definition: SBAddress.h:15
int32_t GetSignalNumberFromName(const char *name) const
bool SetShouldNotify(int32_t signo, bool value)
bool GetShouldNotify(int32_t signo) const
#define LLDB_REGISTER_METHOD(Result, Class, Method, Signature)
#define LLDB_RECORD_METHOD_CONST_NO_ARGS(Result, Class, Method)
#define LLDB_RECORD_RESULT(Result)
#define LLDB_REGISTER_METHOD_CONST(Result, Class, Method, Signature)
void SetSP(const lldb::UnixSignalsSP &signals_sp)
int32_t GetNumSignals() const