2014-06-24 03:30:49 +08:00
|
|
|
//===-- SBUnixSignals.cpp -------------------------------------------*- C++
|
|
|
|
//-*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2014-06-24 03:30:49 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
#include "SBReproducerPrivate.h"
|
2015-07-14 09:09:28 +08:00
|
|
|
#include "lldb/Target/Platform.h"
|
2014-06-24 03:30:49 +08:00
|
|
|
#include "lldb/Target/Process.h"
|
|
|
|
#include "lldb/Target/UnixSignals.h"
|
|
|
|
#include "lldb/lldb-defines.h"
|
|
|
|
|
|
|
|
#include "lldb/API/SBUnixSignals.h"
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
SBUnixSignals::SBUnixSignals() {
|
|
|
|
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBUnixSignals);
|
|
|
|
}
|
2014-06-24 03:30:49 +08:00
|
|
|
|
|
|
|
SBUnixSignals::SBUnixSignals(const SBUnixSignals &rhs)
|
2019-03-06 08:06:00 +08:00
|
|
|
: m_opaque_wp(rhs.m_opaque_wp) {
|
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBUnixSignals, (const lldb::SBUnixSignals &), rhs);
|
|
|
|
}
|
2014-06-24 03:30:49 +08:00
|
|
|
|
2015-07-14 09:09:28 +08:00
|
|
|
SBUnixSignals::SBUnixSignals(ProcessSP &process_sp)
|
|
|
|
: m_opaque_wp(process_sp ? process_sp->GetUnixSignals() : nullptr) {}
|
|
|
|
|
|
|
|
SBUnixSignals::SBUnixSignals(PlatformSP &platform_sp)
|
|
|
|
: m_opaque_wp(platform_sp ? platform_sp->GetUnixSignals() : nullptr) {}
|
2014-06-24 03:30:49 +08:00
|
|
|
|
|
|
|
const SBUnixSignals &SBUnixSignals::operator=(const SBUnixSignals &rhs) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(const lldb::SBUnixSignals &,
|
|
|
|
SBUnixSignals, operator=,(const lldb::SBUnixSignals &),
|
|
|
|
rhs);
|
|
|
|
|
2014-06-24 03:30:49 +08:00
|
|
|
if (this != &rhs)
|
|
|
|
m_opaque_wp = rhs.m_opaque_wp;
|
2019-04-04 05:31:22 +08:00
|
|
|
return LLDB_RECORD_RESULT(*this);
|
2014-06-24 03:30:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBUnixSignals::~SBUnixSignals() {}
|
|
|
|
|
|
|
|
UnixSignalsSP SBUnixSignals::GetSP() const { return m_opaque_wp.lock(); }
|
|
|
|
|
2015-07-14 09:09:28 +08:00
|
|
|
void SBUnixSignals::SetSP(const UnixSignalsSP &signals_sp) {
|
|
|
|
m_opaque_wp = signals_sp;
|
2014-06-24 03:30:49 +08:00
|
|
|
}
|
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
void SBUnixSignals::Clear() {
|
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(void, SBUnixSignals, Clear);
|
|
|
|
|
|
|
|
m_opaque_wp.reset();
|
|
|
|
}
|
2014-06-24 03:30:49 +08:00
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
bool SBUnixSignals::IsValid() const {
|
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBUnixSignals, IsValid);
|
Add "operator bool" to SB APIs
Summary:
Our python version of the SB API has (the python equivalent of)
operator bool, but the C++ version doesn't.
This is because our python operators are added by modify-python-lldb.py,
which performs postprocessing on the swig-generated interface files.
In this patch, I add the "operator bool" to all SB classes which have an
IsValid method (which is the same logic used by modify-python-lldb.py).
This way, we make the two interfaces more constent, and it allows us to
rely on swig's automatic syntesis of python __nonzero__ methods instead
of doing manual fixups.
Reviewers: zturner, jingham, clayborg, jfb, serge-sans-paille
Subscribers: jdoerfert, lldb-commits
Differential Revision: https://reviews.llvm.org/D58792
llvm-svn: 355824
2019-03-11 21:58:46 +08:00
|
|
|
return this->operator bool();
|
|
|
|
}
|
|
|
|
SBUnixSignals::operator bool() const {
|
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBUnixSignals, operator bool);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
|
|
|
return static_cast<bool>(GetSP());
|
|
|
|
}
|
2014-06-24 03:30:49 +08:00
|
|
|
|
|
|
|
const char *SBUnixSignals::GetSignalAsCString(int32_t signo) const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST(const char *, SBUnixSignals, GetSignalAsCString,
|
|
|
|
(int32_t), signo);
|
|
|
|
|
2015-07-14 09:09:28 +08:00
|
|
|
if (auto signals_sp = GetSP())
|
|
|
|
return signals_sp->GetSignalAsCString(signo);
|
|
|
|
|
|
|
|
return nullptr;
|
2014-06-24 03:30:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int32_t SBUnixSignals::GetSignalNumberFromName(const char *name) const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST(int32_t, SBUnixSignals, GetSignalNumberFromName,
|
|
|
|
(const char *), name);
|
|
|
|
|
2015-07-14 09:09:28 +08:00
|
|
|
if (auto signals_sp = GetSP())
|
|
|
|
return signals_sp->GetSignalNumberFromName(name);
|
|
|
|
|
|
|
|
return LLDB_INVALID_SIGNAL_NUMBER;
|
2014-06-24 03:30:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SBUnixSignals::GetShouldSuppress(int32_t signo) const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST(bool, SBUnixSignals, GetShouldSuppress, (int32_t),
|
|
|
|
signo);
|
|
|
|
|
2015-07-14 09:09:28 +08:00
|
|
|
if (auto signals_sp = GetSP())
|
|
|
|
return signals_sp->GetShouldSuppress(signo);
|
|
|
|
|
2014-06-24 03:30:49 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SBUnixSignals::SetShouldSuppress(int32_t signo, bool value) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(bool, SBUnixSignals, SetShouldSuppress, (int32_t, bool),
|
|
|
|
signo, value);
|
|
|
|
|
2015-07-14 09:09:28 +08:00
|
|
|
auto signals_sp = GetSP();
|
2014-06-24 03:30:49 +08:00
|
|
|
|
2015-07-14 09:09:28 +08:00
|
|
|
if (signals_sp)
|
|
|
|
return signals_sp->SetShouldSuppress(signo, value);
|
|
|
|
|
2014-06-24 03:30:49 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SBUnixSignals::GetShouldStop(int32_t signo) const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST(bool, SBUnixSignals, GetShouldStop, (int32_t),
|
|
|
|
signo);
|
|
|
|
|
2015-07-14 09:09:28 +08:00
|
|
|
if (auto signals_sp = GetSP())
|
|
|
|
return signals_sp->GetShouldStop(signo);
|
|
|
|
|
2014-06-24 03:30:49 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SBUnixSignals::SetShouldStop(int32_t signo, bool value) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(bool, SBUnixSignals, SetShouldStop, (int32_t, bool), signo,
|
|
|
|
value);
|
|
|
|
|
2015-07-14 09:09:28 +08:00
|
|
|
auto signals_sp = GetSP();
|
2014-06-24 03:30:49 +08:00
|
|
|
|
2015-07-14 09:09:28 +08:00
|
|
|
if (signals_sp)
|
|
|
|
return signals_sp->SetShouldStop(signo, value);
|
|
|
|
|
2014-06-24 03:30:49 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SBUnixSignals::GetShouldNotify(int32_t signo) const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST(bool, SBUnixSignals, GetShouldNotify, (int32_t),
|
|
|
|
signo);
|
|
|
|
|
2015-07-14 09:09:28 +08:00
|
|
|
if (auto signals_sp = GetSP())
|
|
|
|
return signals_sp->GetShouldNotify(signo);
|
|
|
|
|
2014-06-24 03:30:49 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SBUnixSignals::SetShouldNotify(int32_t signo, bool value) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(bool, SBUnixSignals, SetShouldNotify, (int32_t, bool),
|
|
|
|
signo, value);
|
|
|
|
|
2015-07-14 09:09:28 +08:00
|
|
|
auto signals_sp = GetSP();
|
2014-06-24 03:30:49 +08:00
|
|
|
|
2015-07-14 09:09:28 +08:00
|
|
|
if (signals_sp)
|
|
|
|
return signals_sp->SetShouldNotify(signo, value);
|
|
|
|
|
2014-06-24 03:30:49 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t SBUnixSignals::GetNumSignals() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(int32_t, SBUnixSignals, GetNumSignals);
|
|
|
|
|
2015-07-14 09:09:28 +08:00
|
|
|
if (auto signals_sp = GetSP())
|
|
|
|
return signals_sp->GetNumSignals();
|
|
|
|
|
|
|
|
return -1;
|
2014-06-24 03:30:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int32_t SBUnixSignals::GetSignalAtIndex(int32_t index) const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST(int32_t, SBUnixSignals, GetSignalAtIndex, (int32_t),
|
|
|
|
index);
|
|
|
|
|
2015-07-14 09:09:28 +08:00
|
|
|
if (auto signals_sp = GetSP())
|
|
|
|
return signals_sp->GetSignalAtIndex(index);
|
|
|
|
|
2014-06-24 03:30:49 +08:00
|
|
|
return LLDB_INVALID_SIGNAL_NUMBER;
|
|
|
|
}
|
2019-03-20 01:13:13 +08:00
|
|
|
|
|
|
|
namespace lldb_private {
|
|
|
|
namespace repro {
|
|
|
|
|
|
|
|
template <>
|
|
|
|
void RegisterMethods<SBUnixSignals>(Registry &R) {
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBUnixSignals, ());
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBUnixSignals, (const lldb::SBUnixSignals &));
|
|
|
|
LLDB_REGISTER_METHOD(
|
|
|
|
const lldb::SBUnixSignals &,
|
|
|
|
SBUnixSignals, operator=,(const lldb::SBUnixSignals &));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBUnixSignals, Clear, ());
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBUnixSignals, IsValid, ());
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBUnixSignals, operator bool, ());
|
|
|
|
LLDB_REGISTER_METHOD_CONST(const char *, SBUnixSignals, GetSignalAsCString,
|
|
|
|
(int32_t));
|
|
|
|
LLDB_REGISTER_METHOD_CONST(int32_t, SBUnixSignals, GetSignalNumberFromName,
|
|
|
|
(const char *));
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBUnixSignals, GetShouldSuppress,
|
|
|
|
(int32_t));
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBUnixSignals, SetShouldSuppress,
|
|
|
|
(int32_t, bool));
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBUnixSignals, GetShouldStop, (int32_t));
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBUnixSignals, SetShouldStop, (int32_t, bool));
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBUnixSignals, GetShouldNotify, (int32_t));
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBUnixSignals, SetShouldNotify, (int32_t, bool));
|
|
|
|
LLDB_REGISTER_METHOD_CONST(int32_t, SBUnixSignals, GetNumSignals, ());
|
|
|
|
LLDB_REGISTER_METHOD_CONST(int32_t, SBUnixSignals, GetSignalAtIndex,
|
|
|
|
(int32_t));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|