2016-09-07 04:57:50 +08:00
|
|
|
//===-- SBUnixSignals.cpp -------------------------------------------*- C++
|
|
|
|
//-*-===//
|
2014-06-24 03:30:49 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2015-07-14 09:09:28 +08:00
|
|
|
#include "lldb/Target/Platform.h"
|
2016-09-07 04:57:50 +08:00
|
|
|
#include "lldb/Target/Process.h"
|
2014-06-24 03:30:49 +08:00
|
|
|
#include "lldb/Target/UnixSignals.h"
|
2017-03-04 04:56:28 +08:00
|
|
|
#include "lldb/Utility/Log.h"
|
2016-09-07 04:57:50 +08:00
|
|
|
#include "lldb/lldb-defines.h"
|
2014-06-24 03:30:49 +08:00
|
|
|
|
|
|
|
#include "lldb/API/SBUnixSignals.h"
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBUnixSignals::SBUnixSignals() {}
|
2014-06-24 03:30:49 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBUnixSignals::SBUnixSignals(const SBUnixSignals &rhs)
|
|
|
|
: m_opaque_wp(rhs.m_opaque_wp) {}
|
2014-06-24 03:30:49 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBUnixSignals::SBUnixSignals(ProcessSP &process_sp)
|
|
|
|
: m_opaque_wp(process_sp ? process_sp->GetUnixSignals() : nullptr) {}
|
2015-07-14 09:09:28 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBUnixSignals::SBUnixSignals(PlatformSP &platform_sp)
|
|
|
|
: m_opaque_wp(platform_sp ? platform_sp->GetUnixSignals() : nullptr) {}
|
2014-06-24 03:30:49 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
const SBUnixSignals &SBUnixSignals::operator=(const SBUnixSignals &rhs) {
|
|
|
|
if (this != &rhs)
|
|
|
|
m_opaque_wp = rhs.m_opaque_wp;
|
|
|
|
return *this;
|
2014-06-24 03:30:49 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBUnixSignals::~SBUnixSignals() {}
|
2014-06-24 03:30:49 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
UnixSignalsSP SBUnixSignals::GetSP() const { return m_opaque_wp.lock(); }
|
2014-06-24 03:30:49 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBUnixSignals::SetSP(const UnixSignalsSP &signals_sp) {
|
|
|
|
m_opaque_wp = signals_sp;
|
2014-06-24 03:30:49 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBUnixSignals::Clear() { m_opaque_wp.reset(); }
|
2014-06-24 03:30:49 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBUnixSignals::IsValid() const { return static_cast<bool>(GetSP()); }
|
2014-06-24 03:30:49 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
const char *SBUnixSignals::GetSignalAsCString(int32_t signo) const {
|
|
|
|
if (auto signals_sp = GetSP())
|
|
|
|
return signals_sp->GetSignalAsCString(signo);
|
2015-07-14 09:09:28 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return nullptr;
|
2014-06-24 03:30:49 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
int32_t SBUnixSignals::GetSignalNumberFromName(const char *name) const {
|
|
|
|
if (auto signals_sp = GetSP())
|
|
|
|
return signals_sp->GetSignalNumberFromName(name);
|
2015-07-14 09:09:28 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return LLDB_INVALID_SIGNAL_NUMBER;
|
2014-06-24 03:30:49 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBUnixSignals::GetShouldSuppress(int32_t signo) const {
|
|
|
|
if (auto signals_sp = GetSP())
|
|
|
|
return signals_sp->GetShouldSuppress(signo);
|
2015-07-14 09:09:28 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return false;
|
2014-06-24 03:30:49 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBUnixSignals::SetShouldSuppress(int32_t signo, bool value) {
|
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
|
|
|
auto signals_sp = GetSP();
|
2014-06-24 03:30:49 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (log) {
|
|
|
|
log->Printf("SBUnixSignals(%p)::SetShouldSuppress (signo=%d, value=%d)",
|
|
|
|
static_cast<void *>(signals_sp.get()), signo, value);
|
|
|
|
}
|
2014-06-24 03:30:49 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (signals_sp)
|
|
|
|
return signals_sp->SetShouldSuppress(signo, value);
|
2015-07-14 09:09:28 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return false;
|
2014-06-24 03:30:49 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBUnixSignals::GetShouldStop(int32_t signo) const {
|
|
|
|
if (auto signals_sp = GetSP())
|
|
|
|
return signals_sp->GetShouldStop(signo);
|
2015-07-14 09:09:28 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return false;
|
2014-06-24 03:30:49 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBUnixSignals::SetShouldStop(int32_t signo, bool value) {
|
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
|
|
|
auto signals_sp = GetSP();
|
2014-06-24 03:30:49 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (log) {
|
|
|
|
log->Printf("SBUnixSignals(%p)::SetShouldStop (signo=%d, value=%d)",
|
|
|
|
static_cast<void *>(signals_sp.get()), signo, value);
|
|
|
|
}
|
2014-06-24 03:30:49 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (signals_sp)
|
|
|
|
return signals_sp->SetShouldStop(signo, value);
|
2015-07-14 09:09:28 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return false;
|
2014-06-24 03:30:49 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBUnixSignals::GetShouldNotify(int32_t signo) const {
|
|
|
|
if (auto signals_sp = GetSP())
|
|
|
|
return signals_sp->GetShouldNotify(signo);
|
2015-07-14 09:09:28 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return false;
|
2014-06-24 03:30:49 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool SBUnixSignals::SetShouldNotify(int32_t signo, bool value) {
|
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
|
|
|
|
auto signals_sp = GetSP();
|
2014-06-24 03:30:49 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (log) {
|
|
|
|
log->Printf("SBUnixSignals(%p)::SetShouldNotify (signo=%d, value=%d)",
|
|
|
|
static_cast<void *>(signals_sp.get()), signo, value);
|
|
|
|
}
|
2014-06-24 03:30:49 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (signals_sp)
|
|
|
|
return signals_sp->SetShouldNotify(signo, value);
|
2015-07-14 09:09:28 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return false;
|
2014-06-24 03:30:49 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
int32_t SBUnixSignals::GetNumSignals() const {
|
|
|
|
if (auto signals_sp = GetSP())
|
|
|
|
return signals_sp->GetNumSignals();
|
2015-07-14 09:09:28 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return -1;
|
2014-06-24 03:30:49 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
int32_t SBUnixSignals::GetSignalAtIndex(int32_t index) const {
|
|
|
|
if (auto signals_sp = GetSP())
|
|
|
|
return signals_sp->GetSignalAtIndex(index);
|
2015-07-14 09:09:28 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return LLDB_INVALID_SIGNAL_NUMBER;
|
2014-06-24 03:30:49 +08:00
|
|
|
}
|