LLDB  mainline
SBUnixSignals.cpp
Go to the documentation of this file.
1 //===-- SBUnixSignals.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 "SBReproducerPrivate.h"
10 #include "lldb/Target/Platform.h"
11 #include "lldb/Target/Process.h"
13 #include "lldb/lldb-defines.h"
14 
15 #include "lldb/API/SBUnixSignals.h"
16 
17 using namespace lldb;
18 using namespace lldb_private;
19 
22 }
23 
25  : m_opaque_wp(rhs.m_opaque_wp) {
27 }
28 
29 SBUnixSignals::SBUnixSignals(ProcessSP &process_sp)
30  : m_opaque_wp(process_sp ? process_sp->GetUnixSignals() : nullptr) {}
31 
32 SBUnixSignals::SBUnixSignals(PlatformSP &platform_sp)
33  : m_opaque_wp(platform_sp ? platform_sp->GetUnixSignals() : nullptr) {}
34 
37  SBUnixSignals, operator=,(const lldb::SBUnixSignals &),
38  rhs);
39 
40  if (this != &rhs)
42  return LLDB_RECORD_RESULT(*this);
43 }
44 
46 
47 UnixSignalsSP SBUnixSignals::GetSP() const { return m_opaque_wp.lock(); }
48 
49 void SBUnixSignals::SetSP(const UnixSignalsSP &signals_sp) {
50  m_opaque_wp = signals_sp;
51 }
52 
55 
56  m_opaque_wp.reset();
57 }
58 
59 bool SBUnixSignals::IsValid() const {
61  return this->operator bool();
62 }
63 SBUnixSignals::operator bool() const {
64  LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBUnixSignals, operator bool);
65 
66  return static_cast<bool>(GetSP());
67 }
68 
69 const char *SBUnixSignals::GetSignalAsCString(int32_t signo) const {
71  (int32_t), signo);
72 
73  if (auto signals_sp = GetSP())
74  return signals_sp->GetSignalAsCString(signo);
75 
76  return nullptr;
77 }
78 
79 int32_t SBUnixSignals::GetSignalNumberFromName(const char *name) const {
81  (const char *), name);
82 
83  if (auto signals_sp = GetSP())
84  return signals_sp->GetSignalNumberFromName(name);
85 
87 }
88 
89 bool SBUnixSignals::GetShouldSuppress(int32_t signo) const {
91  signo);
92 
93  if (auto signals_sp = GetSP())
94  return signals_sp->GetShouldSuppress(signo);
95 
96  return false;
97 }
98 
99 bool SBUnixSignals::SetShouldSuppress(int32_t signo, bool value) {
100  LLDB_RECORD_METHOD(bool, SBUnixSignals, SetShouldSuppress, (int32_t, bool),
101  signo, value);
102 
103  auto signals_sp = GetSP();
104 
105  if (signals_sp)
106  return signals_sp->SetShouldSuppress(signo, value);
107 
108  return false;
109 }
110 
111 bool SBUnixSignals::GetShouldStop(int32_t signo) const {
113  signo);
114 
115  if (auto signals_sp = GetSP())
116  return signals_sp->GetShouldStop(signo);
117 
118  return false;
119 }
120 
121 bool SBUnixSignals::SetShouldStop(int32_t signo, bool value) {
122  LLDB_RECORD_METHOD(bool, SBUnixSignals, SetShouldStop, (int32_t, bool), signo,
123  value);
124 
125  auto signals_sp = GetSP();
126 
127  if (signals_sp)
128  return signals_sp->SetShouldStop(signo, value);
129 
130  return false;
131 }
132 
133 bool SBUnixSignals::GetShouldNotify(int32_t signo) const {
135  signo);
136 
137  if (auto signals_sp = GetSP())
138  return signals_sp->GetShouldNotify(signo);
139 
140  return false;
141 }
142 
143 bool SBUnixSignals::SetShouldNotify(int32_t signo, bool value) {
144  LLDB_RECORD_METHOD(bool, SBUnixSignals, SetShouldNotify, (int32_t, bool),
145  signo, value);
146 
147  auto signals_sp = GetSP();
148 
149  if (signals_sp)
150  return signals_sp->SetShouldNotify(signo, value);
151 
152  return false;
153 }
154 
157 
158  if (auto signals_sp = GetSP())
159  return signals_sp->GetNumSignals();
160 
161  return -1;
162 }
163 
164 int32_t SBUnixSignals::GetSignalAtIndex(int32_t index) const {
166  index);
167 
168  if (auto signals_sp = GetSP())
169  return signals_sp->GetSignalAtIndex(index);
170 
172 }
173 
174 namespace lldb_private {
175 namespace repro {
176 
177 template <>
182  const lldb::SBUnixSignals &,
183  SBUnixSignals, operator=,(const lldb::SBUnixSignals &));
186  LLDB_REGISTER_METHOD_CONST(bool, SBUnixSignals, operator bool, ());
188  (int32_t));
190  (const char *));
192  (int32_t));
194  (int32_t, bool));
196  LLDB_REGISTER_METHOD(bool, SBUnixSignals, SetShouldStop, (int32_t, bool));
198  LLDB_REGISTER_METHOD(bool, SBUnixSignals, SetShouldNotify, (int32_t, bool));
201  (int32_t));
202 }
203 
204 }
205 }
The registry contains a unique mapping between functions and their ID.
A class that represents a running process on the host machine.
#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
lldb::UnixSignalsWP m_opaque_wp
Definition: SBUnixSignals.h:66
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