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
10#include "lldb/Target/Process.h"
13#include "lldb/lldb-defines.h"
14
16
17using namespace lldb;
18using namespace lldb_private;
19
21
23 : m_opaque_wp(rhs.m_opaque_wp) {
24 LLDB_INSTRUMENT_VA(this, rhs);
25}
26
28 : m_opaque_wp(process_sp ? process_sp->GetUnixSignals() : nullptr) {}
29
31 : m_opaque_wp(platform_sp ? platform_sp->GetUnixSignals() : nullptr) {}
32
34 LLDB_INSTRUMENT_VA(this, rhs);
35
36 if (this != &rhs)
38 return *this;
39}
40
42
44
45void SBUnixSignals::SetSP(const UnixSignalsSP &signals_sp) {
46 m_opaque_wp = signals_sp;
47}
48
51
52 m_opaque_wp.reset();
53}
54
57 return this->operator bool();
58}
59SBUnixSignals::operator bool() const {
61
62 return static_cast<bool>(GetSP());
63}
64
65const char *SBUnixSignals::GetSignalAsCString(int32_t signo) const {
66 LLDB_INSTRUMENT_VA(this, signo);
67
68 if (auto signals_sp = GetSP())
69 return ConstString(signals_sp->GetSignalAsStringRef(signo)).GetCString();
70
71 return nullptr;
72}
73
74int32_t SBUnixSignals::GetSignalNumberFromName(const char *name) const {
75 LLDB_INSTRUMENT_VA(this, name);
76
77 if (auto signals_sp = GetSP())
78 return signals_sp->GetSignalNumberFromName(name);
79
81}
82
83bool SBUnixSignals::GetShouldSuppress(int32_t signo) const {
84 LLDB_INSTRUMENT_VA(this, signo);
85
86 if (auto signals_sp = GetSP())
87 return signals_sp->GetShouldSuppress(signo);
88
89 return false;
90}
91
92bool SBUnixSignals::SetShouldSuppress(int32_t signo, bool value) {
93 LLDB_INSTRUMENT_VA(this, signo, value);
94
95 auto signals_sp = GetSP();
96
97 if (signals_sp)
98 return signals_sp->SetShouldSuppress(signo, value);
99
100 return false;
101}
102
103bool SBUnixSignals::GetShouldStop(int32_t signo) const {
104 LLDB_INSTRUMENT_VA(this, signo);
105
106 if (auto signals_sp = GetSP())
107 return signals_sp->GetShouldStop(signo);
108
109 return false;
110}
111
112bool SBUnixSignals::SetShouldStop(int32_t signo, bool value) {
113 LLDB_INSTRUMENT_VA(this, signo, value);
114
115 auto signals_sp = GetSP();
116
117 if (signals_sp)
118 return signals_sp->SetShouldStop(signo, value);
119
120 return false;
121}
122
123bool SBUnixSignals::GetShouldNotify(int32_t signo) const {
124 LLDB_INSTRUMENT_VA(this, signo);
125
126 if (auto signals_sp = GetSP())
127 return signals_sp->GetShouldNotify(signo);
128
129 return false;
130}
131
132bool SBUnixSignals::SetShouldNotify(int32_t signo, bool value) {
133 LLDB_INSTRUMENT_VA(this, signo, value);
134
135 auto signals_sp = GetSP();
136
137 if (signals_sp)
138 return signals_sp->SetShouldNotify(signo, value);
139
140 return false;
141}
142
144 LLDB_INSTRUMENT_VA(this);
145
146 if (auto signals_sp = GetSP())
147 return signals_sp->GetNumSignals();
148
149 return -1;
150}
151
152int32_t SBUnixSignals::GetSignalAtIndex(int32_t index) const {
153 LLDB_INSTRUMENT_VA(this, index);
154
155 if (auto signals_sp = GetSP())
156 return signals_sp->GetSignalAtIndex(index);
157
159}
#define LLDB_INSTRUMENT_VA(...)
lldb::UnixSignalsWP m_opaque_wp
Definition: SBUnixSignals.h:66
int32_t GetSignalAtIndex(int32_t index) const
bool SetShouldNotify(int32_t signo, bool value)
const char * GetSignalAsCString(int32_t signo) const
int32_t GetSignalNumberFromName(const char *name) const
const SBUnixSignals & operator=(const lldb::SBUnixSignals &rhs)
bool SetShouldStop(int32_t signo, bool value)
bool IsValid() const
bool SetShouldSuppress(int32_t signo, bool value)
int32_t GetNumSignals() const
void SetSP(const lldb::UnixSignalsSP &signals_sp)
bool GetShouldStop(int32_t signo) const
bool GetShouldNotify(int32_t signo) const
lldb::UnixSignalsSP GetSP() const
bool GetShouldSuppress(int32_t signo) const
A uniqued constant string class.
Definition: ConstString.h:40
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:216
#define LLDB_INVALID_SIGNAL_NUMBER
Definition: lldb-defines.h:92
A class that represents a running process on the host machine.
Definition: SBAddress.h:15
std::shared_ptr< lldb_private::UnixSignals > UnixSignalsSP
Definition: lldb-forward.h:476
std::shared_ptr< lldb_private::Platform > PlatformSP
Definition: lldb-forward.h:386
std::shared_ptr< lldb_private::Process > ProcessSP
Definition: lldb-forward.h:387